Commit c294d392 authored by Adam Chlipala's avatar Adam Chlipala

Prettify rbtree a bit

parent 1a8d980f
...@@ -478,7 +478,7 @@ Section insert. ...@@ -478,7 +478,7 @@ Section insert.
| Black => { c' : color & rbtree c' n } | Black => { c' : color & rbtree c' n }
end. end.
Definition makeBlack c n : insResult c n -> insertResult c n := Definition makeRbtree c n : insResult c n -> insertResult c n :=
match c return insResult c n -> insertResult c n with match c return insResult c n -> insertResult c n with
| Red => fun r => | Red => fun r =>
match r in rtree n return insertResult Red n with match r in rtree n return insertResult Red n with
...@@ -487,16 +487,10 @@ Section insert. ...@@ -487,16 +487,10 @@ Section insert.
| Black => fun r => r | Black => fun r => r
end. end.
Implicit Arguments makeBlack [c n]. Implicit Arguments makeRbtree [c n].
Definition insert c n (t : rbtree c n) : insertResult c n := Definition insert c n (t : rbtree c n) : insertResult c n :=
makeBlack (ins t). makeRbtree (ins t).
Record rbtree' : Set := Rbtree' {
rtC : color;
rtN : nat;
rtT : rbtree rtC rtN
}.
Section present. Section present.
Variable z : nat. Variable z : nat.
...@@ -577,20 +571,21 @@ Section insert. ...@@ -577,20 +571,21 @@ Section insert.
tauto. tauto.
Qed. Qed.
Theorem present_insert_Red : forall n (t : rbtree Red n), Ltac present_insert t :=
present z (insert t)
<-> (z = x \/ present z t).
unfold insert; inversion t; unfold insert; inversion t;
generalize (present_ins t); simpl; generalize (present_ins t); simpl;
dep_destruct (ins t); tauto. dep_destruct (ins t); tauto.
Theorem present_insert_Red : forall n (t : rbtree Red n),
present z (insert t)
<-> (z = x \/ present z t).
intros; present_insert t.
Qed. Qed.
Theorem present_insert_Black : forall n (t : rbtree Black n), Theorem present_insert_Black : forall n (t : rbtree Black n),
present z (projT2 (insert t)) present z (projT2 (insert t))
<-> (z = x \/ present z t). <-> (z = x \/ present z t).
unfold insert; inversion t; intros; present_insert t.
generalize (present_ins t); simpl;
dep_destruct (ins t); tauto.
Qed. Qed.
End present. End present.
End insert. End insert.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment