add mapleaves to General.v
authorAdam Megacz <megacz@cs.berkeley.edu>
Sat, 19 Mar 2011 21:15:18 +0000 (14:15 -0700)
committerAdam Megacz <megacz@cs.berkeley.edu>
Sat, 19 Mar 2011 21:15:18 +0000 (14:15 -0700)
src/General.v

index ffd0d29..7aefcf0 100644 (file)
@@ -301,6 +301,16 @@ Fixpoint unleaves'' {A:Type}(l:list ??A) : Tree ??A :=
     | (a::b) => (unleaves'' b),,(T_Leaf a)
   end.
 
+Lemma mapleaves {T:Type}(t:Tree ??T){Q}{f:T->Q} : leaves (mapOptionTree f t) = map f (leaves t).
+  induction t.
+  destruct a; auto.
+  simpl.
+  rewrite IHt1.
+  rewrite IHt2.
+  rewrite map_app.
+  auto.
+  Qed.
+
 Fixpoint filter {T:Type}(l:list ??T) : list T :=
   match l with
     | nil => nil