diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-02-04 14:03:35 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-02-04 14:03:35 +0100 |
commit | 04dc160b4962fedd1ef1b322809377a2fa1434a2 (patch) | |
tree | 68586dc9f2c204dd704ca529583f9874df1b0a42 /lib/Maps.v | |
parent | 3fde34d48925db4153c5c288fa37da35725502ce (diff) | |
download | compcert-kvx-04dc160b4962fedd1ef1b322809377a2fa1434a2.tar.gz compcert-kvx-04dc160b4962fedd1ef1b322809377a2fa1434a2.zip |
gcombine_null
Diffstat (limited to 'lib/Maps.v')
-rw-r--r-- | lib/Maps.v | 40 |
1 files changed, 39 insertions, 1 deletions
@@ -625,7 +625,45 @@ Module PTree <: TREE. auto. Qed. - Fixpoint xelements (A : Type) (m : t A) (i : positive) + Section COMBINE_NULL. + + Variables A B C: Type. + Variable f: A -> B -> option C. + + + Fixpoint combine_null (m1: t A) (m2: t B) {struct m1} : t C := + match m1, m2 with + | (Node l1 o1 r1), (Node l2 o2 r2) => + Node' (combine_null l1 l2) + (match o1, o2 with + | (Some x1), (Some x2) => f x1 x2 + | _, _ => None + end) + (combine_null r1 r2) + | _, _ => Leaf + end. + + Theorem gcombine_null: + forall (m1: t A) (m2: t B) (i: positive), + get i (combine_null m1 m2) = + match (get i m1), (get i m2) with + | (Some x1), (Some x2) => f x1 x2 + | _, _ => None + end. + Proof. + induction m1; intros; simpl. + - rewrite gleaf. rewrite gleaf. + reflexivity. + - destruct m2; simpl. + + rewrite gleaf. rewrite gleaf. + destruct get; reflexivity. + + rewrite gnode'. + destruct i; simpl; try rewrite IHm1_1; try rewrite IHm1; trivial. + Qed. + + End COMBINE_NULL. + + Fixpoint xelements (A : Type) (m : t A) (i : positive) (k: list (positive * A)) {struct m} : list (positive * A) := match m with |