[STATEMENT]
lemma (in valid_unSimpGraph) total_v_num:
  assumes friend_assm:"\<And>v u. v\<in>V \<Longrightarrow> u\<in>V \<Longrightarrow> v\<noteq>u \<Longrightarrow> \<exists>! n. adjacent v n \<and> adjacent u n"
      and "finite E" and "finite V" and "V\<noteq>{}" and " \<forall>v\<in>V. degree v G = k" and "k>0"
  shows "card V= k*k - k +1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
have k_adj:"\<And>v. v\<in>V\<Longrightarrow>card ({n. adjacent v n})=k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>v. v \<in> V \<Longrightarrow> card {n. adjacent v n} = k
[PROOF STEP]
by (metis assms(2) assms(5) degree_adjacent)
[PROOF STATE]
proof (state)
this:
?v \<in> V \<Longrightarrow> card {n. adjacent ?v n} = k

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
obtain v where "v\<in>V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>v. v \<in> V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>V\<noteq>{}\<close>
[PROOF STATE]
proof (prove)
using this:
V \<noteq> {}

goal (1 subgoal):
 1. (\<And>v. v \<in> V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v \<in> V

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
obtain l2_eq_v where l2_eq_v: "l2_eq_v={ps. length ps=2 \<and> adj_path v ps \<and> last ps=v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>l2_eq_v. l2_eq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps = v} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l2_eq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps = v}

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
have "card l2_eq_v=k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
obtain hds where hds:"hds= hd` l2_eq_v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>hds. hds = hd ` l2_eq_v \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
hds = hd ` l2_eq_v

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
hds = hd ` l2_eq_v

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
have "hds={n. adjacent v n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hds = {n. adjacent v n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. hds = {n. adjacent v n}
[PROOF STEP]
have "\<And>x. x\<in>hds \<Longrightarrow> x\<in> {n. adjacent v n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> hds \<Longrightarrow> x \<in> {n. adjacent v n}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> hds \<Longrightarrow> adjacent v x
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> hds \<Longrightarrow> adjacent v x
[PROOF STEP]
assume "x\<in>hds"
[PROOF STATE]
proof (state)
this:
x \<in> hds

goal (1 subgoal):
 1. \<And>x. x \<in> hds \<Longrightarrow> adjacent v x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> hds
[PROOF STEP]
obtain ps where "hd ps=x" "length ps=2" "adj_path v ps" "last ps=v"
[PROOF STATE]
proof (prove)
using this:
x \<in> hds

goal (1 subgoal):
 1. (\<And>ps. \<lbrakk>hd ps = x; length ps = 2; adj_path v ps; last ps = v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using hds l2_eq_v
[PROOF STATE]
proof (prove)
using this:
x \<in> hds
hds = hd ` l2_eq_v
l2_eq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps = v}

goal (1 subgoal):
 1. (\<And>ps. \<lbrakk>hd ps = x; length ps = 2; adj_path v ps; last ps = v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
hd ps = x
length ps = 2
adj_path v ps
last ps = v

goal (1 subgoal):
 1. \<And>x. x \<in> hds \<Longrightarrow> adjacent v x
[PROOF STEP]
thus "adjacent v x"
[PROOF STATE]
proof (prove)
using this:
hd ps = x
length ps = 2
adj_path v ps
last ps = v

goal (1 subgoal):
 1. adjacent v x
[PROOF STEP]
by (metis (full_types) adj_path.simps(2) list.sel(1) length_0_conv neq_Nil_conv
                  zero_neq_numeral)
[PROOF STATE]
proof (state)
this:
adjacent v x

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> hds \<Longrightarrow> ?x \<in> {n. adjacent v n}

goal (1 subgoal):
 1. hds = {n. adjacent v n}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?x \<in> hds \<Longrightarrow> ?x \<in> {n. adjacent v n}

goal (1 subgoal):
 1. hds = {n. adjacent v n}
[PROOF STEP]
have "\<And>x. x\<in>{n. adjacent v n} \<Longrightarrow> x\<in>hds"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {n. adjacent v n} \<Longrightarrow> x \<in> hds
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {n. adjacent v n} \<Longrightarrow> x \<in> hds
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {n. adjacent v n} \<Longrightarrow> x \<in> hds
[PROOF STEP]
assume "x\<in>{n. adjacent v n}"
[PROOF STATE]
proof (state)
this:
x \<in> {n. adjacent v n}

goal (1 subgoal):
 1. \<And>x. x \<in> {n. adjacent v n} \<Longrightarrow> x \<in> hds
[PROOF STEP]
obtain ps where "ps=[x,v]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>ps. ps = [x, v] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ps = [x, v]

goal (1 subgoal):
 1. \<And>x. x \<in> {n. adjacent v n} \<Longrightarrow> x \<in> hds
[PROOF STEP]
hence "hd ps=x" and "length ps=2" and "adj_path v ps" and "last ps=v"
[PROOF STATE]
proof (prove)
using this:
ps = [x, v]

goal (1 subgoal):
 1. (hd ps = x &&& length ps = 2) &&& adj_path v ps &&& last ps = v
[PROOF STEP]
using \<open>x\<in>{n. adjacent v n}\<close> adjacent_sym
[PROOF STATE]
proof (prove)
using this:
ps = [x, v]
x \<in> {n. adjacent v n}
adjacent ?v ?v' = adjacent ?v' ?v

goal (1 subgoal):
 1. (hd ps = x &&& length ps = 2) &&& adj_path v ps &&& last ps = v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
hd ps = x
length ps = 2
adj_path v ps
last ps = v

goal (1 subgoal):
 1. \<And>x. x \<in> {n. adjacent v n} \<Longrightarrow> x \<in> hds
[PROOF STEP]
thus "x\<in>hds"
[PROOF STATE]
proof (prove)
using this:
hd ps = x
length ps = 2
adj_path v ps
last ps = v

goal (1 subgoal):
 1. x \<in> hds
[PROOF STEP]
by (metis (lifting, mono_tags) hds image_eqI l2_eq_v mem_Collect_eq)
[PROOF STATE]
proof (state)
this:
x \<in> hds

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> {n. adjacent v n} \<Longrightarrow> ?x \<in> hds

goal (1 subgoal):
 1. hds = {n. adjacent v n}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?x \<in> hds \<Longrightarrow> ?x \<in> {n. adjacent v n}
?x \<in> {n. adjacent v n} \<Longrightarrow> ?x \<in> hds
[PROOF STEP]
show "hds={n. adjacent v n}"
[PROOF STATE]
proof (prove)
using this:
?x \<in> hds \<Longrightarrow> ?x \<in> {n. adjacent v n}
?x \<in> {n. adjacent v n} \<Longrightarrow> ?x \<in> hds

goal (1 subgoal):
 1. hds = {n. adjacent v n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
hds = {n. adjacent v n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
hds = {n. adjacent v n}

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
hds = {n. adjacent v n}

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
have "inj_on hd l2_eq_v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on hd l2_eq_v
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>l2_eq_v. \<forall>y\<in>l2_eq_v. hd x = hd y \<longrightarrow> x = y
[PROOF STEP]
proof (rule+)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume "x \<in> l2_eq_v" "y \<in> l2_eq_v" "hd x = hd y"
[PROOF STATE]
proof (state)
this:
x \<in> l2_eq_v
y \<in> l2_eq_v
hd x = hd y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "length x=2" and "last x=last y" and "length y=2"
[PROOF STATE]
proof (prove)
using this:
x \<in> l2_eq_v
y \<in> l2_eq_v
hd x = hd y

goal (1 subgoal):
 1. length x = 2 &&& last x = last y &&& length y = 2
[PROOF STEP]
using l2_eq_v
[PROOF STATE]
proof (prove)
using this:
x \<in> l2_eq_v
y \<in> l2_eq_v
hd x = hd y
l2_eq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps = v}

goal (1 subgoal):
 1. length x = 2 &&& last x = last y &&& length y = 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length x = 2
last x = last y
length y = 2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "x!1=y!1"
[PROOF STATE]
proof (prove)
using this:
length x = 2
last x = last y
length y = 2

goal (1 subgoal):
 1. x ! 1 = y ! 1
[PROOF STEP]
using last_conv_nth[of x] last_conv_nth[of y]
[PROOF STATE]
proof (prove)
using this:
length x = 2
last x = last y
length y = 2
x \<noteq> [] \<Longrightarrow> last x = x ! (length x - 1)
y \<noteq> [] \<Longrightarrow> last y = y ! (length y - 1)

goal (1 subgoal):
 1. x ! 1 = y ! 1
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
x ! 1 = y ! 1

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x ! 1 = y ! 1

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "x!0=y!0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x ! 0 = y ! 0
[PROOF STEP]
using \<open>hd x=hd y\<close> \<open>length x=2\<close> \<open>length y=2\<close>
[PROOF STATE]
proof (prove)
using this:
hd x = hd y
length x = 2
length y = 2

goal (1 subgoal):
 1. x ! 0 = y ! 0
[PROOF STEP]
by(metis hd_conv_nth length_greater_0_conv)
[PROOF STATE]
proof (state)
this:
x ! 0 = y ! 0

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_eq_v; y \<in> l2_eq_v; hd x = hd y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x ! 1 = y ! 1
x ! 0 = y ! 0
[PROOF STEP]
show "x=y"
[PROOF STATE]
proof (prove)
using this:
x ! 1 = y ! 1
x ! 0 = y ! 0

goal (1 subgoal):
 1. x = y
[PROOF STEP]
using \<open>length x=2\<close> \<open>length y=2\<close>
[PROOF STATE]
proof (prove)
using this:
x ! 1 = y ! 1
x ! 0 = y ! 0
length x = 2
length y = 2

goal (1 subgoal):
 1. x = y
[PROOF STEP]
using  nth_equalityI[of x y]
[PROOF STATE]
proof (prove)
using this:
x ! 1 = y ! 1
x ! 0 = y ! 0
length x = 2
length y = 2
\<lbrakk>length x = length y; \<And>i. i < length x \<Longrightarrow> x ! i = y ! i\<rbrakk> \<Longrightarrow> x = y

goal (1 subgoal):
 1. x = y
[PROOF STEP]
by (metis One_nat_def less_2_cases)
[PROOF STATE]
proof (state)
this:
x = y

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

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
hds = hd ` l2_eq_v
hds = {n. adjacent v n}
inj_on hd l2_eq_v
[PROOF STEP]
show "card l2_eq_v=k"
[PROOF STATE]
proof (prove)
using this:
hds = hd ` l2_eq_v
hds = {n. adjacent v n}
inj_on hd l2_eq_v

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
using k_adj[OF \<open>v\<in>V\<close>]
[PROOF STATE]
proof (prove)
using this:
hds = hd ` l2_eq_v
hds = {n. adjacent v n}
inj_on hd l2_eq_v
card {n. adjacent v n} = k

goal (1 subgoal):
 1. card l2_eq_v = k
[PROOF STEP]
by (metis card_image)
[PROOF STATE]
proof (state)
this:
card l2_eq_v = k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card l2_eq_v = k

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
obtain l2_neq_v where l2_neq_v:"l2_neq_v={ps. length ps=2 \<and> adj_path v ps \<and> last ps\<noteq>v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>l2_neq_v. l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v}

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
have "card l2_neq_v = k*k-k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
obtain l2_v where l2_v:"l2_v={ps. length ps=2\<and> adj_path v ps}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>l2_v. l2_v = {ps. length ps = 2 \<and> adj_path v ps} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l2_v = {ps. length ps = 2 \<and> adj_path v ps}

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
hence "card l2_v=k*k"
[PROOF STATE]
proof (prove)
using this:
l2_v = {ps. length ps = 2 \<and> adj_path v ps}

goal (1 subgoal):
 1. card l2_v = k * k
[PROOF STEP]
using path_count[OF k_adj,of v 2] \<open>0<k\<close> \<open>finite V\<close> \<open>v\<in>V\<close>
[PROOF STATE]
proof (prove)
using this:
l2_v = {ps. length ps = 2 \<and> adj_path v ps}
\<lbrakk>\<And>v. v \<in> V \<Longrightarrow> v \<in> V; v \<in> V; finite V; 0 < k\<rbrakk> \<Longrightarrow> card {ps. length ps = 2 \<and> adj_path v ps} = k\<^sup>2
0 < k
finite V
v \<in> V

goal (1 subgoal):
 1. card l2_v = k * k
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
card l2_v = k * k

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
hence "finite l2_v"
[PROOF STATE]
proof (prove)
using this:
card l2_v = k * k

goal (1 subgoal):
 1. finite l2_v
[PROOF STEP]
using \<open>k>0\<close>
[PROOF STATE]
proof (prove)
using this:
card l2_v = k * k
0 < k

goal (1 subgoal):
 1. finite l2_v
[PROOF STEP]
by (metis card.infinite mult_is_0 neq0_conv)
[PROOF STATE]
proof (state)
this:
finite l2_v

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite l2_v

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
have "l2_v=l2_neq_v \<union> l2_eq_v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l2_v = l2_neq_v \<union> l2_eq_v
[PROOF STEP]
using l2_v l2_neq_v l2_eq_v
[PROOF STATE]
proof (prove)
using this:
l2_v = {ps. length ps = 2 \<and> adj_path v ps}
l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v}
l2_eq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps = v}

