[STATEMENT]
lemma cost_swapLeaves:
"\<lbrakk>consistent t; a \<noteq> b\<rbrakk> \<Longrightarrow>
 if a \<in> alphabet t then
   if b \<in> alphabet t then
     cost (swapLeaves t w\<^sub>a a w\<^sub>b b) + freq t a * depth t a
     + freq t b * depth t b =
         cost t + w\<^sub>a * depth t b + w\<^sub>b * depth t a
   else
     cost (swapLeaves t w\<^sub>a a w\<^sub>b b) + freq t a * depth t a =
         cost t + w\<^sub>b * depth t a
 else
   if b \<in> alphabet t then
     cost (swapLeaves t w\<^sub>a a w\<^sub>b b) + freq t b * depth t b =
         cost t + w\<^sub>a * depth t b
   else
     cost (swapLeaves t w\<^sub>a a w\<^sub>b b) = cost t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>consistent t; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t then if b \<in> alphabet t then cost (swapLeaves t w\<^sub>a a w\<^sub>b b) + freq t a * depth t a + freq t b * depth t b = cost t + w\<^sub>a * depth t b + w\<^sub>b * depth t a else cost (swapLeaves t w\<^sub>a a w\<^sub>b b) + freq t a * depth t a = cost t + w\<^sub>b * depth t a else if b \<in> alphabet t then cost (swapLeaves t w\<^sub>a a w\<^sub>b b) + freq t b * depth t b = cost t + w\<^sub>a * depth t b else cost (swapLeaves t w\<^sub>a a w\<^sub>b b) = cost t
[PROOF STEP]
proof (induct t)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x1 x2. \<lbrakk>consistent (Leaf x1 x2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Leaf x1 x2) then if b \<in> alphabet (Leaf x1 x2) then cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1 x2) a * depth (Leaf x1 x2) a + freq (Leaf x1 x2) b * depth (Leaf x1 x2) b = cost (Leaf x1 x2) + w\<^sub>a * depth (Leaf x1 x2) b + w\<^sub>b * depth (Leaf x1 x2) a else cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1 x2) a * depth (Leaf x1 x2) a = cost (Leaf x1 x2) + w\<^sub>b * depth (Leaf x1 x2) a else if b \<in> alphabet (Leaf x1 x2) then cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1 x2) b * depth (Leaf x1 x2) b = cost (Leaf x1 x2) + w\<^sub>a * depth (Leaf x1 x2) b else cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) = cost (Leaf x1 x2)
 2. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
case Leaf
[PROOF STATE]
proof (state)
this:
consistent (Leaf x1_ x2_)
a \<noteq> b

