src/HOL/Data_Structures/RBT_Set.thy
changeset 66088 c9c9438cfc0f
parent 66087 6e0c330f4051
child 67118 ccab07d1196c
equal deleted inserted replaced
66087:6e0c330f4051 66088:c9c9438cfc0f
   226    (auto simp: invc_baldL invc2I split: tree.splits color.splits)
   226    (auto simp: invc_baldL invc2I split: tree.splits color.splits)
   227 
   227 
   228 lemma neq_LeafD: "t \<noteq> Leaf \<Longrightarrow> \<exists>c l x r. t = Node c l x r"
   228 lemma neq_LeafD: "t \<noteq> Leaf \<Longrightarrow> \<exists>c l x r. t = Node c l x r"
   229 by(cases t) auto
   229 by(cases t) auto
   230 
   230 
   231 lemma del_invc_invh: "invh l \<Longrightarrow> invc l \<Longrightarrow> invh (del x l) \<and>
   231 lemma del_invc_invh: "invh t \<Longrightarrow> invc t \<Longrightarrow> invh (del x t) \<and>
   232    (color l = Red \<and> bheight (del x l) = bheight l \<and> invc (del x l) \<or>
   232    (color t = Red \<and> bheight (del x t) = bheight t \<and> invc (del x t) \<or>
   233     color l = Black \<and> bheight (del x l) = bheight l - 1 \<and> invc2 (del x l))"
   233     color t = Black \<and> bheight (del x t) = bheight t - 1 \<and> invc2 (del x t))"
   234 proof (induct x l rule: del.induct)
   234 proof (induct x t rule: del.induct)
   235 case (2 y c _ y' W)
   235 case (2 x c _ y)
   236   have "y = y' \<or> y < y' \<or> y > y'" by auto
   236   have "x = y \<or> x < y \<or> x > y" by auto
   237   thus ?case proof (elim disjE)
   237   thus ?case proof (elim disjE)
   238     assume "y = y'"
   238     assume "x = y"
   239     with 2 show ?thesis
   239     with 2 show ?thesis
   240     by (cases c) (simp_all add: invh_combine invc_combine)
   240     by (cases c) (simp_all add: invh_combine invc_combine)
   241   next
   241   next
   242     assume "y < y'"
   242     assume "x < y"
   243     with 2 show ?thesis
   243     with 2 show ?thesis
   244       by(cases c)
   244       by(cases c)
   245         (auto simp: invh_baldL_invc invc_baldL invc2_baldL dest: neq_LeafD)
   245         (auto simp: invh_baldL_invc invc_baldL invc2_baldL dest: neq_LeafD)
   246   next
   246   next
   247     assume "y' < y"
   247     assume "y < x"
   248     with 2 show ?thesis
   248     with 2 show ?thesis
   249       by(cases c)
   249       by(cases c)
   250         (auto simp: invh_baldR_invc invc_baldR invc2_baldR dest: neq_LeafD)
   250         (auto simp: invh_baldR_invc invc_baldR invc2_baldR dest: neq_LeafD)
   251   qed
   251   qed
   252 qed auto
   252 qed auto