fact
stringlengths
3
2.59k
type
stringclasses
20 values
library
stringclasses
4 values
imports
listlengths
0
18
filename
stringclasses
207 values
symbolic_name
stringlengths
1
36
docstring
stringclasses
269 values
#[local] Instance vector_eqdec {A n} `(EqDec A) : EqDec (vector A n).
Instance
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vector_eqdec
We show that decidable equality of the elements type implied decidable equality of vectors.
Subterm for vector.
Derive
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
Subterm
We automatically derive the signature and subterm relation for vectors and prove it's well-foundedness. The signature provides a [signature_pack] function to pack a vector with its index. The well-founded relation is defined on the packed vector type.
unzip {n} (v : vector (A * B) n) : vector A n * vector B n by wf (signature_pack v) (@t_subterm (A * B)) := unzip []v := ([]v, []v) ; unzip (Vector.cons (x, y) v) with unzip v := { | pair xs ys := (Vector.cons x xs, Vector.cons y ys) }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
unzip
We can use the packed relation to do well-founded recursion on the vector. Note that we do a recursive call on a substerm of type [vector A n] which must be shown smaller than a [vector A (S n)]. They are actually compared at the packed type [{ n : nat & vector A n}].
app {A} (l l' : list A) : list A := app nil l := l; app (cons a v) l := cons a (app v l).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
app
Playing with lists and functional induction, we define a tail-recursive version of [rev] and show its equivalence with the "naïve" [rev].
rev_acc {A} (l : list A) (acc : list A) : list A := rev_acc nil acc := acc; rev_acc (cons a v) acc := rev_acc v (a :: acc).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
rev_acc
null
rev {A} (l : list A) : list A := rev nil := nil; rev (cons a v) := rev v ++ (cons a nil).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
rev
null
app_nil : forall {A} (l : list A), l ++ [] = l.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
app_nil
null
app_assoc : forall {A} (l l' l'' : list A), (l ++ l') ++ l'' = l ++ (l' ++ l'').
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
app_assoc
null
rev_rev_acc : forall {A} (l : list A), rev_acc l [] = rev l.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
rev_rev_acc
null
rev_app : forall {A} (l l' : list A), rev (l ++ l') = rev l' ++ rev l.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
rev_app
null
zip' {A} (f : A -> A -> A) (l l' : list A) : list A := zip' f nil nil := nil ; zip' f (cons a v) (cons b w) := cons (f a b) (zip' f v w) ; zip' f x y := nil.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
zip
null
zip'' {A} (f : A -> A -> A) (l l' : list A) (def : list A) : list A := zip'' f nil nil def := nil ; zip'' f (cons a v) (cons b w) def := cons (f a b) (zip'' f v w def) ; zip'' f nil (cons b w) def := def ; zip'' f (cons a v) nil def := def.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
zip
null
vector_append_one {A n} (v : vector A n) (a : A) : vector A (S n) := vector_append_one nil a := cons a nil; vector_append_one (cons a' v) a := cons a' (vector_append_one v a).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vector_append_one
Vectors
vrev {A n} (v : vector A n) : vector A n := vrev nil := nil; vrev (cons a v) := vector_append_one (vrev v) a.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vrev
null
cast_vector {A n m} (v : vector A n) (H : n = m) : vector A m.
Definition
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
cast_vector
null
vrev_acc {A n m} (v : vector A n) (w : vector A m) : vector A (n + m) := vrev_acc nil w := w; vrev_acc (cons a v) w := cast_vector (vrev_acc v (cons a w)) _.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vrev_acc
null
vect {A} := mkVect { vect_len : nat; vect_vector : vector A vect_len }.
Record
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vect
Vectors
NoConfusion for vect.
Derive
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
NoConfusion
null
Split {X : Type}{m n : nat} : vector X (m + n) -> Type := append : ∀ (xs : vector X m)(ys : vector X n), Split (vapp xs ys).
Inductive
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
Split
Splitting a vector into two parts.
split {X : Type} {m n} (xs : vector X (m + n)) : Split m n xs by wf m := split (m:=O) xs := append nil xs ; split (m:=S m) (cons x xs) with split xs => { | append xs' ys' := append (cons x xs') ys' }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
split
We split by well-founded recursion on the index [m] here.
split_vapp : ∀ (X : Type) m n (v : vector X m) (w : vector X n), let 'append v' w' := split (vapp v w) in v = v' /\ w = w'.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
split_vapp
The [split] and [vapp] functions are inverses.
split_struct {X : Type} {m n} (xs : vector X (m + n)) : Split m n xs := split_struct (m:=0) xs := append nil xs ; split_struct (m:=(S m)) (cons x xs) with split_struct xs => { split_struct (m:=(S m)) (cons x xs) (append xs' ys') := append (cons x xs') ys' }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
split_struct
This function can also be defined by structural recursion on [m].
split_struct_vapp : ∀ (X : Type) m n (v : vector X m) (w : vector X n), let 'append v' w' := split_struct (vapp v w) in v = v' /\ w = w'.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
split_struct_vapp
null
vhead {A n} (v : vector A (S n)) : A := vhead (cons a v) := a.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vhead
Taking the head of a non-empty vector.
vmap' {A B} (f : A -> B) {n} (v : vector A n) : vector B n := vmap' f nil := nil ; vmap' f (cons a v) := cons (f a) (vmap' f v).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vmap
Mapping over a vector.
vmap {A B} (f : A -> B) {n} (v : vector A n) : vector B n by wf n := vmap f (n:=?(O)) nil := nil ; vmap f (cons a v) := cons (f a) (vmap f v).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vmap
The same, using well-founded recursion on [n].
Imf : T -> Type := imf (s : S) : Imf (f s).
Inductive
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
Imf
null
inv (t : T) (im : Imf t) : S := inv ?(f s) (imf s) := s.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
inv
Here [(f s)] is innaccessible.
univ : Set := | ubool | unat | uarrow (from:univ) (to:univ).
Inductive
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
univ
null
interp (u : univ) : Set := interp ubool := bool; interp unat := nat; interp (uarrow from to) := interp from -> interp to.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
interp
null
interp' := Eval compute in @interp.
Definition
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
interp
null
foo (u : univ) (el : interp' u) : interp' u := foo ubool true := false ; foo ubool false := true ; foo unat t := t ; foo (uarrow from to) f := id ∘ f.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
foo
null
vlast {A} {n} (v : vector A (S n)) : A by struct v := vlast (@cons a O _) := a ; vlast (@cons a (S n) v) := vlast v.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vlast
null
Parity : nat -> Set := | even : forall n, Parity (mult 2 n) | odd : forall n, Parity (S (mult 2 n)).
Inductive
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
Parity
The parity predicate embeds a divisor of n or n-1
cast {A B : Type} (a : A) (p : A = B) : B.
Definition
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
cast
The parity predicate embeds a divisor of n or n-1
parity (n : nat) : Parity n := parity O := even 0 ; parity (S n) with parity n => { parity (S ?(mult 2 k)) (even k) := odd k ; parity (S ?(S (mult 2 k))) (odd k) := cast (even (S k)) _ }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
parity
null
half (n : nat) : nat := half n with parity n => { half ?(S (mult 2 k)) (odd k) := k ; half ?(mult 2 k) (even k) := k }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
half
We can halve a natural looking at its parity and using the lower truncation.
vtail {A n} (v : vector A (S n)) : vector A n := vtail (cons a v') := v'.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vtail
null
diag {A n} (v : vector (vector A n) n) : vector A n := diag (n:=O) nil := nil ; diag (n:=S ?(n)) (cons (@cons a n v) v') := cons a (diag (vmap vtail v')).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
diag
null
mat A n m := vector (vector A m) n.
Definition
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
mat
null
vmake {A} (n : nat) (a : A) : vector A n := vmake O a := nil ; vmake (S n) a := cons a (vmake n a).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vmake
null
vfold_right {A : nat -> Type} {B} (f : ∀ n, B -> A n -> A (S n)) (e : A 0) {n} (v : vector B n) : A n := vfold_right f e nil := e ; vfold_right f e (@cons a n v) := f n a (vfold_right f e v).
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vfold_right
null
vzip {A B C n} (f : A -> B -> C) (v : vector A n) (w : vector B n) : vector C n := vzip f nil _ := nil ; vzip f (cons a v) (cons a' v') := cons (f a a') (vzip f v v').
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
vzip
null
transpose {A m n} : mat A m n -> mat A n m := vfold_right (A:=λ m, mat A n m) (λ m', vzip (λ a, cons a)) (vmake n nil).
Definition
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
transpose
null
nth_vmap `(v : vector A n) `(fn : A -> B) (f : fin n) : nth (vmap fn v) f = fn (nth v f).
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
nth_vmap
null
nth_vtail `(v : vector A (S n)) (f : fin n) : nth (vtail v) f = nth v (fs f).
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
nth_vtail
null
diag_nth `(v : vector (vector A n) n) (f : fin n) : nth (diag v) f = nth (nth v f) f.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
diag_nth
null
assoc (x y z : nat) : x + y + z = x + (y + z) := assoc 0 y z := eq_refl; assoc (S x) y z with assoc x y z, x + (y + z) => { assoc (S x) y z eq_refl _ := eq_refl }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
assoc
null
inspect {A} (a : A) : {b | a = b} := exist _ a eq_refl.
Definition
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
inspect
The [inspect] definition is used to pack a value with a proof of an equality to itself. When pattern matching on the first component in this existential type, we keep information about the origin of the pattern available in the second component, the equality.
f_sequence (n : A) : list A by wf n lt := f_sequence n with inspect (f n) := { | Some p eqn: eq1 => p :: f_sequence p; | None eqn:_ => List.nil }.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
f_sequence
If one uses [f n] instead of [inspect (f n)] in the following definition, patterns should be patterns for the option type, but then there is an unprovable obligation that is generated as we don't keep information about the call to [f n] being equal to [Some p] to justify the recursive call to [f_sequence].
in_seq_image (n p : A) : List.In p (f_sequence n) -> exists k, f k = Some p.
Lemma
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
in_seq_image
The following is an illustration of a theorem on f_sequence.
transport {A : Type} (P : A -> Type) {x y : A} (p : x = y) (u : P x) : P y := transport P eq_refl u := u.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
transport
null
path_sigma {A : Type} {P : A -> Type} (u v : sigma P) (p : u.1 = v.1) (q : p # u.2 = v.2) : u = v := path_sigma (_ , _) (_ , _) eq_refl eq_refl := eq_refl.
Equations
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
path_sigma
null
foo := path_sigma_elim.
Example
examples
[ "Program", "Bvector", "List", "Relations", "Equations.Equations", "Equations.Signature", "Utf8", "Arith", "Wf_nat", "Bvector", "Examples" ]
examples/Basics.v
foo
null
f91_graph : nat -> nat -> Prop := | f91_gt n : n > 100 -> f91_graph n (n - 10) | f91_le n nest res : n <= 100 -> f91_graph (n + 11) nest -> f91_graph nest res -> f91_graph n res.
Inductive
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91_graph
The graph of the [f91] function.
Signature for f91_graph.
Derive
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
Signature
null
f91_spec n m : f91_graph n m -> if le_lt_dec n 100 then m = 91 else m = n - 10.
Lemma
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91_spec
It is easy to derive the spec of [f91] from it, by induction.
f91 n : (f91_exists n).1 = if le_lt_dec n 100 then 91 else n - 10.
Lemma
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91
Combining these two things allow us to derive the spec of [f91].
f91_dom : nat -> Prop := | f91_dom_gt n : n > 100 -> f91_dom n | f91_dom_le n : n <= 100 -> f91_dom (n + 11) -> (forall n', f91_graph (n + 11) n' -> f91_dom n') -> f91_dom n.
Inductive
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91_dom
An alternative is to use the domain of [f91] instead, which for nested recursive calls requires a quantification on the graph relation.
le_nle n : n <= 100 -> 100 < n -> False.
Lemma
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
le_nle
null
f91_dom_le_inv_l {n} (prf : f91_dom n) (Hle : n <= 100) : f91_dom (n + 11) := | f91_dom_gt n H | Hle := ltac:(exfalso; eauto using le_nle); | f91_dom_le n H Hd Hg | Hle := Hd.
Equations
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91_dom_le_inv_l
These two structural inversion lemmas are essential: we rely on the fact that they return subterms of their [prf] argument below to define [f91_ongraph] by _structural_ recursion.
f91_dom_le_inv_r {n} (prf : f91_dom n) (Hle : n <= 100) : (forall n', f91_graph (n + 11) n' -> f91_dom n') := | f91_dom_gt n H | Hle := ltac:(exfalso; eauto using le_nle); | f91_dom_le n H Hd Hg | Hle := Hg.
Equations
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91_dom_le_inv_r
null
f91_ongraph_spec n dom : proj1_sig (f91_ongraph n dom) = if le_lt_dec n 100 then 91 else n - 10.
Lemma
examples
[ "Equations.Equations", "Arith", "Lia", "Relations", "Utf8" ]
examples/bove_capretta.v
f91_ongraph_spec
null
Signature NoConfusion NoConfusionHom for t.
Derive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Signature
[t] is just [Vector.t] here.
Ty : Set := | unit : Ty | bool : Ty | arrow (t u : Ty) : Ty | ref : Ty -> Ty.
Inductive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Ty
Types include unit, bool, function types and references
NoConfusion for Ty.
Derive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
NoConfusion
null
Ctx := list Ty.
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Ctx
null
#[universes(template)] Inductive In {A} (x : A) : list A -> Type := | here {xs} : x ∈ (x :: xs) | there {y xs} : x ∈ xs -> x ∈ (y :: xs) where " x ∈ s " := (In x s).
Inductive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
In
null
Signature NoConfusion for In.
Derive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Signature
null
Expr : Ctx -> Ty -> Set := | tt {Γ} : Expr Γ unit | true {Γ} : Expr Γ bool | false {Γ} : Expr Γ bool | ite {Γ t} : Expr Γ bool -> Expr Γ t -> Expr Γ t -> Expr Γ t | var {Γ} {t} : In t Γ -> Expr Γ t | abs {Γ} {t u} : Expr (t :: Γ) u -> Expr Γ (t ⇒ u) | app {Γ} {t u} : Expr Γ (t ⇒ u) -> Expr Γ t -> Expr Γ u | new {Γ t} :...
Inductive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Expr
null
Signature NoConfusion NoConfusionHom for Expr.
Derive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Signature
We derive both [NoConfusion] and [NoConfusionHom] principles here, the later allows to simplify pattern-matching problems on [Expr] which would otherwise require K. It relies on an inversion analysis of every constructor, showing that the context and type indexes in the conclusions of every constructor ...
#[universes(template)] Inductive All {A} (P : A -> Type) : list A -> Type := | all_nil : All P [] | all_cons {x xs} : P x -> All P xs -> All P (x :: xs).
Inductive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
All
null
Signature NoConfusion NoConfusionHom for All.
Derive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Signature
null
map_all {l : list A} : All P l -> All Q l := | all_nil := all_nil | all_cons p ps := all_cons (f _ p) (map_all ps).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
map_all
null
map_all_in {l : list A} (f : forall x, x ∈ l -> P x -> Q x) : All P l -> All Q l := | f, all_nil := all_nil | f, all_cons p ps := all_cons (f _ here p) (map_all_in (fun x inl => f x (there inl)) ps).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
map_all_in
null
StoreTy := list Ty.
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
StoreTy
null
Val : Ty -> StoreTy -> Set := | val_unit {Σ} : Val unit Σ | val_true {Σ} : Val bool Σ | val_false {Σ} : Val bool Σ | val_closure {Σ Γ t u} : Expr (t :: Γ) u -> All (fun t => Val t Σ) Γ -> Val (t ⇒ u) Σ | val_loc {Σ t} : t ∈ Σ -> Val (ref t) Σ.
Inductive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Val
null
Signature NoConfusion NoConfusionHom for Val.
Derive
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Signature
null
Env (Γ : Ctx) (Σ : StoreTy) : Set := All (fun t => Val t Σ) Γ.
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Env
null
Store (Σ : StoreTy) := All (fun t => Val t Σ) Σ.
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
Store
null
lookup : forall {A P xs} {x : A}, All P xs -> x ∈ xs -> P x := lookup (all_cons p _) here := p; lookup (all_cons _ ps) (there ins) := lookup ps ins.
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
lookup
null
update : forall {A P xs} {x : A}, All P xs -> x ∈ xs -> P x -> All P xs := update (all_cons p ps) here p' := all_cons p' ps; update (all_cons p ps) (there ins) p' := all_cons p (update ps ins p').
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
update
null
lookup_store {Σ t} : t ∈ Σ -> Store Σ -> Val t Σ := lookup_store l σ := lookup σ l.
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
lookup_store
null
update_store {Σ t} : t ∈ Σ -> Val t Σ -> Store Σ -> Store Σ := update_store l v σ := update σ l v.
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
update_store
null
store_incl (Σ Σ' : StoreTy) := sigma (fun Σ'' => Σ' = Σ'' ++ Σ).
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
store_incl
null
app_assoc {A} (x y z : list A) : x ++ y ++ z = (x ++ y) ++ z := app_assoc nil y z := eq_refl; app_assoc (cons x xs) y z := f_equal (cons x) (app_assoc xs y z).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
app_assoc
null
pres_in {Σ Σ'} (incl : Σ ⊑ Σ') t (p : t ∈ Σ) : t ∈ Σ' := pres_in (Σ'', eq_refl) t p := aux Σ'' where aux Σ'' : t ∈ (Σ'' ++ Σ) := aux nil := p; aux (cons ty tys) := there (aux tys).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
pres_in
null
refl_incl {Σ} : Σ ⊑ Σ := refl_incl := ([], eq_refl).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
refl_incl
null
trans_incl {Σ Σ' Σ''} (incl : Σ ⊑ Σ') (incl' : Σ' ⊑ Σ'') : Σ ⊑ Σ'' := trans_incl (p, eq_refl) (q, eq_refl) := (q ++ p, app_assoc _ _ _).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
trans_incl
null
store_ext_incl {Σ t} : Σ ⊑ (t :: Σ) := store_ext_incl := ([t], eq_refl).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
store_ext_incl
null
weaken_val {t} (v : Val t Σ) : Val t Σ' := { weaken_val (@val_unit ?(Σ)) := val_unit; weaken_val val_true := val_true; weaken_val val_false := val_false; weaken_val (val_closure b e) := val_closure b (weaken_vals e); weaken_val (val_loc H) := val_loc (pres_in incl _ H) } where weaken_vals {l} (a : All ...
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
weaken_val
null
weakenv_vals {l} a : @weaken_vals l a = map_all (fun t v => weaken_val v) a := weakenv_vals all_nil := eq_refl; weakenv_vals (all_cons p ps) := f_equal (all_cons (weaken_val p)) (weakenv_vals ps).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
weakenv_vals
null
weaken_env {Γ} (v : Env Γ Σ) : Env Γ Σ' := map_all (@weaken_val) v.
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
weaken_env
null
M : forall (Γ : Ctx) (P : StoreTy -> Type) (Σ : StoreTy), Type := M Γ P Σ := forall (E : Env Γ Σ) (μ : Store Σ), option (∃ Σ' (μ' : Store Σ') (_ : P Σ'), Σ ⊑ Σ').
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
M
null
bind {Σ Γ} {P Q : StoreTy -> Type} (f : M Γ P Σ) (g : ∀ {Σ'}, P Σ' -> M Γ Q Σ') : M Γ Q Σ := bind f g E μ with f E μ := | None := None | Some (Σ', μ', x, ext) with g _ x (weaken_env ext E) μ' := | None := None; | Some (_, μ'', y, ext') := Some (_, μ'', y, ext ⊚ ext').
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
bind
null
transp_op {Γ Σ P} (x : Store Σ -> P Σ) : M Γ P Σ := fun E μ => Some (Σ, μ, x μ, refl_incl).
Definition
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
transp_op
null
ret : ∀ {Γ Σ P}, P Σ → M Γ P Σ := ret (Σ:=Σ) a E μ := Some (Σ, μ, a, refl_incl).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
ret
null
getEnv : ∀ {Γ Σ}, M Γ (Env Γ) Σ := getEnv (Σ:=Σ) E μ := Some (Σ, μ, E, refl_incl).
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
getEnv
null
usingEnv {Γ Γ' Σ P} (E : Env Γ Σ) (m : M Γ P Σ) : M Γ' P Σ := usingEnv E m E' μ := m E μ.
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
usingEnv
null
timeout : ∀ {Γ Σ P}, M Γ P Σ := timeout _ _ := None.
Equations
examples
[ "Program", "Coq", "List", "Utf8", "Equations.Equations" ]
examples/definterp.v
timeout
null