# HG changeset patch # User nipkow # Date 1600153067 -7200 # Node ID d488d643e677c6be33ebe14bf03bc62120cbd655 # Parent 25cf074a41884cf3e5914675ccfd8359c37d2b66 added lemma diff -r 25cf074a4188 -r d488d643e677 src/HOL/Data_Structures/Set2_Join_RBT.thy --- a/src/HOL/Data_Structures/Set2_Join_RBT.thy Sun Sep 13 16:11:05 2020 +0100 +++ b/src/HOL/Data_Structures/Set2_Join_RBT.thy Tue Sep 15 08:57:47 2020 +0200 @@ -80,10 +80,6 @@ by(auto simp: invh_baliL bheight_joinL joinL.simps[of l x r] split!: tree.split color.split) qed -lemma bheight_baliR: - "bheight l = bheight r \ bheight (baliR l a r) = Suc (bheight l)" -by (cases "(l,a,r)" rule: baliR.cases) auto - lemma bheight_joinR: "\ invh l; invh r; bheight l \ bheight r \ \ bheight (joinR l x r) = bheight l" proof (induct l x r rule: joinR.induct) @@ -99,10 +95,27 @@ split!: tree.split color.split) qed +text \All invariants in one:\ + +lemma inv_joinL: "\ invc l; invc r; invh l; invh r; bheight l \ bheight r \ + \ invc2 (joinL l x r) \ (bheight l \ bheight r \ color r = Black \ invc (joinL l x r)) + \ invh (joinL l x r) \ bheight (joinL l x r) = bheight r" +proof (induct l x r rule: joinL.induct) + case (1 l x r) thus ?case + by(auto simp: inv_baliL invc2I joinL.simps[of l x r] split!: tree.splits if_splits) +qed + +lemma inv_joinR: "\ invc l; invc r; invh l; invh r; bheight l \ bheight r \ + \ invc2 (joinR l x r) \ (bheight l \ bheight r \ color l = Black \ invc (joinR l x r)) + \ invh (joinR l x r) \ bheight (joinR l x r) = bheight l" +proof (induct l x r rule: joinR.induct) + case (1 l x r) thus ?case + by(auto simp: inv_baliR invc2I joinR.simps[of l x r] split!: tree.splits if_splits) +qed + (* unused *) lemma rbt_join: "\ invc l; invh l; invc r; invh r \ \ rbt(join l x r)" -by(simp add: invc2_joinL invc2_joinR invh_joinL invh_joinR invh_paint rbt_def - color_paint_Black join_def) +by(simp add: inv_joinL inv_joinR invh_paint rbt_def color_paint_Black join_def) text \To make sure the the black height is not increased unnecessarily:\