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 |
|---|---|---|---|---|---|---|
showM @{T} : Type@{Ushow} := forall m : Type@{T}, Injection ascii m -> Monoid m -> m. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | showM | |
ShowScheme @{t} (T : Type@{t}) : Type := { show_mon : Monoid@{t} T ; show_inj : Injection ascii T }. Global Instance ShowScheme_string : ShowScheme string := { show_mon := Monoid_string_append ; show_inj := fun x => String x EmptyString }. Global Instance ShowScheme_string_compose : ShowScheme (string -> string) := { show_mon := Monoid_compose string ; show_inj := String }. | Class | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | ShowScheme | |
runShow {T} {M : ShowScheme T} (m : showM) : T := m _ show_inj show_mon. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | runShow | |
Show @{t m} (T : Type@{t}) : Type := show : T -> showM@{m}. | Class | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | Show | |
to_string {T} {M : Show T} (v : T) : string := runShow (show v) ""%string. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | to_string | |
empty : showM := fun _ _ m => monoid_unit m. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | empty | |
cat (a b : showM) : showM := fun _ i m => monoid_plus m (a _ i m) (b _ i m). Global Instance Injection_ascii_showM : Injection ascii showM := fun v => fun _ i _ => i v. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | cat | |
show_exact (s : string) : showM := match s with | EmptyString => empty | String a s' => cat (inject a) (show_exact s') end. | Fixpoint | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | show_exact | |
show_exact : string >-> showM. | Coercion | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | show_exact | |
_inject_char : ascii -> showM := inject. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | _inject_char | |
_inject_char : ascii >-> showM. | Coercion | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | _inject_char | |
indent (indent : showM) (v : showM) : showM := let nl := Ascii.ascii_of_nat 10 in fun _ inj mon => v _ (fun a => if eq_dec a nl then monoid_plus mon (inj a) (indent _ inj mon) else inj a) mon. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | indent | |
sepBy {T : Type} {F : Foldable T showM} (sep : showM) (ls : T) : showM := match fold (fun s acc => match acc with | None => Some s | Some x => Some (x << sep << s) end) None ls with | None => empty | Some s => s end. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | sepBy | |
sepBy_f (sep : showM) (ls : T) : showM := match fold (fun s acc => match acc with | None => Some (f s) | Some x => Some (x << sep << f s) end) None ls with | None => empty | Some s => s end. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | sepBy_f | |
wrap (before after : showM) (x : showM) : showM := cat before (cat x after). | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | wrap | |
sum_Show @{a m} {A : Type@{a}} {B : Type@{a}} {AS:Show@{a m} A} {BS:Show@{a m} B} : Show@{a m} (A+B) := fun s => let (tag, payload) := match s with | inl a => (show_exact "inl"%string, show a) | inr b => (show_exact "inr"%string, show b) end in "("%char << tag << " "%char << payload << ")"%char. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | sum_Show | |
iter_show (ss : list showM) : showM := match ss with | nil => empty | cons s ss => cat s (iter_show ss) end. | Fixpoint | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | iter_show | |
Fixpoint nat_show (n:nat) {measure n} : showM := if Compare_dec.le_gt_dec n 9 then inject (Char.digit2ascii n) else let n' := Nat.div n 10 in (@nat_show n' _) << (inject (Char.digit2ascii (n - 10 * n'))). | Program | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | Fixpoint | |
Obligation . assert (Nat.div n 10 < n) ; eauto. eapply Nat.div_lt. match goal with [ H : n > _ |- _ ] => inversion H end; apply Nat.lt_0_succ. repeat constructor. Defined. Global Instance nat_Show : Show nat := { show := nat_show }. Global Instance Show_positive : Show positive := fun x => nat_show (Pos.to_nat x). Global Instance Show_Z : Show Z := fun x => match x with | Z0 => "0"%char | Zpos p => show p | Zneg p => "-"%char << show p end. | Next | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | Obligation | |
pair_Show @{a m t} {A : Type@{a}} {B : Type@{a}} {AS:Show A} {BS:Show B} : Show@{_ t} (A*B) := fun p => let (a,b) := p in "("%char << show a << ","%char << show b << ")"%char. | Definition | theories | [
"From Coq Require Ascii.",
"From Coq Require Import String.",
"From Coq.Program Require Import Wf.",
"From Coq Require Import BinPos.",
"From Coq Require Import ZArith.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.",
"Require Import ExtLib.... | theories/Programming/Show.v | pair_Show | |
Ctor {T : Type} (ls : list {x : Type & T -> x}) : Type := match ls with | nil => T | a :: b => (projT1 a) -> Ctor b end. | Fixpoint | theories | [
"Require Import Coq."
] | theories/Programming/With.v | Ctor | |
Struct (T : Type) : Type := { fields : list {x : Type & T -> x} ; ctor : Ctor fields }. | Class | theories | [
"Require Import Coq."
] | theories/Programming/With.v | Struct | |
Mem : list {x : Type & T -> x} -> Type := | Here : forall a b, Mem ((@existT _ _ U a) :: b) | Next : forall a b, Mem b -> Mem (a :: b). | Inductive | theories | [
"Require Import Coq."
] | theories/Programming/With.v | Mem | |
applyRest (f : list {x : Type & T -> x}) : Ctor f -> T := match f as f return Ctor f -> T with | nil => fun x => x | a :: b => fun acc => applyRest b (acc ((projT2 a) rec)) end. | Fixpoint | theories | [
"Require Import Coq."
] | theories/Programming/With.v | applyRest | |
applyUntil (f : list {x : Type & T -> x}) (n : Mem U f) : Ctor f -> T := match n in Mem _ f return Ctor f -> T with | Here a b => fun ctor => applyRest b (ctor v) | Next a b i => fun ctor => applyUntil b i (ctor ((projT2 a) rec)) end. | Fixpoint | theories | [
"Require Import Coq."
] | theories/Programming/With.v | applyUntil | |
structWith {U : Type} (v : U) (n : Mem U fields) : T := applyUntil v fields n ctor. | Definition | theories | [
"Require Import Coq."
] | theories/Programming/With.v | structWith | |
Accessor {T U : Type} {strt : Struct T} (f : T -> U) : Type := { acc : Mem T U fields }. | Class | theories | [
"Require Import Coq."
] | theories/Programming/With.v | Accessor | |
wrapWith {T U : Type} (t : T) (f : T -> U) (v : U) (_strt : Struct T) (_acc : Accessor f) := @structWith _ _ t _ v acc. Delimit Scope struct_scope with record. | Definition | theories | [
"Require Import Coq."
] | theories/Programming/With.v | wrapWith | |
wf_anti_sym T (R : T -> T -> Prop) (wf : well_founded R) : Irreflexive R. Proof. refine (fun a => (@Fix _ _ wf (fun x => x = a -> R x a ->False) (fun x rec pf pfr => rec _ match eq_sym pf in _ = t return R x t with | eq_refl => pfr end pf pfr)) a eq_refl). Qed. | Lemma | theories | [
"Require Import Coq."
] | theories/Recur/Facts.v | wf_anti_sym | |
guard A (R : A -> A -> Prop) (n : nat) (wfR : well_founded R) {struct n}: well_founded R := match n with | 0 => wfR | S n => fun x => Acc_intro x (fun y _ => guard n (guard n wfR) y) end. | Fixpoint | theories | [
"Require Import Coq."
] | theories/Recur/GenRec.v | guard | |
Fix_F_equiv_inv : forall (x : A) (r' s' : Acc R x), r (Fix_F _ F r') (Fix_F _ F s'). Proof. intro x; induction (Rwf x); intros. rewrite <- (Fix_F_eq _ F r'); rewrite <- (Fix_F_eq _ F s'); intros. eapply Hstep. eauto. Qed. | Lemma | theories | [
"Require Import Coq."
] | theories/Recur/GenRec.v | Fix_F_equiv_inv | |
Fix_equiv : forall x : A, r (Fix Rwf P F x) (@F x (fun (y : A) (_ : R y x) => Fix Rwf P F y)). Proof. intro x; unfold Fix. rewrite <- Fix_F_eq. apply Hstep; intros. apply Fix_F_equiv_inv. Qed. | Theorem | theories | [
"Require Import Coq."
] | theories/Recur/GenRec.v | Fix_equiv | |
compose (a b : T) : Prop := R (f a) (f b). | Definition | theories | [
"From Coq.Classes Require Import RelationClasses.",
"From Coq.Arith Require Wf_nat."
] | theories/Recur/Measure.v | compose | |
well_founded_compose : well_founded compose := (fun t => (@Fix _ R well_founded_R (fun x => forall y, f y = x -> Acc compose y) (fun x recur y pf => @Acc_intro _ compose y (fun y' (pf' : R (f y') (f y)) => recur _ match pf in _ = t return R (f y') t with | eq_refl => pf' end _ eq_refl)) (f t) t eq_refl)). | Definition | theories | [
"From Coq.Classes Require Import RelationClasses.",
"From Coq.Arith Require Wf_nat."
] | theories/Recur/Measure.v | well_founded_compose | |
mlt : T -> T -> Prop := compose m lt. | Definition | theories | [
"From Coq.Classes Require Import RelationClasses.",
"From Coq.Arith Require Wf_nat."
] | theories/Recur/Measure.v | mlt | |
well_founded_mlt : well_founded mlt := @well_founded_compose T nat m lt Wf_nat.lt_wf. | Definition | theories | [
"From Coq.Classes Require Import RelationClasses.",
"From Coq.Arith Require Wf_nat."
] | theories/Recur/Measure.v | well_founded_mlt | |
wf_rightTrans : well_founded (rightTrans R). Proof. red. eapply Fix. eapply wf_R. clear. intros. constructor. intros. revert H. induction H0. { intros. eauto. } { intros. eapply IHrightTrans; clear IHrightTrans. specialize (H1 _ H). inversion H1. intros. eapply H2. eapply RTFin. eassumption. } Defined. | Theorem | theories | [
"Require Import ExtLib."
] | theories/Recur/Relation.v | wf_rightTrans | |
wf_leftTrans : well_founded (leftTrans R). Proof. red. eapply Fix. eapply wf_R. clear. intros. constructor. intros. revert H. induction H0. { intros. eauto. } { intros. eapply IHleftTrans; clear IHleftTrans. intros. eapply H1. auto. eapply LTFin. auto. } Defined. | Theorem | theories | [
"Require Import ExtLib."
] | theories/Recur/Relation.v | wf_leftTrans | |
compose (x z : T) : Prop := exists y, R1 x y /\ R2 y z. | Definition | theories | [] | theories/Relations/Compose.v | compose | |
makeRefl (x : T) : T -> Prop := | RRefl : makeRefl x x | RStep : forall y, R x y -> makeRefl x y. Global Instance Refl_makeRefl : Reflexive makeRefl. Proof. constructor. Qed. Global Instance Refl_makeTrans : Transitive R -> Transitive makeRefl. Proof. intro. intro. intros. inversion H0; clear H0; subst; auto. inversion H1; clear H1; subst; auto using RStep. apply RStep. etransitivity; eauto. Qed. (** Transitivity **) | Inductive | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeRefl | |
makeTrans (x y : T) : Prop := | TStep : R x y -> makeTrans x y | TTrans : forall z, makeTrans x z -> makeTrans z y -> makeTrans x y. Global Instance Trans_makeTrans : Transitive makeTrans. Proof. intro. intros; eapply TTrans; eassumption. Qed. Global Instance Trans_makeRefl : Reflexive R -> Reflexive makeTrans. Proof. intro. intro. apply TStep. reflexivity. Qed. | Inductive | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeTrans | |
leftTrans (x y : T) : Prop := | LTFin : R x y -> leftTrans x y | LTStep : forall z, R x z -> leftTrans z y -> leftTrans x y. | Inductive | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | leftTrans | |
rightTrans (x y : T) : Prop := | RTFin : R x y -> rightTrans x y | RTStep : forall z, rightTrans x z -> R z y -> rightTrans x y. (** Equivalence of definitions of transitivity **) | Inductive | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | rightTrans | |
leftTrans_rightTrans_acc x y (l : leftTrans y x) : forall z, rightTrans z y -> rightTrans z x := match l with | LTFin pf => fun z pfR => RTStep pfR pf | LTStep _ pf pfL => fun z pfR => leftTrans_rightTrans_acc pfL (RTStep pfR pf) end. | Fixpoint | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | leftTrans_rightTrans_acc | |
rightTrans_leftTrans_acc x y (l : rightTrans x y) : forall z, leftTrans y z -> leftTrans x z := match l with | RTFin pf => fun z pfR => LTStep pf pfR | RTStep _ pf pfL => fun z pfR => rightTrans_leftTrans_acc pf (LTStep pfL pfR) end. | Fixpoint | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | rightTrans_leftTrans_acc | |
leftTrans_rightTrans : forall x y, leftTrans x y <-> rightTrans x y. Proof. split. { destruct 1. apply RTFin; assumption. eapply leftTrans_rightTrans_acc. eassumption. eapply RTFin. eassumption. } { destruct 1. apply LTFin. assumption. eapply rightTrans_leftTrans_acc. eassumption. eapply LTFin. eassumption. } Qed. | Theorem | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | leftTrans_rightTrans | |
leftTrans_makeTrans_acc x y (l : leftTrans x y) : makeTrans x y := match l with | LTFin pf => TStep pf | LTStep _ pf pfL => TTrans (TStep pf) (leftTrans_makeTrans_acc pfL) end. | Fixpoint | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | leftTrans_makeTrans_acc | |
leftTrans_trans x y (l : leftTrans x y) : forall z (r : leftTrans y z), leftTrans x z := match l with | LTFin pf => fun _ pfL => LTStep pf pfL | LTStep _ pf pfL => fun _ pfR => LTStep pf (leftTrans_trans pfL pfR) end. | Fixpoint | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | leftTrans_trans | |
makeTrans_leftTrans : forall s s', makeTrans s s' <-> leftTrans s s'. Proof. split; intros. { induction H. eapply LTFin. eassumption. eapply leftTrans_trans; eassumption. } { apply leftTrans_makeTrans_acc. assumption. } Qed. | Theorem | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeTrans_leftTrans | |
makeTrans_rightTrans : forall s s', makeTrans s s' <-> rightTrans s s'. Proof. intros. etransitivity. apply makeTrans_leftTrans. apply leftTrans_rightTrans. Qed. | Theorem | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeTrans_rightTrans | |
RTStep_left : forall x y z : T, R x y -> rightTrans y z -> rightTrans x z. intros. revert H. revert x. induction H0. { intros. eapply RTStep. eapply RTFin. eassumption. eassumption. } { intros. eapply RTStep. eapply IHrightTrans. eassumption. eassumption. } Defined. | Definition | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | RTStep_left | |
makeTrans_idem : forall s s', makeTrans (makeTrans R) s s' <-> makeTrans R s s'. Proof. split. { induction 1; eauto using TTrans. } { eapply TStep. } Qed. | Theorem | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeTrans_idem | |
makeTrans_makeRefl_comm : forall s s', makeTrans (makeRefl R) s s' <-> makeRefl (makeTrans R) s s'. Proof. split. { induction 1; repeat match goal with | [ H : makeRefl _ _ _ |- _ ] => inversion H; clear H; subst end; eauto using RRefl, RStep, TStep, TTrans. } { intros. inversion H; clear H; subst; auto. apply TStep. apply RRefl. induction H0; eauto using RStep, TStep, TTrans. } Qed. | Theorem | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeTrans_makeRefl_comm | |
makeRefl_idem : forall s s', makeRefl (makeRefl R) s s' <-> makeRefl R s s'. Proof. split; inversion 1; subst; eauto using RStep, RRefl. Qed. | Theorem | theories | [
"Require Import Coq.",
"Require Import Coq."
] | theories/Relations/TransitiveClosure.v | makeRefl_idem | |
Applicative @{d c} (T : Type@{d} -> Type@{c}) := { pure : forall {A : Type@{d}}, A -> T A ; ap : forall {A B : Type@{d}}, T (A -> B) -> T A -> T B }. Global Hint Mode Applicative ! : typeclass_instances. | Class | theories | [
"From ExtLib Require Import\n Functor."
] | theories/Structures/Applicative.v | Applicative | |
liftA @{d c} {T : Type@{d} -> Type@{c}} {AT:Applicative@{d c} T} {A B : Type@{d}} (f:A -> B) (aT:T A) : T B := pure f <*> aT. | Definition | theories | [
"From ExtLib Require Import\n Functor."
] | theories/Structures/Applicative.v | liftA | |
liftA2 @{d c} {T : Type@{d} -> Type@{c}} {AT:Applicative@{d c} T} {A B C : Type@{d}} (f:A -> B -> C) (aT:T A) (bT:T B) : T C := liftA f aT <*> bT. | Definition | theories | [
"From ExtLib Require Import\n Functor."
] | theories/Structures/Applicative.v | liftA2 | |
LeftUnit : Type := lunit : forall a, equ (op u a) a. | Class | theories | [] | theories/Structures/BinOps.v | LeftUnit | |
RightUnit : Type := runit : forall a, equ (op a u) a. | Class | theories | [] | theories/Structures/BinOps.v | RightUnit | |
Commutative : Type := commut : forall a b, equ (op a b) (op b a). | Class | theories | [] | theories/Structures/BinOps.v | Commutative | |
Associative : Type := assoc : forall a b c, equ (op (op a b) c) (op a (op b c)). | Class | theories | [] | theories/Structures/BinOps.v | Associative | |
CoFunctor @{d c} (F : Type@{d} -> Type@{c}) : Type := { cofmap : forall {A B : Type@{d}}, (B -> A) -> F A -> F B }. | Class | theories | [
"Require Import ExtLib."
] | theories/Structures/CoFunctor.v | CoFunctor | |
CoPFunctor @{d c p} (F : Type@{d} -> Type@{c}) : Type := { CoFunP : Type@{d} -> Type@{p} ; copfmap : forall {A B : Type@{d}} {P : CoFunP B}, (B -> A) -> F A -> F B }. | Class | theories | [
"Require Import ExtLib."
] | theories/Structures/CoFunctor.v | CoPFunctor | |
Class CoFunP. Hint Extern 0 (@CoFunP _ _ _) => progress (simpl CoFunP) : typeclass_instances. Global Instance CoPFunctor_From_CoFunctor@{d c p} (F : Type@{d} -> Type@{c}) (F_ : CoFunctor@{d c} F) : CoPFunctor@{d c p} F := {| CoFunP := Any@{p} ; copfmap := fun _ _ _ f x => cofmap f x |}. | Existing | theories | [
"Require Import ExtLib."
] | theories/Structures/CoFunctor.v | Class | |
CoMonad (m : Type -> Type) : Type := { extract : forall {A}, m A -> A ; extend : forall {A B}, (m A -> B) -> m A -> m B }. (* Aliases for [extract] and [extend] for backward compatiblity *) | Class | theories | [] | theories/Structures/CoMonad.v | CoMonad | |
coret {A: Type} := extract (A:=A). | Definition | theories | [] | theories/Structures/CoMonad.v | coret | |
cobind {A B: Type} := extend (A:=A) (B:=B). | Definition | theories | [] | theories/Structures/CoMonad.v | cobind | |
CoMonadLaws := { extend_extract: forall (A B:Type), extend (B:=A) extract = id ; extract_extend: forall (A B:Type) {f}, extract ∘ extend (A:=A) (B:=B) f = f; extend_extend:forall (A B:Type) {f g}, extend (A:=B) (B:=A) f ∘ extend (A:=A) g = extend (f ∘ extend g) }. | Class | theories | [
"Require Import Coq.",
"Require Import ExtLib."
] | theories/Structures/CoMonadLaws.v | CoMonadLaws | |
UIP_refl : forall {x : A} (p1 : x = x), p1 = refl_equal _. intros. eapply Eqdep_dec.UIP_dec. apply EquivDec.equiv_dec. Qed. | Theorem | theories | [
"From Coq.Logic Require Eqdep_dec.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/EqDep.v | UIP_refl | |
UIP_equal : forall {x y : A} (p1 p2 : x = y), p1 = p2. eapply Eqdep_dec.UIP_dec. apply EquivDec.equiv_dec. Qed. | Theorem | theories | [
"From Coq.Logic Require Eqdep_dec.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/EqDep.v | UIP_equal | |
inj_pair2 : forall (P:A -> Type) (p:A) (x y:P p), existT P p x = existT P p y -> x = y. Proof. intros. eapply Eqdep_dec.inj_pair2_eq_dec; auto. Qed. | Lemma | theories | [
"From Coq.Logic Require Eqdep_dec.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/EqDep.v | inj_pair2 | |
equiv_dec_refl_left : forall a, @EquivDec.equiv_dec _ _ _ dec a a = left eq_refl. Proof. intros. destruct (EquivDec.equiv_dec a a); try congruence. f_equal. apply UIP_equal. Qed. | Theorem | theories | [
"From Coq.Logic Require Eqdep_dec.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/EqDep.v | equiv_dec_refl_left | |
Foldable : Type := { fold_mon : forall m {M : Monoid m}, (A -> m) -> T -> m }. Variable Foldable_T : Foldable. | Class | theories | [
"Require Import Coq.",
"Require Import ExtLib."
] | theories/Structures/Foldable.v | Foldable | |
fold (R : Type) (f : A -> R -> R) (init : R) (s : T) : R := @fold_mon Foldable_T (R -> R) {| monoid_plus := fun f g x => f (g x) ; monoid_unit := fun x => x |} f s init. | Definition | theories | [
"Require Import Coq.",
"Require Import ExtLib."
] | theories/Structures/Foldable.v | fold | |
toList : T -> list A := fold_mon (M := {| monoid_plus := @List.app A ; monoid_unit := nil |}) (fun x => x :: nil). Variable Add : A -> T -> T -> Prop. | Definition | theories | [
"Require Import Coq.",
"Require Import ExtLib."
] | theories/Structures/Foldable.v | toList | |
FoldableOk := { fold_ind : forall m (M : Monoid m) (ML : MonoidLaws M) (P : m -> Prop) f u, P (monoid_unit M) -> (forall x y z, | Class | theories | [
"Require Import Coq.",
"Require Import ExtLib."
] | theories/Structures/Foldable.v | FoldableOk | |
x y z -> P (@fold_mon Foldable_T m M f y) -> P (monoid_plus M (f x) (@fold_mon Foldable_T m M f z))) -> P (@fold_mon Foldable_T m M f u) }. | Add | theories | [
"Require Import Coq.",
"Require Import ExtLib."
] | theories/Structures/Foldable.v | x | |
FunctorLaws {F} (Functor_F : Functor F) := { fmap_id : forall {T} (x : F T), fmap id x = x ; fmap_compose : forall {T U V} (f : T -> U) (g : U -> V) (x : F T), fmap (compose g f) x = fmap g (fmap f x) }. | Class | theories | [
"From Coq.Relations Require Import Relations.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/FunctorLaws.v | FunctorLaws | |
Map : Type := { empty : map ; add : K -> V -> map -> map ; remove : K -> map -> map ; lookup : K -> map -> option V ; union : map -> map -> map }. Variable R : K -> K -> Prop. | Class | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | Map | |
MapOk (M : Map) : Type := { mapsto : K -> V -> map -> Prop ; mapsto_empty : forall k v, ~mapsto k v empty ; mapsto_lookup : forall k v m, lookup k m = Some v <-> mapsto k v m ; mapsto_add_eq : forall m k v, mapsto k v (add k v m) ; mapsto_add_neq : forall m k v k', ~R k k' -> forall v', (mapsto k' v' m <-> mapsto k' v' (add k v m)) ; mapsto_remove_eq: forall m k v, ~ mapsto k v (remove k m) ; mapsto_remove_neq : forall m k k', ~ R k k' -> forall v', (mapsto k' v' m <-> mapsto k' v' (remove k m)) }. Variable M : Map. | Class | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | MapOk | |
contains (k : K) (m : map) : bool := match lookup k m with | None => false | Some _ => true end. | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | contains | |
singleton (k : K) (v : V) : map := add k v empty. (* Finite Maps *) Context {F : Foldable map (K * V)}. | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | singleton | |
combine (f : K -> V -> V -> V) (m1 m2 : map) : map := fold (fun k_v acc => let '(k,v) := k_v in match lookup k acc with | None => add k v acc | Some v' => add k (f k v v') acc end) m2 m1. | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | combine | |
filter (f : K -> V -> bool) (m : map) : map := fold (fun k_v acc => let '(k,v) := k_v in if f k v then add k v acc else acc) empty m. | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | filter | |
submap_with (le : V -> V -> bool) (m1 m2 : map) : bool := fold (fun k_v (acc : bool) => if acc then let '(k,v) := k_v in match lookup k m2 with | None => false | Some v' => le v v' end else false) true m1. (* | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | submap_with | |
keys (s : Type) (_ : DMonad s K) : map T -> s := fold (fun k_v (acc : s) => djoin (dreturn (fst k_v)) acc) dzero. | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | keys | |
values (s : Type) (_ : DMonad s T) : map T -> s := fold (fun k_v (acc : s) => djoin (dreturn (snd k_v)) acc) dzero. *) | Definition | theories | [
"Require Import RelationClasses.",
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Maps.v | values | |
Monad @{d c} (m : Type@{d} -> Type@{c}) : Type := { ret : forall {t : Type@{d}}, t -> m t ; bind : forall {t u : Type@{d}}, m t -> (t -> m u) -> m u }. Global Hint Mode Monad ! : typeclass_instances. | Class | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | Monad | |
liftM @{d c} {m : Type@{d} -> Type@{c}} {M : Monad m} {T U : Type@{d}} (f : T -> U) : m T -> m U := fun x => bind x (fun x => ret (f x)). | Definition | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | liftM | |
liftM2 @{d c} {m : Type@{d} -> Type@{c}} {M : Monad m} {T U V : Type@{d}} (f : T -> U -> V) : m T -> m U -> m V := Eval cbv beta iota zeta delta [ liftM ] in fun x y => bind x (fun x => liftM (f x) y). | Definition | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | liftM2 | |
liftM3 @{d c} {m : Type@{d} -> Type@{c}} {M : Monad m} {T U V W : Type@{d}} (f : T -> U -> V -> W) : m T -> m U -> m V -> m W := Eval cbv beta iota zeta delta [ liftM2 ] in fun x y z => bind x (fun x => liftM2 (f x) y z). | Definition | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | liftM3 | |
apM @{d c} {m : Type@{d} -> Type@{c}} {M : Monad m} {A B : Type@{d}} (fM:m (A -> B)) (aM:m A) : m B := bind fM (fun f => liftM f aM). (* Left-to-right composition of Kleisli arrows. *) | Definition | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | apM | |
mcompose @{c d} {m:Type@{d}->Type@{c}} {M: Monad m} {T U V:Type@{d}} (f: T -> m U) (g: U -> m V): (T -> m V) := fun x => bind (f x) g. | Definition | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | mcompose | |
join @{d c} {m : Type@{d} -> Type@{c}} {a} `{Monad m} : m (m a) -> m a := fun x => bind x (fun y => y). | Definition | theories | [
"Require Import ExtLib.",
"Require Import ExtLib."
] | theories/Structures/Monad.v | join | |
Cont (m : Type -> Type) : Type := { callCC : forall a b, ((a -> m b) -> m a) -> m a }. Arguments callCC {m Cm} {_ _} _ : rename. | Class | theories | [
"Require Import ExtLib."
] | theories/Structures/MonadCont.v | Cont | |
MonadExc (E : Type) (m : Type -> Type) : Type := { raise : forall {T}, E -> m T ; catch : forall {T}, m T -> (E -> m T) -> m T }. Arguments raise {E m mE} {_} _ : rename. Arguments catch {E m mE} {_} _ _ : rename. | Class | theories | [
"Require Import ExtLib."
] | theories/Structures/MonadExc.v | MonadExc | |
MonadFix (m : Type -> Type) : Type := { mfix : forall {T U}, ((T -> m U) -> T -> m U) -> T -> m U }. | Class | theories | [
"Require Import ExtLib."
] | theories/Structures/MonadFix.v | MonadFix | |
ftype (ls : list Type) (r : Type) : Type := match ls with | nil => r | cons l ls => l -> ftype ls r end. | Fixpoint | theories | [
"Require Import ExtLib."
] | theories/Structures/MonadFix.v | ftype | |
tuple (ls : list Type) : Type := match ls with | nil => unit | cons l ls => l * tuple ls end%type. | Fixpoint | theories | [
"Require Import ExtLib."
] | theories/Structures/MonadFix.v | tuple | |
wrap (ls : list Type) R {struct ls} : (tuple ls -> R) -> ftype ls R := match ls as ls return (tuple ls -> R) -> ftype ls R with | nil => fun f => f tt | cons l ls => fun f => fun x => wrap ls (fun g => f (x,g)) end. | Fixpoint | theories | [
"Require Import ExtLib."
] | theories/Structures/MonadFix.v | wrap |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.