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
modify {i o : Type} (f : i -> o) : istate i o i := bind get (fun x : i => bind (put (f x)) (fun _ : unit => ret x)).
Definition
theories
[ "Require Import ExtLib." ]
theories/Data/Monads/IStateMonad.v
modify
modify_ {i o : Type} (f : i -> o) : istate i o unit := bind (modify f) (fun _ => ret tt).
Definition
theories
[ "Require Import ExtLib." ]
theories/Data/Monads/IStateMonad.v
modify_
optionT a := mkOptionT { unOptionT : m (option a) }. Context {M : Monad m}. Global Instance Monad_optionT : Monad optionT := { ret _A := fun x => mkOptionT (ret (Some x)) ; bind _A _B aMM f := mkOptionT (aM <- unOptionT aMM ;; match aM with | None => ret None | Some a => unOptionT (f a) end) }. Global Instance Zero_opt...
Inductive
theories
[ "Require Import ExtLib." ]
theories/Data/Monads/OptionMonad.v
optionT
Plus_optionT_right : MonadPlus optionT := { mplus _A _B a b := mkOptionT (bind (unOptionT b) (fun b => match b with | None => bind (unOptionT a) (fun a => match a with | None => ret None | Some a => ret (Some (inl a)) end) | Some b => ret (Some (inr b)) end)) }.
Instance
theories
[ "Require Import ExtLib." ]
theories/Data/Monads/OptionMonad.v
Plus_optionT_right
Plus_optionT_left : MonadPlus optionT := { mplus _A _B a b := mkOptionT (bind (unOptionT a) (fun a => match a with | None => bind (unOptionT b) (fun b => match b with | None => ret None | Some b => ret (Some (inr b)) end) | Some a => ret (Some (inl a)) end)) }. Global Instance Plus_optionT : MonadPlus optionT := Plus_o...
Instance
theories
[ "Require Import ExtLib." ]
theories/Data/Monads/OptionMonad.v
Plus_optionT_left
OptionTError : MonadExc unit optionT := { raise _u _A := mzero ; catch _A aMM f := mkOptionT (aM <- unOptionT aMM ;; match aM with | None => unOptionT (f tt) | Some x => ret (Some x) end) }.
Instance
theories
[ "Require Import ExtLib." ]
theories/Data/Monads/OptionMonad.v
OptionTError
optionT_eq (a b : optionT m T) : Prop := equal (unOptionT a) (unOptionT b). Global Instance type_optionT : type (optionT m T) := type_from_equal optionT_eq. Variable tokT : typeOk tT. Global Instance typeOk_readerT : typeOk type_optionT. Proof. eapply typeOk_from_equal. { simpl. unfold optionT_eq. intros. generalize (o...
Definition
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
optionT_eq
equal_match : forall (A B : Type) (eA : type A) (eB : type B), typeOk eA -> typeOk eB -> forall (x y : option A) (a b : B) (f g : A -> B), equal x y -> equal a b -> equal f g -> equal match x with | Some a => f a | None => a end match y with | Some a => g a | None => b end. Proof. destruct x; destruct y; intros; eauto ...
Theorem
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
equal_match
proper_match : forall (A B : Type) (eA : type A) (eB : type B), typeOk eA -> typeOk eB -> forall (x : option A), proper x -> forall f : A -> optionT m B, proper f -> proper match x with | Some a => unOptionT (f a) | None => ret None end. Proof. destruct x; intros; eauto with typeclass_instances; type_tac. Qed. Global I...
Instance
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
proper_match
cl := eauto with typeclass_instances.
Ltac
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
cl
tcl := solve [ cl ].
Ltac
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
tcl
monad_rewrite t := first [ t | rewrite bind_rw_0; [ | tcl | tcl | tcl | t | type_tac ] | rewrite bind_rw_1 ]. monad_rewrite ltac:(eapply put_get; eauto with typeclass_instances). rewrite bind_associativity; cl; try solve_proper. rewrite bind_rw_1; [ | tcl | tcl | tcl | intros | type_tac ]. Focus 2. etransitivity. eappl...
Ltac
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
monad_rewrite
Parametric Morphism (T : Type) (tT : type T) (tokT : typeOk tT) : (@equal _ tT) with signature (equal ==> equal ==> iff) as equal_mor. Proof. clear - tokT. intros. split; intros. { etransitivity. symmetry; eassumption. etransitivity; eassumption. } { etransitivity; eauto. etransitivity; eauto. symmetry; auto. } Qed.
Add
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
Parametric
Parametric Morphism (T : Type) (tT : type T) (tokT : typeOk tT) : (@equal _ tT) with signature (equal ==> eq ==> iff) as equal_left_mor. Proof. clear - tokT. intros. split; intros. { etransitivity. symmetry; eassumption. eassumption. } { etransitivity; eauto. } Qed.
Add
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
Parametric
Parametric Morphism (T : Type) (tT : type T) (tokT : typeOk tT) : (@equal _ tT) with signature (eq ==> equal ==> iff) as equal_right_mor. Proof. clear - tokT. intros. split; intros. { etransitivity. eassumption. eassumption. } { etransitivity; eauto. symmetry; auto. } Qed. assert (Morphisms.Proper (equal ==> Basics.fli...
Add
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
Parametric
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)z, equal x z -> proper y -> equal (bind x y) (bind z y). Proof. } { type_tac. rewrite bind_of_return; eauto with typeclass_instances; type_tac. eapply equal_match_option; eauto with typeclass_instances; type_t...
Theorem
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/OptionMonadLaws.v
bind_rw_0
reader (t : Type) : Type := mkReader { runReader : S -> t }. Global Instance Monad_reader : Monad reader := { ret := fun _ v => mkReader (fun _ => v) ; bind := fun _ _ c1 c2 => mkReader (fun s => let v := runReader c1 s in runReader (c2 v) s) }. Global Instance MonadReader_reader : MonadReader S reader := { ask := mkRe...
Record
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/ReaderMonad.v
reader
readerT (t : Type) : Type := mkReaderT { runReaderT : S -> m t }. Variable M : Monad m. Global Instance Monad_readerT : Monad readerT := { ret := fun _ x => mkReaderT (fun s => @ret _ M _ x) ; bind := fun _ _ c1 c2 => mkReaderT (fun s => @bind _ M _ _ (runReaderT c1 s) (fun v => runReaderT (c2 v) s)) }. Global Instance...
Record
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/ReaderMonad.v
readerT
readerT_eq T (tT : type T) (a b : readerT S m T) : Prop := equal (runReaderT a) (runReaderT b). Global Instance type_readerT (T : Type) (tT : type T) : type (readerT S m T) := type_from_equal (readerT_eq tT). Global Instance typeOk_readerT (T : Type) (tT : type T) (tOkT : typeOk tT) : typeOk (type_readerT tT). Proof. e...
Definition
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/ReaderMonadLaws.v
readerT_eq
mproper_red : forall (C : Type) (tC : type C) (o : readerT S m C), proper o -> proper (runReaderT o). Proof. clear. intros. apply H. Qed. Global Instance proper_runReaderT T (tT : type T) : proper (@runReaderT S m T). Proof. repeat red; intros. apply H in H0. apply H0. Qed. Global Instance proper_mkReaderT T (tT : type...
Theorem
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/ReaderMonadLaws.v
mproper_red
unfold_readerT := red; simpl; intros; do 2 (red; simpl); intros. Global Instance MonadLaws_readerT : MonadLaws (@Monad_readerT S _ Monad_m) _. Proof. constructor. { (* bind_of_return *) unfold_readerT. erewrite bind_of_return; eauto with typeclass_instances; type_tac. } { (* return_of_bind *) unfold_readerT. rewrite re...
Ltac
theories
[ "Require Import RelationClasses.", "Require Import Setoid.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/ReaderMonadLaws.v
unfold_readerT
state (t : Type) : Type := mkState { runState : S -> t * S }.
Record
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
state
evalState {t} (c : state t) (s : S) : t := fst (runState c s).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
evalState
execState {t} (c : state t) (s : S) : S := snd (runState c s). Global Instance Monad_state : Monad state := { ret := fun _ v => mkState (fun s => (v, s)) ; bind := fun _ _ c1 c2 => mkState (fun s => let (v,s) := runState c1 s in runState (c2 v) s) }. Global Instance MonadState_state : MonadState S state := { get := mkS...
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
execState
stateT (t : Type) : Type := mkStateT { runStateT : S -> m (t * S)%type }. Variable M : Monad m.
Record
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
stateT
evalStateT {t} (c : stateT t) (s : S) : m t := bind (runStateT c s) (fun x => ret (fst x)).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
evalStateT
execStateT {t} (c : stateT t) (s : S) : m S := bind (runStateT c s) (fun x => ret (snd x)). (** [Monad_stateT] is not a Global Instance because it can cause an infinite loop in typeclass inference under certain circumstances. Use [Existing Instance Monad_stateT.] to bring the instance into context. *)
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
execStateT
Monad_stateT : Monad stateT := { ret := fun _ x => mkStateT (fun s => @ret _ M _ (x,s)) ; bind := fun _ _ c1 c2 => mkStateT (fun s => @bind _ M _ _ (runStateT c1 s) (fun vs => let (v,s) := vs in runStateT (c2 v) s)) }. Global Instance MonadState_stateT : MonadState S stateT := { get := mkStateT (fun x => ret (x,x)) ; p...
Instance
theories
[ "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Monads/StateMonad.v
Monad_stateT
writerT (Monoid_S : Monoid@{s} S) (m : Type@{d} -> Type@{c}) (t : Type@{d}) : Type := mkWriterT { runWriterT : m (pprod t S)%type }. Variable Monoid_S : Monoid S. Variable m : Type@{d} -> Type@{c}. Context {M : Monad m}. Arguments mkWriterT _ [_ _] _.
Record
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
writerT
execWriterT {T} (c : writerT Monoid_S m T) : m S := bind (runWriterT c) (fun (x : pprod T S) => ret (psnd x)).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
execWriterT
evalWriterT {T} (c : writerT Monoid_S m T) : m T := bind (runWriterT c) (fun (x : pprod T S) => ret (pfst x)). Local Notation "( x , y )" := (ppair x y). Global Instance Monad_writerT : Monad (writerT Monoid_S m) := { ret := fun _ x => mkWriterT _ (@ret _ M _ (x, monoid_unit Monoid_S)) ; bind := fun _ _ c1 c2 => mkWrit...
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
evalWriterT
mapWriterT (f: m (pprod A W) -> n (pprod B W')) : writerT Monoid_W m A -> writerT Monoid_W' n B := mkWriterT Monoid_W' ∘ f ∘ runWriterT.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
mapWriterT
castWriterT : writerT Monoid_W m A -> writerT Monoid_W' m A := mkWriterT Monoid_W' ∘ runWriterT.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
castWriterT
writer : Type -> Type := writerT Monoid_W ident.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
writer
runWriter : writer A -> pprod A W := unIdent ∘ (@runWriterT W Monoid_W ident A).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
runWriter
execWriter : writer A -> W := psnd ∘ runWriter.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
execWriter
evalWriter : writer A -> A := pfst ∘ runWriter.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
evalWriter
mapWriter (f: pprod A W -> pprod B W') : writer Monoid_W A -> writer Monoid_W' B := mapWriterT Monoid_W' ident B (mkIdent ∘ f ∘ unIdent).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
mapWriter
castWriter : writer Monoid_W A -> writer Monoid_W' A := castWriterT Monoid_W' (m:=ident).
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import Coq." ]
theories/Data/Monads/WriterMonad.v
castWriter
lset (T : Type) : Type := list T. Variable T : Type. Variable R_dec : T -> T -> bool.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset
lset_contains (v : T) (ls : lset T) : bool := match ls with | nil => false | l :: ls => if R_dec v l then true else lset_contains v ls end.
Fixpoint
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_contains
lset_empty : lset T := nil.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_empty
lset_add (v : T) (ls : lset T) : lset T := if lset_contains v ls then ls else v :: ls.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_add
lset_remove (v : T) : lset T -> lset T := List.filter (fun x => negb (R_dec v x)).
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_remove
lset_union (l r : lset T) : lset T := fold_left (fun x y => lset_add y x) l r.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_union
lset_difference (l r : lset T) : lset T := List.filter (fun x => negb (lset_contains x r)) l.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_difference
lset_intersect (l r : lset T) : lset T := List.filter (fun x => lset_contains x r) l.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_intersect
lset_subset (l r : lset T) : bool := allb (fun x => lset_contains x r) l.
Definition
theories
[ "Require Import List.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/ListSet.v
lset_subset
tree := (* Null_t = _ *) | Null_t : tree (* [a] * Two_t X a Y = / \ * X Y * Invariant: x in X => x < a; y in Y => y > a *) | Two_t : tree -> E -> tree -> tree (* [a][b] * Three_t X a Y b Z = / | \ * X Y Z * Invariant: x in X => x < a; y in Y => a < y < b; z in Z => z > b *) | Three_t : tree -> E -> tree -> E -> tree ->...
Inductive
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
tree
height_t (t:tree) : nat := match t with | Null_t => O | Two_t tl _ tr => max (height_t tl) (height_t tr) | Three_t tl _ tm _ tr => max (max (height_t tl) (height_t tm)) (height_t tr) end. (* a context of a two-three tree. this is the type of taking a tree and * replacing a sub-tree with a hole. *)
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
height_t
context := (* Top_c = _ *) | Top_c : context (* C * TwoLeftHole_c a Y C = | * [a] * / \ * ? Y *) | TwoLeftHole_c : E -> tree -> context -> context (* C * TwoRightHole_c X a C = | * [a] * / \ * X ? *) | TwoRightHole_c : tree -> E -> context -> context (* C * ThreeLeftHole a Y b Z C = | * [a][b] * / | \ * ? Y Z *) | Thre...
Inductive
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
context
zip (t:tree) (c:context) : tree := match c with | Top_c => t | TwoLeftHole_c em tr c' => zip (Two_t t em tr) c' | TwoRightHole_c tl em c' => zip (Two_t tl em t) c' | ThreeLeftHole_c el em er tr c' => zip (Three_t t el em er tr) c' | ThreeMiddleHole_c tl el er tr c' => zip (Three_t tl el t er tr) c' | ThreeRightHole_c t...
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
zip
fuse (c1:context) (c2:context) : context := match c1 with | Top_c => c2 | TwoLeftHole_c em tr c1' => TwoLeftHole_c em tr (fuse c1' c2) | TwoRightHole_c tl em c1' => TwoRightHole_c tl em (fuse c1' c2) | ThreeLeftHole_c el em er tr c1' => ThreeLeftHole_c el em er tr (fuse c1' c2) | ThreeMiddleHole_c tl el er tr c1' => Th...
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
fuse
location := (* C * TwoHole_l X Y C = | * [?] * / \ * X Y *) | TwoHole_l : tree -> tree -> context -> location (* C * TwoHole_l X Y b Z C = | * [?][b] * / | \ * X Y Z *) | ThreeLeftHole_l : tree -> tree -> E -> tree -> context -> location (* C * TwoHole_l X a Y Z C = | * [a][?] * / | \ * X Y Z *) | ThreeRightHole_l : tr...
Inductive
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
location
fillLocation (e:E) (l:location) : tree := match l with | TwoHole_l tl tr c => zip (Two_t tl e tr) c | ThreeLeftHole_l tl tm vr tr c => zip (Three_t tl e tm vr tr) c | ThreeRightHole_l tl el tm tr c => zip (Three_t tl el tm e tr) c end.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
fillLocation
locate (e:E) (t:tree) (c:context) : context + E * location := match t with | Null_t => inl c | Two_t tl em tr => match comp e em with | Lt => locate e tl $ TwoLeftHole_c em tr c | Eq => inr (em, TwoHole_l tl tr c) | Gt => locate e tr $ TwoRightHole_c tl em c end | Three_t tl el tm er tr => match comp e el, comp e er wi...
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
locate
locateGreatest (t:tree) (c:context) : option (E * (context + E * context)) := match t with | Null_t => None | Two_t tl em tr => liftM sum_tot $ locateGreatest tr (TwoRightHole_c tl em c) <+> ret (em, inl c) | Three_t tl el tm er tr => liftM sum_tot $ locateGreatest tr (ThreeRightHole_c tl el tm er c) <+> ret (er, inr (...
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
locateGreatest
single e := Two_t Null_t e Null_t. (* if insertion results in a subtree which is too tall, propegate it up into * its context. *)
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
single
insertUp (tet:tree * E * tree) (c:context) : tree := let '(tl,em,tr) := tet in match c with (* _ * | * [em] => [em] * // \\ / \ * tl tr tl tr *) | Top_c => Two_t tl em tr (* c' c' * | | * [em'] => [em][em'] * / \ / | \ * [em] tr' tl tr tr' * // \\ * tl tr *) | TwoLeftHole_c em' tr' c' => zip (Three_t tl em tr em' tr') ...
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
insertUp
insert (e:E) (t:tree) : tree := match locate e t Top_c with | inl c => insertUp (Null_t, e, Null_t) c | inr (_, l) => fillLocation e l end. (* if remove results in a tree which is too short, propegate the gap into the * context *)
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
insert
removeUp (t:tree) (c:context) : tree := match c with (* _ * || * e => e *) | Top_c => t (* c' c' * | | * [em] => [el'] * // \ / \ * t [el'][er'] [em] [er'] * / | \ / \ / \ * tl' tm' tr' t tl' tm' tr' *) | TwoLeftHole_c em (Three_t tl' el' tm' er' tr') c' => zip (Two_t (Two_t t em tl') el' (Two_t tm' er' tr')) c' (* c' ...
Fixpoint
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
removeUp
remove (e:E) (t:tree) : tree := match locate e t Top_c with (* element doesn't exist *) | inl _ => t (* element found at location [loc] *) | inr (_, loc) => match loc with (* element found at a two-node *) | TwoHole_l tl tr c => let mkContext g c' := TwoLeftHole_c g tr c' in match locateGreatest tl Top_c with (* no chi...
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
remove
tree_wf : tree E -> nat -> EtndTopBot E -> EtndTopBot E -> Prop := | NullTreeWf : forall eLL eRR, tree_wf Null_t O eLL eRR | TwoTreeWf : forall tl em tr h eLL eRR, eLL << IncEtndTopBot em -> IncEtndTopBot em << eRR -> tree_wf tl h eLL (IncEtndTopBot em) -> tree_wf tr h (IncEtndTopBot em) eRR -> tree_wf (Two_t tl em tr)...
Inductive
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
tree_wf
tree_in : E -> tree E -> Prop := | TwoTreeIn : forall e tl em tr, e ~= em \/ tree_in e tl \/ tree_in e tr -> tree_in e (Two_t tl em tr) | ThreeTreeIn : forall e tl el tm er tr, e ~= el \/ e ~= er \/ tree_in e tl \/ tree_in e tm \/ tree_in e tr -> tree_in e (Three_t tl el tm er tr) . (*
Inductive
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
tree_in
swapTwoWf : forall tl em tr h eLL eRR em', tree_wf (Two_t tl em tr) h eLL eRR -> em ~= em' -> tree_wf (Two_t tl em' tr) h eLL eRR. Proof. intros ; induction h. inversion H. inversion H ; subst ; clear H. constructor. repeat (ohsnap ; girlforeal). unfold ltP in H5. destruct eLL ; repeat (ohsnap ; girlforeal). ... *)
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
swapTwoWf
context_wf (c:context) (sth:nat) (sel:E+bool) (ser:E+bool) (th:nat) (eLL:E+bool) (eRR:E+bool) : Prop := forall t:tree, tree_wf t sth sel ser -> tree_wf (zip t c) th eLL eRR.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
context_wf
twoLeftHoleZipWf : forall tl em tr c h eLL eRR, tree_wf (zip (Two_t tl em tr) c) h eLL eRR -> tree_wf (zip tl (TwoLeftHole_c em tr c)) h eLL eRR. Proof. intros. induction tl ; intros ; simpl ; auto. Qed. Hint Immediate twoLeftHoleZipWf : twoThreeDb.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
twoLeftHoleZipWf
twoRightHoleZipWf : forall tl em tr c h eLL eRR, tree_wf (zip (Two_t tl em tr) c) h eLL eRR -> tree_wf (zip tr (TwoRightHole_c tl em c)) h eLL eRR. Proof. intros. induction tl ; intros ; simpl ; auto. Qed. Hint Immediate twoRightHoleZipWf : twoThreeDb.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
twoRightHoleZipWf
threeLeftHoleZipWf : forall tl el tm er tr c h eLL eRR, tree_wf (zip (Three_t tl el tm er tr) c) h eLL eRR-> tree_wf (zip tl (ThreeLeftHole_c el tm er tr c)) h eLL eRR. Proof. intros. induction tl ; intros ; simpl ; auto. Qed. Hint Immediate threeLeftHoleZipWf : twoThreeDb.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
threeLeftHoleZipWf
threeMiddleHoleZipWf : forall tl el tm er tr c h eLL eRR, tree_wf (zip (Three_t tl el tm er tr) c) h eLL eRR -> tree_wf (zip tm (ThreeMiddleHole_c tl el er tr c)) h eLL eRR. Proof. intros. induction tl ; intros ; simpl ; auto. Qed. Hint Immediate threeMiddleHoleZipWf : twoThreeDb.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
threeMiddleHoleZipWf
threeRightHoleZipWf : forall tl el tm er tr c h eLL eRR, tree_wf (zip (Three_t tl el tm er tr) c) h eLL eRR -> tree_wf (zip tr (ThreeRightHole_c tl el tm er c)) h eLL eRR. Proof. intros. induction tl ; intros ; simpl ; auto. Qed. Hint Immediate threeRightHoleZipWf : twoThreeDb.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
threeRightHoleZipWf
location_wf (l:location) h eLL eRR : Prop := forall e:E, tree_wf (fillLocation e l) h eLL eRR.
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
location_wf
zipLocationWf : forall tl em tr c, tree_wf (zip (Two_t tl em tr) c) -> location_wf (TwoHole_l tl tr c). Proof. intros. unfold location_wf. intros. simpl. exists em. auto. Qed. Hint Immediate zipLocationWf : twoThreeDb.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
zipLocationWf
locate_wf : forall e t c, tree_wf (zip t c) -> match locate e t c with inl c => tree_wf (zip Null_t c) | inr (_,l) => location_wf l end. Proof. intros. gd c. gd e. induction t ; intros ; simpl ; auto. destruct (compareo e0 e). pose (twoLeftHoleZipWf _ _ _ _ H). specialize (IHt1 e0 _ t). apply IHt1. eauto with twoThreeD...
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
locate_wf
single_wf : forall e, tree_wf (single e). Proof. intros. simpl. auto. Qed.
Lemma
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
single_wf
insert_wf : forall e t, tree_wf t -> tree_wf (insert e t). Proof. intros. destruct t. simpl. auto. unfold insert. simpl. destruct (compareo e e0). unfold insert. destruct (locate e t Top_c). simpl. *) *)
Definition
theories
[ "Require Import ExtLib.", "Require Import ExtLib.", "Require Import ExtLib." ]
theories/Data/Set/TwoThreeTrees.v
insert_wf