goal (2 subgoals):
 1. \<And>x1 x2. \<lbrakk>consistent (Leaf x1 x2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Leaf x1 x2) then if b \<in> alphabet (Leaf x1 x2) then cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1 x2) a * depth (Leaf x1 x2) a + freq (Leaf x1 x2) b * depth (Leaf x1 x2) b = cost (Leaf x1 x2) + w\<^sub>a * depth (Leaf x1 x2) b + w\<^sub>b * depth (Leaf x1 x2) a else cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1 x2) a * depth (Leaf x1 x2) a = cost (Leaf x1 x2) + w\<^sub>b * depth (Leaf x1 x2) a else if b \<in> alphabet (Leaf x1 x2) then cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1 x2) b * depth (Leaf x1 x2) b = cost (Leaf x1 x2) + w\<^sub>a * depth (Leaf x1 x2) b else cost (swapLeaves (Leaf x1 x2) w\<^sub>a a w\<^sub>b b) = cost (Leaf x1 x2)
 2. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Leaf x1_ x2_) then if b \<in> alphabet (Leaf x1_ x2_) then cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1_ x2_) a * depth (Leaf x1_ x2_) a + freq (Leaf x1_ x2_) b * depth (Leaf x1_ x2_) b = cost (Leaf x1_ x2_) + w\<^sub>a * depth (Leaf x1_ x2_) b + w\<^sub>b * depth (Leaf x1_ x2_) a else cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1_ x2_) a * depth (Leaf x1_ x2_) a = cost (Leaf x1_ x2_) + w\<^sub>b * depth (Leaf x1_ x2_) a else if b \<in> alphabet (Leaf x1_ x2_) then cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1_ x2_) b * depth (Leaf x1_ x2_) b = cost (Leaf x1_ x2_) + w\<^sub>a * depth (Leaf x1_ x2_) b else cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) = cost (Leaf x1_ x2_)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Leaf x1_ x2_) then if b \<in> alphabet (Leaf x1_ x2_) then cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1_ x2_) a * depth (Leaf x1_ x2_) a + freq (Leaf x1_ x2_) b * depth (Leaf x1_ x2_) b = cost (Leaf x1_ x2_) + w\<^sub>a * depth (Leaf x1_ x2_) b + w\<^sub>b * depth (Leaf x1_ x2_) a else cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1_ x2_) a * depth (Leaf x1_ x2_) a = cost (Leaf x1_ x2_) + w\<^sub>b * depth (Leaf x1_ x2_) a else if b \<in> alphabet (Leaf x1_ x2_) then cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) + freq (Leaf x1_ x2_) b * depth (Leaf x1_ x2_) b = cost (Leaf x1_ x2_) + w\<^sub>a * depth (Leaf x1_ x2_) b else cost (swapLeaves (Leaf x1_ x2_) w\<^sub>a a w\<^sub>b b) = cost (Leaf x1_ x2_)

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
case (Node w t\<^sub>1 t\<^sub>2)
[PROOF STATE]
proof (state)
this:
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
note c = \<open>consistent (Node w t\<^sub>1 t\<^sub>2)\<close>
[PROOF STATE]
proof (state)
this:
consistent (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
note hyps = Node
[PROOF STATE]
proof (state)
this:
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
have w\<^sub>1: "if a \<in> alphabet t\<^sub>1 then
              if b \<in> alphabet t\<^sub>1 then
                weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b =
                    weight t\<^sub>1 + w\<^sub>a + w\<^sub>b
                  else
                weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b
            else
              if b \<in> alphabet t\<^sub>1 then
                weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a
              else
                weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
[PROOF STEP]
using hyps
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
[PROOF STEP]
by (simp add: weight_swapLeaves)
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
have w\<^sub>2: "if a \<in> alphabet t\<^sub>2 then
              if b \<in> alphabet t\<^sub>2 then
                weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b =
                    weight t\<^sub>2 + w\<^sub>a + w\<^sub>b
              else
                weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b
            else
              if b \<in> alphabet t\<^sub>2 then
                weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a
              else
                weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
[PROOF STEP]
using hyps
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
[PROOF STEP]
by (simp add: weight_swapLeaves)
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2

goal (1 subgoal):
 1. \<And>x1 t1 t2. \<lbrakk>\<lbrakk>consistent t1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t1 then if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b + w\<^sub>b * depth t1 a else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 a * depth t1 a = cost t1 + w\<^sub>b * depth t1 a else if b \<in> alphabet t1 then cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) + freq t1 b * depth t1 b = cost t1 + w\<^sub>a * depth t1 b else cost (swapLeaves t1 w\<^sub>a a w\<^sub>b b) = cost t1; \<lbrakk>consistent t2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t2 then if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b + w\<^sub>b * depth t2 a else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 a * depth t2 a = cost t2 + w\<^sub>b * depth t2 a else if b \<in> alphabet t2 then cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) + freq t2 b * depth t2 b = cost t2 + w\<^sub>a * depth t2 b else cost (swapLeaves t2 w\<^sub>a a w\<^sub>b b) = cost t2; consistent (Node x1 t1 t2); a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet (Node x1 t1 t2) then if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b + w\<^sub>b * depth (Node x1 t1 t2) a else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) a * depth (Node x1 t1 t2) a = cost (Node x1 t1 t2) + w\<^sub>b * depth (Node x1 t1 t2) a else if b \<in> alphabet (Node x1 t1 t2) then cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) + freq (Node x1 t1 t2) b * depth (Node x1 t1 t2) b = cost (Node x1 t1 t2) + w\<^sub>a * depth (Node x1 t1 t2) b else cost (swapLeaves (Node x1 t1 t2) w\<^sub>a a w\<^sub>b b) = cost (Node x1 t1 t2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume a\<^sub>1: "a \<in> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
a \<in> alphabet t\<^sub>1

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
hence a\<^sub>2: "a \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (prove)
using this:
a \<in> alphabet t\<^sub>1

goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>2
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
a \<in> alphabet t\<^sub>1
consistent (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<notin> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume b\<^sub>1: "b \<in> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
b \<in> alphabet t\<^sub>1

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
hence "b \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>1

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>1
consistent (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2
a \<in> alphabet t\<^sub>1
a \<notin> alphabet t\<^sub>2
b \<in> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume b\<^sub>1: "b \<notin> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>1

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume "b \<in> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
b \<in> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>2
a \<in> alphabet t\<^sub>1
a \<notin> alphabet t\<^sub>2
b \<notin> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume "b \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2
a \<in> alphabet t\<^sub>1
a \<notin> alphabet t\<^sub>2
b \<notin> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume a\<^sub>1: "a \<notin> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
a \<notin> alphabet t\<^sub>1

goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume a\<^sub>2: "a \<in> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
a \<in> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume b\<^sub>1: "b \<in> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
b \<in> alphabet t\<^sub>1

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
hence "b \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>1

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>1
consistent (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2
a \<notin> alphabet t\<^sub>1
a \<in> alphabet t\<^sub>2
b \<in> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume b\<^sub>1: "b \<notin> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>1

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume "b \<in> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
b \<in> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>2
a \<notin> alphabet t\<^sub>1
a \<in> alphabet t\<^sub>2
b \<notin> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume "b \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2
a \<notin> alphabet t\<^sub>1
a \<in> alphabet t\<^sub>2
b \<notin> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume a\<^sub>2: "a \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
a \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. a \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume b\<^sub>1: "b \<in> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
b \<in> alphabet t\<^sub>1

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
hence "b \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>1

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>1
consistent (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2
a \<notin> alphabet t\<^sub>1
a \<notin> alphabet t\<^sub>2
b \<in> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume b\<^sub>1: "b \<notin> alphabet t\<^sub>1"
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>1

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>1 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume "b \<in> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
b \<in> alphabet t\<^sub>2

goal (2 subgoals):
 1. ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
 2. \<not> ?P \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<in> alphabet t\<^sub>2
a \<notin> alphabet t\<^sub>1
a \<notin> alphabet t\<^sub>2
b \<notin> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
assume "b \<notin> alphabet t\<^sub>2"
[PROOF STATE]
proof (state)
this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. b \<notin> alphabet t\<^sub>2 \<Longrightarrow> if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
using a\<^sub>1 a\<^sub>2 b\<^sub>1 w\<^sub>1 w\<^sub>2 hyps
[PROOF STATE]
proof (prove)
using this:
b \<notin> alphabet t\<^sub>2
a \<notin> alphabet t\<^sub>1
a \<notin> alphabet t\<^sub>2
b \<notin> alphabet t\<^sub>1
if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a = weight t\<^sub>1 + w\<^sub>b else if b \<in> alphabet t\<^sub>1 then weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b = weight t\<^sub>1 + w\<^sub>a else weight (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>1
if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a + w\<^sub>b else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a = weight t\<^sub>2 + w\<^sub>b else if b \<in> alphabet t\<^sub>2 then weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b = weight t\<^sub>2 + w\<^sub>a else weight (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = weight t\<^sub>2
\<lbrakk>consistent t\<^sub>1; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>1 then if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b + w\<^sub>b * depth t\<^sub>1 a else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 a * depth t\<^sub>1 a = cost t\<^sub>1 + w\<^sub>b * depth t\<^sub>1 a else if b \<in> alphabet t\<^sub>1 then cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>1 b * depth t\<^sub>1 b = cost t\<^sub>1 + w\<^sub>a * depth t\<^sub>1 b else cost (swapLeaves t\<^sub>1 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>1
\<lbrakk>consistent t\<^sub>2; a \<noteq> b\<rbrakk> \<Longrightarrow> if a \<in> alphabet t\<^sub>2 then if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b + w\<^sub>b * depth t\<^sub>2 a else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 a * depth t\<^sub>2 a = cost t\<^sub>2 + w\<^sub>b * depth t\<^sub>2 a else if b \<in> alphabet t\<^sub>2 then cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) + freq t\<^sub>2 b * depth t\<^sub>2 b = cost t\<^sub>2 + w\<^sub>a * depth t\<^sub>2 b else cost (swapLeaves t\<^sub>2 w\<^sub>a a w\<^sub>b b) = cost t\<^sub>2
consistent (Node w t\<^sub>1 t\<^sub>2)
a \<noteq> b

goal (1 subgoal):
 1. if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
if a \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) a * depth (Node w t\<^sub>1 t\<^sub>2) a = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>b * depth (Node w t\<^sub>1 t\<^sub>2) a else if b \<in> alphabet (Node w t\<^sub>1 t\<^sub>2) then cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) + freq (Node w t\<^sub>1 t\<^sub>2) b * depth (Node w t\<^sub>1 t\<^sub>2) b = cost (Node w t\<^sub>1 t\<^sub>2) + w\<^sub>a * depth (Node w t\<^sub>1 t\<^sub>2) b else cost (swapLeaves (Node w t\<^sub>1 t\<^sub>2) w\<^sub>a a w\<^sub>b b) = cost (Node w t\<^sub>1 t\<^sub>2)

goal:
No subgoals!
[PROOF STEP]
qed