goal (1 subgoal):
 1. l2_v = l2_neq_v \<union> l2_eq_v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l2_v = l2_neq_v \<union> l2_eq_v

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
l2_v = l2_neq_v \<union> l2_eq_v

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
have "l2_neq_v \<inter> l2_eq_v ={}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l2_neq_v \<inter> l2_eq_v = {}
[PROOF STEP]
using l2_neq_v l2_eq_v
[PROOF STATE]
proof (prove)
using this:
l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v}
l2_eq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps = v}

goal (1 subgoal):
 1. l2_neq_v \<inter> l2_eq_v = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l2_neq_v \<inter> l2_eq_v = {}

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite l2_v
l2_v = l2_neq_v \<union> l2_eq_v
l2_neq_v \<inter> l2_eq_v = {}
[PROOF STEP]
have "card l2_neq_v = card l2_v - card l2_eq_v"
[PROOF STATE]
proof (prove)
using this:
finite l2_v
l2_v = l2_neq_v \<union> l2_eq_v
l2_neq_v \<inter> l2_eq_v = {}

goal (1 subgoal):
 1. card l2_neq_v = card l2_v - card l2_eq_v
[PROOF STEP]
by (metis Int_commute Nat.add_0_right Un_commute card_Diff_subset_Int card_Un_Int
                  card_gt_0_iff diff_add_inverse finite_Diff finite_Un inf_sup_absorb
                  less_nat_zero_code)
[PROOF STATE]
proof (state)
this:
card l2_neq_v = card l2_v - card l2_eq_v

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
thus "card l2_neq_v = k*k-k"
[PROOF STATE]
proof (prove)
using this:
card l2_neq_v = card l2_v - card l2_eq_v

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
using \<open>card l2_eq_v=k\<close>
[PROOF STATE]
proof (prove)
using this:
card l2_neq_v = card l2_v - card l2_eq_v
card l2_eq_v = k

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
using \<open>card l2_v=k*k\<close>
[PROOF STATE]
proof (prove)
using this:
card l2_neq_v = card l2_v - card l2_eq_v
card l2_eq_v = k
card l2_v = k * k

goal (1 subgoal):
 1. card l2_neq_v = k * k - k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card l2_neq_v = k * k - k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card l2_neq_v = k * k - k

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card l2_neq_v = k * k - k

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
have "bij_betw last l2_neq_v {n. n\<in>V \<and> n\<noteq>v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}
[PROOF STEP]
have "last ` l2_neq_v = {n. n\<in>V \<and> n\<noteq>v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
have "\<And>x. x\<in> last` l2_neq_v \<Longrightarrow> x\<in>{n. n\<in>V \<and> n\<noteq>v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> last ` l2_neq_v \<Longrightarrow> x \<in> {n \<in> V. n \<noteq> v}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> last ` l2_neq_v \<Longrightarrow> x \<in> V \<and> x \<noteq> v
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> last ` l2_neq_v \<Longrightarrow> x \<in> V \<and> x \<noteq> v
[PROOF STEP]
assume "x\<in>last` l2_neq_v"
[PROOF STATE]
proof (state)
this:
x \<in> last ` l2_neq_v

goal (1 subgoal):
 1. \<And>x. x \<in> last ` l2_neq_v \<Longrightarrow> x \<in> V \<and> x \<noteq> v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> last ` l2_neq_v
[PROOF STEP]
obtain ps where "length ps = 2"  "adj_path v ps" "last ps=x" "last ps\<noteq>v"
[PROOF STATE]
proof (prove)
using this:
x \<in> last ` l2_neq_v

