replaced raw proof blocks by local lemmas
authornipkow
Fri Nov 10 22:05:30 2017 +0100 (17 months ago)
changeset 67040c1b87d15774a
parent 67039 690b4b334889
child 67041 f8b0367046bd
child 67071 a462583f0a37
replaced raw proof blocks by local lemmas
src/HOL/Data_Structures/AA_Map.thy
src/HOL/Data_Structures/AA_Set.thy
src/HOL/Data_Structures/Brother12_Map.thy
src/HOL/Data_Structures/Brother12_Set.thy
     1.1 --- a/src/HOL/Data_Structures/AA_Map.thy	Thu Nov 09 10:24:00 2017 +0100
     1.2 +++ b/src/HOL/Data_Structures/AA_Map.thy	Fri Nov 10 22:05:30 2017 +0100
     1.3 @@ -72,64 +72,62 @@
     1.4  
     1.5  lemma invar_update: "invar t \<Longrightarrow> invar(update a b t)"
     1.6  proof(induction t)
     1.7 -  case (Node n l xy r)
     1.8 +  case N: (Node n l xy r)
     1.9    hence il: "invar l" and ir: "invar r" by auto
    1.10 +  note iil = N.IH(1)[OF il]
    1.11 +  note iir = N.IH(2)[OF ir]
    1.12    obtain x y where [simp]: "xy = (x,y)" by fastforce
    1.13 -  note N = Node
    1.14    let ?t = "Node n l xy r"
    1.15    have "a < x \<or> a = x \<or> x < a" by auto
    1.16    moreover
    1.17 -  { assume "a < x"
    1.18 -    note iil = Node.IH(1)[OF il]
    1.19 -    have ?case
    1.20 -    proof (cases rule: lvl_update[of a b l])
    1.21 -      case (Same) thus ?thesis
    1.22 -        using \<open>a<x\<close> invar_NodeL[OF Node.prems iil Same]
    1.23 -        by (simp add: skew_invar split_invar del: invar.simps)
    1.24 +  have ?case if "a < x"
    1.25 +  proof (cases rule: lvl_update[of a b l])
    1.26 +    case (Same) thus ?thesis
    1.27 +      using \<open>a<x\<close> invar_NodeL[OF N.prems iil Same]
    1.28 +      by (simp add: skew_invar split_invar del: invar.simps)
    1.29 +  next
    1.30 +    case (Incr)
    1.31 +    then obtain t1 w t2 where ial[simp]: "update a b l = Node n t1 w t2"
    1.32 +      using N.prems by (auto simp: lvl_Suc_iff)
    1.33 +    have l12: "lvl t1 = lvl t2"
    1.34 +      by (metis Incr(1) ial lvl_update_incr_iff tree.inject)
    1.35 +    have "update a b ?t = split(skew(Node n (update a b l) xy r))"
    1.36 +      by(simp add: \<open>a<x\<close>)
    1.37 +    also have "skew(Node n (update a b l) xy r) = Node n t1 w (Node n t2 xy r)"
    1.38 +      by(simp)
    1.39 +    also have "invar(split \<dots>)"
    1.40 +    proof (cases r)
    1.41 +      case Leaf
    1.42 +      hence "l = Leaf" using N.prems by(auto simp: lvl_0_iff)
    1.43 +      thus ?thesis using Leaf ial by simp
    1.44      next
    1.45 -      case (Incr)
    1.46 -      then obtain t1 w t2 where ial[simp]: "update a b l = Node n t1 w t2"
    1.47 -        using Node.prems by (auto simp: lvl_Suc_iff)
    1.48 -      have l12: "lvl t1 = lvl t2"
    1.49 -        by (metis Incr(1) ial lvl_update_incr_iff tree.inject)
    1.50 -      have "update a b ?t = split(skew(Node n (update a b l) xy r))"
    1.51 -        by(simp add: \<open>a<x\<close>)
    1.52 -      also have "skew(Node n (update a b l) xy r) = Node n t1 w (Node n t2 xy r)"
    1.53 -        by(simp)
    1.54 -      also have "invar(split \<dots>)"
    1.55 -      proof (cases r)
    1.56 -        case Leaf
    1.57 -        hence "l = Leaf" using Node.prems by(auto simp: lvl_0_iff)
    1.58 -        thus ?thesis using Leaf ial by simp
    1.59 +      case [simp]: (Node m t3 y t4)
    1.60 +      show ?thesis (*using N(3) iil l12 by(auto)*)
    1.61 +      proof cases
    1.62 +        assume "m = n" thus ?thesis using N(3) iil by(auto)
    1.63        next
    1.64 -        case [simp]: (Node m t3 y t4)
    1.65 -        show ?thesis (*using N(3) iil l12 by(auto)*)
    1.66 -        proof cases
    1.67 -          assume "m = n" thus ?thesis using N(3) iil by(auto)
    1.68 -        next
    1.69 -          assume "m \<noteq> n" thus ?thesis using N(3) iil l12 by(auto)
    1.70 -        qed
    1.71 +        assume "m \<noteq> n" thus ?thesis using N(3) iil l12 by(auto)
    1.72        qed
    1.73 -      finally show ?thesis .
    1.74      qed
    1.75 -  }
    1.76 +    finally show ?thesis .
    1.77 +  qed
    1.78    moreover
    1.79 -  { assume "x < a"
    1.80 -    note iir = Node.IH(2)[OF ir]
    1.81 +  have ?case if "x < a"
    1.82 +  proof -
    1.83      from \<open>invar ?t\<close> have "n = lvl r \<or> n = lvl r + 1" by auto
    1.84 -    hence ?case
    1.85 +    thus ?case
    1.86      proof
    1.87        assume 0: "n = lvl r"
    1.88        have "update a b ?t = split(skew(Node n l xy (update a b r)))"
    1.89          using \<open>a>x\<close> by(auto)
    1.90        also have "skew(Node n l xy (update a b r)) = Node n l xy (update a b r)"
    1.91 -        using Node.prems by(simp add: skew_case split: tree.split)
    1.92 +        using N.prems by(simp add: skew_case split: tree.split)
    1.93        also have "invar(split \<dots>)"
    1.94        proof -
    1.95          from lvl_update_sngl[OF ir sngl_if_invar[OF \<open>invar ?t\<close> 0], of a b]
    1.96          obtain t1 p t2 where iar: "update a b r = Node n t1 p t2"
    1.97 -          using Node.prems 0 by (auto simp: lvl_Suc_iff)
    1.98 -        from Node.prems iar 0 iir
    1.99 +          using N.prems 0 by (auto simp: lvl_Suc_iff)
   1.100 +        from N.prems iar 0 iir
   1.101          show ?thesis by (auto simp: split_case split: tree.splits)
   1.102        qed
   1.103        finally show ?thesis .
   1.104 @@ -139,7 +137,7 @@
   1.105        show ?thesis
   1.106        proof (cases rule: lvl_update[of a b r])
   1.107          case (Same)
   1.108 -        show ?thesis using \<open>x<a\<close> il ir invar_NodeR[OF Node.prems 1 iir Same]
   1.109 +        show ?thesis using \<open>x<a\<close> il ir invar_NodeR[OF N.prems 1 iir Same]
   1.110            by (auto simp add: skew_invar split_invar)
   1.111        next
   1.112          case (Incr)
   1.113 @@ -147,8 +145,9 @@
   1.114            by (auto simp add: skew_invar split_invar split: if_splits)
   1.115        qed
   1.116      qed
   1.117 -  }
   1.118 -  moreover { assume "a = x" hence ?case using Node.prems by auto }
   1.119 +  qed
   1.120 +  moreover
   1.121 +  have "a = x \<Longrightarrow> ?case" using N.prems by auto
   1.122    ultimately show ?case by blast
   1.123  qed simp
   1.124  
     2.1 --- a/src/HOL/Data_Structures/AA_Set.thy	Thu Nov 09 10:24:00 2017 +0100
     2.2 +++ b/src/HOL/Data_Structures/AA_Set.thy	Fri Nov 10 22:05:30 2017 +0100
     2.3 @@ -201,63 +201,61 @@
     2.4  
     2.5  lemma invar_insert: "invar t \<Longrightarrow> invar(insert a t)"
     2.6  proof(induction t)
     2.7 -  case (Node n l x r)
     2.8 +  case N: (Node n l x r)
     2.9    hence il: "invar l" and ir: "invar r" by auto
    2.10 -  note N = Node
    2.11 +  note iil = N.IH(1)[OF il]
    2.12 +  note iir = N.IH(2)[OF ir]
    2.13    let ?t = "Node n l x r"
    2.14    have "a < x \<or> a = x \<or> x < a" by auto
    2.15    moreover
    2.16 -  { assume "a < x"
    2.17 -    note iil = Node.IH(1)[OF il]
    2.18 -    have ?case
    2.19 -    proof (cases rule: lvl_insert[of a l])
    2.20 -      case (Same) thus ?thesis
    2.21 -        using \<open>a<x\<close> invar_NodeL[OF Node.prems iil Same]
    2.22 -        by (simp add: skew_invar split_invar del: invar.simps)
    2.23 +  have ?case if "a < x"
    2.24 +  proof (cases rule: lvl_insert[of a l])
    2.25 +    case (Same) thus ?thesis
    2.26 +      using \<open>a<x\<close> invar_NodeL[OF N.prems iil Same]
    2.27 +      by (simp add: skew_invar split_invar del: invar.simps)
    2.28 +  next
    2.29 +    case (Incr)
    2.30 +    then obtain t1 w t2 where ial[simp]: "insert a l = Node n t1 w t2"
    2.31 +      using N.prems by (auto simp: lvl_Suc_iff)
    2.32 +    have l12: "lvl t1 = lvl t2"
    2.33 +      by (metis Incr(1) ial lvl_insert_incr_iff tree.inject)
    2.34 +    have "insert a ?t = split(skew(Node n (insert a l) x r))"
    2.35 +      by(simp add: \<open>a<x\<close>)
    2.36 +    also have "skew(Node n (insert a l) x r) = Node n t1 w (Node n t2 x r)"
    2.37 +      by(simp)
    2.38 +    also have "invar(split \<dots>)"
    2.39 +    proof (cases r)
    2.40 +      case Leaf
    2.41 +      hence "l = Leaf" using N.prems by(auto simp: lvl_0_iff)
    2.42 +      thus ?thesis using Leaf ial by simp
    2.43      next
    2.44 -      case (Incr)
    2.45 -      then obtain t1 w t2 where ial[simp]: "insert a l = Node n t1 w t2"
    2.46 -        using Node.prems by (auto simp: lvl_Suc_iff)
    2.47 -      have l12: "lvl t1 = lvl t2"
    2.48 -        by (metis Incr(1) ial lvl_insert_incr_iff tree.inject)
    2.49 -      have "insert a ?t = split(skew(Node n (insert a l) x r))"
    2.50 -        by(simp add: \<open>a<x\<close>)
    2.51 -      also have "skew(Node n (insert a l) x r) = Node n t1 w (Node n t2 x r)"
    2.52 -        by(simp)
    2.53 -      also have "invar(split \<dots>)"
    2.54 -      proof (cases r)
    2.55 -        case Leaf
    2.56 -        hence "l = Leaf" using Node.prems by(auto simp: lvl_0_iff)
    2.57 -        thus ?thesis using Leaf ial by simp
    2.58 +      case [simp]: (Node m t3 y t4)
    2.59 +      show ?thesis (*using N(3) iil l12 by(auto)*)
    2.60 +      proof cases
    2.61 +        assume "m = n" thus ?thesis using N(3) iil by(auto)
    2.62        next
    2.63 -        case [simp]: (Node m t3 y t4)
    2.64 -        show ?thesis (*using N(3) iil l12 by(auto)*)
    2.65 -        proof cases
    2.66 -          assume "m = n" thus ?thesis using N(3) iil by(auto)
    2.67 -        next
    2.68 -          assume "m \<noteq> n" thus ?thesis using N(3) iil l12 by(auto)
    2.69 -        qed
    2.70 +        assume "m \<noteq> n" thus ?thesis using N(3) iil l12 by(auto)
    2.71        qed
    2.72 -      finally show ?thesis .
    2.73      qed
    2.74 -  }
    2.75 +    finally show ?thesis .
    2.76 +  qed
    2.77    moreover
    2.78 -  { assume "x < a"
    2.79 -    note iir = Node.IH(2)[OF ir]
    2.80 +  have ?case if "x < a"
    2.81 +  proof -
    2.82      from \<open>invar ?t\<close> have "n = lvl r \<or> n = lvl r + 1" by auto
    2.83 -    hence ?case
    2.84 +    thus ?case
    2.85      proof
    2.86        assume 0: "n = lvl r"
    2.87        have "insert a ?t = split(skew(Node n l x (insert a r)))"
    2.88          using \<open>a>x\<close> by(auto)
    2.89        also have "skew(Node n l x (insert a r)) = Node n l x (insert a r)"
    2.90 -        using Node.prems by(simp add: skew_case split: tree.split)
    2.91 +        using N.prems by(simp add: skew_case split: tree.split)
    2.92        also have "invar(split \<dots>)"
    2.93        proof -
    2.94          from lvl_insert_sngl[OF ir sngl_if_invar[OF \<open>invar ?t\<close> 0], of a]
    2.95          obtain t1 y t2 where iar: "insert a r = Node n t1 y t2"
    2.96 -          using Node.prems 0 by (auto simp: lvl_Suc_iff)
    2.97 -        from Node.prems iar 0 iir
    2.98 +          using N.prems 0 by (auto simp: lvl_Suc_iff)
    2.99 +        from N.prems iar 0 iir
   2.100          show ?thesis by (auto simp: split_case split: tree.splits)
   2.101        qed
   2.102        finally show ?thesis .
   2.103 @@ -267,7 +265,7 @@
   2.104        show ?thesis
   2.105        proof (cases rule: lvl_insert[of a r])
   2.106          case (Same)
   2.107 -        show ?thesis using \<open>x<a\<close> il ir invar_NodeR[OF Node.prems 1 iir Same]
   2.108 +        show ?thesis using \<open>x<a\<close> il ir invar_NodeR[OF N.prems 1 iir Same]
   2.109            by (auto simp add: skew_invar split_invar)
   2.110        next
   2.111          case (Incr)
   2.112 @@ -275,8 +273,9 @@
   2.113            by (auto simp add: skew_invar split_invar split: if_splits)
   2.114        qed
   2.115      qed
   2.116 -  }
   2.117 -  moreover { assume "a = x" hence ?case using Node.prems by auto }
   2.118 +  qed
   2.119 +  moreover
   2.120 +  have "a = x \<Longrightarrow> ?case" using N.prems by auto
   2.121    ultimately show ?case by blast
   2.122  qed simp
   2.123  
     3.1 --- a/src/HOL/Data_Structures/Brother12_Map.thy	Thu Nov 09 10:24:00 2017 +0100
     3.2 +++ b/src/HOL/Data_Structures/Brother12_Map.thy	Fri Nov 10 22:05:30 2017 +0100
     3.3 @@ -126,61 +126,58 @@
     3.4    { case 1
     3.5      then obtain l a b r where [simp]: "t = N2 l (a,b) r" and
     3.6        lr: "l \<in> T h" "r \<in> T h" "l \<in> B h \<or> r \<in> B h" by auto
     3.7 -    { assume "x < a"
     3.8 -      have ?case
     3.9 -      proof cases
    3.10 -        assume "l \<in> B h"
    3.11 -        from n2_type3[OF Suc.IH(1)[OF this] lr(2)]
    3.12 -        show ?thesis using `x<a` by(simp)
    3.13 -      next
    3.14 -        assume "l \<notin> B h"
    3.15 -        hence "l \<in> U h" "r \<in> B h" using lr by auto
    3.16 -        from n2_type1[OF Suc.IH(2)[OF this(1)] this(2)]
    3.17 -        show ?thesis using `x<a` by(simp)
    3.18 -      qed
    3.19 -    } moreover
    3.20 -    { assume "x > a"
    3.21 -      have ?case
    3.22 +    have ?case if "x < a"
    3.23 +    proof cases
    3.24 +      assume "l \<in> B h"
    3.25 +      from n2_type3[OF Suc.IH(1)[OF this] lr(2)]
    3.26 +      show ?thesis using `x<a` by(simp)
    3.27 +    next
    3.28 +      assume "l \<notin> B h"
    3.29 +      hence "l \<in> U h" "r \<in> B h" using lr by auto
    3.30 +      from n2_type1[OF Suc.IH(2)[OF this(1)] this(2)]
    3.31 +      show ?thesis using `x<a` by(simp)
    3.32 +    qed
    3.33 +    moreover
    3.34 +    have ?case if "x > a"
    3.35 +    proof cases
    3.36 +      assume "r \<in> B h"
    3.37 +      from n2_type3[OF lr(1) Suc.IH(1)[OF this]]
    3.38 +      show ?thesis using `x>a` by(simp)
    3.39 +    next
    3.40 +      assume "r \<notin> B h"
    3.41 +      hence "l \<in> B h" "r \<in> U h" using lr by auto
    3.42 +      from n2_type2[OF this(1) Suc.IH(2)[OF this(2)]]
    3.43 +      show ?thesis using `x>a` by(simp)
    3.44 +    qed
    3.45 +    moreover
    3.46 +    have ?case if [simp]: "x=a"
    3.47 +    proof (cases "del_min r")
    3.48 +      case None
    3.49 +      show ?thesis
    3.50        proof cases
    3.51          assume "r \<in> B h"
    3.52 -        from n2_type3[OF lr(1) Suc.IH(1)[OF this]]
    3.53 -        show ?thesis using `x>a` by(simp)
    3.54 +        with del_minNoneN0[OF this None] lr show ?thesis by(simp)
    3.55        next
    3.56          assume "r \<notin> B h"
    3.57 -        hence "l \<in> B h" "r \<in> U h" using lr by auto
    3.58 -        from n2_type2[OF this(1) Suc.IH(2)[OF this(2)]]
    3.59 -        show ?thesis using `x>a` by(simp)
    3.60 +        hence "r \<in> U h" using lr by auto
    3.61 +        with del_minNoneN1[OF this None] lr(3) show ?thesis by (simp)
    3.62        qed
    3.63 -    } moreover
    3.64 -    { assume [simp]: "x=a"
    3.65 -      have ?case
    3.66 -      proof (cases "del_min r")
    3.67 -        case None
    3.68 -        show ?thesis
    3.69 -        proof cases
    3.70 -          assume "r \<in> B h"
    3.71 -          with del_minNoneN0[OF this None] lr show ?thesis by(simp)
    3.72 -        next
    3.73 -          assume "r \<notin> B h"
    3.74 -          hence "r \<in> U h" using lr by auto
    3.75 -          with del_minNoneN1[OF this None] lr(3) show ?thesis by (simp)
    3.76 -        qed
    3.77 +    next
    3.78 +      case [simp]: (Some br')
    3.79 +      obtain b r' where [simp]: "br' = (b,r')" by fastforce
    3.80 +      show ?thesis
    3.81 +      proof cases
    3.82 +        assume "r \<in> B h"
    3.83 +        from del_min_type(1)[OF this] n2_type3[OF lr(1)]
    3.84 +        show ?thesis by simp
    3.85        next
    3.86 -        case [simp]: (Some br')
    3.87 -        obtain b r' where [simp]: "br' = (b,r')" by fastforce
    3.88 -        show ?thesis
    3.89 -        proof cases
    3.90 -          assume "r \<in> B h"
    3.91 -          from del_min_type(1)[OF this] n2_type3[OF lr(1)]
    3.92 -          show ?thesis by simp
    3.93 -        next
    3.94 -          assume "r \<notin> B h"
    3.95 -          hence "l \<in> B h" and "r \<in> U h" using lr by auto
    3.96 -          from del_min_type(2)[OF this(2)] n2_type2[OF this(1)]
    3.97 -          show ?thesis by simp
    3.98 -        qed
    3.99 +        assume "r \<notin> B h"
   3.100 +        hence "l \<in> B h" and "r \<in> U h" using lr by auto
   3.101 +        from del_min_type(2)[OF this(2)] n2_type2[OF this(1)]
   3.102 +        show ?thesis by simp
   3.103        qed
   3.104 -    } ultimately show ?case by auto                         
   3.105 +    qed
   3.106 +    ultimately show ?case by auto                         
   3.107    }
   3.108    { case 2 with Suc.IH(1) show ?case by auto }
   3.109  qed auto
     4.1 --- a/src/HOL/Data_Structures/Brother12_Set.thy	Thu Nov 09 10:24:00 2017 +0100
     4.2 +++ b/src/HOL/Data_Structures/Brother12_Set.thy	Fri Nov 10 22:05:30 2017 +0100
     4.3 @@ -258,9 +258,9 @@
     4.4      then obtain t1 a t2 where [simp]: "t = N2 t1 a t2" and
     4.5        t1: "t1 \<in> T h" and t2: "t2 \<in> T h" and t12: "t1 \<in> B h \<or> t2 \<in> B h"
     4.6        by auto
     4.7 -    { assume "x < a"
     4.8 -      hence "?case \<longleftrightarrow> n2 (ins x t1) a t2 \<in> Bp (Suc h)" by simp
     4.9 -      also have "\<dots>"
    4.10 +    have ?case if "x < a"
    4.11 +    proof -
    4.12 +      have "n2 (ins x t1) a t2 \<in> Bp (Suc h)"
    4.13        proof cases
    4.14          assume "t1 \<in> B h"
    4.15          with t2 show ?thesis by (simp add: Suc.IH(1) n2_type)
    4.16 @@ -269,12 +269,12 @@
    4.17          hence 1: "t1 \<in> U h" and 2: "t2 \<in> B h" using t1 t12 by auto
    4.18          show ?thesis by (metis Suc.IH(2)[OF 1] Bp_if_B[OF 2] n2_type)
    4.19        qed
    4.20 -      finally have ?case .
    4.21 -    }
    4.22 +      with `x < a` show ?case by simp
    4.23 +    qed
    4.24      moreover
    4.25 -    { assume "a < x"
    4.26 -      hence "?case \<longleftrightarrow> n2 t1 a (ins x t2) \<in> Bp (Suc h)" by simp
    4.27 -      also have "\<dots>"
    4.28 +    have ?case if "a < x"
    4.29 +    proof -
    4.30 +      have "n2 t1 a (ins x t2) \<in> Bp (Suc h)"
    4.31        proof cases
    4.32          assume "t2 \<in> B h"
    4.33          with t1 show ?thesis by (simp add: Suc.IH(1) n2_type)
    4.34 @@ -283,12 +283,14 @@
    4.35          hence 1: "t1 \<in> B h" and 2: "t2 \<in> U h" using t2 t12 by auto
    4.36          show ?thesis by (metis Bp_if_B[OF 1] Suc.IH(2)[OF 2] n2_type)
    4.37        qed
    4.38 -    }
    4.39 -    moreover 
    4.40 -    { assume "x = a"
    4.41 +      with `a < x` show ?case by simp
    4.42 +    qed
    4.43 +    moreover
    4.44 +    have ?case if "x = a"
    4.45 +    proof -
    4.46        from 1 have "t \<in> Bp (Suc h)" by(rule Bp_if_B)
    4.47 -      hence "?case" using `x = a` by simp
    4.48 -    }
    4.49 +      thus "?case" using `x = a` by simp
    4.50 +    qed
    4.51      ultimately show ?case by auto
    4.52    next
    4.53      case 2 thus ?case using Suc(1) n1_type by fastforce }
    4.54 @@ -398,61 +400,58 @@
    4.55    { case 1
    4.56      then obtain l a r where [simp]: "t = N2 l a r" and
    4.57        lr: "l \<in> T h" "r \<in> T h" "l \<in> B h \<or> r \<in> B h" by auto
    4.58 -    { assume "x < a"
    4.59 -      have ?case
    4.60 -      proof cases
    4.61 -        assume "l \<in> B h"
    4.62 -        from n2_type3[OF Suc.IH(1)[OF this] lr(2)]
    4.63 -        show ?thesis using `x<a` by(simp)
    4.64 -      next
    4.65 -        assume "l \<notin> B h"
    4.66 -        hence "l \<in> U h" "r \<in> B h" using lr by auto
    4.67 -        from n2_type1[OF Suc.IH(2)[OF this(1)] this(2)]
    4.68 -        show ?thesis using `x<a` by(simp)
    4.69 -      qed
    4.70 -    } moreover
    4.71 -    { assume "x > a"
    4.72 -      have ?case
    4.73 +    have ?case if "x < a"
    4.74 +    proof cases
    4.75 +      assume "l \<in> B h"
    4.76 +      from n2_type3[OF Suc.IH(1)[OF this] lr(2)]
    4.77 +      show ?thesis using `x<a` by(simp)
    4.78 +    next
    4.79 +      assume "l \<notin> B h"
    4.80 +      hence "l \<in> U h" "r \<in> B h" using lr by auto
    4.81 +      from n2_type1[OF Suc.IH(2)[OF this(1)] this(2)]
    4.82 +      show ?thesis using `x<a` by(simp)
    4.83 +    qed
    4.84 +    moreover
    4.85 +    have ?case if "x > a"
    4.86 +    proof cases
    4.87 +      assume "r \<in> B h"
    4.88 +      from n2_type3[OF lr(1) Suc.IH(1)[OF this]]
    4.89 +      show ?thesis using `x>a` by(simp)
    4.90 +    next
    4.91 +      assume "r \<notin> B h"
    4.92 +      hence "l \<in> B h" "r \<in> U h" using lr by auto
    4.93 +      from n2_type2[OF this(1) Suc.IH(2)[OF this(2)]]
    4.94 +      show ?thesis using `x>a` by(simp)
    4.95 +    qed
    4.96 +    moreover
    4.97 +    have ?case if [simp]: "x=a"
    4.98 +    proof (cases "del_min r")
    4.99 +      case None
   4.100 +      show ?thesis
   4.101        proof cases
   4.102          assume "r \<in> B h"
   4.103 -        from n2_type3[OF lr(1) Suc.IH(1)[OF this]]
   4.104 -        show ?thesis using `x>a` by(simp)
   4.105 +        with del_minNoneN0[OF this None] lr show ?thesis by(simp)
   4.106        next
   4.107          assume "r \<notin> B h"
   4.108 -        hence "l \<in> B h" "r \<in> U h" using lr by auto
   4.109 -        from n2_type2[OF this(1) Suc.IH(2)[OF this(2)]]
   4.110 -        show ?thesis using `x>a` by(simp)
   4.111 +        hence "r \<in> U h" using lr by auto
   4.112 +        with del_minNoneN1[OF this None] lr(3) show ?thesis by (simp)
   4.113        qed
   4.114 -    } moreover
   4.115 -    { assume [simp]: "x=a"
   4.116 -      have ?case
   4.117 -      proof (cases "del_min r")
   4.118 -        case None
   4.119 -        show ?thesis
   4.120 -        proof cases
   4.121 -          assume "r \<in> B h"
   4.122 -          with del_minNoneN0[OF this None] lr show ?thesis by(simp)
   4.123 -        next
   4.124 -          assume "r \<notin> B h"
   4.125 -          hence "r \<in> U h" using lr by auto
   4.126 -          with del_minNoneN1[OF this None] lr(3) show ?thesis by (simp)
   4.127 -        qed
   4.128 +    next
   4.129 +      case [simp]: (Some br')
   4.130 +      obtain b r' where [simp]: "br' = (b,r')" by fastforce
   4.131 +      show ?thesis
   4.132 +      proof cases
   4.133 +        assume "r \<in> B h"
   4.134 +        from del_min_type(1)[OF this] n2_type3[OF lr(1)]
   4.135 +        show ?thesis by simp
   4.136        next
   4.137 -        case [simp]: (Some br')
   4.138 -        obtain b r' where [simp]: "br' = (b,r')" by fastforce
   4.139 -        show ?thesis
   4.140 -        proof cases
   4.141 -          assume "r \<in> B h"
   4.142 -          from del_min_type(1)[OF this] n2_type3[OF lr(1)]
   4.143 -          show ?thesis by simp
   4.144 -        next
   4.145 -          assume "r \<notin> B h"
   4.146 -          hence "l \<in> B h" and "r \<in> U h" using lr by auto
   4.147 -          from del_min_type(2)[OF this(2)] n2_type2[OF this(1)]
   4.148 -          show ?thesis by simp
   4.149 -        qed
   4.150 +        assume "r \<notin> B h"
   4.151 +        hence "l \<in> B h" and "r \<in> U h" using lr by auto
   4.152 +        from del_min_type(2)[OF this(2)] n2_type2[OF this(1)]
   4.153 +        show ?thesis by simp
   4.154        qed
   4.155 -    } ultimately show ?case by auto
   4.156 +    qed
   4.157 +    ultimately show ?case by auto
   4.158    }
   4.159    { case 2 with Suc.IH(1) show ?case by auto }
   4.160  qed auto