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
apply (ls : list Type) R {struct ls} : ftype ls R -> tuple ls -> R := match ls as ls return ftype ls R -> tuple ls -> R with | nil => fun f _ => f | cons l ls => fun f t => @apply ls R (f (fst t)) (snd t) end. Context {m : Type -> Type} {MF : MonadFix m}.
Fixpoint
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadFix.v
apply
mfix_multi (ls : list Type) (R : Type) (f : ftype ls (m R) -> ftype ls (m R)) : ftype ls (m R) := @wrap ls (m R) (@mfix _ MF (tuple ls) R (fun packed => apply ls (m R) (f (wrap ls packed)))). Context {mMonad:Monad m}.
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadFix.v
mfix_multi
mfix2 A B C (ff:(A -> B -> m C) -> (A -> B -> m C)) (a:A) (b:B) : m C := let ff' fabp (abp:A*B) := let (a,b) := abp in let fab a b := fabp (a,b) in ff fab a b in mfix ff' (a,b).
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadFix.v
mfix2
mfix3 A B C D (ff:(A -> B -> C -> m D) -> (A -> B -> C -> m D)) (a:A) (b:B) (c:C) : m D := let ff' fabcp (abcp:A*B*C) := let (abp,c) := abcp in let (a,b) := abp in let fabc a b c := fabcp (a,b,c) in ff fabc a b c in mfix ff' (a,b,c).
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadFix.v
mfix3
MonadLaws := { bind_of_return : forall {A B} (a : A) (f : A -> m B), bind (ret a) f = f a ; return_of_bind : forall {A} (aM: m A), bind aM ret = aM ; bind_associativity : forall {A B C} (aM:m A) (f:A -> m B) (g:B -> m C), bind (bind aM f) g = bind aM (fun a => bind (f a) g) }.
Class
theories
[ "Require Import Setoid.", "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadLaws.v
MonadLaws
MonadTLaws {n} (nM : Monad n) (MT : MonadT m n) := { lift_ret : forall {T} (x : T), lift (ret x) = ret x ; lift_bind : forall {T U} (c : n T) (f : T -> n U), lift (bind c f) = bind (lift c) (fun x => lift (f x)) }.
Class
theories
[ "Require Import Setoid.", "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadLaws.v
MonadTLaws
MonadStateLaws (MS : MonadState S m) := { get_put : bind get put = ret tt :> m unit ; put_get : forall x : S, bind (put x) (fun _ => get) = bind (put x) (fun _ => ret x) :> m S ; put_put : forall {A} (x y : S) (f : unit -> m A), bind (put x) (fun _ => bind (put y) f) = bind (put y) f ; get_get : forall {A} (f : S -> S -> m A), bind get (fun s => bind get (f s)) = bind get (fun s => f s s) ; get_ignore : forall {A} (aM : m A), bind get (fun _ => aM) = aM }.
Class
theories
[ "Require Import Setoid.", "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadLaws.v
MonadStateLaws
MonadReaderLaws (MR : MonadReader S m) := { ask_local : forall f : S -> S, local f ask = bind ask (fun x => ret (f x)) ; local_bind : forall {A B} (aM : m A) (f : S -> S) (g : A -> m B), local f (bind aM g) = bind (local f aM) (fun x => local f (g x)) ; local_ret : forall {A} (x : A) (f : S -> S), local f (ret x) = ret x ; local_local : forall {T} (s s' : S -> S) (c : m T), local s (local s' c) = local (fun x => s' (s x)) c }.
Class
theories
[ "Require Import Setoid.", "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadLaws.v
MonadReaderLaws
MonadZeroLaws (MZ : MonadZero m) := { bind_zero : forall {A B} (f : A -> m B), bind mzero f = mzero }.
Class
theories
[ "Require Import Setoid.", "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadLaws.v
MonadZeroLaws
MonadFixLaws (MF : MonadFix m) : Type := { mleq : forall {T}, relation T -> relation (m T) ; mfix_monotonic : forall {T U} (F : (T -> m U) -> T -> m U), respectful eq (mleq eq) (mfix F) (F (mfix F)) }.
Class
theories
[ "Require Import Setoid.", "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadLaws.v
MonadFixLaws
MonadPlus (m : Type -> Type) : Type := { mplus : forall {A B:Type}, m A -> m B -> m (A + B)%type }.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadPlus.v
MonadPlus
mjoin {m : Type -> Type} {M : Monad m} {MP : MonadPlus m} {T} (a b : m T) : m T := bind (mplus a b) (fun x => match x with | inl x | inr x => ret x end).
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadPlus.v
mjoin
MonadReader @{d c} (T : Type@{d}) (m : Type@{d} -> Type@{c}) : Type := { local : forall {t : Type@{d}}, (T -> T) -> m t -> m t ; ask : m T }. Arguments local {T} {m} {_} {t} _ _ : rename. Arguments ask {T} {m} {_} : rename.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadReader.v
MonadReader
asks @{d c} {m : Type@{d} -> Type@{c}} {M : Monad m} {T : Type@{d}} {MR : MonadReader@{d c} T m} {U : Type@{d}} (f : T -> U) : m U := bind ask (fun x => ret (f x)).
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadReader.v
asks
ReaderProd @{d c} {m : Type@{d} -> Type@{c}} {M : Monad m} {T S : Type@{d}} {MR : MonadReader T m} (f : T -> S) (g : S -> T -> T) : MonadReader@{d c} S m := {| ask := @asks m M T MR S f ; local := fun _T up (c : m _T) => @local T m MR _ (fun s => g (up (f s)) s) c |}.
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadReader.v
ReaderProd
MonadState @{s d c} (T : Type@{s}) (m : Type@{d} -> Type@{c}) : Type := { get : m T ; put : T -> m unit }. Arguments get {_ m MS} : rename. Arguments put {_ m MS} _ : rename.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadState.v
MonadState
modify (f : T -> T) : m T := bind get (fun x => bind (put (f x)) (fun _ => ret x)).
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadState.v
modify
gets {U} (f : T -> U) : m U := bind get (fun x => ret (f x)).
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadState.v
gets
StateProd (f : T -> S) (g : S -> T -> T) : MonadState S m := {| get := @gets m M T MS S f ; put := fun x => bind get (fun s => put (g x s)) |}.
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadState.v
StateProd
MonadT (m : Type -> Type) (mt : Type -> Type) : Type := { lift : forall {t}, mt t -> m t }.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadTrans.v
MonadT
MonadWriter @{d c s} (T : Type@{s}) (M : Monoid T) (m : Type@{d} -> Type@{c}) : Type := { tell : T -> m unit ; listen : forall {A : Type@{d}}, m A -> m (A * T)%type ; pass : forall {A : Type@{d}}, m (A * (T -> T))%type -> m A }. Arguments tell {T MT m _} _ : rename. Arguments listen {T MT m _ _} _ : rename. Arguments pass {T MT m _} {_} _ : rename. Arguments MonadWriter {T} MT _ : rename.
Class
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadWriter.v
MonadWriter
listens @{d c s} {m : Type@{d} -> Type@{c}} {S : Type@{s}} {Monad_m : Monad m} {Monoid_S : Monoid S} {Writer_m : MonadWriter Monoid_S m} {A B : Type@{d}} (f : S -> B) (c : m A) : m (A * B)%type := liftM (fun x => (fst x, f (snd x))) (listen c).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadWriter.v
listens
censor @{d c s} {m : Type@{d} -> Type@{c}} {S : Type@{s}} {Monad_m : Monad m} {Monoid_S : Monoid S} {Writer_m : MonadWriter Monoid_S m} {A : Type@{d}} (f : S -> S) (c : m A) : m A := pass (liftM (fun x => (x, f)) c).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/MonadWriter.v
censor
MonadZero (m : Type -> Type) : Type := { mzero : forall {T}, m T }.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadZero.v
MonadZero
assert (b : bool) : m unit := if b then ret tt else mzero.
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/MonadZero.v
assert
Monoid @{} : Type := { monoid_plus : S -> S -> S ; monoid_unit : S }.
Record
theories
[ "Require Import ExtLib." ]
theories/Structures/Monoid.v
Monoid
MonoidLaws @{} (M : Monoid) := { monoid_assoc : Associative M.(monoid_plus) eq ; monoid_lunit : LeftUnit M.(monoid_plus) M.(monoid_unit) eq ; monoid_runit : RightUnit M.(monoid_plus) M.(monoid_unit) eq }. #[global] Existing Instance monoid_assoc. #[global] Existing Instance monoid_lunit. #[global] Existing Instance monoid_runit.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/Monoid.v
MonoidLaws
Ident : Type := lunit : forall a, equ (op u a) a.
Class
theories
[]
theories/Structures/Ops.v
Ident
RightUnit : Type := runit : forall a, equ (op a u) a.
Class
theories
[]
theories/Structures/Ops.v
RightUnit
Reducible (T E : Type) : Type := reduce : forall {A} (base : A) (single : E -> A) (join : A -> A -> A), T -> A.
Class
theories
[ "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/Reducible.v
Reducible
Foldable (T E : Type) : Type := fold : forall {A} (add : E -> A -> A) (base : A), T -> A.
Class
theories
[ "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/Reducible.v
Foldable
foldM {A} (add : E -> A -> m A) (base : m A) (t : T) : m A := fold (fun x acc => bind acc (add x)) base t.
Definition
theories
[ "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/Reducible.v
foldM
reduceM {A} (base : m A) (single : E -> m A) (join : A -> A -> m A) (t : T) : m A := reduce base single (fun x y => bind x (fun x => bind y (fun y => join x y))) t.
Definition
theories
[ "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/Reducible.v
reduceM
iterM : T -> m unit := reduce (ret tt) f (fun x y => bind x (fun _ => y)).
Definition
theories
[ "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/Reducible.v
iterM
ReducibleLaw : Prop := reduce_spec : forall A (unit : A) (single : E -> A) (join : A -> A -> A) (eqA : A -> A -> Prop), LeftUnit join unit eqA -> RightUnit join unit eqA -> Commutative join eqA -> Associative join eqA -> forall t, eqA (reduce unit single join t) (fold_right (fun acc x => join acc (single x)) ?? unit) *)
Class
theories
[ "Require Import Coq.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Structures/Reducible.v
ReducibleLaw
DSet : Type := { contains : T -> S -> bool ; empty : S ; singleton : T -> S ; union : S -> S -> S ; filter : (T -> bool) -> S -> S ; intersect : S -> S -> S ; difference : S -> S -> S ; subset : S -> S -> bool (** point-wise **) ; add : T -> S -> S ; remove : T -> S -> S }. Variable DS : DSet. Variable eqT : T -> T -> Prop.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/Sets.v
DSet
DSet_Laws : Type := { DSet_WF : S -> Prop ; empty_WF : DSet_WF empty ; singleton_WF : forall x, DSet_WF (singleton x) ; union_WF : forall s s', DSet_WF s -> DSet_WF s' -> DSet_WF (union s s') ; filter_WF : forall s f, DSet_WF s -> DSet_WF (filter f s) ; intersect_WF : forall s s', DSet_WF s -> DSet_WF s' -> DSet_WF (intersect s s') ; difference_WF : forall s s', DSet_WF s -> DSet_WF s' -> DSet_WF (difference s s') ; add_WF : forall s x, DSet_WF s -> DSet_WF (add x s) ; remove_WF : forall s x, DSet_WF s -> DSet_WF (remove x s) ; empty_not_contains : forall t, contains t empty = false ; singleton_contains : forall t u, contains t (singleton u) = true <-> eqT t u ; union_contains : forall s s', DSet_WF s -> DSet_WF s' -> forall x, orb (contains x s) (contains x s') = contains x (union s s') ; intersect_contains : forall s s', DSet_WF s -> DSet_WF s' -> forall x, andb (contains x s) (contains x s') = contains x (intersect s s') ; difference_contains : forall s s', DSet_WF s -> DSet_WF s' -> forall x, andb (contains x s) (negb (contains x s')) = contains x (difference s s') ; subset_contains : forall s s', DSet_WF s -> DSet_WF s' -> subset s s' = true <-> (forall x, contains x s = true -> contains x s' = true) ; add_contains : forall s x, DSet_WF s -> contains x (add x s) = true ; add_contains_not : forall s x y, DSet_WF s -> ~eqT x y -> contains x (add y s) = contains x s ; remove_contains : forall s x, DSet_WF s -> contains x (remove x s) = false ; remove_contains_not : forall s x y, DSet_WF s -> ~eqT x y -> contains x (remove y s) = contains x s }.
Class
theories
[ "Require Import ExtLib." ]
theories/Structures/Sets.v
DSet_Laws
Monoid_set_union : Monoid S := {| monoid_plus := union ; monoid_unit := empty |}.
Definition
theories
[ "Require Import ExtLib." ]
theories/Structures/Sets.v
Monoid_set_union
negb_true : forall a, negb a = true -> a = false. Proof. destruct a; auto. Qed.
Lemma
theories
[ "Require Import Coq." ]
theories/Tactics/BoolTac.v
negb_true
negb_false : forall a, negb a = false -> a = true. Proof. destruct a; auto. Qed.
Lemma
theories
[ "Require Import Coq." ]
theories/Tactics/BoolTac.v
negb_false
do_bool' runner := ( autorewrite with bool_rw in * ); repeat match goal with | [ H : negb _ = true |- _ ] => apply negb_true in H | [ H : negb _ = false |- _ ] => apply negb_false in H | [ H : andb _ _ = true |- _ ] => apply andb_true_iff in H; destruct H | [ H : orb _ _ = false |- _ ] => apply orb_false_iff in H; destruct H | [ H : true = andb _ _ |- _ ] => symmetry in H; apply andb_true_iff in H; destruct H | [ H : false = orb _ _ |- _ ] => symmetry in H; apply orb_false_iff in H; destruct H | [ H : andb _ _ = false |- _ ] => apply andb_false_iff in H; runner H | [ H : orb _ _ = true |- _ ] => apply orb_true_iff in H; runner H | [ H : false = andb _ _ |- _ ] => symmetry in H; apply andb_false_iff in H; runner H | [ H : true = orb _ _ |- _ ] => symmetry in H; apply orb_true_iff in H; runner H end.
Ltac
theories
[ "Require Import Coq." ]
theories/Tactics/BoolTac.v
do_bool'
do_bool_case := let t H := (destruct H) in do_bool' t.
Ltac
theories
[ "Require Import Coq." ]
theories/Tactics/BoolTac.v
do_bool_case
do_bool := let t _ := idtac in do_bool' t. (** Test **) (* Goal forall a b c d e f : bool, negb (a || b) = true -> negb (a && b) = false -> a && b && c = true -> b && c && d = false -> d || e || f = true -> b || c || d = false -> true = a && b && c -> false = b && c && d -> true = d || e || f -> false = b || c || d -> if a && b then True else False. Proof. intros. do_bool. Abort. *)
Ltac
theories
[ "Require Import Coq." ]
theories/Tactics/BoolTac.v
do_bool
forward' dst sol := let check X := match X with | match _ with _ => _ end => fail 1 | if _ then _ else _ => fail 1 | _ => idtac end in let go X := first [ (dst X; try solve [ sol ]); [ intros ] | dst X; solve [ sol ] ] in repeat match goal with | [ H : context [ match ?X with _ => _ end ] |- _ ] => go X | [ H : context [ if ?X then _ else _ ] |- _ ] => go X | [ |- context [ match ?X with _ => _ end ] ] => go X | [ |- context [ if ?X then _ else _ ] ] => go X end.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
forward'
forward := forward' ltac:(fun x => consider x; intros) ltac:(intuition congruence).
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
forward
forward_unsafe' dst sol := let check X := match X with | match _ with _ => _ end => fail 1 | if _ then _ else _ => fail 1 | _ => idtac end in let go X := dst X; try solve [ sol ] in repeat match goal with | [ H : context [ match ?X with _ => _ end ] |- _ ] => go X | [ H : context [ if ?X then _ else _ ] |- _ ] => go X | [ |- context [ match ?X with _ => _ end ] ] => go X | [ |- context [ if ?X then _ else _ ] ] => go X end.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
forward_unsafe'
forward_unsafe := forward_unsafe' ltac:(fun x => consider x; intros) ltac:(intuition congruence).
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
forward_unsafe
change_rewrite H := match type of H with | ?X = _ => match goal with | |- context [ ?Y ] => change Y with X ; rewrite H end end.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
change_rewrite
change_rewrite_in H H' := match type of H with | ?X = _ => match type of H' with | context [ ?Y ] => change Y with X in H' ; rewrite H in H' end end. Tactic Notation "change_rewrite" hyp(H) := (change_rewrite H). Tactic Notation "change_rewrite" hyp(H) "in" hyp(H') := (change_rewrite_in H H').
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
change_rewrite_in
rewrite_all_goal := repeat match goal with | [ H : _ |- _ ] => progress (erewrite H by eauto with typeclass_instances) end.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
rewrite_all_goal
rewrite_all_in H' := repeat match goal with | [ H : _ |- _ ] => progress (erewrite H in H' by eauto with typeclass_instances) end.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
rewrite_all_in
rewrite_all_star := repeat match goal with | [ H : _ |- _ ] => progress (erewrite H in * by eauto with typeclass_instances) end. (*
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
rewrite_all_star
rewrite_all := rewrite_all_goal. *)
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Cases.v
rewrite_all
reflect (P Q : Prop) : bool -> Type := | reflect_true : P -> reflect P Q true | reflect_false : Q -> reflect P Q false.
Inductive
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
reflect
semi_reflect (P : Prop) : bool -> Type := | semi_reflect_true : P -> semi_reflect P true | semi_reflect_false : semi_reflect P false.
Inductive
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
semi_reflect
iff_to_reflect {A B} (P : A -> B -> Prop) (T : A -> B -> bool) : (forall x y, T x y = true <-> P x y) -> (forall x y, reflect (P x y) (~P x y) (T x y)). Proof. intros. case_eq (T x y); intros Hxy; constructor. apply H. assumption. intros Hf. apply H in Hf. congruence. Qed.
Lemma
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
iff_to_reflect
impl_to_semireflect {A B} (P : A -> B -> Prop) (T : A -> B -> bool) : (forall x y, T x y = true -> P x y) -> (forall x y, semi_reflect (P x y) (T x y)). Proof. intros. case_eq (T x y); intros Hxy; constructor. apply H; auto. Qed.
Lemma
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
impl_to_semireflect
reflect_true_inv P Q : reflect P Q true -> P. Proof. exact (fun x => match x in reflect _ _ b return if b then P else ID with | reflect_true _ _ H => H | reflect_false _ _ H => (fun _ x => x) end). Qed.
Lemma
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
reflect_true_inv
reflect_false_inv P Q : reflect P Q false -> Q. Proof. exact (fun x => match x in reflect _ _ b return if b then ID else Q with | reflect_true _ _ H => fun _ x => x | reflect_false _ _ H => H end). Qed.
Lemma
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
reflect_false_inv
semi_reflect_true_inv P : semi_reflect P true -> P. Proof. exact (fun x => match x in semi_reflect _ b return if b then P else ID with | semi_reflect_true _ H => H | semi_reflect_false _ => (fun _ x => x) end). Qed.
Lemma
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
semi_reflect_true_inv
Reflect (T : bool) (P Q : Prop) := _Reflect : reflect P Q T.
Class
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
Reflect
SemiReflect (T : bool) (P : Prop) := _SemiReflect : semi_reflect P T.
Class
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
SemiReflect
t := repeat match goal with | H: Reflect true ?P ?Q |- _ => apply (reflect_true_inv P Q) in H | H: Reflect false ?P ?Q |- _ => apply (reflect_false_inv P Q) in H end. Context {T1 T2 P1 Q1 P2 Q2} {R1 : Reflect T1 P1 Q1} {R2: Reflect T2 P2 Q2}. Global Instance Reflect_andb : Reflect (T1 && T2)%bool (P1 /\ P2) (Q1 \/ Q2). Proof. destruct T1; destruct T2; t; constructor; tauto. Qed. Global Instance Reflect_orb : Reflect (T1 || T2)%bool (P1 \/ P2) (Q1 /\ Q2). Proof. destruct T1; destruct T2; t; constructor; tauto. Qed. Global Instance Reflect_negb : Reflect (negb T1)%bool Q1 P1. Proof. destruct T1; t; constructor; tauto. Qed.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
t
consider f := let rec clean := match goal with | |- true = true -> _ => intros _ ; clean | |- false = true -> _ => discriminate | |- ?P1 -> ?P2 => let H := fresh in intros H ; clean; revert H | |- _ => idtac end in (repeat match goal with | [ H : context [ f ] |- _ ] => revert H end) ; match type of f with | sumbool _ _ => destruct f | _ => match goal with | _ => ((let c := constr:(_ : Reflect f _ _) in case c)) (*; let H := fresh in intros H; try rewrite H; revert H)) *) | _ => ((let c := constr:(_ : SemiReflect f _) in case c)) (*; let H := fresh in try (intros H; try rewrite H; revert H))) *) | _ => (** default to remembering the equality **) case_eq f end end ; clean.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Consider.v
consider
UIP_refl : forall {x : A} (p1 : x = x), p1 = refl_equal _. intros. eapply Eqdep_dec.UIP_dec. apply equiv_dec. Qed.
Theorem
theories
[ "From Coq.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/EqDep.v
UIP_refl
UIP_equal : forall {x y : A} (p1 p2 : x = y), p1 = p2. eapply Eqdep_dec.UIP_dec. apply equiv_dec. Qed.
Theorem
theories
[ "From Coq.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/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.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/EqDep.v
inj_pair2
notVar X := match X with | _ _ => idtac | _ _ _ => idtac | _ _ _ _ => idtac | _ _ _ _ _ => idtac | _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ _ _ _ _ _ => idtac | _ _ _ _ _ _ _ _ _ _ _ _ _ _ => idtac end.
Ltac
theories
[ "From Coq.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/EqDep.v
notVar
gen_refl := repeat match goal with | H : context [ @eq_refl ?X ?Y ] |- _ => generalize dependent (@eq_refl X Y) | |- context [ @eq_refl ?X ?Y ] => generalize dependent (@eq_refl X Y) end.
Ltac
theories
[ "From Coq.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/EqDep.v
gen_refl
uip_all := repeat match goal with | [ H : _ = _ |- _ ] => rewrite H | [ |- context [ match ?X in _ = t return _ with | refl_equal => _ end ] ] => notVar X; generalize X | [ |- context [ eq_rect_r _ _ ?X ] ] => notVar X; generalize X end; intros; repeat match goal with | [ H : ?X = ?X |- _ ] => rewrite (UIP_refl H) in * | [ _ : context [ ?H ] |- _ ] => rewrite (UIP_refl H) in * | [ |- context [ ?H ] ] => rewrite (UIP_refl H) in * end.
Ltac
theories
[ "From Coq.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/EqDep.v
uip_all
uip_all' := repeat match goal with | [ H : _ = _ |- _ ] => rewrite H | [ |- context [ match ?X in _ = t return _ with | refl_equal => _ end ] ] => notVar X; generalize X | [ |- context [ eq_rect_r _ _ ?X ] ] => notVar X; generalize X end; intros; repeat match goal with | [ H : ?X = ?X |- _ ] => generalize dependent H; let pf := fresh in intro pf; rewrite (UIP_refl pf) in * ; try clear pf end. Export EquivDec.
Ltac
theories
[ "From Coq.Classes Require Import EquivDec.", "Require Import ExtLib.", "From Coq.Logic Require Eqdep_dec." ]
theories/Tactics/EqDep.v
uip_all'
eq_rw_goal := autorewrite with eq_rw.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Equality.v
eq_rw_goal
eq_rw_hyp H := autorewrite with eq_rw in H.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Equality.v
eq_rw_hyp
eq_rw_star := autorewrite with eq_rw in *. Tactic Notation "eq_rw" := eq_rw_goal. Tactic Notation "eq_rw" "in" hyp(H) := eq_rw_hyp H. Tactic Notation "eq_rw" "in" "*" := eq_rw_star.
Ltac
theories
[ "Require Import ExtLib." ]
theories/Tactics/Equality.v
eq_rw_star
forward_reason := repeat match goal with | H : exists x, _ |- _ => destruct H | H : _ /\ _ |- _ => destruct H | H' : ?X , H : ?X -> ?Y |- _ => match type of X with | Prop => specialize (H H') end | H : ?X -> ?Y |- _ => match type of X with | Prop => let H' := fresh in assert (H' : X) by eauto ; specialize (H H') ; clear H' end end.
Ltac
theories
[]
theories/Tactics/Forward.v
forward_reason
rwHyps := repeat match goal with [ H: ?l = ?r |- _] => match r with | context [l] => idtac | _ => rewrite -> H end end.
Ltac
theories
[]
theories/Tactics/Forward.v
rwHyps
rwHypsR := repeat match goal with [ H: _ = _ |- _] => rewrite <- H end.
Ltac
theories
[]
theories/Tactics/Forward.v
rwHypsR
rwHypsA := repeat match goal with [ H: _ = _ |- _] => rewrite -> H in * end.
Ltac
theories
[]
theories/Tactics/Forward.v
rwHypsA
rwHypsRA := repeat match goal with [ H: _ = _ |- _] => rewrite <- H in * end. (* based on a tactic written by Vincent Rahli *)
Ltac
theories
[]
theories/Tactics/Forward.v
rwHypsRA
clear_trivials := repeat match goal with | [ H : ?T = ?T |- _ ] => clear H | [ H : ?T <-> ?T |- _ ] => clear H | [ H : ?T -> ?T |- _ ] => clear H | [ H1 : ?T, H2 : ?T |- _ ] => clear H2 | [ H : True |- _ ] => clear H | [ H : not False |- _ ] => clear H end.
Ltac
theories
[]
theories/Tactics/Forward.v
clear_trivials
Hidden (P:Type) : Prop:= | hidden (p:P): Hidden P.
Inductive
theories
[]
theories/Tactics/Hide.v
Hidden
show_hyp H := destruct H as [H].
Ltac
theories
[]
theories/Tactics/Hide.v
show_hyp
hide_hyp H := apply hidden in H.
Ltac
theories
[]
theories/Tactics/Hide.v
hide_hyp
show_hyps := repeat match goal with H: Hidden _ |- _ => show_hyp H end.
Ltac
theories
[]
theories/Tactics/Hide.v
show_hyps
Injective (P : Prop) : Type := { result : Prop ; injection : P -> result }.
Class
theories
[]
theories/Tactics/Injection.v
Injective
destruct_ands H := match type of H with | _ /\ _ => let H1 := fresh in let H2 := fresh in destruct H as [ H1 H2 ] ; destruct_ands H1 ; destruct_ands H2 | exists x , _ => let H1 := fresh in destruct H as [ ? H1 ] ; destruct_ands H1 | _ => idtac end.
Ltac
theories
[]
theories/Tactics/Injection.v
destruct_ands
inv_all := repeat match goal with | [ H : ?X |- _ ] => let z := constr:(_ : Injective X) in eapply (@injection X z) in H; do 2 red in H ; destruct_ands H end. (* Example Global Instance Injective_Some (T : Type) (a b : T) : Injective (Some a = Some b) := { result := a = b }. abstract (inversion 1; auto). Defined. Goal forall x y : nat, Some x = Some y -> x = y. Proof. intros; inv_all; assumption. Qed. *)
Ltac
theories
[]
theories/Tactics/Injection.v
inv_all
bind_rw_0 : forall A B (tA : type A) (tB : type B), typeOk tA -> typeOk tB -> forall (x z : m A) (y : A -> m B), equal x z -> proper y -> equal (bind x y) (bind z y). Proof. intros. eapply bind_proper; eauto. Qed.
Theorem
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Tactics/MonadTac.v
bind_rw_0
bind_rw_1 : forall A B (tA : type A) (tB : type B), typeOk tA -> typeOk tB -> forall (x z : A -> m B) (y : m A), (forall a b, equal a b -> equal (x a) (z b)) -> proper y -> equal (bind y x) (bind y z). Proof. intros. eapply bind_proper; eauto. solve_equal. Qed.
Theorem
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Tactics/MonadTac.v
bind_rw_1
Proper_red : forall T U (rT : relation T) (rU : relation U) (f : T -> U), (forall x x', rT x x' -> rU (f x) (f x')) -> Proper (rT ==> rU) f. intuition. Qed.
Theorem
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
Proper_red
respectful_red : forall T U (rT : relation T) (rU : relation U) (f g : T -> U), (forall x x', rT x x' -> rU (f x) (g x')) -> respectful rT rU f g. intuition. Qed.
Theorem
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
respectful_red
respectful_if_bool T : forall (x x' : bool) (t t' f f' : T) eqT, x = x' -> eqT t t' -> eqT f f' -> eqT (if x then t else f) (if x' then t' else f') . intros; subst; auto; destruct x'; auto. Qed.
Theorem
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
respectful_if_bool
derive_morph := repeat first [ lazymatch goal with | |- Proper _ _ => red; intros | |- (_ ==> _)%signature _ _ => red; intros end | apply respectful_red; intros | apply respectful_if_bool; intros | match goal with | [ H : (_ ==> ?EQ)%signature ?F ?F' |- ?EQ (?F _) (?F' _) ] => apply H | [ |- ?EQ (?F _) (?F _) ] => let inst := constr:(_ : Proper (_ ==> EQ) F) in apply inst | [ H : (_ ==> _ ==> ?EQ)%signature ?F ?F' |- ?EQ (?F _ _) (?F' _ _) ] => apply H | [ |- ?EQ (?F _ _) (?F' _ _) ] => let inst := constr:(_ : Proper (_ ==> _ ==> EQ) F) in apply inst | [ |- ?EQ (?F _ _ _) (?F _ _ _) ] => let inst := constr:(_ : Proper (_ ==> _ ==> _ ==> EQ) F) in apply inst | [ |- ?EQ (?F _) (?F _) ] => unfold F | [ |- ?EQ (?F _ _) (?F _ _) ] => unfold F | [ |- ?EQ (?F _ _ _) (?F _ _ _) ] => unfold F end ]. Global Instance Proper_andb : Proper (@eq bool ==> @eq bool ==> @eq bool) andb. derive_morph; auto. Qed.
Ltac
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
derive_morph
Instance Fproper.
Existing
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
Instance
food (x y z : bool) : bool := F x (F y z). Global Instance Proper_food : Proper (@eq bool ==> @eq bool ==> @eq bool ==> @eq bool) food. Proof. derive_morph; auto. Qed. Global Instance Proper_S : Proper (@eq nat ==> @eq nat) S. Proof. derive_morph; auto. Qed.
Definition
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
food
listEq {T} (eqT : relation T) : relation (list T) := | listEq_nil : listEq eqT nil nil | listEq_cons : forall x x' y y', eqT x x' -> listEq eqT y y' ->listEq eqT (x :: y) (x' :: y').
Inductive
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
listEq
listEq_match V U (eqV : relation V) (eqU : relation U) : forall x x' : list V, forall X X' Y Y', eqU X X' -> (eqV ==> listEq eqV ==> eqU)%signature Y Y' -> listEq eqV x x' -> eqU (match x with | nil => X | x :: xs => Y x xs end) (match x' with | nil => X' | x :: xs => Y' x xs end). Proof. intros. induction H1; auto. derive_morph; auto. Qed. Variable U : Type. Variable eqU : relation U. Variable f : T -> U. Variable fproper : Proper (eqT ==> eqU) f.
Theorem
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
listEq_match
hd (l : list T) : option T := match l with | nil => None | l :: _ => Some l end. (* Global Instance Proper_hd : Proper (listEq eqT ==> optionEq eqT) hd. Proof. foo. (** This has binders in the match... **) Abort. *)
Definition
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
hd
map' (l : list T) : list U := match l with | nil => nil | l :: ls => f l :: map' ls end. Global Instance Proper_map' : Proper (listEq eqT ==> listEq eqU) map'. Proof. derive_morph. induction H; econstructor; derive_morph; auto. Qed.
Fixpoint
theories
[ "Require Import Setoid.", "Require Import RelationClasses.", "Require Import Morphisms.", "Require Import List." ]
theories/Tactics/Parametric.v
map'
ClassReify (v : Q) : Type := { reify : P ; reify_sound : D reify = v }.
Class
theories
[ "Require Import Lists." ]
theories/Tactics/Reify.v
ClassReify