goal (1 subgoal):
 1. (\<And>ps. \<lbrakk>length ps = 2; adj_path v ps; last ps = x; last ps \<noteq> v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using l2_neq_v
[PROOF STATE]
proof (prove)
using this:
x \<in> last ` l2_neq_v
l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v}

goal (1 subgoal):
 1. (\<And>ps. \<lbrakk>length ps = 2; adj_path v ps; last ps = x; last ps \<noteq> v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length ps = 2
adj_path v ps
last ps = x
last ps \<noteq> v

goal (1 subgoal):
 1. \<And>x. x \<in> last ` l2_neq_v \<Longrightarrow> x \<in> V \<and> x \<noteq> v
[PROOF STEP]
hence "(last ps)\<in>V"
[PROOF STATE]
proof (prove)
using this:
length ps = 2
adj_path v ps
last ps = x
last ps \<noteq> v

goal (1 subgoal):
 1. last ps \<in> V
[PROOF STEP]
by (metis (full_types) adj_path_V last_in_set length_0_conv rev_subsetD
                  zero_neq_numeral)
[PROOF STATE]
proof (state)
this:
last ps \<in> V

goal (1 subgoal):
 1. \<And>x. x \<in> last ` l2_neq_v \<Longrightarrow> x \<in> V \<and> x \<noteq> v
[PROOF STEP]
thus " x \<in> V \<and> x \<noteq> v"
[PROOF STATE]
proof (prove)
using this:
last ps \<in> V

goal (1 subgoal):
 1. x \<in> V \<and> x \<noteq> v
[PROOF STEP]
using \<open>last ps=x\<close> \<open>last ps\<noteq>v\<close>
[PROOF STATE]
proof (prove)
using this:
last ps \<in> V
last ps = x
last ps \<noteq> v

goal (1 subgoal):
 1. x \<in> V \<and> x \<noteq> v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> V \<and> x \<noteq> v

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> last ` l2_neq_v \<Longrightarrow> ?x \<in> {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?x \<in> last ` l2_neq_v \<Longrightarrow> ?x \<in> {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
have "\<And>x. x\<in>{n. n\<in>V \<and> n\<noteq>v} \<Longrightarrow> x\<in> last` l2_neq_v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
assume x:"x \<in> {n \<in> V. n \<noteq> v}"
[PROOF STATE]
proof (state)
this:
x \<in> {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {n \<in> V. n \<noteq> v}
[PROOF STEP]
obtain y where "adjacent v y" "adjacent x y"
[PROOF STATE]
proof (prove)
using this:
x \<in> {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>adjacent v y; adjacent x y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using friend_assm[of v x] \<open>v\<in>V\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {n \<in> V. n \<noteq> v}
\<lbrakk>v \<in> V; x \<in> V; v \<noteq> x\<rbrakk> \<Longrightarrow> \<exists>!n. adjacent v n \<and> adjacent x n
v \<in> V

goal (1 subgoal):
 1. (\<And>y. \<lbrakk>adjacent v y; adjacent x y\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
adjacent v y
adjacent x y

goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
hence "adj_path v [y,x]"
[PROOF STATE]
proof (prove)
using this:
adjacent v y
adjacent x y

goal (1 subgoal):
 1. adj_path v [y, x]
[PROOF STEP]
using adjacent_sym[of x y]
[PROOF STATE]
proof (prove)
using this:
adjacent v y
adjacent x y
adjacent x y = adjacent y x

goal (1 subgoal):
 1. adj_path v [y, x]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
adj_path v [y, x]

goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
hence "[y,x]\<in>l2_neq_v"
[PROOF STATE]
proof (prove)
using this:
adj_path v [y, x]

goal (1 subgoal):
 1. [y, x] \<in> l2_neq_v
[PROOF STEP]
using l2_neq_v x
[PROOF STATE]
proof (prove)
using this:
adj_path v [y, x]
l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v}
x \<in> {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. [y, x] \<in> l2_neq_v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[y, x] \<in> l2_neq_v

goal (1 subgoal):
 1. \<And>x. x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> x \<in> last ` l2_neq_v
[PROOF STEP]
thus "x\<in> last` l2_neq_v"
[PROOF STATE]
proof (prove)
using this:
[y, x] \<in> l2_neq_v

goal (1 subgoal):
 1. x \<in> last ` l2_neq_v
[PROOF STEP]
by (metis imageI last.simps not_Cons_self2)
[PROOF STATE]
proof (state)
this:
x \<in> last ` l2_neq_v

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> ?x \<in> last ` l2_neq_v

goal (1 subgoal):
 1. last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?x \<in> last ` l2_neq_v \<Longrightarrow> ?x \<in> {n \<in> V. n \<noteq> v}
?x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> ?x \<in> last ` l2_neq_v
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
?x \<in> last ` l2_neq_v \<Longrightarrow> ?x \<in> {n \<in> V. n \<noteq> v}
?x \<in> {n \<in> V. n \<noteq> v} \<Longrightarrow> ?x \<in> last ` l2_neq_v

goal (1 subgoal):
 1. last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
last ` l2_neq_v = {n \<in> V. n \<noteq> v}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
last ` l2_neq_v = {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
last ` l2_neq_v = {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}
[PROOF STEP]
have "inj_on last l2_neq_v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on last l2_neq_v
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>l2_neq_v. \<forall>y\<in>l2_neq_v. last x = last y \<longrightarrow> x = y
[PROOF STEP]
proof (rule,rule,rule)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume "x \<in> l2_neq_v"  "y \<in> l2_neq_v"  "last x = last y"
[PROOF STATE]
proof (state)
this:
x \<in> l2_neq_v
y \<in> l2_neq_v
last x = last y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "length x=2" and "adj_path v x" and "last x\<noteq>v" and "length y=2" and "adj_path v y"
              and "last y\<noteq>v"
[PROOF STATE]
proof (prove)
using this:
x \<in> l2_neq_v
y \<in> l2_neq_v
last x = last y

goal (1 subgoal):
 1. (length x = 2 &&& adj_path v x &&& last x \<noteq> v) &&& length y = 2 &&& adj_path v y &&& last y \<noteq> v
[PROOF STEP]
using l2_neq_v
[PROOF STATE]
proof (prove)
using this:
x \<in> l2_neq_v
y \<in> l2_neq_v
last x = last y
l2_neq_v = {ps. length ps = 2 \<and> adj_path v ps \<and> last ps \<noteq> v}

goal (1 subgoal):
 1. (length x = 2 &&& adj_path v x &&& last x \<noteq> v) &&& length y = 2 &&& adj_path v y &&& last y \<noteq> v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length x = 2
adj_path v x
last x \<noteq> v
length y = 2
adj_path v y
last y \<noteq> v

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
obtain x1 x2 y1 y2 where x:"x=[x1,x2]" and y:"y=[y1,y2]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
fix l
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
assume "length l=2"
[PROOF STATE]
proof (state)
this:
length l = 2

goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain h1 t where "l=h1#t" and "length t=1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>h1 t. \<lbrakk>l = h1 # t; length t = 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>length l=2\<close> Suc_length_conv[of 1 l]
[PROOF STATE]
proof (prove)
using this:
length l = 2
(Suc 1 = length l) = (\<exists>y ys. l = y # ys \<and> length ys = 1)

goal (1 subgoal):
 1. (\<And>h1 t. \<lbrakk>l = h1 # t; length t = 1\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
l = h1 # t
length t = 1

goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
l = h1 # t
length t = 1
[PROOF STEP]
obtain h2 where "t=[h2]"
[PROOF STATE]
proof (prove)
using this:
l = h1 # t
length t = 1

goal (1 subgoal):
 1. (\<And>h2. t = [h2] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Suc_length_conv[of 0 t]
[PROOF STATE]
proof (prove)
using this:
l = h1 # t
length t = 1
(Suc 0 = length t) = (\<exists>y ys. t = y # ys \<and> length ys = 0)

goal (1 subgoal):
 1. (\<And>h2. t = [h2] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
t = [h2]

goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "\<exists>h1 h2. l=[h1,h2]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>h1 h2. l = [h1, h2]
[PROOF STEP]
using \<open>l=h1#t\<close> \<open>t=[h2]\<close>
[PROOF STATE]
proof (prove)
using this:
l = h1 # t
t = [h2]

goal (1 subgoal):
 1. \<exists>h1 h2. l = [h1, h2]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>h1 h2. l = [h1, h2]

goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
length ?l2 = 2 \<Longrightarrow> \<exists>h1 h2. ?l2 = [h1, h2]

goal (1 subgoal):
 1. (\<And>x1 x2 y1 y2. \<lbrakk>x = [x1, x2]; y = [y1, y2]\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
length ?l2 = 2 \<Longrightarrow> \<exists>h1 h2. ?l2 = [h1, h2]

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that \<open>length x=2\<close> \<open>length y=2\<close>
[PROOF STATE]
proof (prove)
using this:
length ?l2 = 2 \<Longrightarrow> \<exists>h1 h2. ?l2 = [h1, h2]
\<lbrakk>x = [?x1.0, ?x2.0]; y = [?y1.0, ?y2.0]\<rbrakk> \<Longrightarrow> thesis
length x = 2
length y = 2

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x = [x1, x2]
y = [y1, y2]

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "x2\<noteq>v" and "y2\<noteq>v"
[PROOF STATE]
proof (prove)
using this:
x = [x1, x2]
y = [y1, y2]

goal (1 subgoal):
 1. x2 \<noteq> v &&& y2 \<noteq> v
[PROOF STEP]
using \<open>last x\<noteq>v\<close> \<open>last y\<noteq>v\<close>
[PROOF STATE]
proof (prove)
using this:
x = [x1, x2]
y = [y1, y2]
last x \<noteq> v
last y \<noteq> v

goal (1 subgoal):
 1. x2 \<noteq> v &&& y2 \<noteq> v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x2 \<noteq> v
y2 \<noteq> v

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x2 \<noteq> v
y2 \<noteq> v

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "adjacent v x1" and "adjacent x2 x1" and "x2\<in>V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. adjacent v x1 &&& adjacent x2 x1 &&& x2 \<in> V
[PROOF STEP]
using \<open>adj_path v x\<close> x adjacent_sym
[PROOF STATE]
proof (prove)
using this:
adj_path v x
x = [x1, x2]
adjacent ?v ?v' = adjacent ?v' ?v

goal (1 subgoal):
 1. adjacent v x1 &&& adjacent x2 x1 &&& x2 \<in> V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
adjacent v x1
adjacent x2 x1
x2 \<in> V

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
adjacent v x1
adjacent x2 x1
x2 \<in> V

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "adjacent v y1" and "adjacent y2 y1" and "y2\<in>V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. adjacent v y1 &&& adjacent y2 y1 &&& y2 \<in> V
[PROOF STEP]
using \<open>adj_path v y\<close> y adjacent_sym
[PROOF STATE]
proof (prove)
using this:
adj_path v y
y = [y1, y2]
adjacent ?v ?v' = adjacent ?v' ?v

goal (1 subgoal):
 1. adjacent v y1 &&& adjacent y2 y1 &&& y2 \<in> V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
adjacent v y1
adjacent y2 y1
y2 \<in> V

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x2 \<noteq> v
y2 \<noteq> v
adjacent v x1
adjacent x2 x1
x2 \<in> V
adjacent v y1
adjacent y2 y1
y2 \<in> V
[PROOF STEP]
have "x1=y1"
[PROOF STATE]
proof (prove)
using this:
x2 \<noteq> v
y2 \<noteq> v
adjacent v x1
adjacent x2 x1
x2 \<in> V
adjacent v y1
adjacent y2 y1
y2 \<in> V

goal (1 subgoal):
 1. x1 = y1
[PROOF STEP]
using friend_assm \<open>v\<in>V\<close>
[PROOF STATE]
proof (prove)
using this:
x2 \<noteq> v
y2 \<noteq> v
adjacent v x1
adjacent x2 x1
x2 \<in> V
adjacent v y1
adjacent y2 y1
y2 \<in> V
\<lbrakk>?v \<in> V; ?u \<in> V; ?v \<noteq> ?u\<rbrakk> \<Longrightarrow> \<exists>!n. adjacent ?v n \<and> adjacent ?u n
v \<in> V

goal (1 subgoal):
 1. x1 = y1
[PROOF STEP]
by (metis \<open>last x = last y\<close> last_ConsL last_ConsR not_Cons_self2 x y)
[PROOF STATE]
proof (state)
this:
x1 = y1

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x \<in> l2_neq_v; y \<in> l2_neq_v; last x = last y\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
thus "x=y"
[PROOF STATE]
proof (prove)
using this:
x1 = y1

goal (1 subgoal):
 1. x = y
[PROOF STEP]
using x y \<open>last x = last y\<close>
[PROOF STATE]
proof (prove)
using this:
x1 = y1
x = [x1, x2]
y = [y1, y2]
last x = last y

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

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

goal (1 subgoal):
 1. bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
last ` l2_neq_v = {n \<in> V. n \<noteq> v}
inj_on last l2_neq_v
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
last ` l2_neq_v = {n \<in> V. n \<noteq> v}
inj_on last l2_neq_v

goal (1 subgoal):
 1. bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
using this:
last ` l2_neq_v = {n \<in> V. n \<noteq> v}
inj_on last l2_neq_v

goal (1 subgoal):
 1. inj_on last l2_neq_v \<and> last ` l2_neq_v = {n \<in> V. n \<noteq> v}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
hence "card l2_neq_v = card {n. n\<in>V \<and> n\<noteq>v}"
[PROOF STATE]
proof (prove)
using this:
bij_betw last l2_neq_v {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. card l2_neq_v = card {n \<in> V. n \<noteq> v}
[PROOF STEP]
by (metis bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card l2_neq_v = card {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card l2_neq_v = k * k - k
card l2_neq_v = card {n \<in> V. n \<noteq> v}
[PROOF STEP]
have "card {n. n\<in>V \<and> n\<noteq>v}=k*k-k"
[PROOF STATE]
proof (prove)
using this:
card l2_neq_v = k * k - k
card l2_neq_v = card {n \<in> V. n \<noteq> v}

goal (1 subgoal):
 1. card {n \<in> V. n \<noteq> v} = k * k - k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card {n \<in> V. n \<noteq> v} = k * k - k

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card {n \<in> V. n \<noteq> v} = k * k - k

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
have "card V = card {n. n\<in>V\<and>n\<noteq>v} + card {v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
have "V={n. n\<in>V \<and> n\<noteq>v} \<union> {v}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. V = {n \<in> V. n \<noteq> v} \<union> {v}
[PROOF STEP]
using \<open>v\<in>V\<close>
[PROOF STATE]
proof (prove)
using this:
v \<in> V

goal (1 subgoal):
 1. V = {n \<in> V. n \<noteq> v} \<union> {v}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
V = {n \<in> V. n \<noteq> v} \<union> {v}

goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
V = {n \<in> V. n \<noteq> v} \<union> {v}

goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
have "{n. n\<in>V \<and> n\<noteq>v} \<inter> {v}={}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {n \<in> V. n \<noteq> v} \<inter> {v} = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{n \<in> V. n \<noteq> v} \<inter> {v} = {}

goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
V = {n \<in> V. n \<noteq> v} \<union> {v}
{n \<in> V. n \<noteq> v} \<inter> {v} = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
V = {n \<in> V. n \<noteq> v} \<union> {v}
{n \<in> V. n \<noteq> v} \<inter> {v} = {}

goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
using \<open>finite V\<close> card_Un_disjoint[of "{n \<in> V. n \<noteq> v}" "{v}"] finite_Un
[PROOF STATE]
proof (prove)
using this:
V = {n \<in> V. n \<noteq> v} \<union> {v}
{n \<in> V. n \<noteq> v} \<inter> {v} = {}
finite V
\<lbrakk>finite {n \<in> V. n \<noteq> v}; finite {v}; {n \<in> V. n \<noteq> v} \<inter> {v} = {}\<rbrakk> \<Longrightarrow> card ({n \<in> V. n \<noteq> v} \<union> {v}) = card {n \<in> V. n \<noteq> v} + card {v}
finite (?F \<union> ?G) = (finite ?F \<and> finite ?G)

goal (1 subgoal):
 1. card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card V = card {n \<in> V. n \<noteq> v} + card {v}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card V = card {n \<in> V. n \<noteq> v} + card {v}

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card {n \<in> V. n \<noteq> v} = k * k - k
card V = card {n \<in> V. n \<noteq> v} + card {v}
[PROOF STEP]
show "card V = k*k-k+1"
[PROOF STATE]
proof (prove)
using this:
card {n \<in> V. n \<noteq> v} = k * k - k
card V = card {n \<in> V. n \<noteq> v} + card {v}

goal (1 subgoal):
 1. card V = k * k - k + 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card V = k * k - k + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma index_nth_id:
  "\<lbrakk> distinct xs;  n < length xs \<rbrakk> \<Longrightarrow> index xs (xs ! n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct xs; n < length xs\<rbrakk> \<Longrightarrow> index xs (xs ! n) = n
[PROOF STEP]
by (metis in_set_conv_nth index_less_size_conv nth_eq_iff_index_eq nth_index)


[STATEMENT]
lemma tensor_smult_assoc:
fixes A::"'a::ring tensor"
shows "\<alpha> \<cdot> (\<beta> \<cdot> A) = (\<alpha> * \<beta>) \<cdot> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<alpha> \<cdot> (\<beta> \<cdot> A) = \<alpha> * \<beta> \<cdot> A
[PROOF STEP]
by (rule tensor_lookup_eqI, simp, metis lookup_smult dims_smult mult.assoc)


[STATEMENT]
lemma list_RECURSION:
 "\<forall>nil' cons'. \<exists>fn::'A list \<Rightarrow> 'Z. fn [] = nil' \<and> (\<forall>(a0::'A) a1::'A list. fn (a0 # a1) = cons' a0 a1 (fn a1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>nil' cons'. \<exists>fn. fn [] = nil' \<and> (\<forall>a0 a1. fn (a0 # a1) = cons' a0 a1 (fn a1))
[PROOF STEP]
by (intro allI, rule_tac x="rec_list nil' cons'" in exI) auto


[STATEMENT]
lemma mpoly_to_poly_map_mpoly_hom: "mpoly_to_poly x (map_mpoly hom p) = map_poly hom (mpoly_to_poly x p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mpoly_to_poly x (map_mpoly hom p) = map_poly hom (mpoly_to_poly x p)
[PROOF STEP]
by (rule poly_eqI, unfold coeff_mpoly_to_poly coeff_map_poly_hom, subst coeff_map_mpoly', auto)


[STATEMENT]
lemma (in vec_space) lincomb_eq_mat_mult:
assumes "A \<in> carrier_mat n nc"
assumes "v \<in> carrier_vec nc"
assumes "distinct (cols A)"
shows "lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = (A *\<^sub>v v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v
[PROOF STEP]
have "\<And>i. i < nc \<Longrightarrow> find_first (col A i) (cols A) = i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < nc \<Longrightarrow> find_first (col A i) (cols A) = i
[PROOF STEP]
using assms(1) assms(3) find_first_unique
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n nc
distinct (cols A)
\<lbrakk>distinct ?xs; ?i < length ?xs\<rbrakk> \<Longrightarrow> find_first (?xs ! ?i) ?xs = ?i

goal (1 subgoal):
 1. \<And>i. i < nc \<Longrightarrow> find_first (col A i) (cols A) = i
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?i1 < nc \<Longrightarrow> find_first (col A ?i1) (cols A) = ?i1

goal (1 subgoal):
 1. lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?i1 < nc \<Longrightarrow> find_first (col A ?i1) (cols A) = ?i1
[PROOF STEP]
have "vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v"
[PROOF STATE]
proof (prove)
using this:
?i1 < nc \<Longrightarrow> find_first (col A ?i1) (cols A) = ?i1

goal (1 subgoal):
 1. vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
?i1 < nc \<Longrightarrow> find_first (col A ?i1) (cols A) = ?i1
v \<in> carrier_vec nc

goal (1 subgoal):
 1. vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v

goal (1 subgoal):
 1. lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v

goal (1 subgoal):
 1. lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v
[PROOF STEP]
using mat_mult_eq_lincomb[where a = "(\<lambda>a. v $ find_first a (cols A))", OF assms(1) assms(3)]
[PROOF STATE]
proof (prove)
using this:
vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = v
A *\<^sub>v vec nc (\<lambda>i. v $ find_first (col A i) (cols A)) = lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A))

goal (1 subgoal):
 1. lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lincomb (\<lambda>a. v $ find_first a (cols A)) (set (cols A)) = A *\<^sub>v v

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nth_prime_eq_iff [simp]: "nth_prime m = nth_prime n \<longleftrightarrow> m = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (nth_prime m = nth_prime n) = (m = n)
[PROOF STEP]
using strict_mono_eq[OF strict_mono_nth_prime]
[PROOF STATE]
proof (prove)
using this:
(nth_prime ?x = nth_prime ?y) = (?x = ?y)

goal (1 subgoal):
 1. (nth_prime m = nth_prime n) = (m = n)
[PROOF STEP]
by blast


[STATEMENT]
lemma diag_block_mat_mult:
  assumes "length Al = length Bl"
  and "\<forall>i < length Al. dim_col (Al!i) = dim_row (Bl!i)"
shows "diag_block_mat Al * (diag_block_mat Bl) =
  (diag_block_mat (map2 (*) Al Bl))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
length Al = length Bl
\<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl)
[PROOF STEP]
proof (induct Al arbitrary: Bl)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>Bl. \<lbrakk>length [] = length Bl; \<forall>i<length []. dim_col ([] ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat [] * diag_block_mat Bl = diag_block_mat (map2 (*) [] Bl)
 2. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
length [] = length Bl
\<forall>i<length []. dim_col ([] ! i) = dim_row (Bl ! i)

goal (2 subgoals):
 1. \<And>Bl. \<lbrakk>length [] = length Bl; \<forall>i<length []. dim_col ([] ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat [] * diag_block_mat Bl = diag_block_mat (map2 (*) [] Bl)
 2. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length [] = length Bl
\<forall>i<length []. dim_col ([] ! i) = dim_row (Bl ! i)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
length [] = length Bl
\<forall>i<length []. dim_col ([] ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. diag_block_mat [] * diag_block_mat Bl = diag_block_mat (map2 (*) [] Bl)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
diag_block_mat [] * diag_block_mat Bl = diag_block_mat (map2 (*) [] Bl)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
case (Cons a Al)
[PROOF STATE]
proof (state)
this:
\<lbrakk>length Al = length ?Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (?Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat ?Bl = diag_block_mat (map2 (*) Al ?Bl)
length (a # Al) = length Bl
\<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
define A where "A = diag_block_mat Al"
[PROOF STATE]
proof (state)
this:
A = diag_block_mat Al

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
define B where "B = diag_block_mat (tl Bl)"
[PROOF STATE]
proof (state)
this:
B = diag_block_mat (tl Bl)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "0 < length Bl"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < length Bl
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length Al = length ?Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (?Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat ?Bl = diag_block_mat (map2 (*) Al ?Bl)
length (a # Al) = length Bl
\<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. 0 < length Bl
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < length Bl

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
hence "Bl = hd Bl # (tl Bl)"
[PROOF STATE]
proof (prove)
using this:
0 < length Bl

goal (1 subgoal):
 1. Bl = hd Bl # tl Bl
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Bl = hd Bl # tl Bl

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "length (tl Bl) = length Al"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (tl Bl) = length Al
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length Al = length ?Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (?Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat ?Bl = diag_block_mat (map2 (*) Al ?Bl)
length (a # Al) = length Bl
\<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. length (tl Bl) = length Al
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (tl Bl) = length Al

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have dim: "\<forall>i<length Al. dim_col (Al ! i) = dim_row (tl Bl ! i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length Al. dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
proof (intro allI impI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
assume "i < length Al"
[PROOF STATE]
proof (state)
this:
i < length Al

goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
hence "dim_col (Al ! i) = dim_col ((a#Al)!(Suc i))"
[PROOF STATE]
proof (prove)
using this:
i < length Al

goal (1 subgoal):
 1. dim_col (Al ! i) = dim_col ((a # Al) ! Suc i)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dim_col (Al ! i) = dim_col ((a # Al) ! Suc i)

goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_col (Al ! i) = dim_col ((a # Al) ! Suc i)

goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
have "... = dim_row (Bl!(Suc i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col ((a # Al) ! Suc i) = dim_row (Bl ! Suc i)
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length Al = length ?Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (?Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat ?Bl = diag_block_mat (map2 (*) Al ?Bl)
length (a # Al) = length Bl
\<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. dim_col ((a # Al) ! Suc i) = dim_row (Bl ! Suc i)
[PROOF STEP]
by (metis Suc_lessI \<open>i < length Al\<close> length_Cons less_Suc_eq)
[PROOF STATE]
proof (state)
this:
dim_col ((a # Al) ! Suc i) = dim_row (Bl ! Suc i)

goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_col ((a # Al) ! Suc i) = dim_row (Bl ! Suc i)

goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
have "... = dim_row (tl Bl!i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (Bl ! Suc i) = dim_row (tl Bl ! i)
[PROOF STEP]
by (metis \<open>Bl = hd Bl # tl Bl\<close> nth_Cons_Suc)
[PROOF STATE]
proof (state)
this:
dim_row (Bl ! Suc i) = dim_row (tl Bl ! i)

goal (1 subgoal):
 1. \<And>i. i < length Al \<Longrightarrow> dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
show "dim_col (Al ! i) = dim_row (tl Bl!i)"
[PROOF STATE]
proof (prove)
using this:
dim_col (Al ! i) = dim_row (tl Bl ! i)

goal (1 subgoal):
 1. dim_col (Al ! i) = dim_row (tl Bl ! i)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_col (Al ! i) = dim_row (tl Bl ! i)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>i<length Al. dim_col (Al ! i) = dim_row (tl Bl ! i)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
define C where "C = map2 (*) (a # Al) Bl"
[PROOF STATE]
proof (state)
this:
C = map2 (*) (a # Al) Bl

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "hd C = a * hd Bl"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd C = a * hd Bl
[PROOF STEP]
using \<open>Bl = hd Bl # tl Bl\<close>
[PROOF STATE]
proof (prove)
using this:
Bl = hd Bl # tl Bl

goal (1 subgoal):
 1. hd C = a * hd Bl
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
using this:
Bl = hd Bl # tl Bl

goal (1 subgoal):
 1. hd (map2 (*) (a # Al) Bl) = a * hd Bl
[PROOF STEP]
by (metis list.map(2) list.sel(1) prod.simps(2) zip_Cons_Cons)
[PROOF STATE]
proof (state)
this:
hd C = a * hd Bl

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "tl C = map2 (*) Al (tl Bl)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tl C = map2 (*) Al (tl Bl)
[PROOF STEP]
by (metis (no_types, lifting) C_def \<open>Bl = hd Bl # tl Bl\<close> list.sel(3)
        map_tl zip_Cons_Cons)
[PROOF STATE]
proof (state)
this:
tl C = map2 (*) Al (tl Bl)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "C = hd C # (tl C)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. C = hd C # tl C
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map2 (*) (a # Al) Bl = hd (map2 (*) (a # Al) Bl) # tl (map2 (*) (a # Al) Bl)
[PROOF STEP]
by (metis Nil_eq_zip_iff Nil_is_map_conv \<open>Bl = hd Bl # tl Bl\<close>
        list.exhaust_sel list.simps(3))
[PROOF STATE]
proof (state)
this:
C = hd C # tl C

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "dim_row B = sum_list (map dim_row (tl Bl))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row B = sum_list (map dim_row (tl Bl))
[PROOF STEP]
unfolding B_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (diag_block_mat (tl Bl)) = sum_list (map dim_row (tl Bl))
[PROOF STEP]
by (simp add: dim_diag_block_mat(1))
[PROOF STATE]
proof (state)
this:
dim_row B = sum_list (map dim_row (tl Bl))

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dim_row B = sum_list (map dim_row (tl Bl))

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "... = sum_list (map dim_col Al)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map dim_row (tl Bl)) = sum_list (map dim_col Al)
[PROOF STEP]
proof (rule sum_list_cong)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. length (map dim_row (tl Bl)) = length (map dim_col Al)
 2. \<forall>i<length (map dim_row (tl Bl)). map dim_row (tl Bl) ! i = map dim_col Al ! i
[PROOF STEP]
show "length (map dim_row (tl Bl)) = length (map dim_col Al)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map dim_row (tl Bl)) = length (map dim_col Al)
[PROOF STEP]
using  \<open>length (tl Bl) = length Al\<close>
[PROOF STATE]
proof (prove)
using this:
length (tl Bl) = length Al

goal (1 subgoal):
 1. length (map dim_row (tl Bl)) = length (map dim_col Al)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (map dim_row (tl Bl)) = length (map dim_col Al)

goal (1 subgoal):
 1. \<forall>i<length (map dim_row (tl Bl)). map dim_row (tl Bl) ! i = map dim_col Al ! i
[PROOF STEP]
show "\<forall>i<length (map dim_row (tl Bl)).
      map dim_row (tl Bl) ! i = map dim_col Al ! i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<length (map dim_row (tl Bl)). map dim_row (tl Bl) ! i = map dim_col Al ! i
[PROOF STEP]
by (metis \<open>length (tl Bl) = length Al\<close> dim length_map nth_map)
[PROOF STATE]
proof (state)
this:
\<forall>i<length (map dim_row (tl Bl)). map dim_row (tl Bl) ! i = map dim_col Al ! i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sum_list (map dim_row (tl Bl)) = sum_list (map dim_col Al)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum_list (map dim_row (tl Bl)) = sum_list (map dim_col Al)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "... = dim_col A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map dim_col Al) = dim_col A
[PROOF STEP]
unfolding A_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map dim_col Al) = dim_col (diag_block_mat Al)
[PROOF STEP]
by (simp add: dim_diag_block_mat(2))
[PROOF STATE]
proof (state)
this:
sum_list (map dim_col Al) = dim_col A

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dim_row B = dim_col A
[PROOF STEP]
have ba: "dim_row B = dim_col A"
[PROOF STATE]
proof (prove)
using this:
dim_row B = dim_col A

goal (1 subgoal):
 1. dim_row B = dim_col A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dim_row B = dim_col A

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "diag_block_mat (a#Al) * (diag_block_mat Bl) =
    four_block_diag a A * (four_block_diag (hd Bl) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diag_block_mat (a # Al) * diag_block_mat Bl = four_block_diag a A * four_block_diag (hd Bl) B
[PROOF STEP]
using diag_block_mat.simps(2) \<open>Bl = hd Bl # (tl Bl)\<close>
[PROOF STATE]
proof (prove)
using this:
diag_block_mat (?A # ?As) = Let (diag_block_mat ?As) (four_block_diag ?A)
Bl = hd Bl # tl Bl

goal (1 subgoal):
 1. diag_block_mat (a # Al) * diag_block_mat Bl = four_block_diag a A * four_block_diag (hd Bl) B
[PROOF STEP]
unfolding Let_def A_def B_def
[PROOF STATE]
proof (prove)
using this:
diag_block_mat (?A # ?As) = four_block_diag ?A (diag_block_mat ?As)
Bl = hd Bl # tl Bl

goal (1 subgoal):
 1. diag_block_mat (a # Al) * diag_block_mat Bl = four_block_diag a (diag_block_mat Al) * four_block_diag (hd Bl) (diag_block_mat (tl Bl))
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
diag_block_mat (a # Al) * diag_block_mat Bl = four_block_diag a A * four_block_diag (hd Bl) B

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
diag_block_mat (a # Al) * diag_block_mat Bl = four_block_diag a A * four_block_diag (hd Bl) B

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "... = four_block_diag (a * hd Bl) (A * B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. four_block_diag a A * four_block_diag (hd Bl) B = four_block_diag (a * hd Bl) (A * B)
[PROOF STEP]
proof (rule mult_four_block_diag)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. a \<in> carrier_mat ?nr1.0 ?n1.0
 2. A \<in> carrier_mat ?nr2.0 ?n2.0
 3. hd Bl \<in> carrier_mat ?n1.0 ?nc1.0
 4. B \<in> carrier_mat ?n2.0 ?nc2.0
[PROOF STEP]
show "a\<in> carrier_mat (dim_row a) (dim_col a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> carrier_mat (dim_row a) (dim_col a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a \<in> carrier_mat (dim_row a) (dim_col a)

goal (3 subgoals):
 1. A \<in> carrier_mat ?nr2.0 ?n2.0
 2. hd Bl \<in> carrier_mat (dim_col a) ?nc1.0
 3. B \<in> carrier_mat ?n2.0 ?nc2.0
[PROOF STEP]
show "hd Bl \<in> carrier_mat (dim_col a) (dim_col (hd Bl))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hd Bl \<in> carrier_mat (dim_col a) (dim_col (hd Bl))
[PROOF STEP]
using Cons
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>length Al = length ?Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (?Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat ?Bl = diag_block_mat (map2 (*) Al ?Bl)
length (a # Al) = length Bl
\<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)

goal (1 subgoal):
 1. hd Bl \<in> carrier_mat (dim_col a) (dim_col (hd Bl))
[PROOF STEP]
by (metis \<open>0 < length Bl\<close> \<open>Bl = hd Bl # tl Bl\<close> carrier_mat_triv nth_Cons_0)
[PROOF STATE]
proof (state)
this:
hd Bl \<in> carrier_mat (dim_col a) (dim_col (hd Bl))

goal (2 subgoals):
 1. A \<in> carrier_mat ?nr2.0 ?n2.0
 2. B \<in> carrier_mat ?n2.0 ?nc2.0
[PROOF STEP]
show "A \<in> carrier_mat (dim_row A) (dim_col A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<in> carrier_mat (dim_row A) (dim_col A)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A \<in> carrier_mat (dim_row A) (dim_col A)

goal (1 subgoal):
 1. B \<in> carrier_mat (dim_col A) ?nc2.0
[PROOF STEP]
show " B \<in> carrier_mat (dim_col A) (dim_col B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<in> carrier_mat (dim_col A) (dim_col B)
[PROOF STEP]
using ba
[PROOF STATE]
proof (prove)
using this:
dim_row B = dim_col A

goal (1 subgoal):
 1. B \<in> carrier_mat (dim_col A) (dim_col B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B \<in> carrier_mat (dim_col A) (dim_col B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
four_block_diag a A * four_block_diag (hd Bl) B = four_block_diag (a * hd Bl) (A * B)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
four_block_diag a A * four_block_diag (hd Bl) B = four_block_diag (a * hd Bl) (A * B)

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "... = four_block_diag (hd C) (diag_block_mat (tl C))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. four_block_diag (a * hd Bl) (A * B) = four_block_diag (hd C) (diag_block_mat (tl C))
[PROOF STEP]
unfolding A_def B_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. four_block_diag (a * hd Bl) (diag_block_mat Al * diag_block_mat (tl Bl)) = four_block_diag (hd C) (diag_block_mat (tl C))
[PROOF STEP]
using C_def \<open>hd C = a * hd Bl\<close> \<open>length (tl Bl) = length Al\<close>
      \<open>tl C = map2 (*) Al (tl Bl)\<close> dim local.Cons(1)
[PROOF STATE]
proof (prove)
using this:
C = map2 (*) (a # Al) Bl
hd C = a * hd Bl
length (tl Bl) = length Al
tl C = map2 (*) Al (tl Bl)
\<forall>i<length Al. dim_col (Al ! i) = dim_row (tl Bl ! i)
\<lbrakk>length Al = length ?Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (?Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat ?Bl = diag_block_mat (map2 (*) Al ?Bl)

goal (1 subgoal):
 1. four_block_diag (a * hd Bl) (diag_block_mat Al * diag_block_mat (tl Bl)) = four_block_diag (hd C) (diag_block_mat (tl C))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
four_block_diag (a * hd Bl) (A * B) = four_block_diag (hd C) (diag_block_mat (tl C))

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
four_block_diag (a * hd Bl) (A * B) = four_block_diag (hd C) (diag_block_mat (tl C))

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
have "... = diag_block_mat C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. four_block_diag (hd C) (diag_block_mat (tl C)) = diag_block_mat C
[PROOF STEP]
using \<open>C = hd C#(tl C)\<close> diag_block_mat.simps(2)
[PROOF STATE]
proof (prove)
using this:
C = hd C # tl C
diag_block_mat (?A # ?As) = Let (diag_block_mat ?As) (four_block_diag ?A)

goal (1 subgoal):
 1. four_block_diag (hd C) (diag_block_mat (tl C)) = diag_block_mat C
[PROOF STEP]
unfolding Let_def
[PROOF STATE]
proof (prove)
using this:
C = hd C # tl C
diag_block_mat (?A # ?As) = four_block_diag ?A (diag_block_mat ?As)

goal (1 subgoal):
 1. four_block_diag (hd C) (diag_block_mat (tl C)) = diag_block_mat C
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
four_block_diag (hd C) (diag_block_mat (tl C)) = diag_block_mat C

goal (1 subgoal):
 1. \<And>a Al Bl. \<lbrakk>\<And>Bl. \<lbrakk>length Al = length Bl; \<forall>i<length Al. dim_col (Al ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat Al * diag_block_mat Bl = diag_block_mat (map2 (*) Al Bl); length (a # Al) = length Bl; \<forall>i<length (a # Al). dim_col ((a # Al) ! i) = dim_row (Bl ! i)\<rbrakk> \<Longrightarrow> diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat C
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat C

goal (1 subgoal):
 1. diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
unfolding C_def
[PROOF STATE]
proof (prove)
using this:
diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)

goal (1 subgoal):
 1. diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diag_block_mat (a # Al) * diag_block_mat Bl = diag_block_mat (map2 (*) (a # Al) Bl)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma algebraic_int_norm_complex [intro]:
  assumes "algebraic_int (z :: complex)"
  shows   "algebraic_int (norm z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int (cmod z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. algebraic_int (cmod z)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
algebraic_int z
[PROOF STEP]
have "algebraic_int (z * cnj z)"
[PROOF STATE]
proof (prove)
using this:
algebraic_int z

goal (1 subgoal):
 1. algebraic_int (z * cnj z)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
algebraic_int (z * cnj z)

goal (1 subgoal):
 1. algebraic_int (cmod z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
algebraic_int (z * cnj z)

goal (1 subgoal):
 1. algebraic_int (cmod z)
[PROOF STEP]
have "z * cnj z = of_real (norm z ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z * cnj z = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
by (rule complex_norm_square [symmetric])
[PROOF STATE]
proof (state)
this:
z * cnj z = complex_of_real ((cmod z)\<^sup>2)

goal (1 subgoal):
 1. algebraic_int (cmod z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
algebraic_int (complex_of_real ((cmod z)\<^sup>2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
algebraic_int (complex_of_real ((cmod z)\<^sup>2))

goal (1 subgoal):
 1. algebraic_int (cmod z)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
algebraic_int (cmod z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma bottom_pow: "order.bottom (Pow A) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order.bottom (Pow A) = {}
[PROOF STEP]
proof (rule order.bottomI[THEN sym])
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {} \<in> Pow A
 2. \<And>y. y \<in> Pow A \<Longrightarrow> {} \<subseteq> y
[PROOF STEP]
qed auto


[STATEMENT]
lemma affine_hull_3_imp_collinear: "c \<in> affine hull {a,b} \<Longrightarrow> collinear {a,b,c}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<in> affine hull {a, b} \<Longrightarrow> collinear {a, b, c}
[PROOF STEP]
by (metis collinear_2 collinear_affine_hull_collinear hull_redundant insert_commute)


[STATEMENT]
lemma blinfun_to_matrix_scaleR: "blinfun_to_matrix (c *\<^sub>R f) = c *\<^sub>R blinfun_to_matrix f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. blinfun_to_matrix (c *\<^sub>R f) = c *\<^sub>R blinfun_to_matrix f
[PROOF STEP]
by (auto simp: matrix_eq blinfun_to_matrix_mult'' scaleR_matrix_vector_assoc[symmetric]
      blinfun.scaleR_left vector_scalar_mult_def[of c, unfolded scalar_mult_eq_scaleR])


[STATEMENT]
lemma subdivide_lipschitz:
  assumes "\<bar>s - t\<bar> \<le> abs (t1 - t0) / Suc subdivide_count"
  shows "\<bar>s - t\<bar> * L < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>s - t\<bar> * L < 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>s - t\<bar> * L < 1
[PROOF STEP]
from assms L_nonneg
[PROOF STATE]
proof (chain)
picking this:
\<bar>s - t\<bar> \<le> \<bar>t1 - t0\<bar> / real (Suc subdivide_count)
0 \<le> L
[PROOF STEP]
have "\<bar>s - t\<bar> * L \<le> abs (t1 - t0) / Suc subdivide_count * L"
[PROOF STATE]
proof (prove)
using this:
\<bar>s - t\<bar> \<le> \<bar>t1 - t0\<bar> / real (Suc subdivide_count)
0 \<le> L

goal (1 subgoal):
 1. \<bar>s - t\<bar> * L \<le> \<bar>t1 - t0\<bar> / real (Suc subdivide_count) * L
[PROOF STEP]
by (rule mult_right_mono)
[PROOF STATE]
proof (state)
this:
\<bar>s - t\<bar> * L \<le> \<bar>t1 - t0\<bar> / real (Suc subdivide_count) * L

goal (1 subgoal):
 1. \<bar>s - t\<bar> * L < 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>s - t\<bar> * L \<le> \<bar>t1 - t0\<bar> / real (Suc subdivide_count) * L

goal (1 subgoal):
 1. \<bar>s - t\<bar> * L < 1
[PROOF STEP]
have "\<dots> < 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>t1 - t0\<bar> / real (Suc subdivide_count) * L < 1
[PROOF STEP]
using subdivide_count
[PROOF STATE]
proof (prove)
using this:
L * \<bar>t1 - t0\<bar> / real (Suc subdivide_count) < 1

goal (1 subgoal):
 1. \<bar>t1 - t0\<bar> / real (Suc subdivide_count) * L < 1
[PROOF STEP]
by (simp add: ac_simps)
[PROOF STATE]
proof (state)
this:
\<bar>t1 - t0\<bar> / real (Suc subdivide_count) * L < 1

goal (1 subgoal):
 1. \<bar>s - t\<bar> * L < 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>s - t\<bar> * L < 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>s - t\<bar> * L < 1

goal (1 subgoal):
 1. \<bar>s - t\<bar> * L < 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<bar>s - t\<bar> * L < 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in module) finite_lin_dep:
  fixes S
  assumes finS:"finite S" and ld: "lin_dep S" and inC: "S\<subseteq>carrier M"
  shows "\<exists>a v. (a\<in> (S\<rightarrow>carrier R)) \<and> (lincomb a S = \<zero>\<^bsub>M\<^esub>) \<and> (v\<in>S) \<and> (a v\<noteq> \<zero>\<^bsub>R\<^esub>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
from ld
[PROOF STATE]
proof (chain)
picking this:
lin_dep S
[PROOF STEP]
obtain A a v where A: "(A\<subseteq>S \<and> (a\<in> (A\<rightarrow>carrier R)) \<and> (lincomb a A = \<zero>\<^bsub>M\<^esub>) \<and> (v\<in>A) \<and> (a v\<noteq> \<zero>\<^bsub>R\<^esub>))"
[PROOF STATE]
proof (prove)
using this:
lin_dep S

goal (1 subgoal):
 1. (\<And>A a v. A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (unfold lin_dep_def, auto)
[PROOF STATE]
proof (state)
this:
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>

goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
let ?b="\<lambda>w. if w\<in>A then a w else \<zero>\<^bsub>R\<^esub>"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
(*extend the coefficients to be 0 outside of A*)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
from finS inC A
[PROOF STATE]
proof (chain)
picking this:
finite S
S \<subseteq> carrier M
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>
[PROOF STEP]
have if_in: "(\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v else \<zero>) \<odot>\<^bsub>M\<^esub> v) = (\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>))"
[PROOF STATE]
proof (prove)
using this:
finite S
S \<subseteq> carrier M
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>

goal (1 subgoal):
 1. (\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v else \<zero>) \<odot>\<^bsub>M\<^esub> v) = (\<Oplus>\<^bsub>M\<^esub>v\<in>S. if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>)
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<subseteq> carrier M; A \<subseteq> S; a \<in> A \<rightarrow> carrier R; lincomb a A = \<zero>\<^bsub>M\<^esub>; v \<in> A; a v \<noteq> \<zero>\<rbrakk> \<Longrightarrow> (\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v else \<zero>) \<odot>\<^bsub>M\<^esub> v) = (\<Oplus>\<^bsub>M\<^esub>v\<in>S. if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>)
[PROOF STEP]
apply (intro finsum_cong')
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>finite S; S \<subseteq> carrier M; A \<subseteq> S; a \<in> A \<rightarrow> carrier R; lincomb a A = \<zero>\<^bsub>M\<^esub>; v \<in> A; a v \<noteq> \<zero>\<rbrakk> \<Longrightarrow> S = S
 2. \<lbrakk>finite S; S \<subseteq> carrier M; A \<subseteq> S; a \<in> A \<rightarrow> carrier R; lincomb a A = \<zero>\<^bsub>M\<^esub>; v \<in> A; a v \<noteq> \<zero>\<rbrakk> \<Longrightarrow> (\<lambda>v. if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>) \<in> S \<rightarrow> carrier M
 3. \<And>i. \<lbrakk>finite S; S \<subseteq> carrier M; A \<subseteq> S; a \<in> A \<rightarrow> carrier R; lincomb a A = \<zero>\<^bsub>M\<^esub>; v \<in> A; a v \<noteq> \<zero>; i \<in> S\<rbrakk> \<Longrightarrow> (if i \<in> A then a i else \<zero>) \<odot>\<^bsub>M\<^esub> i = (if i \<in> A then a i \<odot>\<^bsub>M\<^esub> i else \<zero>\<^bsub>M\<^esub>)
[PROOF STEP]
by (auto simp add: coeff_in_ring)
[PROOF STATE]
proof (state)
this:
(\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v else \<zero>) \<odot>\<^bsub>M\<^esub> v) = (\<Oplus>\<^bsub>M\<^esub>v\<in>S. if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>)

goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
(*massage the sum*)
[PROOF STATE]
proof (state)
this:
(\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v else \<zero>) \<odot>\<^bsub>M\<^esub> v) = (\<Oplus>\<^bsub>M\<^esub>v\<in>S. if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>)

goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
from finS inC A
[PROOF STATE]
proof (chain)
picking this:
finite S
S \<subseteq> carrier M
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>
[PROOF STEP]
have b: "lincomb ?b S = \<zero>\<^bsub>M\<^esub>"
[PROOF STATE]
proof (prove)
using this:
finite S
S \<subseteq> carrier M
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>

goal (1 subgoal):
 1. lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub>
[PROOF STEP]
apply (unfold lincomb_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<subseteq> carrier M; A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> (\<Oplus>\<^bsub>M\<^esub>v\<in>A. a v \<odot>\<^bsub>M\<^esub> v) = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>\<rbrakk> \<Longrightarrow> (\<Oplus>\<^bsub>M\<^esub>v\<in>S. (if v \<in> A then a v else \<zero>) \<odot>\<^bsub>M\<^esub> v) = \<zero>\<^bsub>M\<^esub>
[PROOF STEP]
apply (subst if_in)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; S \<subseteq> carrier M; A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> (\<Oplus>\<^bsub>M\<^esub>v\<in>A. a v \<odot>\<^bsub>M\<^esub> v) = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>\<rbrakk> \<Longrightarrow> (\<Oplus>\<^bsub>M\<^esub>v\<in>S. if v \<in> A then a v \<odot>\<^bsub>M\<^esub> v else \<zero>\<^bsub>M\<^esub>) = \<zero>\<^bsub>M\<^esub>
[PROOF STEP]
by (subst extend_sum, auto)
[PROOF STATE]
proof (state)
this:
lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub>

goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
from A b
[PROOF STATE]
proof (chain)
picking this:
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>
lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>
lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub>

goal (1 subgoal):
 1. \<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>
[PROOF STEP]
apply (rule_tac x="?b" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>; lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub>\<rbrakk> \<Longrightarrow> \<exists>v. (\<lambda>w. if w \<in> A then a w else \<zero>) \<in> S \<rightarrow> carrier R \<and> lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> (if v \<in> A then a v else \<zero>) \<noteq> \<zero>
[PROOF STEP]
apply (rule_tac x="v" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<subseteq> S \<and> a \<in> A \<rightarrow> carrier R \<and> lincomb a A = \<zero>\<^bsub>M\<^esub> \<and> v \<in> A \<and> a v \<noteq> \<zero>; lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub>\<rbrakk> \<Longrightarrow> (\<lambda>w. if w \<in> A then a w else \<zero>) \<in> S \<rightarrow> carrier R \<and> lincomb (\<lambda>w. if w \<in> A then a w else \<zero>) S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> (if v \<in> A then a v else \<zero>) \<noteq> \<zero>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>a v. a \<in> S \<rightarrow> carrier R \<and> lincomb a S = \<zero>\<^bsub>M\<^esub> \<and> v \<in> S \<and> a v \<noteq> \<zero>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma moebius_dilatation_inverse [simp]:
  assumes "a > 0"
  shows "moebius_inv (moebius_dilatation a) = moebius_dilatation (1/a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. moebius_inv (moebius_dilatation a) = moebius_dilatation (1 / a)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < a

goal (1 subgoal):
 1. moebius_inv (moebius_dilatation a) = moebius_dilatation (1 / a)
[PROOF STEP]
unfolding moebius_dilatation_def
[PROOF STATE]
proof (prove)
using this:
0 < a

goal (1 subgoal):
 1. moebius_inv (moebius_similarity (cor a) 0) = moebius_similarity (cor (1 / a)) 0
[PROOF STEP]
by simp


[STATEMENT]
lemma cong_prime_prod_zero_int:
  "[a * b = 0] (mod p) \<Longrightarrow> prime p \<Longrightarrow> [a = 0] (mod p) \<or> [b = 0] (mod p)"
  for a :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>[a * b = 0] (mod p); prime p\<rbrakk> \<Longrightarrow> [a = 0] (mod p) \<or> [b = 0] (mod p)
[PROOF STEP]
by (simp add: cong_0_iff prime_dvd_mult_iff)


[STATEMENT]
lemma obtuse_per__lta:
  assumes "Obtuse A B C" and
    "D \<noteq> E" and
    "E \<noteq> F" and
    "Per D E F"
  shows "D E F LtA A B C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D E F LtA A B C
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. D E F LtA A B C
[PROOF STEP]
obtain G H I where P1: "Per G H I \<and> G H I LtA A B C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>G H I. Per G H I \<and> G H I LtA A B C \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Obtuse_def assms(1)
[PROOF STATE]
proof (prove)
using this:
Obtuse ?A ?B ?C \<equiv> \<exists>A' B' C'. Per A' B' C' \<and> A' B' C' LtA ?A ?B ?C
Obtuse A B C

goal (1 subgoal):
 1. (\<And>G H I. Per G H I \<and> G H I LtA A B C \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Per G H I \<and> G H I LtA A B C

goal (1 subgoal):
 1. D E F LtA A B C
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Per G H I \<and> G H I LtA A B C
[PROOF STEP]
have "G H I CongA D E F"
[PROOF STATE]
proof (prove)
using this:
Per G H I \<and> G H I LtA A B C

goal (1 subgoal):
 1. G H I CongA D E F
[PROOF STEP]
using assms(2) assms(3) assms(4) l11_16 lta_distincts
[PROOF STATE]
proof (prove)
using this:
Per G H I \<and> G H I LtA A B C
D \<noteq> E
E \<noteq> F
Per D E F
\<lbrakk>Per ?A ?B ?C; ?A \<noteq> ?B; ?C \<noteq> ?B; Per ?A' ?B' ?C'; ?A' \<noteq> ?B'; ?C' \<noteq> ?B'\<rbrakk> \<Longrightarrow> ?A ?B ?C CongA ?A' ?B' ?C'
?A ?B ?C LtA ?D ?E ?F \<Longrightarrow> ?A \<noteq> ?B \<and> ?C \<noteq> ?B \<and> ?D \<noteq> ?E \<and> ?F \<noteq> ?E \<and> ?D \<noteq> ?F

goal (1 subgoal):
 1. G H I CongA D E F
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
G H I CongA D E F

goal (1 subgoal):
 1. D E F LtA A B C
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
G H I CongA D E F

goal (1 subgoal):
 1. D E F LtA A B C
[PROOF STEP]
by (metis P1 Tarski_neutral_dimensionless.l11_51 Tarski_neutral_dimensionless_axioms assms(1) cong_reflexivity conga_preserves_lta obtuse_distincts)
[PROOF STATE]
proof (state)
this:
D E F LtA A B C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ccNeighbors_ccSquare:
  "ccNeighbors x (ccSquare S) = (if x \<in> S then S else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccNeighbors x (S\<^sup>2) = (if x \<in> S then S else {})
[PROOF STEP]
unfolding ccSquare_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccNeighbors x (S G\<times> S) = (if x \<in> S then S else {})
[PROOF STEP]
by (auto simp add: ccNeighbors_ccProd)


[STATEMENT]
lemma idx_ran:
  assumes "distinct xs"
  shows "ran (idx xs) = {..<length xs}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ran (idx xs) = {..<length xs}
[PROOF STEP]
using ran_is_image[where M="idx xs"]
[PROOF STATE]
proof (prove)
using this:
ran (idx xs) = (the \<circ>\<circ> idx) xs ` dom (idx xs)

goal (1 subgoal):
 1. ran (idx xs) = {..<length xs}
[PROOF STEP]
using idx_image_self[OF assms] idx_dom[OF assms]
[PROOF STATE]
proof (prove)
using this:
ran (idx xs) = (the \<circ>\<circ> idx) xs ` dom (idx xs)
(the \<circ>\<circ> idx) xs ` set xs = {..<length xs}
dom (idx xs) = set xs

goal (1 subgoal):
 1. ran (idx xs) = {..<length xs}
[PROOF STEP]
by simp


[STATEMENT]
lemma dghm_cn_cov_comp_ObjMap_vrange:
  assumes "\<GG> : \<BB> \<^sub>D\<^sub>G\<mapsto>\<mapsto>\<^bsub>\<alpha>\<^esub> \<CC>" and "\<FF> : \<AA> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^bsub>\<alpha>\<^esub> \<BB>"
  shows "\<R>\<^sub>\<circ> ((\<GG> \<^sub>D\<^sub>G\<^sub>H\<^sub>M\<circ> \<FF>)\<lparr>ObjMap\<rparr>) \<subseteq>\<^sub>\<circ> \<CC>\<lparr>Obj\<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<R>\<^sub>\<circ> ((\<GG> \<^sub>D\<^sub>G\<^sub>H\<^sub>M\<circ> \<FF>)\<lparr>ObjMap\<rparr>) \<subseteq>\<^sub>\<circ> \<CC>\<lparr>Obj\<rparr>
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<GG> : op_dg \<BB> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^bsub>\<alpha>\<^esub> \<CC>
\<FF> : \<AA> \<mapsto>\<mapsto>\<^sub>D\<^sub>G\<^bsub>\<alpha>\<^esub> \<BB>

goal (1 subgoal):
 1. \<R>\<^sub>\<circ> ((\<GG> \<^sub>D\<^sub>G\<^sub>H\<^sub>M\<circ> \<FF>)\<lparr>ObjMap\<rparr>) \<subseteq>\<^sub>\<circ> \<CC>\<lparr>Obj\<rparr>
[PROOF STEP]
by
    (
      cs_concl cs_shallow
        cs_simp: dghm_cn_comp_components
        cs_intro: is_dghm.dghm_ObjMap_vrange V_cs_intros
    )


[STATEMENT]
lemma polyfun_linear_factor:
  fixes a :: "'a::{comm_ring,monoid_mult}"
  shows  "\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z^i) =
                  (z-a) * (\<Sum>i<n. b i * z^i) + (\<Sum>i\<le>n. c i * a^i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
fix z
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
have "(\<Sum>i\<le>n. c i * z^i) - (\<Sum>i\<le>n. c i * a^i) =
          (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a^(k - Suc j)) * z^j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. c i * z ^ i) - (\<Sum>i\<le>n. c i * a ^ i) = (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * z ^ j)
[PROOF STEP]
by (simp add: sub_polyfun sum_distrib_right)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. c i * z ^ i) - (\<Sum>i\<le>n. c i * a ^ i) = (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * z ^ j)

goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<le>n. c i * z ^ i) - (\<Sum>i\<le>n. c i * a ^ i) = (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * z ^ j)
[PROOF STEP]
have "(\<Sum>i\<le>n. c i * z^i) =
          (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a^(k - Suc j)) * z^j)
          + (\<Sum>i\<le>n. c i * a^i)"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<le>n. c i * z ^ i) - (\<Sum>i\<le>n. c i * a ^ i) = (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * z ^ j)

goal (1 subgoal):
 1. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * z ^ j) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * z ^ j) + (\<Sum>i\<le>n. c i * a ^ i)

goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. c i * ?z2 ^ i) = (?z2 - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * ?z2 ^ j) + (\<Sum>i\<le>n. c i * a ^ i)

goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>i\<le>n. c i * ?z2 ^ i) = (?z2 - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * ?z2 ^ j) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i\<le>n. c i * ?z2 ^ i) = (?z2 - a) * (\<Sum>j<n. (\<Sum>k = Suc j..n. c k * a ^ (k - Suc j)) * ?z2 ^ j) + (\<Sum>i\<le>n. c i * a ^ i)

goal (1 subgoal):
 1. \<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)
[PROOF STEP]
by (intro exI allI)
[PROOF STATE]
proof (state)
this:
\<exists>b. \<forall>z. (\<Sum>i\<le>n. c i * z ^ i) = (z - a) * (\<Sum>i<n. b i * z ^ i) + (\<Sum>i\<le>n. c i * a ^ i)

goal:
No subgoals!
[PROOF STEP]
qed