[STATEMENT]
lemma merge_correct :
assumes l1_OK: "distinct l1 \<and> sorted l1"
assumes l2_OK: "distinct l2 \<and> sorted l2"
shows "distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
distinct l1 \<and> sorted l1
distinct l2 \<and> sorted l2

goal (1 subgoal):
 1. distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2
[PROOF STEP]
proof (induct l1 arbitrary: l2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>l2. \<lbrakk>distinct [] \<and> sorted []; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge [] l2) \<and> sorted (merge [] l2) \<and> set (merge [] l2) = set [] \<union> set l2
 2. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
distinct [] \<and> sorted []
distinct l2 \<and> sorted l2

goal (2 subgoals):
 1. \<And>l2. \<lbrakk>distinct [] \<and> sorted []; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge [] l2) \<and> sorted (merge [] l2) \<and> set (merge [] l2) = set [] \<union> set l2
 2. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
distinct [] \<and> sorted []
distinct l2 \<and> sorted l2

goal (1 subgoal):
 1. distinct (merge [] l2) \<and> sorted (merge [] l2) \<and> set (merge [] l2) = set [] \<union> set l2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
distinct (merge [] l2) \<and> sorted (merge [] l2) \<and> set (merge [] l2) = set [] \<union> set l2

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
case (Cons x1 l1 l2)
[PROOF STATE]
proof (state)
this:
\<lbrakk>distinct l1 \<and> sorted l1; distinct ?l2.0 \<and> sorted ?l2.0\<rbrakk> \<Longrightarrow> distinct (merge l1 ?l2.0) \<and> sorted (merge l1 ?l2.0) \<and> set (merge l1 ?l2.0) = set l1 \<union> set ?l2.0
distinct (x1 # l1) \<and> sorted (x1 # l1)
distinct l2 \<and> sorted l2

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
note x1_l1_props = Cons(2)
[PROOF STATE]
proof (state)
this:
distinct (x1 # l1) \<and> sorted (x1 # l1)

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
note l2_props = Cons(3)
[PROOF STATE]
proof (state)
this:
distinct l2 \<and> sorted l2

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
from x1_l1_props
[PROOF STATE]
proof (chain)
picking this:
distinct (x1 # l1) \<and> sorted (x1 # l1)
[PROOF STEP]
have l1_props: "distinct l1 \<and> sorted l1"
                    and x1_nin_l1: "x1 \<notin> set l1"
                    and x1_le: "\<And>x. x \<in> set l1 \<Longrightarrow> x1 \<le> x"
[PROOF STATE]
proof (prove)
using this:
distinct (x1 # l1) \<and> sorted (x1 # l1)

goal (1 subgoal):
 1. distinct l1 \<and> sorted l1 &&& x1 \<notin> set l1 &&& (\<And>x. x \<in> set l1 \<Longrightarrow> x1 \<le> x)
[PROOF STEP]
by (simp_all add: Ball_def)
[PROOF STATE]
proof (state)
this:
distinct l1 \<and> sorted l1
x1 \<notin> set l1
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
note ind_hyp_l1 = Cons(1)[OF l1_props]
[PROOF STATE]
proof (state)
this:
distinct ?l2.0 \<and> sorted ?l2.0 \<Longrightarrow> distinct (merge l1 ?l2.0) \<and> sorted (merge l1 ?l2.0) \<and> set (merge l1 ?l2.0) = set l1 \<union> set ?l2.0

goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. \<lbrakk>distinct l1 \<and> sorted l1; distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2; distinct (a # l1) \<and> sorted (a # l1); distinct l2 \<and> sorted l2\<rbrakk> \<Longrightarrow> distinct (merge (a # l1) l2) \<and> sorted (merge (a # l1) l2) \<and> set (merge (a # l1) l2) = set (a # l1) \<union> set l2
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2
[PROOF STEP]
using l2_props
[PROOF STATE]
proof (prove)
using this:
distinct l2 \<and> sorted l2

goal (1 subgoal):
 1. distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2
[PROOF STEP]
proof (induct l2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. distinct [] \<and> sorted [] \<Longrightarrow> distinct (merge (x1 # l1) []) \<and> sorted (merge (x1 # l1) []) \<and> set (merge (x1 # l1) []) = set (x1 # l1) \<union> set []
 2. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
distinct [] \<and> sorted []

goal (2 subgoals):
 1. distinct [] \<and> sorted [] \<Longrightarrow> distinct (merge (x1 # l1) []) \<and> sorted (merge (x1 # l1) []) \<and> set (merge (x1 # l1) []) = set (x1 # l1) \<union> set []
 2. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
with x1_l1_props
[PROOF STATE]
proof (chain)
picking this:
distinct (x1 # l1) \<and> sorted (x1 # l1)
distinct [] \<and> sorted []
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
distinct (x1 # l1) \<and> sorted (x1 # l1)
distinct [] \<and> sorted []

goal (1 subgoal):
 1. distinct (merge (x1 # l1) []) \<and> sorted (merge (x1 # l1) []) \<and> set (merge (x1 # l1) []) = set (x1 # l1) \<union> set []
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) []) \<and> sorted (merge (x1 # l1) []) \<and> set (merge (x1 # l1) []) = set (x1 # l1) \<union> set []

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
case (Cons x2 l2)
[PROOF STATE]
proof (state)
this:
distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2
distinct (x2 # l2) \<and> sorted (x2 # l2)

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
note x2_l2_props = Cons(2)
[PROOF STATE]
proof (state)
this:
distinct (x2 # l2) \<and> sorted (x2 # l2)

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
from x2_l2_props
[PROOF STATE]
proof (chain)
picking this:
distinct (x2 # l2) \<and> sorted (x2 # l2)
[PROOF STEP]
have l2_props: "distinct l2 \<and> sorted l2"
                    and x2_nin_l2: "x2 \<notin> set l2"
                    and x2_le: "\<And>x. x \<in> set l2 \<Longrightarrow> x2 \<le> x"
[PROOF STATE]
proof (prove)
using this:
distinct (x2 # l2) \<and> sorted (x2 # l2)

goal (1 subgoal):
 1. distinct l2 \<and> sorted l2 &&& x2 \<notin> set l2 &&& (\<And>x. x \<in> set l2 \<Longrightarrow> x2 \<le> x)
[PROOF STEP]
by (simp_all add: Ball_def)
[PROOF STATE]
proof (state)
this:
distinct l2 \<and> sorted l2
x2 \<notin> set l2
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
note ind_hyp_l2 = Cons(1)[OF l2_props]
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2

goal (1 subgoal):
 1. \<And>a l2. \<lbrakk>distinct l2 \<and> sorted l2 \<Longrightarrow> distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2; distinct (a # l2) \<and> sorted (a # l2)\<rbrakk> \<Longrightarrow> distinct (merge (x1 # l1) (a # l2)) \<and> sorted (merge (x1 # l1) (a # l2)) \<and> set (merge (x1 # l1) (a # l2)) = set (x1 # l1) \<union> set (a # l2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
proof (cases "x1 < x2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
 2. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x1 < x2

goal (2 subgoals):
 1. x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
 2. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
note x1_less_x2 = this
[PROOF STATE]
proof (state)
this:
x1 < x2

goal (2 subgoals):
 1. x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
 2. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
from ind_hyp_l1[OF x2_l2_props] x1_less_x2 x1_nin_l1 x1_le x2_le
[PROOF STATE]
proof (chain)
picking this:
distinct (merge l1 (x2 # l2)) \<and> sorted (merge l1 (x2 # l2)) \<and> set (merge l1 (x2 # l2)) = set l1 \<union> set (x2 # l2)
x1 < x2
x1 \<notin> set l1
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
distinct (merge l1 (x2 # l2)) \<and> sorted (merge l1 (x2 # l2)) \<and> set (merge l1 (x2 # l2)) = set l1 \<union> set (x2 # l2)
x1 < x2
x1 \<notin> set l1
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x

goal (1 subgoal):
 1. distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
apply (auto simp add: Ball_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>x1 < x2; x1 \<notin> set l1; \<And>x. x \<in> set l1 \<Longrightarrow> x1 \<le> x; \<And>x. x \<in> set l2 \<Longrightarrow> x2 \<le> x; distinct (merge l1 (x2 # l2)); sorted (merge l1 (x2 # l2)); set (merge l1 (x2 # l2)) = insert x2 (set l1 \<union> set l2); x1 \<in> set l2\<rbrakk> \<Longrightarrow> False
 2. \<And>x. \<lbrakk>x1 < x2; x1 \<notin> set l1; \<And>x. x \<in> set l1 \<Longrightarrow> x1 \<le> x; \<And>x. x \<in> set l2 \<Longrightarrow> x2 \<le> x; distinct (merge l1 (x2 # l2)); sorted (merge l1 (x2 # l2)); set (merge l1 (x2 # l2)) = insert x2 (set l1 \<union> set l2); x \<in> set l2\<rbrakk> \<Longrightarrow> x1 \<le> x
[PROOF STEP]
apply (metis linorder_not_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>x1 < x2; x1 \<notin> set l1; \<And>x. x \<in> set l1 \<Longrightarrow> x1 \<le> x; \<And>x. x \<in> set l2 \<Longrightarrow> x2 \<le> x; distinct (merge l1 (x2 # l2)); sorted (merge l1 (x2 # l2)); set (merge l1 (x2 # l2)) = insert x2 (set l1 \<union> set l2); x \<in> set l2\<rbrakk> \<Longrightarrow> x1 \<le> x
[PROOF STEP]
apply (metis linorder_not_less xt1(6) xt1(9))
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)

goal (1 subgoal):
 1. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> x1 < x2

goal (1 subgoal):
 1. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
note x2_le_x1 = this
[PROOF STATE]
proof (state)
this:
\<not> x1 < x2

goal (1 subgoal):
 1. \<not> x1 < x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
proof (cases "x1 = x2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x1 = x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
 2. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x1 = x2

goal (2 subgoals):
 1. x1 = x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
 2. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
note x1_eq_x2 = this
[PROOF STATE]
proof (state)
this:
x1 = x2

goal (2 subgoals):
 1. x1 = x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
 2. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
from ind_hyp_l1[OF l2_props] x1_le x2_le x2_nin_l2 x1_eq_x2 x1_nin_l1
[PROOF STATE]
proof (chain)
picking this:
distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x
x2 \<notin> set l2
x1 = x2
x1 \<notin> set l1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
distinct (merge l1 l2) \<and> sorted (merge l1 l2) \<and> set (merge l1 l2) = set l1 \<union> set l2
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x
x2 \<notin> set l2
x1 = x2
x1 \<notin> set l1

goal (1 subgoal):
 1. distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
by (simp add: x1_eq_x2 Ball_def)
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x1 \<noteq> x2

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
note x1_neq_x2 = this
[PROOF STATE]
proof (state)
this:
x1 \<noteq> x2

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
with x2_le_x1
[PROOF STATE]
proof (chain)
picking this:
\<not> x1 < x2
x1 \<noteq> x2
[PROOF STEP]
have x2_less_x1 : "x2 < x1"
[PROOF STATE]
proof (prove)
using this:
\<not> x1 < x2
x1 \<noteq> x2

goal (1 subgoal):
 1. x2 < x1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x2 < x1

goal (1 subgoal):
 1. x1 \<noteq> x2 \<Longrightarrow> distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
from ind_hyp_l2 x2_le_x1 x1_neq_x2 x2_le x2_nin_l2 x1_le
[PROOF STATE]
proof (chain)
picking this:
distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2
\<not> x1 < x2
x1 \<noteq> x2
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2
\<not> x1 < x2
x1 \<noteq> x2
?x \<in> set l2 \<Longrightarrow> x2 \<le> ?x
x2 \<notin> set l2
?x \<in> set l1 \<Longrightarrow> x1 \<le> ?x

goal (1 subgoal):
 1. distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)
[PROOF STEP]
apply (simp add: x2_less_x1 Ball_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = insert x1 (set l1 \<union> set l2); \<not> x1 < x2; x1 \<noteq> x2; \<And>x. x \<in> set l2 \<Longrightarrow> x2 \<le> x; x2 \<notin> set l2; \<And>x. x \<in> set l1 \<Longrightarrow> x1 \<le> x\<rbrakk> \<Longrightarrow> x2 \<notin> set l1 \<and> (\<forall>x. (x = x1 \<longrightarrow> x2 \<le> x1) \<and> (x \<in> set l1 \<longrightarrow> x2 \<le> x))
[PROOF STEP]
apply (metis linorder_not_le x2_less_x1 xt1(7))
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) (x2 # l2)) \<and> sorted (merge (x1 # l1) (x2 # l2)) \<and> set (merge (x1 # l1) (x2 # l2)) = set (x1 # l1) \<union> set (x2 # l2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct (merge (x1 # l1) l2) \<and> sorted (merge (x1 # l1) l2) \<and> set (merge (x1 # l1) l2) = set (x1 # l1) \<union> set l2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fls_shift_delta:
  "fls_shift m (Abs_fls (\<lambda>n. if n=a then b else 0)) = Abs_fls (\<lambda>n. if n=a-m then b else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_shift m (Abs_fls (\<lambda>n. if n = a then b else (0::'a))) = Abs_fls (\<lambda>n. if n = a - m then b else (0::'a))
[PROOF STEP]
by (intro fls_eqI) simp


[STATEMENT]
lemma int_prop:
  fixes P:: "int \<Rightarrow> bool"
  assumes "P n"
  assumes "\<forall>m. m \<le>N \<longrightarrow> \<not> P m"
  shows  "\<exists>n. P n \<and> (\<forall>n'. P n'\<longrightarrow> n' \<ge>n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have "n > N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. N < n
[PROOF STEP]
by (meson assms(1) assms(2) not_less)
[PROOF STATE]
proof (state)
this:
N < n

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
obtain k::nat  where k_def: "k = nat (n - N)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>k. k = nat (n - N) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
k = nat (n - N)

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
obtain l::nat where l_def: "l = (LEAST M.  P (N + int M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>l. l = (LEAST M. P (N + int M)) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
l = (LEAST M. P (N + int M))

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have 0: " P (N + int l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P (N + int l)
[PROOF STEP]
by (metis (full_types) LeastI \<open>N < n\<close> assms(1) l_def zless_iff_Suc_zadd)
[PROOF STATE]
proof (state)
this:
P (N + int l)

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have 1: "l > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < l
[PROOF STEP]
using "0" assms(2) of_nat_0_less_iff
[PROOF STATE]
proof (prove)
using this:
P (N + int l)
\<forall>m\<le>N. \<not> P m
((0::?'a) < of_nat ?n) = (0 < ?n)

goal (1 subgoal):
 1. 0 < l
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
0 < l

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have 2: "\<And>M. M < l \<longrightarrow> \<not> P (N + M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>M. M < l \<longrightarrow> \<not> P (N + int M)
[PROOF STEP]
by (metis Least_le l_def less_le_trans nat_less_le)
[PROOF STATE]
proof (state)
this:
?M1 < l \<longrightarrow> \<not> P (N + int ?M1)

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
obtain n where n_def: "n = (N + int l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. n = N + int l \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
n = N + int l

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have "P n \<and> (\<forall>n'. P n'\<longrightarrow> n' \<ge> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have "P n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P n
[PROOF STEP]
by (simp add: "0" n_def)
[PROOF STATE]
proof (state)
this:
P n

goal (1 subgoal):
 1. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
have "(\<forall>n'. P n'\<longrightarrow> n' \<ge> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n'. P n' \<longrightarrow> n \<le> n'
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n'. P n' \<longrightarrow> n \<le> n'
[PROOF STEP]
fix n'
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n'. P n' \<longrightarrow> n \<le> n'
[PROOF STEP]
show "P n' \<longrightarrow> n \<le> n'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P n' \<longrightarrow> n \<le> n'
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. P n' \<Longrightarrow> n \<le> n'
[PROOF STEP]
assume "P n'"
[PROOF STATE]
proof (state)
this:
P n'

goal (1 subgoal):
 1. P n' \<Longrightarrow> n \<le> n'
[PROOF STEP]
show  "n \<le>n'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> n'
[PROOF STEP]
proof(rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> n \<le> n' \<Longrightarrow> False
[PROOF STEP]
assume " \<not> n \<le> n'"
[PROOF STATE]
proof (state)
this:
\<not> n \<le> n'

goal (1 subgoal):
 1. \<not> n \<le> n' \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> n \<le> n'
[PROOF STEP]
have C: "n' < n"
[PROOF STATE]
proof (prove)
using this:
\<not> n \<le> n'

goal (1 subgoal):
 1. n' < n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n' < n

goal (1 subgoal):
 1. \<not> n \<le> n' \<Longrightarrow> False
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof(cases "n' \<ge> N")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. N \<le> n' \<Longrightarrow> False
 2. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
N \<le> n'

goal (2 subgoals):
 1. N \<le> n' \<Longrightarrow> False
 2. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
obtain M where M_def: "nat (n' - N) = M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>M. nat (n' - N) = M \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nat (n' - N) = M

goal (2 subgoals):
 1. N \<le> n' \<Longrightarrow> False
 2. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nat (n' - N) = M
[PROOF STEP]
have M0: "n' = N + int M "
[PROOF STATE]
proof (prove)
using this:
nat (n' - N) = M

goal (1 subgoal):
 1. n' = N + int M
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
nat (n' - N) = M
N \<le> n'

goal (1 subgoal):
 1. n' = N + int M
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
n' = N + int M

goal (2 subgoals):
 1. N \<le> n' \<Longrightarrow> False
 2. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
have M1: "M < l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M < l
[PROOF STEP]
using n_def C M0
[PROOF STATE]
proof (prove)
using this:
n = N + int l
n' < n
n' = N + int M

goal (1 subgoal):
 1. M < l
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
M < l

goal (2 subgoals):
 1. N \<le> n' \<Longrightarrow> False
 2. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
M < l
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
M < l

goal (1 subgoal):
 1. False
[PROOF STEP]
using 2 M_def M0 M1
[PROOF STATE]
proof (prove)
using this:
M < l
?M1 < l \<longrightarrow> \<not> P (N + int ?M1)
nat (n' - N) = M
n' = N + int M
M < l

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>P n'\<close>
[PROOF STATE]
proof (prove)
using this:
M < l
?M1 < l \<longrightarrow> \<not> P (N + int ?M1)
nat (n' - N) = M
n' = N + int M
M < l
P n'

goal (1 subgoal):
 1. False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
False

goal (1 subgoal):
 1. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> N \<le> n'

goal (1 subgoal):
 1. \<not> N \<le> n' \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> N \<le> n'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> N \<le> n'

goal (1 subgoal):
 1. False
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<not> N \<le> n'
P n
\<forall>m\<le>N. \<not> P m

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>P n'\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> N \<le> n'
P n
\<forall>m\<le>N. \<not> P m
P n'

goal (1 subgoal):
 1. False
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
False

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n \<le> n'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
P n' \<longrightarrow> n \<le> n'

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>n'. P n' \<longrightarrow> n \<le> n'

goal (1 subgoal):
 1. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>n'. P n' \<longrightarrow> n \<le> n'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>n'. P n' \<longrightarrow> n \<le> n'

goal (1 subgoal):
 1. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
using \<open>P n\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>n'. P n' \<longrightarrow> n \<le> n'
P n

goal (1 subgoal):
 1. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')

goal (1 subgoal):
 1. \<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>n. P n \<and> (\<forall>n'. P n' \<longrightarrow> n \<le> n')

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma emeasure_eq_0:
  "N \<in> sets M \<Longrightarrow> emeasure M N = 0 \<Longrightarrow> K \<subseteq> N \<Longrightarrow> emeasure M K = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>N \<in> sets M; emeasure M N = 0; K \<subseteq> N\<rbrakk> \<Longrightarrow> emeasure M K = 0
[PROOF STEP]
by (metis emeasure_mono order_eq_iff zero_le)


[STATEMENT]
lemma div_3251:
  fixes b k m:: nat
  assumes "b>2" and "k>0"
  defines "n \<equiv> m mod k"
  defines "l \<equiv> (m-n) div k"
  shows "A b m = mat_mul (A b n) (mat_pow l (A b k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from assms(2) l_def n_def representation
[PROOF STATE]
proof (chain)
picking this:
0 < k
l \<equiv> (m - n) div k
n \<equiv> m mod k
\<lbrakk>0 < ?k; ?n = ?m mod ?k; ?l = (?m - ?n) div ?k\<rbrakk> \<Longrightarrow> ?m = ?n + ?k * ?l \<and> 0 \<le> ?n \<and> ?n \<le> ?k - 1
[PROOF STEP]
have m: "m = n+k*l \<and> 0\<le>n \<and> n\<le>k-1"
[PROOF STATE]
proof (prove)
using this:
0 < k
l \<equiv> (m - n) div k
n \<equiv> m mod k
\<lbrakk>0 < ?k; ?n = ?m mod ?k; ?l = (?m - ?n) div ?k\<rbrakk> \<Longrightarrow> ?m = ?n + ?k * ?l \<and> 0 \<le> ?n \<and> ?n \<le> ?k - 1

goal (1 subgoal):
 1. m = n + k * l \<and> 0 \<le> n \<and> n \<le> k - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
m = n + k * l \<and> 0 \<le> n \<and> n \<le> k - 1

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from A_pow assms(1)
[PROOF STATE]
proof (chain)
picking this:
2 < ?b \<Longrightarrow> A ?b ?n = mat_pow ?n (B ?b)
2 < b
[PROOF STEP]
have Abm2: "A b m = mat_pow m (B b)"
[PROOF STATE]
proof (prove)
using this:
2 < ?b \<Longrightarrow> A ?b ?n = mat_pow ?n (B ?b)
2 < b

goal (1 subgoal):
 1. A b m = mat_pow m (B b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A b m = mat_pow m (B b)

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from m
[PROOF STATE]
proof (chain)
picking this:
m = n + k * l \<and> 0 \<le> n \<and> n \<le> k - 1
[PROOF STEP]
have Bm: "mat_pow m (B b) =mat_pow (n+k*l) (B b)"
[PROOF STATE]
proof (prove)
using this:
m = n + k * l \<and> 0 \<le> n \<and> n \<le> k - 1

goal (1 subgoal):
 1. mat_pow m (B b) = mat_pow (n + k * l) (B b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_pow m (B b) = mat_pow (n + k * l) (B b)

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from mat_exp_law
[PROOF STATE]
proof (chain)
picking this:
mat_mul (mat_pow ?n ?M) (mat_pow ?m ?M) = mat_pow (?n + ?m) ?M
[PROOF STEP]
have as1: "mat_pow (n+k*l) (B b)
                            = mat_mul (mat_pow n (B b)) (mat_pow (k*l) (B b))"
[PROOF STATE]
proof (prove)
using this:
mat_mul (mat_pow ?n ?M) (mat_pow ?m ?M) = mat_pow (?n + ?m) ?M

goal (1 subgoal):
 1. mat_pow (n + k * l) (B b) = mat_mul (mat_pow n (B b)) (mat_pow (k * l) (B b))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_pow (n + k * l) (B b) = mat_mul (mat_pow n (B b)) (mat_pow (k * l) (B b))

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from mat_exp_law_mult
[PROOF STATE]
proof (chain)
picking this:
mat_pow (?n * ?m) ?M = mat_pow ?n (mat_pow ?m ?M)
[PROOF STEP]
have as2: "mat_pow (k*l) (B b) = mat_pow l (mat_pow k (B b))"
[PROOF STATE]
proof (prove)
using this:
mat_pow (?n * ?m) ?M = mat_pow ?n (mat_pow ?m ?M)

goal (1 subgoal):
 1. mat_pow (k * l) (B b) = mat_pow l (mat_pow k (B b))
[PROOF STEP]
by (metis mult.commute)
[PROOF STATE]
proof (state)
this:
mat_pow (k * l) (B b) = mat_pow l (mat_pow k (B b))

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from A_pow assms
[PROOF STATE]
proof (chain)
picking this:
2 < ?b \<Longrightarrow> A ?b ?n = mat_pow ?n (B ?b)
2 < b
0 < k
n \<equiv> m mod k
l \<equiv> (m - n) div k
[PROOF STEP]
have Abn: "mat_pow n (B b) = A b n"
[PROOF STATE]
proof (prove)
using this:
2 < ?b \<Longrightarrow> A ?b ?n = mat_pow ?n (B ?b)
2 < b
0 < k
n \<equiv> m mod k
l \<equiv> (m - n) div k

goal (1 subgoal):
 1. mat_pow n (B b) = A b n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_pow n (B b) = A b n

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from A_pow assms(1)
[PROOF STATE]
proof (chain)
picking this:
2 < ?b \<Longrightarrow> A ?b ?n = mat_pow ?n (B ?b)
2 < b
[PROOF STEP]
have Ablk: "mat_pow l (mat_pow k (B b)) = mat_pow l (A b k)"
[PROOF STATE]
proof (prove)
using this:
2 < ?b \<Longrightarrow> A ?b ?n = mat_pow ?n (B ?b)
2 < b

goal (1 subgoal):
 1. mat_pow l (mat_pow k (B b)) = mat_pow l (A b k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
mat_pow l (mat_pow k (B b)) = mat_pow l (A b k)

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
from Ablk Abm2 Abn Bm as1 as2
[PROOF STATE]
proof (chain)
picking this:
mat_pow l (mat_pow k (B b)) = mat_pow l (A b k)
A b m = mat_pow m (B b)
mat_pow n (B b) = A b n
mat_pow m (B b) = mat_pow (n + k * l) (B b)
mat_pow (n + k * l) (B b) = mat_mul (mat_pow n (B b)) (mat_pow (k * l) (B b))
mat_pow (k * l) (B b) = mat_pow l (mat_pow k (B b))
[PROOF STEP]
show Abm: "A b m = mat_mul (A b n) (mat_pow l (A b k))"
[PROOF STATE]
proof (prove)
using this:
mat_pow l (mat_pow k (B b)) = mat_pow l (A b k)
A b m = mat_pow m (B b)
mat_pow n (B b) = A b n
mat_pow m (B b) = mat_pow (n + k * l) (B b)
mat_pow (n + k * l) (B b) = mat_mul (mat_pow n (B b)) (mat_pow (k * l) (B b))
mat_pow (k * l) (B b) = mat_pow l (mat_pow k (B b))

goal (1 subgoal):
 1. A b m = mat_mul (A b n) (mat_pow l (A b k))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A b m = mat_mul (A b n) (mat_pow l (A b k))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma power_eq_prime_powerD:
  fixes p :: "'a :: factorial_semiring"
  assumes "prime p" "n > 0" "x ^ n = p ^ k"
  shows   "\<exists>i. normalize x = normalize (p ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>i. normalize x = normalize (p ^ i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>i. normalize x = normalize (p ^ i)
[PROOF STEP]
have "normalize x = normalize (p ^ multiplicity p x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. normalize x = normalize (p ^ multiplicity p x)
[PROOF STEP]
proof (rule multiplicity_eq_imp_eq)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x \<noteq> (0::'a)
 2. p ^ multiplicity p x \<noteq> (0::'a)
 3. \<And>pa. prime pa \<Longrightarrow> multiplicity pa x = multiplicity pa (p ^ multiplicity p x)
[PROOF STEP]
fix q :: 'a
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x \<noteq> (0::'a)
 2. p ^ multiplicity p x \<noteq> (0::'a)
 3. \<And>pa. prime pa \<Longrightarrow> multiplicity pa x = multiplicity pa (p ^ multiplicity p x)
[PROOF STEP]
assume "prime q"
[PROOF STATE]
proof (state)
this:
prime q

goal (3 subgoals):
 1. x \<noteq> (0::'a)
 2. p ^ multiplicity p x \<noteq> (0::'a)
 3. \<And>pa. prime pa \<Longrightarrow> multiplicity pa x = multiplicity pa (p ^ multiplicity p x)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
prime p
0 < n
x ^ n = p ^ k
[PROOF STEP]
have "multiplicity q (x ^ n) = multiplicity q (p ^ k)"
[PROOF STATE]
proof (prove)
using this:
prime p
0 < n
x ^ n = p ^ k

goal (1 subgoal):
 1. multiplicity q (x ^ n) = multiplicity q (p ^ k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
multiplicity q (x ^ n) = multiplicity q (p ^ k)

goal (3 subgoals):
 1. x \<noteq> (0::'a)
 2. p ^ multiplicity p x \<noteq> (0::'a)
 3. \<And>pa. prime pa \<Longrightarrow> multiplicity pa x = multiplicity pa (p ^ multiplicity p x)
[PROOF STEP]
with \<open>prime q\<close> and assms
[PROOF STATE]
proof (chain)
picking this:
prime q
prime p
0 < n
x ^ n = p ^ k
multiplicity q (x ^ n) = multiplicity q (p ^ k)
[PROOF STEP]
have "n * multiplicity q x = k * multiplicity q p"
[PROOF STATE]
proof (prove)
using this:
prime q
prime p
0 < n
x ^ n = p ^ k
multiplicity q (x ^ n) = multiplicity q (p ^ k)

goal (1 subgoal):
 1. n * multiplicity q x = k * multiplicity q p
[PROOF STEP]
by (subst (asm) (1 2) prime_elem_multiplicity_power_distrib) (auto simp: power_0_left)
[PROOF STATE]
proof (state)
this:
n * multiplicity q x = k * multiplicity q p

goal (3 subgoals):
 1. x \<noteq> (0::'a)
 2. p ^ multiplicity p x \<noteq> (0::'a)
 3. \<And>pa. prime pa \<Longrightarrow> multiplicity pa x = multiplicity pa (p ^ multiplicity p x)
[PROOF STEP]
with assms and \<open>prime q\<close>
[PROOF STATE]
proof (chain)
picking this:
prime p
0 < n
x ^ n = p ^ k
prime q
n * multiplicity q x = k * multiplicity q p
[PROOF STEP]
show "multiplicity q x = multiplicity q (p ^ multiplicity p x)"
[PROOF STATE]
proof (prove)
using this:
prime p
0 < n
x ^ n = p ^ k
prime q
n * multiplicity q x = k * multiplicity q p

goal (1 subgoal):
 1. multiplicity q x = multiplicity q (p ^ multiplicity p x)
[PROOF STEP]
by (cases "p = q") (auto simp: multiplicity_distinct_prime_power prime_multiplicity_other)
[PROOF STATE]
proof (state)
this:
multiplicity q x = multiplicity q (p ^ multiplicity p x)

goal (2 subgoals):
 1. x \<noteq> (0::'a)
 2. p ^ multiplicity p x \<noteq> (0::'a)
[PROOF STEP]
qed (insert assms, auto simp: power_0_left)
[PROOF STATE]
proof (state)
this:
normalize x = normalize (p ^ multiplicity p x)

goal (1 subgoal):
 1. \<exists>i. normalize x = normalize (p ^ i)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
normalize x = normalize (p ^ multiplicity p x)

goal (1 subgoal):
 1. \<exists>i. normalize x = normalize (p ^ i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>i. normalize x = normalize (p ^ i)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma col_space_eq:
  fixes A::"'a::{field}^'m::{finite, wellorder}^'n"
  shows "col_space A = {y. \<exists>x. A *v x = y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col_space A = {y. \<exists>x. A *v x = y}
[PROOF STEP]
proof (unfold col_space_def vec.span_finite[OF finite_columns], auto)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
 2. \<And>xa. A *v xa \<in> range (\<lambda>u. \<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
 2. \<And>xa. A *v xa \<in> range (\<lambda>u. \<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
show "A *v x \<in> range (\<lambda>u. \<Sum>v\<in>columns A. u v *s v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A *v x \<in> range (\<lambda>u. \<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
using matrix_vmult_column_sum[of A x]
[PROOF STATE]
proof (prove)
using this:
\<exists>f. A *v x = (\<Sum>y\<in>columns A. f y *s y)

goal (1 subgoal):
 1. A *v x \<in> range (\<lambda>u. \<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A *v x \<in> range (\<lambda>u. \<Sum>v\<in>columns A. u v *s v)

goal (1 subgoal):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
fix u::"('a, 'n) vec \<Rightarrow> 'a"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
let ?g="\<lambda>y. {i. y=column i A}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
let ?x="(\<chi> i. if i=(LEAST a. a \<in> ?g (column i A)) then u (column i A) else 0)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>u. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
show "\<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
proof (unfold matrix_mult_sum, rule exI[of _ "?x"], auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
have inj: "inj_on ?g (columns A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>y. {i. y = column i A}) (columns A)
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>columns A. \<forall>y\<in>columns A. {i. x = column i A} = {i. y = column i A} \<longrightarrow> x = y
[PROOF STEP]
unfolding columns_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{column i A |i. i \<in> UNIV}. \<forall>y\<in>{column i A |i. i \<in> UNIV}. {i. x = column i A} = {i. y = column i A} \<longrightarrow> x = y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>y. {i. y = column i A}) (columns A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
have union_univ: "\<Union>(?g`(columns A)) = UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>y\<in>columns A. {i. y = column i A}) = UNIV
[PROOF STEP]
unfolding columns_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>y\<in>{column i A |i. i \<in> UNIV}. {i. y = column i A}) = UNIV
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Union>y\<in>columns A. {i. y = column i A}) = UNIV

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
have "sum (\<lambda>i.(if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A) UNIV
        = sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A) (\<Union>(?g`(columns A)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>i\<in>(\<Union>y\<in>columns A. {i. y = column i A}). (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)
[PROOF STEP]
unfolding union_univ
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>i\<in>(\<Union>y\<in>columns A. {i. y = column i A}). (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>i\<in>(\<Union>y\<in>columns A. {i. y = column i A}). (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
have "... = sum (sum (\<lambda>i.(if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A)) (?g`(columns A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>(\<Union>y\<in>columns A. {i. y = column i A}). (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)) ((\<lambda>y. {i. y = column i A}) ` columns A)
[PROOF STEP]
by (rule sum.Union_disjoint[unfolded o_def], auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>(\<Union>y\<in>columns A. {i. y = column i A}). (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)) ((\<lambda>y. {i. y = column i A}) ` columns A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>(\<Union>y\<in>columns A. {i. y = column i A}). (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)) ((\<lambda>y. {i. y = column i A}) ` columns A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
have "... = sum ((sum (\<lambda>i.(if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A)) \<circ> ?g)
        (columns A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)) ((\<lambda>y. {i. y = column i A}) ` columns A) = sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) \<circ> (\<lambda>y. {i. y = column i A})) (columns A)
[PROOF STEP]
by (rule sum.reindex, simp add: inj)
[PROOF STATE]
proof (state)
this:
sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)) ((\<lambda>y. {i. y = column i A}) ` columns A) = sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) \<circ> (\<lambda>y. {i. y = column i A})) (columns A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)) ((\<lambda>y. {i. y = column i A}) ` columns A) = sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) \<circ> (\<lambda>y. {i. y = column i A})) (columns A)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
have "... = sum (\<lambda>y. u y *s y) (columns A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) \<circ> (\<lambda>y. {i. y = column i A})) (columns A) = (\<Sum>y\<in>columns A. u y *s y)
[PROOF STEP]
proof (rule sum.cong, auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
assume x_in_cols: "x \<in> columns A"
[PROOF STATE]
proof (state)
this:
x \<in> columns A

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
obtain b where b: "x=column b A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b. x = column b A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using x_in_cols
[PROOF STATE]
proof (prove)
using this:
x \<in> columns A

goal (1 subgoal):
 1. (\<And>b. x = column b A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding columns_def
[PROOF STATE]
proof (prove)
using this:
x \<in> {column i A |i. i \<in> UNIV}

goal (1 subgoal):
 1. (\<And>b. x = column b A \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x = column b A

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
let ?f="(\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
have sum_rw: "sum ?f ({i. x = column i A} - {LEAST a. x = column a A}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = 0
[PROOF STEP]
by (rule sum.neutral, auto)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = 0

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
have "sum ?f {i. x = column i A} = ?f (LEAST a. x = column a A) + sum ?f ({i. x = column i A} - {LEAST a. x = column a A})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)
[PROOF STEP]
apply (rule sum.remove, auto, rule LeastI_ex)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>xa. x = column xa A
[PROOF STEP]
using x_in_cols
[PROOF STATE]
proof (prove)
using this:
x \<in> columns A

goal (1 subgoal):
 1. \<exists>xa. x = column xa A
[PROOF STEP]
unfolding columns_def
[PROOF STATE]
proof (prove)
using this:
x \<in> {column i A |i. i \<in> UNIV}

goal (1 subgoal):
 1. \<exists>xa. x = column xa A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A)

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
have "... = ?f (LEAST a. x = column a A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A
[PROOF STEP]
unfolding sum_rw
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + 0 = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A + (\<Sum>i\<in>{i. x = column i A} - {LEAST a. x = column a A}. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
have "... = u x *s x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A = u x *s x
[PROOF STEP]
proof (auto, rule LeastI2)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) \<Longrightarrow> x = column ?a8 A
 2. \<And>xa. \<lbrakk>(LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A); x = column xa A\<rbrakk> \<Longrightarrow> u (column xa A) *s column xa A = u x *s x
 3. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
show "x = column b A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = column b A
[PROOF STEP]
using b
[PROOF STATE]
proof (prove)
using this:
x = column b A

goal (1 subgoal):
 1. x = column b A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x = column b A

goal (2 subgoals):
 1. \<And>xa. \<lbrakk>(LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A); x = column xa A\<rbrakk> \<Longrightarrow> u (column xa A) *s column xa A = u x *s x
 2. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
fix xa
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>xa. \<lbrakk>(LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A); x = column xa A\<rbrakk> \<Longrightarrow> u (column xa A) *s column xa A = u x *s x
 2. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
assume x: "x = column xa A"
[PROOF STATE]
proof (state)
this:
x = column xa A

goal (2 subgoals):
 1. \<And>xa. \<lbrakk>(LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A); x = column xa A\<rbrakk> \<Longrightarrow> u (column xa A) *s column xa A = u x *s x
 2. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
show "u (column xa A) *s column xa A = u x *s x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u (column xa A) *s column xa A = u x *s x
[PROOF STEP]
unfolding x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u (column xa A) *s column xa A = u (column xa A) *s column xa A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
u (column xa A) *s column xa A = u x *s x

goal (1 subgoal):
 1. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
assume "(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST c. x = column c A) A = column a A)"
[PROOF STATE]
proof (state)
this:
(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST c. x = column c A) A = column a A)

goal (1 subgoal):
 1. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST c. x = column c A) A = column a A)

goal (1 subgoal):
 1. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
have "(LEAST a. x = column a A) = (LEAST a. column (LEAST c. x = column c A) A = column a A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST a. x = column a A) = (LEAST a. column (LEAST c. x = column c A) A = column a A)
[PROOF STEP]
by (rule Least_equality[symmetric], rule LeastI2, simp_all add: b, rule Least_le, metis (lifting, full_types) LeastI)
[PROOF STATE]
proof (state)
this:
(LEAST a. x = column a A) = (LEAST a. column (LEAST c. x = column c A) A = column a A)

goal (1 subgoal):
 1. \<lbrakk>(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST a. x = column a A) A = column a A); x \<noteq> 0\<rbrakk> \<Longrightarrow> u x = (0::'a)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST c. x = column c A) A = column a A)
(LEAST a. x = column a A) = (LEAST a. column (LEAST c. x = column c A) A = column a A)
[PROOF STEP]
show "u x = 0"
[PROOF STATE]
proof (prove)
using this:
(LEAST a. x = column a A) \<noteq> (LEAST a. column (LEAST c. x = column c A) A = column a A)
(LEAST a. x = column a A) = (LEAST a. column (LEAST c. x = column c A) A = column a A)

goal (1 subgoal):
 1. u x = (0::'a)
[PROOF STEP]
by contradiction
[PROOF STATE]
proof (state)
this:
u x = (0::'a)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if (LEAST a. x = column a A) = (LEAST a. column (LEAST a. x = column a A) A = column a A) then u (column (LEAST a. x = column a A) A) else (0::'a)) *s column (LEAST a. x = column a A) A = u x *s x

goal (1 subgoal):
 1. \<And>x. x \<in> columns A \<Longrightarrow> (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
show " (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A) = u x *s x"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x

goal (1 subgoal):
 1. (\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i | x = column i A. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = u x *s x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sum (sum (\<lambda>i. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) \<circ> (\<lambda>y. {i. y = column i A})) (columns A) = (\<Sum>y\<in>columns A. u y *s y)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>v\<in>columns A. u v *s v)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>y\<in>columns A. u y *s y)
[PROOF STEP]
show "(\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else 0) *s column i A) = (\<Sum>y\<in>columns A. u y *s y)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>y\<in>columns A. u y *s y)

goal (1 subgoal):
 1. (\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>y\<in>columns A. u y *s y)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<in>UNIV. (if i = (LEAST a. column i A = column a A) then u (column i A) else (0::'a)) *s column i A) = (\<Sum>y\<in>columns A. u y *s y)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>x. A *v x = (\<Sum>v\<in>columns A. u v *s v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma zero_under: "x \<in> Field r \<Longrightarrow> zero \<in> under x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> Field r \<Longrightarrow> local.zero \<in> local.under x
[PROOF STEP]
unfolding under_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> Field r \<Longrightarrow> local.zero \<in> {b. (b, x) \<in> r}
[PROOF STEP]
by (auto intro: zero_smallest)


[STATEMENT]
lemma rtranclp_1n_induct [consumes 1, case_names base step]:
  "\<lbrakk>r\<^sup>*\<^sup>* a b; P a; \<And>y z. \<lbrakk>r y z; r\<^sup>*\<^sup>* z b; P y\<rbrakk> \<Longrightarrow> P z\<rbrakk> \<Longrightarrow> P b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>r\<^sup>*\<^sup>* a b; P a; \<And>y z. \<lbrakk>r y z; r\<^sup>*\<^sup>* z b; P y\<rbrakk> \<Longrightarrow> P z\<rbrakk> \<Longrightarrow> P b
[PROOF STEP]
by (induct rule: rtranclp.induct)
    (simp add: rtranclp.rtrancl_into_rtrancl)+


[STATEMENT]
lemma eval_poly_code[code]: "eval_poly h p x = fold_coeffs (\<lambda> a b. h a + x * b) p 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eval_poly h p x = fold_coeffs (\<lambda>a b. h a + x * b) p (0::'a)
[PROOF STEP]
by (induct p, auto simp: eval_poly_def)


[STATEMENT]
lemma enum_obtain_index_finite:
  fixes N :: "nat set"
  assumes "x \<in> N" "finite N"
  obtains i where "i < card N" "x = enum N i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < card N; x = enum N i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis \<open>x \<in> N\<close> \<open>finite N\<close> enum_works_finite imageE lessThan_iff)


[STATEMENT]
lemma (in disc_equity_market) disc_rfr_constant_time:
shows "\<exists>c. \<forall>w \<in> space (F 0).  (disc_rfr_proc r n) w = c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c. \<forall>w\<in>space (F 0). disc_rfr_proc r n w = c
[PROOF STEP]
proof (rule triv_measurable_cst)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. space (F 0) = space ?M
 2. space ?M \<noteq> {}
 3. sets (F 0) = {{}, space ?M}
 4. disc_rfr_proc r n \<in> borel_measurable (F 0)
[PROOF STEP]
show "space (F 0) = space M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space (F 0) = space M
[PROOF STEP]
using filtration
[PROOF STATE]
proof (prove)
using this:
Filtration.filtration M F

goal (1 subgoal):
 1. space (F 0) = space M
[PROOF STEP]
by (simp add:filtration_def subalgebra_def)
[PROOF STATE]
proof (state)
this:
space (F 0) = space M

goal (3 subgoals):
 1. space M \<noteq> {}
 2. sets (F 0) = {{}, space M}
 3. disc_rfr_proc r n \<in> borel_measurable (F 0)
[PROOF STEP]
show "sets (F 0) = {{}, space M}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sets (F 0) = {{}, space M}
[PROOF STEP]
using info_disc_filtr
[PROOF STATE]
proof (prove)
using this:
disc_filtr M F \<and> sets (F \<bottom>) = {{}, space M}

goal (1 subgoal):
 1. sets (F 0) = {{}, space M}
[PROOF STEP]
by (simp add: bot_nat_def init_triv_filt_def)
[PROOF STATE]
proof (state)
this:
sets (F 0) = {{}, space M}

goal (2 subgoals):
 1. space M \<noteq> {}
 2. disc_rfr_proc r n \<in> borel_measurable (F 0)
[PROOF STEP]
show "(disc_rfr_proc r n) \<in> borel_measurable (F 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disc_rfr_proc r n \<in> borel_measurable (F 0)
[PROOF STEP]
using disc_rfr_proc_nonrandom
[PROOF STATE]
proof (prove)
using this:
disc_rfr_proc ?r ?n \<in> borel_measurable (?F (0::?'b))

goal (1 subgoal):
 1. disc_rfr_proc r n \<in> borel_measurable (F 0)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
disc_rfr_proc r n \<in> borel_measurable (F 0)

goal (1 subgoal):
 1. space M \<noteq> {}
[PROOF STEP]
show "space M \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. space M \<noteq> {}
[PROOF STEP]
by (simp add:not_empty)
[PROOF STATE]
proof (state)
this:
space M \<noteq> {}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma enumeratesE:
  assumes "enumerates A f"
  shows "finite A" "A = f ` {..< card A}" "inj_on f {..< card A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A &&& A = f ` {..<card A} &&& inj_on f {..<card A}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
enumerates A f

goal (1 subgoal):
 1. finite A &&& A = f ` {..<card A} &&& inj_on f {..<card A}
[PROOF STEP]
unfolding enumerates_def
[PROOF STATE]
proof (prove)
using this:
finite A \<and> A = f ` {..<card A} \<and> inj_on f {..<card A}

goal (1 subgoal):
 1. finite A &&& A = f ` {..<card A} &&& inj_on f {..<card A}
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. A = f ` {..<card A}
 2. inj_on f {..<card A}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
enumerates A f

goal (2 subgoals):
 1. A = f ` {..<card A}
 2. inj_on f {..<card A}
[PROOF STEP]
unfolding enumerates_def
[PROOF STATE]
proof (prove)
using this:
finite A \<and> A = f ` {..<card A} \<and> inj_on f {..<card A}

goal (2 subgoals):
 1. A = f ` {..<card A}
 2. inj_on f {..<card A}
[PROOF STEP]
apply blast
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on f {..<card A}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
enumerates A f

goal (1 subgoal):
 1. inj_on f {..<card A}
[PROOF STEP]
unfolding enumerates_def
[PROOF STATE]
proof (prove)
using this:
finite A \<and> A = f ` {..<card A} \<and> inj_on f {..<card A}

goal (1 subgoal):
 1. inj_on f {..<card A}
[PROOF STEP]
by blast


[STATEMENT]
lemma zipf_zip: "\<lbrakk>length l1 = length l2\<rbrakk> \<Longrightarrow> zipf Pair l1 l2 = zip l1 l2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length l1 = length l2 \<Longrightarrow> zipf Pair l1 l2 = zip l1 l2
[PROOF STEP]
apply (induct l1 arbitrary: l2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>l2. length [] = length l2 \<Longrightarrow> zipf Pair [] l2 = zip [] l2
 2. \<And>a l1 l2. \<lbrakk>\<And>l2. length l1 = length l2 \<Longrightarrow> zipf Pair l1 l2 = zip l1 l2; length (a # l1) = length l2\<rbrakk> \<Longrightarrow> zipf Pair (a # l1) l2 = zip (a # l1) l2
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. length l1 = length l2 \<Longrightarrow> zipf Pair l1 l2 = zip l1 l2; Suc (length l1) = length l2\<rbrakk> \<Longrightarrow> zipf Pair (a # l1) l2 = zip (a # l1) l2
[PROOF STEP]
apply (case_tac l2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a l1 l2. \<lbrakk>\<And>l2. length l1 = length l2 \<Longrightarrow> zipf Pair l1 l2 = zip l1 l2; Suc (length l1) = length l2; l2 = []\<rbrakk> \<Longrightarrow> zipf Pair (a # l1) l2 = zip (a # l1) l2
 2. \<And>a l1 l2 aa list. \<lbrakk>\<And>l2. length l1 = length l2 \<Longrightarrow> zipf Pair l1 l2 = zip l1 l2; Suc (length l1) = length l2; l2 = aa # list\<rbrakk> \<Longrightarrow> zipf Pair (a # l1) l2 = zip (a # l1) l2
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done

  \<comment> \<open>All quantification over zipped lists\<close>


[STATEMENT]
lemma map_of_zip_map: "map_of (zip (map f rs) rs) k = Some v \<Longrightarrow> k = f v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_of (zip (map f rs) rs) k = Some v \<Longrightarrow> k = f v
[PROOF STEP]
apply(induction rs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. map_of (zip (map f []) []) k = Some v \<Longrightarrow> k = f v
 2. \<And>a rs. \<lbrakk>map_of (zip (map f rs) rs) k = Some v \<Longrightarrow> k = f v; map_of (zip (map f (a # rs)) (a # rs)) k = Some v\<rbrakk> \<Longrightarrow> k = f v
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a rs. \<lbrakk>map_of (zip (map f rs) rs) k = Some v \<Longrightarrow> k = f v; map_of (zip (map f (a # rs)) (a # rs)) k = Some v\<rbrakk> \<Longrightarrow> k = f v
[PROOF STEP]
apply(simp split: if_split_asm)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma contractible_space_retraction_map_image:
  assumes "retraction_map X Y f" and X: "contractible_space X"
  shows "contractible_space Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. contractible_space Y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. contractible_space Y
[PROOF STEP]
obtain g where f: "continuous_map X Y f" and g: "continuous_map Y X g" and fg: "\<forall>y \<in> topspace Y. f(g y) = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>g. \<lbrakk>continuous_map X Y f; continuous_map Y X g; \<forall>y\<in>topspace Y. f (g y) = y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
retraction_map X Y f
contractible_space X

goal (1 subgoal):
 1. (\<And>g. \<lbrakk>continuous_map X Y f; continuous_map Y X g; \<forall>y\<in>topspace Y. f (g y) = y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: retraction_map_def retraction_maps_def)
[PROOF STATE]
proof (state)
this:
continuous_map X Y f
continuous_map Y X g
\<forall>y\<in>topspace Y. f (g y) = y

goal (1 subgoal):
 1. contractible_space Y
[PROOF STEP]
obtain a where a: "homotopic_with (\<lambda>x. True) X X id (\<lambda>x. a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. homotopic_with (\<lambda>x. True) X X id (\<lambda>x. a) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using X
[PROOF STATE]
proof (prove)
using this:
contractible_space X

goal (1 subgoal):
 1. (\<And>a. homotopic_with (\<lambda>x. True) X X id (\<lambda>x. a) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: contractible_space_def)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) X X id (\<lambda>x. a)

goal (1 subgoal):
 1. contractible_space Y
[PROOF STEP]
have "homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. f a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. f a)
[PROOF STEP]
proof (rule homotopic_with_eq)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. homotopic_with (\<lambda>x. True) Y Y ?f ?g
 2. \<And>x. x \<in> topspace Y \<Longrightarrow> id x = ?f x
 3. \<And>x. x \<in> topspace Y \<Longrightarrow> f a = ?g x
 4. \<And>h k. (\<And>x. x \<in> topspace Y \<Longrightarrow> h x = k x) \<Longrightarrow> True = True
[PROOF STEP]
show "homotopic_with (\<lambda>x. True) Y Y (f \<circ> id \<circ> g) (f \<circ> (\<lambda>x. a) \<circ> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) Y Y (f \<circ> id \<circ> g) (f \<circ> (\<lambda>x. a) \<circ> g)
[PROOF STEP]
using f g a homotopic_with_compose_continuous_map_left homotopic_with_compose_continuous_map_right
[PROOF STATE]
proof (prove)
using this:
continuous_map X Y f
continuous_map Y X g
homotopic_with (\<lambda>x. True) X X id (\<lambda>x. a)
\<lbrakk>homotopic_with ?p ?X1.0 ?X2.0 ?f ?g; continuous_map ?X2.0 ?X3.0 ?h; \<And>j. ?p j \<Longrightarrow> ?q (?h \<circ> j)\<rbrakk> \<Longrightarrow> homotopic_with ?q ?X1.0 ?X3.0 (?h \<circ> ?f) (?h \<circ> ?g)
\<lbrakk>homotopic_with ?p ?X2.0 ?X3.0 ?f ?g; continuous_map ?X1.0 ?X2.0 ?h; \<And>j. ?p j \<Longrightarrow> ?q (j \<circ> ?h)\<rbrakk> \<Longrightarrow> homotopic_with ?q ?X1.0 ?X3.0 (?f \<circ> ?h) (?g \<circ> ?h)

goal (1 subgoal):
 1. homotopic_with (\<lambda>x. True) Y Y (f \<circ> id \<circ> g) (f \<circ> (\<lambda>x. a) \<circ> g)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) Y Y (f \<circ> id \<circ> g) (f \<circ> (\<lambda>x. a) \<circ> g)

goal (3 subgoals):
 1. \<And>x. x \<in> topspace Y \<Longrightarrow> id x = (f \<circ> id \<circ> g) x
 2. \<And>x. x \<in> topspace Y \<Longrightarrow> f a = (f \<circ> (\<lambda>x. a) \<circ> g) x
 3. \<And>h k. (\<And>x. x \<in> topspace Y \<Longrightarrow> h x = k x) \<Longrightarrow> True = True
[PROOF STEP]
qed (use fg in auto)
[PROOF STATE]
proof (state)
this:
homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. f a)

goal (1 subgoal):
 1. contractible_space Y
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. f a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. f a)

goal (1 subgoal):
 1. contractible_space Y
[PROOF STEP]
unfolding contractible_space_def
[PROOF STATE]
proof (prove)
using this:
homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. f a)

goal (1 subgoal):
 1. \<exists>a. homotopic_with (\<lambda>x. True) Y Y id (\<lambda>x. a)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
contractible_space Y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma f_join_singleton_if: "
  xs \<Join>\<^sub>f {n} = (if n < length xs then [xs ! n] else [])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<Join>\<^sub> {n} = (if n < length xs then [xs ! n] else [])
[PROOF STEP]
apply (clarsimp simp: list_eq_iff f_join_length cut_less_singleton)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < length xs \<Longrightarrow> xs \<Join>\<^sub> {n} ! 0 = xs ! n
[PROOF STEP]
apply (insert f_join_nth[of 0 xs "{n}"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < length xs; 0 < length (xs \<Join>\<^sub> {n}) \<Longrightarrow> xs \<Join>\<^sub> {n} ! 0 = xs ! ({n} \<rightarrow> 0)\<rbrakk> \<Longrightarrow> xs \<Join>\<^sub> {n} ! 0 = xs ! n
[PROOF STEP]
apply (simp add: f_join_length cut_less_singleton)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in discrete) open_iff [iff]:
  "t open = (t \<in> Pow carrier)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (t open) = (t \<in> Pow carrier)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (t open) = (t \<in> Pow carrier)
[PROOF STEP]
have "t open = (t \<in> Pow X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (t open) = (t \<in> Pow X)
[PROOF STEP]
by (auto simp: T_def discrete_top_def is_open_def)
[PROOF STATE]
proof (state)
this:
(t open) = (t \<in> Pow X)

goal (1 subgoal):
 1. (t open) = (t \<in> Pow carrier)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(t open) = (t \<in> Pow X)

goal (1 subgoal):
 1. (t open) = (t \<in> Pow carrier)
[PROOF STEP]
by (simp add: carrier)
[PROOF STATE]
proof (state)
this:
(t open) = (t \<in> Pow carrier)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in ring) subset_Idl_subset:
  assumes Icarr: "I \<subseteq> carrier R"
    and HI: "H \<subseteq> I"
  shows "Idl H \<subseteq> Idl I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Idl H \<subseteq> Idl I
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Idl H \<subseteq> Idl I
[PROOF STEP]
from Icarr
[PROOF STATE]
proof (chain)
picking this:
I \<subseteq> carrier R
[PROOF STEP]
have Iideal: "ideal (Idl I) R"
[PROOF STATE]
proof (prove)
using this:
I \<subseteq> carrier R

goal (1 subgoal):
 1. ideal (Idl I) R
[PROOF STEP]
by (rule genideal_ideal)
[PROOF STATE]
proof (state)
this:
ideal (Idl I) R

goal (1 subgoal):
 1. Idl H \<subseteq> Idl I
[PROOF STEP]
from HI and Icarr
[PROOF STATE]
proof (chain)
picking this:
H \<subseteq> I
I \<subseteq> carrier R
[PROOF STEP]
have "H \<subseteq> carrier R"
[PROOF STATE]
proof (prove)
using this:
H \<subseteq> I
I \<subseteq> carrier R

goal (1 subgoal):
 1. H \<subseteq> carrier R
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
H \<subseteq> carrier R

goal (1 subgoal):
 1. Idl H \<subseteq> Idl I
[PROOF STEP]
with Iideal
[PROOF STATE]
proof (chain)
picking this:
ideal (Idl I) R
H \<subseteq> carrier R
[PROOF STEP]
have "(H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)"
[PROOF STATE]
proof (prove)
using this:
ideal (Idl I) R
H \<subseteq> carrier R

goal (1 subgoal):
 1. (H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)
[PROOF STEP]
by (rule Idl_subset_ideal[symmetric])
[PROOF STATE]
proof (state)
this:
(H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)

goal (1 subgoal):
 1. Idl H \<subseteq> Idl I
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)
[PROOF STEP]
show "Idl H \<subseteq> Idl I"
[PROOF STATE]
proof (prove)
using this:
(H \<subseteq> Idl I) = (Idl H \<subseteq> Idl I)

goal (1 subgoal):
 1. Idl H \<subseteq> Idl I
[PROOF STEP]
by (meson HI Icarr genideal_self order_trans)
[PROOF STATE]
proof (state)
this:
Idl H \<subseteq> Idl I

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma snd_o_funPair [simp]: "snd o (funPair f g) = g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. snd \<circ> funPair f g = g
[PROOF STEP]
by (simp add: funPair_def o_def)


[STATEMENT]
lemma path_append_target_hd :
  assumes "length p > 0"
  shows "target q p = target (t_target (hd p)) (tl p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. target q p = target (t_target (hd p)) (tl p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < length p

goal (1 subgoal):
 1. target q p = target (t_target (hd p)) (tl p)
[PROOF STEP]
by (induction p) (simp+)


[STATEMENT]
lemma vrestr_Inter [simp]:
  assumes "A \<noteq> {}"
  shows "f --` (\<Inter>A) = (\<Inter>X\<in>A. f --` X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f --` \<Inter> A = \<Inter> ((--`) f ` A)
[PROOF STEP]
using vimage_restr_def assms
[PROOF STATE]
proof (prove)
using this:
?f --` ?A \<equiv> ?f -` (?A \<inter> space M) \<inter> space M
A \<noteq> {}

goal (1 subgoal):
 1. f --` \<Inter> A = \<Inter> ((--`) f ` A)
[PROOF STEP]
by auto


[STATEMENT]
lemma IArray_nth_equalityI: "IArray.length xs = length ys \<Longrightarrow>
  (\<And>i. i < IArray.length xs \<Longrightarrow> IArray.sub xs i = ys ! i) \<Longrightarrow> xs = IArray ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>IArray.length xs = length ys; \<And>i. i < IArray.length xs \<Longrightarrow> xs !! i = ys ! i\<rbrakk> \<Longrightarrow> xs = IArray ys
[PROOF STEP]
by (induction xs arbitrary: ys) (auto intro: nth_equalityI)


[STATEMENT]
lemma height_primrec: "height = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. height x = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b)) x
[PROOF STEP]
fix t :: "'a tree"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. height x = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b)) x
[PROOF STEP]
show "height t = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b)) t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. height t = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b)) t
[PROOF STEP]
by (induction t) simp_all
[PROOF STATE]
proof (state)
this:
height t = rec_tree 0 (\<lambda>_ _ _ a b. Suc (max a b)) t

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma diagseq_mono: "diagseq n < diagseq (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
have "diagseq n < seqseq n (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagseq n < seqseq n (Suc n)
[PROOF STEP]
using subseq_seqseq[of n]
[PROOF STATE]
proof (prove)
using this:
strict_mono (seqseq n)

goal (1 subgoal):
 1. diagseq n < seqseq n (Suc n)
[PROOF STEP]
by (simp add: diagseq_def strict_mono_def)
[PROOF STATE]
proof (state)
this:
diagseq n < seqseq n (Suc n)

goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
diagseq n < seqseq n (Suc n)

goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
have "\<dots> \<le> seqseq n (reduce (seqseq n) n (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. seqseq n (Suc n) \<le> seqseq n (reduce (seqseq n) n (Suc n))
[PROOF STEP]
using strict_mono_less_eq seq_suble
[PROOF STATE]
proof (prove)
using this:
strict_mono ?f \<Longrightarrow> (?f ?x \<le> ?f ?y) = (?x \<le> ?y)
strict_mono ?f \<Longrightarrow> ?n \<le> ?f ?n

goal (1 subgoal):
 1. seqseq n (Suc n) \<le> seqseq n (reduce (seqseq n) n (Suc n))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
seqseq n (Suc n) \<le> seqseq n (reduce (seqseq n) n (Suc n))

goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
seqseq n (Suc n) \<le> seqseq n (reduce (seqseq n) n (Suc n))

goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
have "\<dots> = diagseq (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. seqseq n (reduce (seqseq n) n (Suc n)) = diagseq (Suc n)
[PROOF STEP]
by (simp add: diagseq_def)
[PROOF STATE]
proof (state)
this:
seqseq n (reduce (seqseq n) n (Suc n)) = diagseq (Suc n)

goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
diagseq n < diagseq (Suc n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
diagseq n < diagseq (Suc n)

goal (1 subgoal):
 1. diagseq n < diagseq (Suc n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagseq n < diagseq (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_set_of_finite_maps:
  assumes "finite A" "finite B"
  shows "finite {m. dom m = A \<and> ran m \<subseteq> B}" (is "finite ?S")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
let ?S' = "{m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
have "?S = ?S'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {m. dom m = A \<and> ran m \<subseteq> B} = {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {m. dom m = A \<and> ran m \<subseteq> B} \<subseteq> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}
 2. {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<subseteq> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
show "?S \<subseteq> ?S'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {m. dom m = A \<and> ran m \<subseteq> B} \<subseteq> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}
[PROOF STEP]
by (auto simp: dom_def ran_def image_def)
[PROOF STATE]
proof (state)
this:
{m. dom m = A \<and> ran m \<subseteq> B} \<subseteq> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}

goal (1 subgoal):
 1. {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<subseteq> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
show "?S' \<subseteq> ?S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<subseteq> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<Longrightarrow> x \<in> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
fix m
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<Longrightarrow> x \<in> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
assume "m \<in> ?S'"
[PROOF STATE]
proof (state)
this:
m \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}

goal (1 subgoal):
 1. \<And>x. x \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<Longrightarrow> x \<in> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
hence 1: "dom m = A"
[PROOF STATE]
proof (prove)
using this:
m \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}

goal (1 subgoal):
 1. dom m = A
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
dom m = A

goal (1 subgoal):
 1. \<And>x. x \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<Longrightarrow> x \<in> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
hence 2: "ran m \<subseteq> B"
[PROOF STATE]
proof (prove)
using this:
dom m = A

goal (1 subgoal):
 1. ran m \<subseteq> B
[PROOF STEP]
using \<open>m \<in> ?S'\<close>
[PROOF STATE]
proof (prove)
using this:
dom m = A
m \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}

goal (1 subgoal):
 1. ran m \<subseteq> B
[PROOF STEP]
by (auto simp: dom_def ran_def)
[PROOF STATE]
proof (state)
this:
ran m \<subseteq> B

goal (1 subgoal):
 1. \<And>x. x \<in> {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<Longrightarrow> x \<in> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
from 1 2
[PROOF STATE]
proof (chain)
picking this:
dom m = A
ran m \<subseteq> B
[PROOF STEP]
show "m \<in> ?S"
[PROOF STATE]
proof (prove)
using this:
dom m = A
ran m \<subseteq> B

goal (1 subgoal):
 1. m \<in> {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m \<in> {m. dom m = A \<and> ran m \<subseteq> B}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)} \<subseteq> {m. dom m = A \<and> ran m \<subseteq> B}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{m. dom m = A \<and> ran m \<subseteq> B} = {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}

goal (1 subgoal):
 1. finite {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
finite A
finite B
{m. dom m = A \<and> ran m \<subseteq> B} = {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite A
finite B
{m. dom m = A \<and> ran m \<subseteq> B} = {m. \<forall>x. (x \<in> A \<longrightarrow> m x \<in> Some ` B) \<and> (x \<notin> A \<longrightarrow> m x = None)}

goal (1 subgoal):
 1. finite {m. dom m = A \<and> ran m \<subseteq> B}
[PROOF STEP]
by(simp add: finite_set_of_finite_funs)
[PROOF STATE]
proof (state)
this:
finite {m. dom m = A \<and> ran m \<subseteq> B}

goal:
No subgoals!
[PROOF STEP]
qed