playground/coq/ranged.v

38 lines
898 B
Coq

Require Import Streams.
Require Import Lia.
Inductive range {A:Type} (p:A->Prop) (low high:nat)
: Stream A -> nat -> Prop :=
| RangeStart: forall (s:Stream A),
range p low high s 0
| RangeMore: forall (s:Stream A) (n:nat),
n>=low /\ (S n)<=high
-> p (hd s)
-> range p (low-1) (high-1) (tl s) n
-> range p low high s (S n).
Definition egstr1 := const 3.
Goal
range (fun x=>x=2) 2 5
(Cons 2 (Cons 2 (Cons 2 (Cons 2 (Cons 2 egstr1))))) 3.
Proof.
eapply RangeMore; simpl; try lia.
eapply RangeMore; simpl; try lia.
eapply RangeMore; simpl; try lia.
eapply RangeStart.
Qed.
(*
Inductive range {A:Type} (p:A->Prop) (low high:nat)
: Stream A -> nat -> Prop :=
| RangeDone: forall (s:Stream A) (n:nat),
n>=low /\ n<=high
-> range p low high s n
| RangeMore: forall (s:Stream A) (n:nat),
p (hd s)
-> range p low high (tl s) (S n)
-> range p low high s n.
*)