Proof Assistant Projects
Collection
Digesting proof assistant libraries for AI ingestion.
•
79 items
•
Updated
•
2
fact
stringlengths 17
6.18k
| type
stringclasses 17
values | library
stringclasses 3
values | imports
listlengths 0
12
| filename
stringclasses 115
values | symbolic_name
stringlengths 1
30
| docstring
stringclasses 1
value |
|---|---|---|---|---|---|---|
value : Type := | Int : nat -> value | Bool : bool -> value.
|
Inductive
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/EvalWithExc.v
|
value
| |
exp : Type := | ConstI : nat -> exp | ConstB : bool -> exp | Plus : exp -> exp -> exp | If : exp -> exp -> exp -> exp.
|
Inductive
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/EvalWithExc.v
|
exp
| |
asInt (v : value) : m nat := match v with | Int n => ret n | _ => (** if we don't have an integer, signal an error using ** [raise] from the MoandExc instance **) raise ("expected integer got bool")%string end.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/EvalWithExc.v
|
asInt
| |
asBool (v : value) : m bool := match v with | Bool b => ret b | _ => raise ("expected bool got integer")%string end. (** The main evaluator routine returns a [value], but since we are ** working in the [m] monad, we return [m value] **)
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/EvalWithExc.v
|
asBool
| |
eval' (e : exp) : m value := match e with (** when there is no error, we can just return (i.e. [ret]) ** the answer **) | ConstI i => ret (Int i) | ConstB b => ret (Bool b) | Plus l r => (** evaluate the sub-terms to numbers **) l <- eval' l ;; l <- asInt l ;; r <- eval' r ;; r <- asInt r ;; (** Combine the result **) ret (Int (l + r)) | If t tr fa => (** evaluate the test condition to a boolean **) t <- eval' t ;; t <- asBool t ;; (** case split and perform the appropriate recursion **) if (t : bool) then eval' tr else eval' fa end.
|
Fixpoint
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/EvalWithExc.v
|
eval'
| |
eval : exp -> string + value := eval' (m := sum string). (** Some tests **) Eval compute in eval (Plus (ConstI 1) (ConstI 2)). Eval compute in eval (Plus (ConstI 1) (ConstB false)). (** Other useful monads: ** * Reader - for handling lexicographic environments ** * State - for handling non-lexical state, like a heap ** * MonadFix - for handling unbounded recursion **)
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/EvalWithExc.v
|
eval
| |
update1 : istate A B unit := modify_ function1.
|
Definition
|
examples
|
[
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/indexedstate.v
|
update1
| |
update2 : istate B C unit := modify_ function2.
|
Definition
|
examples
|
[
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/indexedstate.v
|
update2
| |
compose : istate A C unit := update1 ;; update2.
|
Definition
|
examples
|
[
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/indexedstate.v
|
compose
| |
proper_eta : forall T U (f : T -> U) (type_T : type T) (type_U : type U), proper f -> proper (fun x => f x). Proof. intros; do 3 red; intros. eapply H. assumption. Qed. Goal forall x : T, proper x -> equal (bind (ret x) (fun x => ret x)) (ret x). Proof. intros. etransitivity. { eapply bind_of_return; eauto. eapply proper_eta. eapply ret_proper; eauto. } { eapply ret_proper; eauto. eapply equiv_prefl; eauto. } Qed. Goal forall x : T, proper x -> equal (bind (ret x) (fun x => ret x)) (ret x). Proof. intros. etransitivity. { eapply bind_of_return; eauto. eapply proper_eta. eapply ret_proper; eauto. } { eapply ret_proper; eauto. eapply equiv_prefl; eauto. } Qed.
|
Lemma
|
examples
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/MonadReasoning.v
|
proper_eta
| |
repeatM `{Monad M} (n : nat) `(x : A) (p : A -> M A) : M unit := match n with | O => ret tt | S n => y <- p x;; repeatM n y p end.
|
Fixpoint
|
examples
|
[
"Require Import ExtLib."
] |
examples/Notations.v
|
repeatM
| |
repeatM `{Monad M} (n : nat) `(x : A) (p : A -> M A) : M unit := match n with | O => ret tt | S n => let* y := p x in repeatM n y p end.
|
Fixpoint
|
examples
|
[
"Require Import ExtLib."
] |
examples/Notations.v
|
repeatM
| |
PrinterMonad : Type -> Type := writerT (@show_mon _ ShowScheme_string_compose) ident.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/Printing.v
|
PrinterMonad
| |
print {T : Type} {ST : Show T} (val : T) : PrinterMonad unit := @MonadWriter.tell _ (@show_mon _ ShowScheme_string_compose) _ _ (@show _ ST val _ show_inj (@show_mon _ ShowScheme_string_compose)).
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/Printing.v
|
print
| |
printString (str : string) : PrinterMonad unit := @MonadWriter.tell _ (@show_mon _ ShowScheme_string_compose) _ _ (@show_exact str _ show_inj (@show_mon _ ShowScheme_string_compose)).
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/Printing.v
|
printString
| |
runPrinter {T : Type} (c : PrinterMonad T) : T * string := let '(ppair val str) := unIdent (runWriterT c) in (val, str ""%string). Eval compute in runPrinter (Monad.bind (print 1) (fun _ => print 2)). Eval compute in runPrinter (Monad.bind (print "hello "%string) (fun _ => print 2)). Eval compute in runPrinter (Monad.bind (printString "hello "%string) (fun _ => print 2)).
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/Printing.v
|
runPrinter
| |
use of State monad Passes a string of dictionary {a,b,c} Game is to produce a number from the string. By default the game is off, a C toggles the game on and off. A 'a' gives +1 and a b gives -1. E.g 'ab' = 0 'ca' = 1 'cabca' = 0 State = game is on or off & current score = (Bool, Int) *) Require Import Coq.ZArith.ZArith_base Coq.Strings.String Coq.Strings.Ascii. Require Import ExtLib.Data.Monads.StateMonad ExtLib.Structures.Monads.
|
Example
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib."
] |
examples/StateGame.v
|
use
| |
GameValue : Type := Z.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib."
] |
examples/StateGame.v
|
GameValue
| |
GameState : Type := (prod bool Z). Variable m : Type -> Type. Context {Monad_m: Monad m}. Context {State_m: MonadState GameState m}.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib."
] |
examples/StateGame.v
|
GameState
| |
playGame (s: string) {struct s}: m GameValue := match s with | EmptyString => v <- get ;; let '(on, score) := v in ret score | String x xs => v <- get ;; let '(on, score) := v in match x, on with | "a", true => put (on, score + 1) | "b", true => put (on, score - 1) | "c", _ => put (negb on, score) | _, _ => put (on, score) end ;; playGame xs end.
|
Fixpoint
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib."
] |
examples/StateGame.v
|
playGame
| |
startState : GameState := (false, 0).
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib."
] |
examples/StateGame.v
|
startState
| |
main : GameValue := (@evalState GameState GameValue (playGame (state GameState) "abcaaacbbcabbab") startState). (* The following should return '2%Z' *) Compute main.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib."
] |
examples/StateGame.v
|
main
| |
foo : stateT unit option unit := ret tt.
|
Definition
|
examples
|
[] |
examples/StateTMonad.v
|
foo
| |
contains_both (v1 v2 : V) (s : set) : bool := contains v1 s && contains v2 s. (** Iteration requires foldability **) Context {Foldable_set : Foldable set V}.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/UsingSets.v
|
contains_both
| |
toList (s : set) : list V := fold (@cons _) nil s.
|
Definition
|
examples
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
examples/UsingSets.v
|
toList
| |
RTest : Set := mkRTest { a : bool ; b : nat ; c : bool }. Bind Scope struct_scope with RTest. Global Instance Struct_RTest : Struct RTest := { fields := ((@existT _ _ _ a) :: (@existT _ _ _ b) :: (@existT _ _ _ c):: nil) ; ctor := mkRTest }. Global Instance Acc_RTest_a : Accessor a := { acc := Here }. Global Instance Acc_RTest_b : Accessor b := { acc := Next Here }. Global Instance Acc_RTest_c : Accessor c := { acc := Next (Next Here) }. Eval compute in {$ mkRTest true 1 true with c := false $}%record. Eval compute in forall x : RTest, c {$ x with c := false $}%record = false.
|
Record
|
examples
|
[
"Require Import List.",
"Require Import ExtLib."
] |
examples/WithDemo.v
|
RTest
| |
compose (A B C : Type) (f : A -> B) (g : B -> C) : A -> C := fun x => g (f x).
|
Definition
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
compose
| |
pure (T : Type) : T -> m T := @ret _ _ _.
|
Definition
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
pure
| |
fapply (T U : Type) (f : m (T -> U)) (x : m T) : m U := bind f (fun f => bind x (fun x => ret (f x))).
|
Definition
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
fapply
| |
Instance fun_trans.
|
Existing
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
Instance
| |
Instance fun_refl. Variables A B C : Type. Context (rA : relation A) (rB : relation B) (rC : relation C) (pA : Proper rA) (pB : Proper rB) (pC : Proper rC). Context (Ra : PReflexive rA) (Rb : PReflexive rB) (Rc : PReflexive rC). Context (Ta : PTransitive rA) (Tb : PTransitive rB) (Tc : PTransitive rC).
|
Existing
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
Instance
| |
fun_app_proper (A B : Type) (rA : relation A) (rB : relation B) (pA : Proper rA) (pB : Proper rB) (f : A -> B) x : proper f -> proper x -> proper (f x). Proof. intros. apply H. auto. Qed.
|
Instance
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
fun_app_proper
| |
fun_abs (A B : Type) (rA : relation A) (rB : relation B) (pA : Proper rA) (pB : Proper rB) (f : A -> B) : (forall x, proper x -> proper (f x)) -> (forall x y, proper x -> proper y -> rA x y -> rB (f x) (f y)) -> proper (fun x => f x). Proof. intros. split; auto; eapply H. Qed.
|
Instance
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
fun_abs
| |
prove_proper x k := match x with | _ => match goal with | [ H : proper x |- _ ] => k H end | bind ?A ?B => prove_proper A ltac:(fun a => prove_proper B ltac:(fun b => let H := fresh in assert (H : proper x); [ eapply bind_proper; eauto with typeclass_instances | k H ])) | ret ?A => prove_proper A ltac:(fun a => let H := fresh in assert (H : proper x); [ eapply ret_proper; eauto with typeclass_instances | k H ]) | (fun x => _) => let H := fresh in assert (H : proper x); [ eapply fun_abs; intros; [ propers | repeat red; intros; prove_mleq ] | k H ] | _ => let H := fresh in assert (H : proper x); [ eauto with typeclass_instances | k H ] end with prove_mleq := try match goal with | |- proper (fun x => _) => eapply fun_abs; intros; [ propers | repeat red; intros; prove_mleq ] | [ R : _ , H' : pfun_ext ?R _ ?F ?G |- ?R (?F _) (?G _) ] => eapply H'; [ propers | propers | prove_mleq ] | [ H' : proper ?F |- ?R (?F _) (?F _) ] => eapply H'; [ propers | propers | try assumption; prove_mleq ] | [ |- mleq _ (bind _ _) (bind _ _) ] => eapply bind_respectful_leq; [ eauto with typeclass_instances | eauto with typeclass_instances | prove_mleq | intros; prove_mleq ] | [ |- mleq _ (ret _) (ret _) ] => eapply ret_respectful_leq; [ eauto with typeclass_instances | eauto with typeclass_instances | prove_mleq ] | [ H : proper ?f |- pfun_ext _ _ ?f ?f ] => apply H | [ H : proper ?f |- pfun_ext _ _ (fun x => _) (fun y => _) ] => red; intros; prove_mleq | _ => eassumption end with propers := match goal with | |- proper ?X => prove_proper X ltac:(fun x => eapply x) | |- mleq _ ?X ?Y => prove_proper X ltac:(fun x => prove_proper Y ltac:(fun x => idtac)) end.
|
Ltac
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
prove_proper
| |
PReflexive_stuff : PReflexive (pfun_ext (pfun_ext (pfun_ext rC pA) (Proper_pfun pB pC)) (Proper_pfun pA pB)). Proof. intuition. Qed.
|
Instance
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
PReflexive_stuff
| |
bind_law : forall (f : A -> B) (g : B -> C), proper f -> proper g -> mleq (pfun_ext rC pA) (fapply (fapply (pure (@compose A B C)) (pure f)) (pure g)) (pure (compose f g)). Proof. unfold fapply, pure, compose; simpl; intros. propers. (eapply ptransitive; [ | | | | eapply (@bind_associativity _ _ _ _ MonadLaws_mleq) | ]); eauto with typeclass_instances; propers. (eapply ptransitive; [ | | | | eapply (@bind_of_return _ _ _ _ MonadLaws_mleq) | ]); eauto with typeclass_instances; propers. (eapply ptransitive; [ | | | | eapply (@bind_associativity _ _ _ _ MonadLaws_mleq) | ]); eauto with typeclass_instances; propers. (eapply ptransitive; [ | | | | eapply (@bind_of_return _ _ _ _ MonadLaws_mleq) | ]); eauto with typeclass_instances; propers. (eapply ptransitive; [ | | | | eapply (@bind_of_return _ _ _ _ MonadLaws_mleq) | ]); eauto with typeclass_instances; propers. (eapply ptransitive; [ | | | | eapply (@bind_of_return _ _ _ _ MonadLaws_mleq) | ]); eauto with typeclass_instances; propers. eapply preflexive; eauto with typeclass_instances. Qed.
|
Theorem
|
scratch
|
[
"Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
scratch/FunctorFromMonad.v
|
bind_law
| |
Class RESOLVE. #[global] Hint Extern 0 (RESOLVE _) => unfold RESOLVE : typeclass_instances.
|
Existing
|
theories
|
[] |
theories/Core/Any.v
|
Class
| |
CmpDec (T : Type) (equ : T -> T -> Prop) (ltu : T -> T -> Prop) : Type := { cmp_dec : T -> T -> comparison }.
|
Class
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
CmpDec
| |
CmpDec_Correct T (equ ltu : T -> T -> Prop) (ED : CmpDec equ ltu) : Prop := { cmp_dec_correct : forall x y : T, match cmp_dec x y with | Eq => equ x y | Lt => ltu x y | Gt => ltu y x end }.
|
Class
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
CmpDec_Correct
| |
cmp_case (P Q R : Prop) : comparison -> Prop := | CaseEq : P -> cmp_case P Q R Eq | CaseLt : Q -> cmp_case P Q R Lt | CaseGt : R -> cmp_case P Q R Gt.
|
Inductive
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
cmp_case
| |
eq_pair (a b : T * U) : Prop := eqt (fst a) (fst b) /\ equ (snd a) (snd b).
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
eq_pair
| |
lt_pair (a b : T * U) : Prop := ltt (fst a) (fst b) \/ (eqt (fst a) (fst b) /\ ltu (snd a) (snd b)). Variable cdt : CmpDec eqt ltt. Variable cdu : CmpDec equ ltu.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
lt_pair
| |
CmpDec_pair : CmpDec eq_pair lt_pair := { cmp_dec := fun a b => let '(al,ar) := a in let '(bl,br) := b in match cmp_dec al bl with | Eq => cmp_dec ar br | x => x end }. Variable cdtC : CmpDec_Correct cdt. Variable cduC : CmpDec_Correct cdu. Variable Symmetric_eqt : Symmetric eqt.
|
Instance
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
CmpDec_pair
| |
CmpDec_Correct_pair : CmpDec_Correct CmpDec_pair. Proof. constructor. destruct x; destruct y; unfold eq_pair, lt_pair; simpl in *. generalize (cmp_dec_correct t t0); destruct (cmp_dec t t0); simpl; intros; auto. generalize (cmp_dec_correct u u0); destruct (cmp_dec u u0); simpl; intros; auto. Qed.
|
Instance
|
theories
|
[
"Require Import Coq.",
"Require Import Coq.",
"Require Import ExtLib."
] |
theories/Core/CmpDec.v
|
CmpDec_Correct_pair
| |
decideP (P : Prop) {D : Decidable P} : {P} + {~P} := match @Decidable_witness P D as X return (X = true -> P) -> (X = false -> ~P) -> {P} + {~P} with | true => fun pf _ => left (pf eq_refl) | false => fun _ pf => right (pf eq_refl) end (@Decidable_sound _ D) (@Decidable_complete_alt _ D).
|
Definition
|
theories
|
[
"From Coq.Classes Require Import DecidableClass."
] |
theories/Core/Decision.v
|
decideP
| |
cases_ifd Hn := match goal with |- context[if ?d then ?tt else ?ff] => let Hnt := fresh Hn "t" in let Hnf := fresh Hn "f" in destruct d as [Hnt | Hnf] end.
|
Ltac
|
theories
|
[
"From Coq.Classes Require Import DecidableClass."
] |
theories/Core/Decision.v
|
cases_ifd
| |
decide_decideP {P:Prop }`{Decidable P} {R:Type} (a b : R) : (if (decide P) then a else b) = (if (decideP P) then a else b). Proof. symmetry. unfold decide. destruct (decideP P). - rewrite Decidable_complete; auto. - rewrite Decidable_sound_alt; auto. Qed.
|
Lemma
|
theories
|
[
"From Coq.Classes Require Import DecidableClass."
] |
theories/Core/Decision.v
|
decide_decideP
| |
EquivDec_refl_left {T : Type} {c : EqDec T (@eq T)} : forall (n : T), equiv_dec n n = left (refl_equal _). Proof. intros. destruct (equiv_dec n n); try congruence. Require Eqdep_dec. rewrite (Eqdep_dec.UIP_dec (A := T) (@equiv_dec _ _ _ c) e (refl_equal _)). reflexivity. Qed. Export EquivDec.
|
Theorem
|
theories
|
[
"From Coq.Classes Require Import EquivDec."
] |
theories/Core/EquivDec.v
|
EquivDec_refl_left
| |
RelDec (T : Type) (equ : T -> T -> Prop) : Type := { rel_dec : T -> T -> bool }. Arguments rel_dec {_} {equ} {_} _ _. Arguments rel_dec _ _ _ !x !y.
|
Class
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
RelDec
| |
RelDec_Correct T (equ : T -> T -> Prop) (ED : RelDec equ) : Prop := { rel_dec_correct : forall x y : T, rel_dec x y = true <-> equ x y }.
|
Class
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
RelDec_Correct
| |
eq_dec {T : Type} {ED : RelDec (@eq T)} := rel_dec.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
eq_dec
| |
neg_rel_dec_correct : forall {x y}, ~R x y <-> rel_dec x y = false. Proof. intros x y. destruct (bool_dec (rel_dec x y) true) ; constructor ; intros ; repeat match goal with | [ |- ~ _ ] => unfold not ; intros | [ H1 : ?P, H2 : ~?P |- _ ] => specialize (H2 H1) ; contradiction | [ H1 : ?P = true, H2 : ?P = false |- _ ] => rewrite H1 in H2 ; discriminate | [ H1 : ?P <> true |- ?P = false ] => apply not_true_is_false ; exact H1 | [ H1 : ?rel_dec ?a ?b = true, H2 : ~?R ?a ?b |- _ ] => apply rel_dec_correct in H1 | [ H1 : ?rel_dec ?a ?b = false, H2 : ?R ?a ?b |- _ ] => apply rel_dec_correct in H2 end. Qed.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
neg_rel_dec_correct
| |
rel_dec_p (x:T) (y:T) : {R x y} + {~R x y}. Proof. destruct (bool_dec (rel_dec x y) true) as [H | H]. apply rel_dec_correct in H ; eauto. apply not_true_is_false in H ; apply neg_rel_dec_correct in H ; eauto. Qed.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
rel_dec_p
| |
neg_rel_dec_p (x:T) (y:T) : {~R x y} + {R x y}. Proof. destruct (rel_dec_p x y) ; [ right | left ] ; auto. Qed.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
neg_rel_dec_p
| |
rel_dec_eq_true : forall x y, eqt x y -> rel_dec x y = true. Proof. intros. eapply rel_dec_correct in H. assumption. Qed.
|
Theorem
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
rel_dec_eq_true
| |
rel_dec_neq_false : forall x y, ~eqt x y -> rel_dec x y = false. Proof. intros. remember (x ?[ eqt ] y). symmetry in Heqb. destruct b; try reflexivity. exfalso. eapply (@rel_dec_correct _ _ _ rc) in Heqb. auto. Qed.
|
Theorem
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
rel_dec_neq_false
| |
rel_dec_sym : Symmetric eqt -> forall x y, x ?[ eqt ] y = y ?[ eqt ] x. Proof. intros. remember (x ?[ eqt ] y); remember (y ?[ eqt ] x); intuition. destruct b; destruct b0; auto. { symmetry in Heqb; symmetry in Heqb0. eapply (@rel_dec_correct _ _ _ rc) in Heqb. symmetry in Heqb. eapply (@rel_dec_correct _ _ _ rc) in Heqb. congruence. } { symmetry in Heqb; symmetry in Heqb0. eapply (@rel_dec_correct _ _ _ rc) in Heqb0. symmetry in Heqb0. eapply (@rel_dec_correct _ _ _ rc) in Heqb0. congruence. } Qed.
|
Theorem
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
rel_dec_sym
| |
RelDec_from_dec : RelDec R := {| rel_dec := fun a b => match f a b with | left _ => true | right _ => false end |}. Global Instance RelDec_Correct_eq_typ : RelDec_Correct RelDec_from_dec. Proof. constructor. intros. unfold rel_dec; simpl. destruct (f x y). - tauto. - split. + inversion 1. + intro. apply n in H. tauto. Qed.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import Coq."
] |
theories/Core/RelDec.v
|
RelDec_from_dec
| |
digit2ascii (n:nat) : Ascii.ascii := match n with | 0 => "0" | 1 => "1" | 2 => "2" | 3 => "3" | 4 => "4" | 5 => "5" | 6 => "6" | 7 => "7" | 8 => "8" | 9 => "9" | n => ascii_of_nat (n - 10 + nat_of_ascii "A") end%char.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Char.v
|
digit2ascii
| |
chr_newline : ascii := Eval compute in ascii_of_nat 10. Export Ascii.
|
Definition
|
theories
|
[
"Require Import Coq.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Char.v
|
chr_newline
| |
Checked : option T -> Type := | Success : forall {v}, F v -> Checked (Some v) | Failure : Checked None.
|
Inductive
|
theories
|
[] |
theories/Data/Checked.v
|
Checked
| |
succeeded (o : option T) (d : Checked o) : bool := match d with | Success _ _ => true | Failure => false end.
|
Definition
|
theories
|
[] |
theories/Data/Checked.v
|
succeeded
| |
failed (o : option T) (d : Checked o) : bool := match d with | Success _ _ => false | Failure => true end.
|
Definition
|
theories
|
[] |
theories/Data/Checked.v
|
failed
| |
asOption (o : option T) (d : Checked o) : option (match o with | None => False | Some x => F x end) := match d in Checked o return option match o with | None => False | Some x => F x end with | Success _ x => Some x | Failure => None end.
|
Definition
|
theories
|
[] |
theories/Data/Checked.v
|
asOption
| |
eq_sym_eq : forall T (a b : T) (pf : a = b) (F : T -> Type) val, match eq_sym pf in _ = x return F x with | eq_refl => val end = match pf in _ = x return F x -> F a with | eq_refl => fun x => x end val. Proof. destruct pf. reflexivity. Defined.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
eq_sym_eq
| |
match_eq_sym_eq : forall T (a b : T) (pf : a = b) F X, match pf in _ = t return F t with | eq_refl => match eq_sym pf in _ = t return F t with | eq_refl => X end end = X. Proof. destruct pf. reflexivity. Defined. #[global] Hint Rewrite match_eq_sym_eq : eq_rw.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
match_eq_sym_eq
| |
match_eq_sym_eq' : forall T (a b : T) (pf : a = b) F X, match eq_sym pf in _ = t return F t with | eq_refl => match pf in _ = t return F t with | eq_refl => X end end = X. Proof. destruct pf. reflexivity. Defined. #[global] Hint Rewrite match_eq_sym_eq' : eq_rw.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
match_eq_sym_eq'
| |
match_eq_match_eq : forall T F (a b : T) (pf : a = b) X Y, X = Y -> match pf in _ = T return F T with | eq_refl => X end = match pf in _ = T return F T with | eq_refl => Y end. Proof. intros. subst. auto. Defined.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
match_eq_match_eq
| |
eq_sym_eq_trans : forall T (a b c : T) (pf : a = b) (pf' : b = c), eq_sym (eq_trans pf pf') = eq_trans (eq_sym pf') (eq_sym pf). Proof. clear. destruct pf. destruct pf'. reflexivity. Defined. (** Particular Instances **)
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
eq_sym_eq_trans
| |
eq_Const_eq : forall T (a b : T) (pf : a = b) (R : Type) val, match pf in _ = x return R with | eq_refl => val end = val. Proof. destruct pf. reflexivity. Defined. #[global] Hint Rewrite eq_Const_eq : eq_rw.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
eq_Const_eq
| |
eq_Arr_eq : forall T (a b : T) (pf : a = b) (F G : T -> Type) val x, match pf in _ = x return F x -> G x with | eq_refl => val end x = match pf in _ = x return G x with | eq_refl => val match eq_sym pf in _ = x return F x with | eq_refl => x end end. Proof. destruct pf. reflexivity. Defined. #[global] Hint Rewrite eq_Arr_eq : eq_rw.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
eq_Arr_eq
| |
eq_sym_eq_sym : forall (T : Type) (a b : T) (pf : a = b), eq_sym (eq_sym pf) = pf. Proof. destruct pf. reflexivity. Defined. #[global] Hint Rewrite eq_sym_eq_sym : eq_rw.
|
Lemma
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
eq_sym_eq_sym
| |
autorewrite_eq_rw := repeat progress (autorewrite with eq_rw; repeat match goal with | |- context [ match ?X in @eq _ _ _ return _ -> _ with | eq_refl => _ end ] => rewrite (eq_Arr_eq X) end). Require Export ExtLib.Data.Eq.UIP_trans.
|
Ltac
|
theories
|
[
"Require Export ExtLib."
] |
theories/Data/Eq.v
|
autorewrite_eq_rw
| |
fin : nat -> Type := | F0 : forall {n}, fin (S n) | FS : forall {n}, fin n -> fin (S n).
|
Inductive
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
fin
| |
fin_all (n : nat) : list (fin n) := match n as n return list (fin n) with | 0 => nil | S n => @F0 n :: List.map (@FS _) (fin_all n) end%list.
|
Fixpoint
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
fin_all
| |
fin_all_In : forall {n} (f : fin n), List.In f (fin_all n). Proof. induction n; intros. inversion f. remember (S n). destruct f. simpl; firstorder. inversion Heqn0. subst. simpl. right. apply List.in_map. auto. Qed.
|
Theorem
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
fin_all_In
| |
fin_case : forall n (f : fin (S n)), f = F0 \/ exists f', f = FS f'. Proof. intros. generalize (fin_all_In f). intros. destruct H; auto. eapply List.in_map_iff in H. right. destruct H. exists x. intuition. Qed.
|
Theorem
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
fin_case
| |
fin0_elim (f : fin 0) : forall T, T := match f in fin n return match n with | 0 => forall T, T | _ => unit end with | F0 _ => tt | FS _ _ => tt end.
|
Definition
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
fin0_elim
| |
pf_lt (n m : nat) : Prop := match n , m with | 0 , S _ => True | S n , S m => pf_lt n m | _ , _ => False end.
|
Fixpoint
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
pf_lt
| |
make (m n : nat) {struct m} : pf_lt n m -> fin m := match n as n , m as m return pf_lt n m -> fin m with | 0 , 0 => @False_rect _ | 0 , S n => fun _ => F0 | S n , 0 => @False_rect _ | S n , S m => fun pf => FS (make m n pf) end.
|
Fixpoint
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
make
| |
fin_eq_dec {n} (x : fin n) {struct x} : fin n -> bool := match x in fin n' return fin n' -> bool with | F0 _ => fun y => match y with | F0 _ => true | _ => false end | FS n' x' => fun y : fin (S n') => match y in fin n'' return (match n'' with | 0 => unit | S n'' => fin n'' end -> bool) -> bool with | F0 _ => fun _ => false | FS _ y' => fun f => f y' end (fun y => fin_eq_dec x' y) end. Global Instance RelDec_fin_eq (n : nat) : RelDec (@eq (fin n)) := { rel_dec := fin_eq_dec }. Global Instance RelDec_Correct_fin_eq (n : nat) : RelDec_Correct (RelDec_fin_eq n). Proof. constructor. induction x. simpl. intro. destruct (fin_case y) ; subst. intuition. destruct H ; subst. intuition; auto with *; try congruence. (* inversion H.*) intro ; destruct (fin_case y) ; subst ; simpl. intuition ; try congruence. inversion H. destruct H ; subst. split ; intro. f_equal ; eauto. eapply IHx. eapply H. inv_all ; subst. apply IHx. reflexivity. Qed.
|
Fixpoint
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fin.v
|
fin_eq_dec
| |
Monoid_compose T : Monoid (T -> T) := {| monoid_plus g f x := g (f x) ; monoid_unit x := x |}. Export PreFun.
|
Definition
|
theories
|
[
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib."
] |
theories/Data/Fun.v
|
Monoid_compose
| |
app_ass_trans @{X} : forall {T : Type@{X} } (a b c : list T), (a ++ b) ++ c = a ++ b ++ c. Proof. induction a; simpl. reflexivity. intros. destruct (IHa b c). reflexivity. Defined.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
app_ass_trans
| |
app_nil_r_trans : forall {T : Type} (a : list T), a ++ nil = a. Proof. induction a; simpl. reflexivity. refine match IHa in _ = X return _ = _ :: X with | eq_refl => eq_refl end. Defined. Monomorphic Universe hlist_large. (** Core Type and Functions **)
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
app_nil_r_trans
| |
hlist : list iT -> Type := | Hnil : hlist nil | Hcons : forall l ls, F l -> hlist ls -> hlist (l :: ls).
|
Inductive
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist
| |
hlist_hd {a b} (hl : hlist (a :: b)) : F a := match hl in hlist x return match x return Type@{Uv} with | nil => unit | l :: _ => F l end with | Hnil => tt | Hcons _ _ x _ => x end.
|
Definition
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_hd
| |
hlist_tl {a b} (hl : hlist (a :: b)) : hlist b := match hl in hlist x return match x return Type@{hlist_large} with | nil => unit | _ :: ls => hlist ls end with | Hnil => tt | Hcons _ _ _ x => x end.
|
Definition
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_tl
| |
hlist_eta : forall ls (h : hlist ls), h = match ls as ls return hlist ls -> hlist ls with | nil => fun _ => Hnil | a :: b => fun h => Hcons (hlist_hd h) (hlist_tl h) end h. Proof. intros. destruct h; auto. Qed.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_eta
| |
hlist_app ll lr (h : hlist ll) : hlist lr -> hlist (ll ++ lr) := match h in hlist ll return hlist lr -> hlist (ll ++ lr) with | Hnil => fun x => x | Hcons _ _ hd tl => fun r => Hcons hd (hlist_app tl r) end.
|
Fixpoint
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_app
| |
hlist_app_nil_r : forall ls (h : hlist ls), hlist_app h Hnil = match eq_sym (app_nil_r_trans ls) in _ = t return hlist t with | eq_refl => h end. Proof. induction h; simpl; intros; auto. rewrite IHh at 1. unfold eq_trans. unfold f_equal. unfold eq_sym. clear. revert h. generalize dependent (app_nil_r_trans ls). destruct e. reflexivity. Qed.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_app_nil_r
| |
hlist_rev' ls ls' (h : hlist ls) : hlist ls' -> hlist (rev ls ++ ls') := match h in hlist ls return hlist ls' -> hlist (rev ls ++ ls') with | Hnil => fun h => h | Hcons l ls0 x h' => fun hacc => match app_ass_trans (rev ls0) (l :: nil) ls' in _ = t return hlist t -> hlist _ with | eq_refl => fun x => x end (@hlist_rev' _ (l :: ls') h' (Hcons x hacc)) end.
|
Fixpoint
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_rev'
| |
hlist_rev ls (h : hlist ls) : hlist (rev ls) := match app_nil_r_trans (rev ls) in _ = t return hlist t with | eq_refl => hlist_rev' h Hnil end.
|
Definition
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_rev
| |
hlist_rev_nil : hlist_rev Hnil = Hnil. Proof. reflexivity. Qed. (** TODO: I need hlist_rev_cons **) (** Equivalence **) (** TODO: This should change to relations **)
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_rev_nil
| |
equiv_hlist : forall ls, hlist ls -> hlist ls -> Prop := | hlist_eqv_nil : equiv_hlist Hnil Hnil | hlist_eqv_cons : forall l ls x y h1 h2, eqv x y -> equiv_hlist h1 h2 -> @equiv_hlist (l :: ls) (Hcons x h1) (Hcons y h2). Global Instance Reflexive_equiv_hlist (R : forall t, Reflexive (@eqv t)) ls : Reflexive (@equiv_hlist ls). Proof. red. induction x; constructor; auto. reflexivity. Qed. Global Instance Symmetric_equiv_hlist (R : forall t, Symmetric (@eqv t)) ls : Symmetric (@equiv_hlist ls). Proof. red. induction 1. { constructor. } { constructor. symmetry. assumption. auto. } Qed. Global Instance Transitive_equiv_hlist (R : forall t, Transitive (@eqv t)) ls : Transitive (@equiv_hlist ls). Proof. red. induction 1. { intro; assumption. } { rewrite (hlist_eta z). refine (fun H' => match H' in @equiv_hlist ls X Y return match ls as ls return hlist ls -> hlist ls -> Prop with | nil => fun _ _ : hlist nil => True | l :: ls => fun (X Y : hlist (l :: ls)) => forall Z x xs, eqv (hlist_hd Z) (hlist_hd X) -> equiv_hlist xs (hlist_tl X) -> (forall z : hlist ls, equiv_hlist (hlist_tl X) z -> equiv_hlist (hlist_tl Z) z) -> @equiv_hlist (l :: ls) Z Y end X Y with | hlist_eqv_nil => I | hlist_eqv_cons l ls x y h1 h2 pf pf' => _ end (Hcons x h1) x _ H H0 (@IHequiv_hlist)). intros. rewrite (hlist_eta Z). constructor. simpl in *. etransitivity. eassumption. eassumption. eapply H3. simpl in *. eassumption. } Qed.
|
Inductive
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
equiv_hlist
| |
equiv_hlist_Hcons : forall ls i a b (c : hlist ls) d, equiv_hlist (Hcons a c) (@Hcons i ls b d) -> (@eqv i a b /\ equiv_hlist c d). Proof. clear. intros. refine match H in @equiv_hlist ls' l r return match ls' as ls' return hlist ls' -> hlist ls' -> _ with | nil => fun _ _ => True | l :: ls => fun l r => eqv (hlist_hd l) (hlist_hd r) /\ equiv_hlist (hlist_tl l) (hlist_tl r) end l r with | hlist_eqv_nil => I | hlist_eqv_cons _ _ _ _ _ _ pf pf' => conj pf pf' end. Defined.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
equiv_hlist_Hcons
| |
equiv_hlist_app : forall a b (c c' : hlist a) (d d' : hlist b), (equiv_hlist c c' /\ equiv_hlist d d') <-> equiv_hlist (hlist_app c d) (hlist_app c' d'). Proof. clear. split. - destruct 1. induction H. + assumption. + simpl. constructor; auto. - induction c. + rewrite (hlist_eta c'). simpl; intros; split; auto. constructor. + rewrite (hlist_eta c'); simpl. specialize (IHc (hlist_tl c')). intro. eapply equiv_hlist_Hcons in H. intuition. constructor; auto. Qed. Global Instance Injection_equiv_hlist_cons ls i a b (c : hlist ls) d : Injective (equiv_hlist (Hcons a c) (@Hcons i ls b d)) := { result := @eqv i a b /\ equiv_hlist c d ; injection := @equiv_hlist_Hcons _ _ _ _ _ _ }. Global Instance Injection_equiv_hlist_app a b (c c' : hlist a) (d d' : hlist b) : Injective (equiv_hlist (hlist_app c d) (hlist_app c' d')) := { result := equiv_hlist c c' /\ equiv_hlist d d' ; injection := fun x => proj2 (@equiv_hlist_app _ _ _ _ _ _) x }.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
equiv_hlist_app
| |
hlist_nil_eta : forall (h : hlist nil), h = Hnil. Proof. intros; rewrite (hlist_eta h); reflexivity. Qed.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_nil_eta
| |
hlist_cons_eta : forall a b (h : hlist (a :: b)), h = Hcons (hlist_hd h) (hlist_tl h). Proof. intros; rewrite (hlist_eta h); reflexivity. Qed.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
hlist_cons_eta
| |
Hcons_inv : forall l ls a b c d, @eq (hlist (l :: ls)) (Hcons a b) (Hcons c d) -> a = c /\ b = d. Proof. intros. refine ( match H as K in _ = Z return match Z in hlist LS return match LS with | nil => Prop | l :: ls => F l -> hlist ls -> Prop end with | Hcons X Y x y => fun a b => a = x /\ b = y | Hnil => True end a b with | eq_refl => conj eq_refl eq_refl end). Qed. Global Instance Injection_hlist_cons ls t (a : F t) (b : hlist ls) c d : Injective (Hcons a b = Hcons c d) := { result := a = c /\ b = d ; injection := @Hcons_inv t ls a b c d }.
|
Lemma
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
Hcons_inv
| |
equiv_eq_eq : forall ls (x y : hlist ls), equiv_hlist (fun x => @eq _) x y <-> x = y. Proof. induction x; simpl; intros. { split. inversion 1. rewrite hlist_nil_eta. reflexivity. intros; subst; constructor. } { split. { intro. rewrite (hlist_eta y). specialize (IHx (hlist_tl y)). refine (match H in @equiv_hlist _ LS X Y return match X in hlist LS return F match LS with | nil => l | l :: _ => l end -> hlist match LS with | nil => ls | _ :: ls => ls end -> Prop with | Hnil => fun _ _ => True | Hcons a b c d => fun x y => (equiv_hlist (fun x0 : iT => eq) d y <-> d = y) -> @Hcons a b c d = Hcons x y end (match LS as LS return hlist LS -> F match LS with | nil => l | l :: _ => l end with | nil => fun _ => f | l :: ls => hlist_hd end Y) (match LS as LS return hlist LS -> hlist match LS with | nil => ls | _ :: ls => ls end with | nil => fun _ => x | l :: ls => hlist_tl end Y) with | hlist_eqv_nil => I | hlist_eqv_cons l ls x y h1 h2 pf1 pf2 => _ end IHx). simpl. subst. intros. f_equal. apply H0. assumption. } { intros; subst. constructor; auto. reflexivity. } } Qed.
|
Theorem
|
theories
|
[
"From Coq Require Import List PeanoNat.",
"Require Import Relations RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import Coq."
] |
theories/Data/HList.v
|
equiv_eq_eq
|
Structured dataset from coq-ext-lib — Extended standard library with monads and data structures.
776 declarations extracted from Coq source files.
| Column | Type | Description |
|---|---|---|
| fact | string | Declaration body |
| type | string | Lemma, Definition, Theorem, etc. |
| library | string | Source module |
| imports | list | Required imports |
| filename | string | Source file path |
| symbolic_name | string | Identifier |