X-Git-Url: http://git.megacz.com/?p=coq-hetmet.git;a=blobdiff_plain;f=src%2FGeneral.v;h=ee5cb1690a13480f641daa7d808a7f20fd2925db;hp=5d19e9c60bf7b75bdd3cf32962dda8dcefbf07b5;hb=423b0bd3972c5bcbbd757cb715e13b5b9104a9a6;hpb=e1c9b2e7a28fabb4c0a9ce3cbd4d2ae099d60b5a diff --git a/src/General.v b/src/General.v index 5d19e9c..ee5cb16 100644 --- a/src/General.v +++ b/src/General.v @@ -106,6 +106,11 @@ Fixpoint treeReduce {T:Type}{R:Type}(mapLeaf:T->R)(mergeBranches:R->R->R) (t:Tre end. Definition treeDecomposition {D T:Type} (mapLeaf:T->D) (mergeBranches:D->D->D) := forall d:D, { tt:Tree T & d = treeReduce mapLeaf mergeBranches tt }. +Lemma mapOptionTree_distributes + : forall T R (a b:Tree ??T) (f:T->R), + mapOptionTree f (a,,b) = (mapOptionTree f a),,(mapOptionTree f b). + reflexivity. + Qed. Fixpoint reduceTree {T}(unit:T)(merge:T -> T -> T)(tt:Tree ??T) : T := match tt with @@ -520,6 +525,12 @@ Fixpoint takeT {T}{Σ:Tree T}(tf:TreeFlags Σ) : ??(Tree T) := end end. +Definition takeT' {T}{Σ:Tree ??T}(tf:TreeFlags Σ) : Tree ??T := + match takeT tf with + | None => [] + | Some x => x + end. + (* lift a function T->bool to a function (option T)->bool by yielding (None |-> b) *) Definition liftBoolFunc {T}(b:bool)(f:T -> bool) : ??T -> bool := fun t => @@ -866,6 +877,8 @@ Definition map2 {A}{B}(f:A->B)(t:A*A) : (B*B) := ((f (fst t)), (f (snd t))). (* boolean "not" *) Definition bnot (b:bool) : bool := if b then false else true. +Definition band (b1 b2:bool) : bool := if b1 then b2 else false. +Definition bor (b1 b2:bool) : bool := if b1 then true else b2. (* string stuff *) Variable eol : string.