[STATEMENT]
theorem (in Graph) treewidth_complete_graph:
  assumes "\<And>v w. \<lbrakk> v \<in> V; w \<in> V; v \<noteq> w \<rbrakk> \<Longrightarrow> v\<rightarrow>w"
  shows "treewidth = card V - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
assume "V \<noteq> {}"
[PROOF STATE]
proof (state)
this:
V \<noteq> {}

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
obtain T bag where
      T: "TreeDecomposition G (T :: nat Graph) bag" "treewidth = TreeDecomposition.width T bag"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>T bag. \<lbrakk>TreeDecomposition G T bag; treewidth = TreeDecomposition.width T bag\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using treewidth_cards_treewidth
[PROOF STATE]
proof (prove)
using this:
\<exists>T bag. TreeDecomposition G T bag \<and> treewidth = TreeDecomposition.width T bag

goal (1 subgoal):
 1. (\<And>T bag. \<lbrakk>TreeDecomposition G T bag; treewidth = TreeDecomposition.width T bag\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
TreeDecomposition G T bag
treewidth = TreeDecomposition.width T bag

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
interpret TreeDecomposition G T bag
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. TreeDecomposition G T bag
[PROOF STEP]
using T(1)
[PROOF STATE]
proof (prove)
using this:
TreeDecomposition G T bag

goal (1 subgoal):
 1. TreeDecomposition G T bag
[PROOF STEP]
.
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
assume "\<not>?thesis"
[PROOF STATE]
proof (state)
this:
treewidth \<noteq> card V - 1

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
hence "width \<noteq> card V - 1"
[PROOF STATE]
proof (prove)
using this:
treewidth \<noteq> card V - 1

goal (1 subgoal):
 1. width \<noteq> card V - 1
[PROOF STEP]
by (simp add: T(2))
[PROOF STATE]
proof (state)
this:
width \<noteq> card V - 1

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
text \<open>Let @{term s} be a bag of maximal size.\<close>
[PROOF STATE]
proof (state)
this:
width \<noteq> card V - 1

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
width \<noteq> card V - 1

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
obtain s where s: "s \<in> V\<^bsub>T\<^esub>" "card (bag s) = max_bag_card"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>s. \<lbrakk>s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using max_bag_card_in_bag_cards \<open>V \<noteq> {}\<close>
[PROOF STATE]
proof (prove)
using this:
V \<noteq> {} \<Longrightarrow> max_bag_card \<in> bag_cards
V \<noteq> {}

goal (1 subgoal):
 1. (\<And>s. \<lbrakk>s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
text \<open>The treewidth cannot be larger than @{term "card V - 1"}, so due to our assumption
      @{term "width \<noteq> card V - 1" } it must be smaller, hence @{term "card (bag s) < card V"}.\<close>
[PROOF STATE]
proof (state)
this:
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
width \<noteq> card V - 1
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
[PROOF STEP]
have "card (bag s) < card V"
[PROOF STATE]
proof (prove)
using this:
width \<noteq> card V - 1
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card

goal (1 subgoal):
 1. card (bag s) < card V
[PROOF STEP]
unfolding width_def
[PROOF STATE]
proof (prove)
using this:
(if V\<^bsub>T\<^esub> = {} then 0 else max_bag_card - 1) \<noteq> card V - 1
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card

goal (1 subgoal):
 1. card (bag s) < card V
[PROOF STEP]
using \<open>V \<noteq> {}\<close> empty_tree_empty_V le_eq_less_or_eq max_bag_card_upper_bound_V
[PROOF STATE]
proof (prove)
using this:
(if V\<^bsub>T\<^esub> = {} then 0 else max_bag_card - 1) \<noteq> card V - 1
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
V \<noteq> {}
V\<^bsub>T\<^esub> = {} \<Longrightarrow> V = {}
(?m \<le> ?n) = (?m < ?n \<or> ?m = ?n)
V \<noteq> {} \<Longrightarrow> max_bag_card \<le> card V

goal (1 subgoal):
 1. card (bag s) < card V
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
card (bag s) < card V

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (bag s) < card V
[PROOF STEP]
obtain v where v: "v \<in> V" "v \<notin> bag s"
[PROOF STATE]
proof (prove)
using this:
card (bag s) < card V

goal (1 subgoal):
 1. (\<And>v. \<lbrakk>v \<in> V; v \<notin> bag s\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (meson bag_finite card_mono not_less s(1) subsetI)
[PROOF STATE]
proof (state)
this:
v \<in> V
v \<notin> bag s

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
text \<open>There exists a bag containing @{term v}.  We consider the path from @{term s} to
      @{term t} and find that somewhere along this path there exists a bag containing
      @{term "insert v (bag s)"}, which is a contradiction because such a bag would be too big.\<close>
[PROOF STATE]
proof (state)
this:
v \<in> V
v \<notin> bag s

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
obtain t where t: "t \<in> V\<^bsub>T\<^esub>" "v \<in> bag t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t. \<lbrakk>t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using bags_exist v(1)
[PROOF STATE]
proof (prove)
using this:
?v \<in> V \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. ?v \<in> bag t
v \<in> V

goal (1 subgoal):
 1. (\<And>t. \<lbrakk>t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
with s
[PROOF STATE]
proof (chain)
picking this:
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t
[PROOF STEP]
have "\<exists>t \<in> V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t"
[PROOF STATE]
proof (prove)
using this:
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
proof (induct "s \<leadsto>\<^bsub>T\<^esub> t" arbitrary: s)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>s. \<lbrakk>[] = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
 2. \<And>a x s. \<lbrakk>\<And>s. \<lbrakk>x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t; a # x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
[] = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t

goal (2 subgoals):
 1. \<And>s. \<lbrakk>[] = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
 2. \<And>a x s. \<lbrakk>\<And>s. \<lbrakk>x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t; a # x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
[] = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
using T.unique_connecting_path_properties(2)
[PROOF STATE]
proof (prove)
using this:
[] = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t
\<lbrakk>?v \<in> V\<^bsub>T\<^esub>; ?w \<in> V\<^bsub>T\<^esub>\<rbrakk> \<Longrightarrow> ?v \<leadsto>\<^bsub>T\<^esub> ?w \<noteq> []

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t

goal (1 subgoal):
 1. \<And>a x s. \<lbrakk>\<And>s. \<lbrakk>x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t; a # x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a x s. \<lbrakk>\<And>s. \<lbrakk>x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t; a # x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
case (Cons x xs s)
[PROOF STATE]
proof (state)
this:
\<lbrakk>xs = ?s \<leadsto>\<^bsub>T\<^esub> t; ?s \<in> V\<^bsub>T\<^esub>; card (bag ?s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag ?s) \<subseteq> bag t
x # xs = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t

goal (1 subgoal):
 1. \<And>a x s. \<lbrakk>\<And>s. \<lbrakk>x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t; a # x = s \<leadsto>\<^bsub>T\<^esub> t; s \<in> V\<^bsub>T\<^esub>; card (bag s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
proof (cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
 2. \<not> ?P \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
assume "v \<in> bag s"
[PROOF STATE]
proof (state)
this:
v \<in> bag s

goal (2 subgoals):
 1. ?P \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
 2. \<not> ?P \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
v \<in> bag s

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
using t Cons.prems(1)
[PROOF STATE]
proof (prove)
using this:
v \<in> bag s
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t
s \<in> V\<^bsub>T\<^esub>

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
assume "v \<notin> bag s"
[PROOF STATE]
proof (state)
this:
v \<notin> bag s

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
hence "s \<noteq> t"
[PROOF STATE]
proof (prove)
using this:
v \<notin> bag s

goal (1 subgoal):
 1. s \<noteq> t
[PROOF STEP]
using t(2)
[PROOF STATE]
proof (prove)
using this:
v \<notin> bag s
v \<in> bag t

goal (1 subgoal):
 1. s \<noteq> t
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
s \<noteq> t

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
hence "xs \<noteq> Nil"
[PROOF STATE]
proof (prove)
using this:
s \<noteq> t

goal (1 subgoal):
 1. xs \<noteq> []
[PROOF STEP]
using Cons.hyps(2) Cons.prems(1,3)
[PROOF STATE]
proof (prove)
using this:
s \<noteq> t
x # xs = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
t \<in> V\<^bsub>T\<^esub>

goal (1 subgoal):
 1. xs \<noteq> []
[PROOF STEP]
by (metis T.unique_connecting_path_properties(3,4) last_ConsL list.sel(1))
[PROOF STATE]
proof (state)
this:
xs \<noteq> []

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
xs \<noteq> []

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
have "x = s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = s
[PROOF STEP]
using Cons.hyps(2) Cons.prems(1) t(1)
[PROOF STATE]
proof (prove)
using this:
x # xs = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
t \<in> V\<^bsub>T\<^esub>

goal (1 subgoal):
 1. x = s
[PROOF STEP]
by (metis T.unique_connecting_path_properties(3) list.sel(1))
[PROOF STATE]
proof (state)
this:
x = s

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
xs \<noteq> []
x = s
[PROOF STEP]
obtain s' xs' where s': "s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t"
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> []
x = s

goal (1 subgoal):
 1. (\<And>s' xs'. s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Cons.hyps(2) list.exhaust
[PROOF STATE]
proof (prove)
using this:
xs \<noteq> []
x = s
x # xs = s \<leadsto>\<^bsub>T\<^esub> t
\<lbrakk>?y = [] \<Longrightarrow> ?P; \<And>x21 x22. ?y = x21 # x22 \<Longrightarrow> ?P\<rbrakk> \<Longrightarrow> ?P

goal (1 subgoal):
 1. (\<And>s' xs'. s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
have st_path: "T.path (s \<leadsto>\<^bsub>T\<^esub> t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. T.path (s \<leadsto>\<^bsub>T\<^esub> t)
[PROOF STEP]
by (simp add: Cons.prems(1) T.unique_connecting_path_properties(1) t(1))
[PROOF STATE]
proof (state)
this:
T.path (s \<leadsto>\<^bsub>T\<^esub> t)

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t
T.path (s \<leadsto>\<^bsub>T\<^esub> t)
[PROOF STEP]
have "s' \<in> V\<^bsub>T\<^esub>"
[PROOF STATE]
proof (prove)
using this:
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t
T.path (s \<leadsto>\<^bsub>T\<^esub> t)

goal (1 subgoal):
 1. s' \<in> V\<^bsub>T\<^esub>
[PROOF STEP]
by (metis T.edges_are_in_V(2) T.path_first_edge)
[PROOF STATE]
proof (state)
this:
s' \<in> V\<^bsub>T\<^esub>

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
text \<open>Bags can never drop vertices because every vertex has a neighbor in @{term G} which
          has not yet been visited.\<close>
[PROOF STATE]
proof (state)
this:
s' \<in> V\<^bsub>T\<^esub>

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
have s_in_s': "bag s \<subseteq> bag s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bag s \<subseteq> bag s'
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
fix w
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
assume "w \<in> bag s"
[PROOF STATE]
proof (state)
this:
w \<in> bag s

goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
w \<in> bag s

goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
have "s \<rightarrow>\<^bsub>T\<^esub> s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. s \<rightarrow>\<^bsub>T\<^esub> s'
[PROOF STEP]
using s' st_path
[PROOF STATE]
proof (prove)
using this:
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t
T.path (s \<leadsto>\<^bsub>T\<^esub> t)

goal (1 subgoal):
 1. s \<rightarrow>\<^bsub>T\<^esub> s'
[PROOF STEP]
by (metis T.walk_first_edge)
[PROOF STATE]
proof (state)
this:
s \<rightarrow>\<^bsub>T\<^esub> s'

goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
s \<rightarrow>\<^bsub>T\<^esub> s'

goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
have "v \<in> left_part s' s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<in> left_part s' s
[PROOF STEP]
using Cons.prems(1,4) s' t(1)
[PROOF STATE]
proof (prove)
using this:
s \<in> V\<^bsub>T\<^esub>
v \<in> bag t
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t
t \<in> V\<^bsub>T\<^esub>

goal (1 subgoal):
 1. v \<in> left_part s' s
[PROOF STEP]
by (metis T.left_treeI T.unique_connecting_path_rev insert_subset left_partI
                list.simps(15) set_rev subsetI)
[PROOF STATE]
proof (state)
this:
v \<in> left_part s' s

goal (1 subgoal):
 1. \<And>x. x \<in> bag s \<Longrightarrow> x \<in> bag s'
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
w \<in> bag s
s \<rightarrow>\<^bsub>T\<^esub> s'
v \<in> left_part s' s
[PROOF STEP]
show "w \<in> bag s'"
[PROOF STATE]
proof (prove)
using this:
w \<in> bag s
s \<rightarrow>\<^bsub>T\<^esub> s'
v \<in> left_part s' s

goal (1 subgoal):
 1. w \<in> bag s'
[PROOF STEP]
using bag_no_drop Cons.prems(1,4) \<open>v \<notin> bag s\<close> assms bags_in_V v(1)
[PROOF STATE]
proof (prove)
using this:
w \<in> bag s
s \<rightarrow>\<^bsub>T\<^esub> s'
v \<in> left_part s' s
\<lbrakk>?s \<rightarrow>\<^bsub>T\<^esub> ?t; ?v \<rightarrow> ?w; ?v \<in> bag ?s; ?w \<notin> bag ?s; ?w \<in> left_part ?t ?s\<rbrakk> \<Longrightarrow> ?v \<in> bag ?t
s \<in> V\<^bsub>T\<^esub>
v \<in> bag t
v \<notin> bag s
\<lbrakk>?v \<in> V; ?w \<in> V; ?v \<noteq> ?w\<rbrakk> \<Longrightarrow> ?v \<rightarrow> ?w
?t \<in> V\<^bsub>T\<^esub> \<Longrightarrow> bag ?t \<subseteq> V
v \<in> V

goal (1 subgoal):
 1. w \<in> bag s'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
w \<in> bag s'

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

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
text \<open>Bags can never gain vertices because we started with a bag of maximal size.\<close>
[PROOF STATE]
proof (state)
this:
bag s \<subseteq> bag s'

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
bag s \<subseteq> bag s'

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
have "card (bag s') \<le> card (bag s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (bag s') \<le> card (bag s)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (bag s') \<le> card (bag s)
[PROOF STEP]
have "card (bag s') \<le> max_bag_card"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (bag s') \<le> max_bag_card
[PROOF STEP]
unfolding max_bag_card_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (bag s') \<le> Max bag_cards
[PROOF STEP]
using Max_ge \<open>s' \<in> V\<^bsub>T\<^esub>\<close> bag_cards_finite
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?A; ?x \<in> ?A\<rbrakk> \<Longrightarrow> ?x \<le> Max ?A
s' \<in> V\<^bsub>T\<^esub>
finite bag_cards

goal (1 subgoal):
 1. card (bag s') \<le> Max bag_cards
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (bag s') \<le> max_bag_card

goal (1 subgoal):
 1. card (bag s') \<le> card (bag s)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
card (bag s') \<le> max_bag_card

goal (1 subgoal):
 1. card (bag s') \<le> card (bag s)
[PROOF STEP]
using Cons.prems(2)
[PROOF STATE]
proof (prove)
using this:
card (bag s') \<le> max_bag_card
card (bag s) = max_bag_card

goal (1 subgoal):
 1. card (bag s') \<le> card (bag s)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (bag s') \<le> card (bag s)

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

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
bag s \<subseteq> bag s'
card (bag s') \<le> card (bag s)
[PROOF STEP]
have "bag s' = bag s"
[PROOF STATE]
proof (prove)
using this:
bag s \<subseteq> bag s'
card (bag s') \<le> card (bag s)

goal (1 subgoal):
 1. bag s' = bag s
[PROOF STEP]
using \<open>s' \<in> V\<^bsub>T\<^esub>\<close> bag_finite card_seteq
[PROOF STATE]
proof (prove)
using this:
bag s \<subseteq> bag s'
card (bag s') \<le> card (bag s)
s' \<in> V\<^bsub>T\<^esub>
?t \<in> V\<^bsub>T\<^esub> \<Longrightarrow> finite (bag ?t)
\<lbrakk>finite ?B; ?A \<subseteq> ?B; card ?B \<le> card ?A\<rbrakk> \<Longrightarrow> ?A = ?B

goal (1 subgoal):
 1. bag s' = bag s
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bag s' = bag s

goal (1 subgoal):
 1. v \<notin> bag s \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
bag s' = bag s

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
using Cons.hyps Cons.prems(1,2) \<open>s' \<in> V\<^bsub>T\<^esub>\<close> t s' st_path \<open>xs \<noteq> []\<close>
[PROOF STATE]
proof (prove)
using this:
bag s' = bag s
\<lbrakk>xs = ?s \<leadsto>\<^bsub>T\<^esub> t; ?s \<in> V\<^bsub>T\<^esub>; card (bag ?s) = max_bag_card; t \<in> V\<^bsub>T\<^esub>; v \<in> bag t\<rbrakk> \<Longrightarrow> \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag ?s) \<subseteq> bag t
x # xs = s \<leadsto>\<^bsub>T\<^esub> t
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
s' \<in> V\<^bsub>T\<^esub>
t \<in> V\<^bsub>T\<^esub>
v \<in> bag t
s # s' # xs' = s \<leadsto>\<^bsub>T\<^esub> t
T.path (s \<leadsto>\<^bsub>T\<^esub> t)
xs \<noteq> []

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
[PROOF STEP]
by (metis T.path_from_toI T.path_tl T.unique_connecting_path_properties(4)
              T.unique_connecting_path_unique last.simps list.sel(1,3))
[PROOF STATE]
proof (state)
this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
hence "\<exists>t \<in> V\<^bsub>T\<^esub>. card (bag s) < card (bag t)"
[PROOF STATE]
proof (prove)
using this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. card (bag s) < card (bag t)
[PROOF STEP]
using v(2)
[PROOF STATE]
proof (prove)
using this:
\<exists>t\<in>V\<^bsub>T\<^esub>. insert v (bag s) \<subseteq> bag t
v \<notin> bag s

goal (1 subgoal):
 1. \<exists>t\<in>V\<^bsub>T\<^esub>. card (bag s) < card (bag t)
[PROOF STEP]
by (metis bag_finite card_seteq insert_subset not_le)
[PROOF STATE]
proof (state)
this:
\<exists>t\<in>V\<^bsub>T\<^esub>. card (bag s) < card (bag t)

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
hence False
[PROOF STATE]
proof (prove)
using this:
\<exists>t\<in>V\<^bsub>T\<^esub>. card (bag s) < card (bag t)

goal (1 subgoal):
 1. False
[PROOF STEP]
using s Max.coboundedI bag_cards_finite not_le
[PROOF STATE]
proof (prove)
using this:
\<exists>t\<in>V\<^bsub>T\<^esub>. card (bag s) < card (bag t)
s \<in> V\<^bsub>T\<^esub>
card (bag s) = max_bag_card
\<lbrakk>finite ?A; ?a \<in> ?A\<rbrakk> \<Longrightarrow> ?a \<le> Max ?A
finite bag_cards
(\<not> ?x \<le> ?y) = (?y < ?x)

goal (1 subgoal):
 1. False
[PROOF STEP]
unfolding max_bag_card_def
[PROOF STATE]
proof (prove)
using this:
\<exists>t\<in>V\<^bsub>T\<^esub>. card (bag s) < card (bag t)
s \<in> V\<^bsub>T\<^esub>
card (bag s) = Max bag_cards
\<lbrakk>finite ?A; ?a \<in> ?A\<rbrakk> \<Longrightarrow> ?a \<le> Max ?A
finite bag_cards
(\<not> ?x \<le> ?y) = (?y < ?x)

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

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>V \<noteq> {}; treewidth \<noteq> card V - 1\<rbrakk> \<Longrightarrow> False

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>V \<noteq> {}; treewidth \<noteq> card V - 1\<rbrakk> \<Longrightarrow> False

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
using treewidth_upper_bound_V card.empty diff_diff_cancel zero_diff
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>V \<noteq> {}; treewidth \<noteq> card V - 1\<rbrakk> \<Longrightarrow> False
treewidth \<le> card V - 1
card {} = 0
?i \<le> ?n \<Longrightarrow> ?n - (?n - ?i) = ?i
(0::?'a) - ?a = (0::?'a)

goal (1 subgoal):
 1. treewidth = card V - 1
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
treewidth = card V - 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma trace_measurement:
  assumes m: "measurement d n M" and dA: "A \<in> carrier_mat d d"
  shows "trace (matrix_sum d (\<lambda>k. (M k) * A * adjoint (M k)) n) = trace A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have dMk: "k < n \<Longrightarrow> (M k) \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> M k \<in> carrier_mat d d
[PROOF STEP]
using m
[PROOF STATE]
proof (prove)
using this:
measurement d n M

goal (1 subgoal):
 1. k < n \<Longrightarrow> M k \<in> carrier_mat d d
[PROOF STEP]
unfolding measurement_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>j<n. M j \<in> carrier_mat d d) \<and> matrix_sum d (\<lambda>j. adjoint (M j) * M j) n = 1\<^sub>m d

goal (1 subgoal):
 1. k < n \<Longrightarrow> M k \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
[PROOF STEP]
have daMk: "k < n \<Longrightarrow> adjoint (M k) \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
using m adjoint_dim
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
measurement d n M
?A \<in> carrier_mat ?n ?n \<Longrightarrow> adjoint ?A \<in> carrier_mat ?n ?n

goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
unfolding measurement_def
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
(\<forall>j<n. M j \<in> carrier_mat d d) \<and> matrix_sum d (\<lambda>j. adjoint (M j) * M j) n = 1\<^sub>m d
?A \<in> carrier_mat ?n ?n \<Longrightarrow> adjoint ?A \<in> carrier_mat ?n ?n

goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> adjoint (M ?k) \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have d1: "k < n \<Longrightarrow> M k * A * adjoint (M k) \<in> carrier_mat d d"for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * A * adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
using dMk daMk dA
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> adjoint (M ?k) \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * A * adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> M ?k * A * adjoint (M ?k) \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> M ?k * A * adjoint (M ?k) \<in> carrier_mat d d
[PROOF STEP]
have ds1: "k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k * A * adjoint (M ?k) \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k \<in> carrier_mat d d
[PROOF STEP]
using matrix_sum_dim[of k "\<lambda>k. M k * A * adjoint (M k)" d]
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k * A * adjoint (M ?k) \<in> carrier_mat d d
(\<And>ka. ka < k \<Longrightarrow> M ka * A * adjoint (M ka) \<in> carrier_mat d d) \<Longrightarrow> matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have d2: "k < n \<Longrightarrow> adjoint (M k) *M k * A  \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) * M k * A \<in> carrier_mat d d
[PROOF STEP]
using daMk dMk dA
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> adjoint (M ?k) \<in> carrier_mat d d
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) * M k * A \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k * A \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k * A \<in> carrier_mat d d
[PROOF STEP]
have ds2: "k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) *M k * A) k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k * A \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k \<in> carrier_mat d d
[PROOF STEP]
using matrix_sum_dim[of k "\<lambda>k. adjoint (M k) *M k * A" d]
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k * A \<in> carrier_mat d d
(\<And>ka. ka < k \<Longrightarrow> adjoint (M ka) * M ka * A \<in> carrier_mat d d) \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have daMMk: "k < n \<Longrightarrow> adjoint (M k) * M k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) * M k \<in> carrier_mat d d
[PROOF STEP]
using dMk
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) * M k \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have "k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. (M k) * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * (M k) * A) k)" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
[PROOF STEP]
proof (induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) 0) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) 0)
 2. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 \<le> n

goal (2 subgoals):
 1. 0 \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) 0) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) 0)
 2. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 \<le> n

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) 0) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) 0) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) 0)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
Suc k \<le> n

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
Suc k \<le> n
[PROOF STEP]
have k: "k < n"
[PROOF STATE]
proof (prove)
using this:
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
Suc k \<le> n

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

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
have "trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)
[PROOF STEP]
using dA
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)
[PROOF STEP]
apply (mat_assoc d)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M k \<in> carrier_mat d d
[PROOF STEP]
using dMk k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
k < n

goal (1 subgoal):
 1. M k \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))
[PROOF STEP]
unfolding matrix_sum.simps
[PROOF STATE]
proof (prove)
using this:
trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)

goal (1 subgoal):
 1. trace (M k * A * adjoint (M k) + matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (adjoint (M k) * M k * A + matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
[PROOF STEP]
using ds1 ds2 d1 d2 k Suc daMk dMk dA
[PROOF STATE]
proof (prove)
using this:
trace (M k * A * adjoint (M k)) = trace (adjoint (M k) * M k * A)
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) ?k \<in> carrier_mat d d
?k < n \<Longrightarrow> M ?k * A * adjoint (M ?k) \<in> carrier_mat d d
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k * A \<in> carrier_mat d d
k < n
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
Suc k \<le> n
?k < n \<Longrightarrow> adjoint (M ?k) \<in> carrier_mat d d
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (M k * A * adjoint (M k) + matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) k) = trace (adjoint (M k) * M k * A + matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) k)
[PROOF STEP]
by (subst trace_add_linear[of _ d], auto)+
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) (Suc k)) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) (Suc k))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) ?k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) ?k)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) ?k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) ?k)
[PROOF STEP]
have "trace (matrix_sum d (\<lambda>k. (M k) * A * adjoint (M k)) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * (M k) * A) n)"
[PROOF STATE]
proof (prove)
using this:
?k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) ?k) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) ?k)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have "\<dots> = trace (matrix_sum d (\<lambda>k. adjoint (M k) * (M k)) n * A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A)
[PROOF STEP]
using matrix_sum_mult_right[OF daMMk, of n id A] dA
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>k. k < n \<Longrightarrow> id k < n; A \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M (id k)) * M (id k) * A) n = matrix_sum d (\<lambda>k. adjoint (M (id k)) * M (id k)) n * A
A \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k * A) n) = trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A)

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
have "\<dots> = trace A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A) = trace A
[PROOF STEP]
using m dA
[PROOF STATE]
proof (prove)
using this:
measurement d n M
A \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A) = trace A
[PROOF STEP]
unfolding measurement_def
[PROOF STATE]
proof (prove)
using this:
(\<forall>j<n. M j \<in> carrier_mat d d) \<and> matrix_sum d (\<lambda>j. adjoint (M j) * M j) n = 1\<^sub>m d
A \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A) = trace A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * M k) n * A) = trace A

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. M k * A * adjoint (M k)) n) = trace A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma less_fun_const_quot:
  assumes "f \<lless> g" "c \<noteq> 0"
  shows "(\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)
[PROOF STEP]
have "(\<lambda>n. (b * (f n / g n)) / c) \<longlonglongrightarrow> (b * 0) / c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. b * (f n / g n) / c) \<longlonglongrightarrow> b * 0 / c
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<lless> g
c \<noteq> 0

goal (1 subgoal):
 1. (\<lambda>n. b * (f n / g n) / c) \<longlonglongrightarrow> b * 0 / c
[PROOF STEP]
by (rule LIMSEQ_const_div[OF LIMSEQ_const_mult])
[PROOF STATE]
proof (state)
this:
(\<lambda>n. b * (f n / g n) / c) \<longlonglongrightarrow> b * 0 / c

goal (1 subgoal):
 1. (\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)
[PROOF STEP]
hence "(\<lambda>n. (b * (f n / g n)) / c) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. b * (f n / g n) / c) \<longlonglongrightarrow> b * 0 / c

goal (1 subgoal):
 1. (\<lambda>n. b * (f n / g n)) \<lless> (\<lambda>n. c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. b * (f n / g n)) \<lless> (\<lambda>n. c)

goal (1 subgoal):
 1. (\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)
[PROOF STEP]
with eventually_sequentiallyI
[PROOF STATE]
proof (chain)
picking this:
(\<And>x. ?c \<le> x \<Longrightarrow> ?P x) \<Longrightarrow> evseq ?P
(\<lambda>n. b * (f n / g n)) \<lless> (\<lambda>n. c)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<And>x. ?c \<le> x \<Longrightarrow> ?P x) \<Longrightarrow> evseq ?P
(\<lambda>n. b * (f n / g n)) \<lless> (\<lambda>n. c)

goal (1 subgoal):
 1. (\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)
[PROOF STEP]
by (fastforce intro: Lim_transform_eventually)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. b * f n) \<lless> (\<lambda>n. c * g n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lexmax_le_multiset: assumes t:"trans r" shows "r|\<sigma>| \<subseteq># mset \<sigma>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r|\<sigma>| \<subseteq># mset \<sigma>
[PROOF STEP]
proof (induct "\<sigma>")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. r|[]| \<subseteq># mset []
 2. \<And>a \<sigma>. r|\<sigma>| \<subseteq># mset \<sigma> \<Longrightarrow> r|a # \<sigma>| \<subseteq># mset (a # \<sigma>)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. r|[]| \<subseteq># mset []
 2. \<And>a \<sigma>. r|\<sigma>| \<subseteq># mset \<sigma> \<Longrightarrow> r|a # \<sigma>| \<subseteq># mset (a # \<sigma>)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r|[]| \<subseteq># mset []
[PROOF STEP]
unfolding lexmax.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {#} \<subseteq># mset []
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r|[]| \<subseteq># mset []

goal (1 subgoal):
 1. \<And>a \<sigma>. r|\<sigma>| \<subseteq># mset \<sigma> \<Longrightarrow> r|a # \<sigma>| \<subseteq># mset (a # \<sigma>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a \<sigma>. r|\<sigma>| \<subseteq># mset \<sigma> \<Longrightarrow> r|a # \<sigma>| \<subseteq># mset (a # \<sigma>)
[PROOF STEP]
case (Cons s \<tau>)
[PROOF STATE]
proof (state)
this:
r|\<tau>| \<subseteq># mset \<tau>

goal (1 subgoal):
 1. \<And>a \<sigma>. r|\<sigma>| \<subseteq># mset \<sigma> \<Longrightarrow> r|a # \<sigma>| \<subseteq># mset (a # \<sigma>)
[PROOF STEP]
hence "lexmax r \<tau> -s ds r {s} \<subseteq># mset \<tau>"
[PROOF STATE]
proof (prove)
using this:
r|\<tau>| \<subseteq># mset \<tau>

goal (1 subgoal):
 1. r|\<tau>| -s r \<down>s {s} \<subseteq># mset \<tau>
[PROOF STEP]
using lemmaA_3_10 mset_subset_eq_add_right subset_mset.order_trans
[PROOF STATE]
proof (prove)
using this:
r|\<tau>| \<subseteq># mset \<tau>
?M = ?M \<inter>s ?S + ?M -s ?S
?B \<subseteq># ?A + ?B
\<lbrakk>?x \<subseteq># ?y; ?y \<subseteq># ?z\<rbrakk> \<Longrightarrow> ?x \<subseteq># ?z

goal (1 subgoal):
 1. r|\<tau>| -s r \<down>s {s} \<subseteq># mset \<tau>
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
r|\<tau>| -s r \<down>s {s} \<subseteq># mset \<tau>

goal (1 subgoal):
 1. \<And>a \<sigma>. r|\<sigma>| \<subseteq># mset \<sigma> \<Longrightarrow> r|a # \<sigma>| \<subseteq># mset (a # \<sigma>)
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
r|\<tau>| -s r \<down>s {s} \<subseteq># mset \<tau>

goal (1 subgoal):
 1. r|s # \<tau>| \<subseteq># mset (s # \<tau>)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
r|s # \<tau>| \<subseteq># mset (s # \<tau>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma m_translate_functions:
  assumes "c \<in> carrier R"
  shows "m_translate c \<in> carrier (Fun R)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m_translate c \<in> carrier (function_ring (carrier R) R)
[PROOF STEP]
apply(rule function_ring_car_memI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>a. a \<in> carrier R \<Longrightarrow> m_translate c a \<in> carrier R
 2. \<And>a. a \<notin> carrier R \<Longrightarrow> m_translate c a = undefined
[PROOF STEP]
using assms m_translate_def
[PROOF STATE]
proof (prove)
using this:
c \<in> carrier R
m_translate = (\<lambda>r\<in>carrier R. restrict ((\<otimes>) r) (carrier R))

goal (2 subgoals):
 1. \<And>a. a \<in> carrier R \<Longrightarrow> m_translate c a \<in> carrier R
 2. \<And>a. a \<notin> carrier R \<Longrightarrow> m_translate c a = undefined
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. a \<notin> carrier R \<Longrightarrow> m_translate c a = undefined
[PROOF STEP]
using assms m_translate_def
[PROOF STATE]
proof (prove)
using this:
c \<in> carrier R
m_translate = (\<lambda>r\<in>carrier R. restrict ((\<otimes>) r) (carrier R))

goal (1 subgoal):
 1. \<And>a. a \<notin> carrier R \<Longrightarrow> m_translate c a = undefined
[PROOF STEP]
by simp


[STATEMENT]
lemma ordLeq3_finite_infinite:
  assumes A: "finite A" and B: "infinite B" shows "ordLeq3 (card_of A) (card_of B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B)
[PROOF STEP]
have \<open>ordLeq3 (card_of A) (card_of B) \<or> ordLeq3 (card_of B) (card_of A)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B) \<or> ordLeq3 (card_of B) (card_of A)
[PROOF STEP]
by (intro ordLeq_total card_of_Well_order)
[PROOF STATE]
proof (state)
this:
ordLeq3 (card_of A) (card_of B) \<or> ordLeq3 (card_of B) (card_of A)

goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
ordLeq3 (card_of A) (card_of B) \<or> ordLeq3 (card_of B) (card_of A)

goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B)
[PROOF STEP]
have "\<not> ordLeq3 (card_of B) (card_of A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (card_of B, card_of A) \<notin> ordLeq
[PROOF STEP]
using B A card_of_ordLeq_finite[of B A]
[PROOF STATE]
proof (prove)
using this:
infinite B
finite A
\<lbrakk>ordLeq3 (card_of B) (card_of A); finite A\<rbrakk> \<Longrightarrow> finite B

goal (1 subgoal):
 1. (card_of B, card_of A) \<notin> ordLeq
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(card_of B, card_of A) \<notin> ordLeq

goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
ordLeq3 (card_of A) (card_of B) \<or> ordLeq3 (card_of B) (card_of A)
(card_of B, card_of A) \<notin> ordLeq
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ordLeq3 (card_of A) (card_of B) \<or> ordLeq3 (card_of B) (card_of A)
(card_of B, card_of A) \<notin> ordLeq

goal (1 subgoal):
 1. ordLeq3 (card_of A) (card_of B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
ordLeq3 (card_of A) (card_of B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma successors_predecessors[simp]: "n \<in> set (\<alpha>n g) \<Longrightarrow> n \<in> set (successors g m) \<longleftrightarrow> m \<in> set (predecessors g n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<in> set (\<alpha>n g) \<Longrightarrow> (n \<in> set (successors g m)) = (m \<in> set (predecessors g n))
[PROOF STEP]
by (auto simp:successors_def predecessors_def)


[STATEMENT]
lemma rbt_lookup_keys: "rbt_sorted t \<Longrightarrow> dom (rbt_lookup t) = set (keys t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rbt_sorted t \<Longrightarrow> dom (rbt_lookup t) = set (keys t)
[PROOF STEP]
by (induct t) (auto simp: dom_def rbt_greater_prop rbt_less_prop)


[STATEMENT]
lemma emptiness_preservance: "A,\<R> \<turnstile> \<langle>l, R\<rangle> \<leadsto> \<langle>l',R'\<rangle> \<Longrightarrow> R = {} \<Longrightarrow> R' = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A,\<R> \<turnstile> \<langle>l, R\<rangle> \<leadsto> \<langle>l', R'\<rangle>; R = {}\<rbrakk> \<Longrightarrow> R' = {}
[PROOF STEP]
by (induction rule: step_r.cases) (auto simp: region_set'_def)


[STATEMENT]
lemma asymp_equiv_filtermap_iff:
  "f \<sim>[filtermap h F] g \<longleftrightarrow> (\<lambda>x. f (h x)) \<sim>[F] (\<lambda>x. g (h x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<sim>[filtermap h F] g) = ((\<lambda>x. f (h x)) \<sim>[F] (\<lambda>x. g (h x)))
[PROOF STEP]
by (simp add: asymp_equiv_def filterlim_filtermap)


[STATEMENT]
lemma symmetry_preserves_per:
  assumes "Per B P A" and
    "B Midpoint A A'" and
    "B Midpoint P P'"
  shows "Per B P' A'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
obtain C where P1: "P Midpoint A C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>C. P Midpoint A C \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using symmetric_point_construction
[PROOF STATE]
proof (prove)
using this:
\<exists>P'. ?A Midpoint ?P P'

goal (1 subgoal):
 1. (\<And>C. P Midpoint A C \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P Midpoint A C

goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
obtain C' where P2: "B Midpoint C C'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>C'. B Midpoint C C' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using symmetric_point_construction
[PROOF STATE]
proof (prove)
using this:
\<exists>P'. ?A Midpoint ?P P'

goal (1 subgoal):
 1. (\<And>C'. B Midpoint C C' \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
B Midpoint C C'

goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
have P3: "P' Midpoint A' C'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P' Midpoint A' C'
[PROOF STEP]
using P1 P2 assms(2) assms(3) symmetry_preserves_midpoint
[PROOF STATE]
proof (prove)
using this:
P Midpoint A C
B Midpoint C C'
B Midpoint A A'
B Midpoint P P'
\<lbrakk>?Z Midpoint ?A ?D; ?Z Midpoint ?B ?E; ?Z Midpoint ?C ?F; ?B Midpoint ?A ?C\<rbrakk> \<Longrightarrow> ?E Midpoint ?D ?F

goal (1 subgoal):
 1. P' Midpoint A' C'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
P' Midpoint A' C'

goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
have "Cong B A' B C'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cong B A' B C'
[PROOF STEP]
by (meson P1 P2 assms(1) assms(2) l7_16 l7_3_2 per_double_cong)
[PROOF STATE]
proof (state)
this:
Cong B A' B C'

goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Cong B A' B C'
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Cong B A' B C'

goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
using P3 Per_def
[PROOF STATE]
proof (prove)
using this:
Cong B A' B C'
P' Midpoint A' C'
Per ?A ?B ?C \<equiv> \<exists>C'. ?B Midpoint ?C C' \<and> Cong ?A ?C ?A C'

goal (1 subgoal):
 1. Per B P' A'
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Per B P' A'

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mat_row_eqI:
  assumes wf1: "mat nr nc m1"
  and wf2: "mat nr nc m2"
  and id: "\<And> i. i < nr \<Longrightarrow> row m1 i = row m2 i"
  shows "m1 = m2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m1 = m2
[PROOF STEP]
unfolding mat_row_eq[OF wf1 wf2]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i<nr. row m1 i = row m2 i
[PROOF STEP]
using id
[PROOF STATE]
proof (prove)
using this:
?i < nr \<Longrightarrow> row m1 ?i = row m2 ?i

goal (1 subgoal):
 1. \<forall>i<nr. row m1 i = row m2 i
[PROOF STEP]
by auto


[STATEMENT]
theorem AndAnd:
  \<open>\<stileturn> [And (Pred ''A'' []) (Pred ''B'' []), Neg (And (Pred ''B'' []) (Pred ''A'' []))]\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<stileturn> [And (Pred ''A'' []) (Pred ''B'' []), Neg (And (Pred ''B'' []) (Pred ''A'' []))]
[PROOF STEP]
apply (rule AlphaAnd)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<stileturn> [Pred ''A'' [], Pred ''B'' [], Neg (And (Pred ''B'' []) (Pred ''A'' []))]
[PROOF STEP]
apply (rule Shift, rule Shift, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<stileturn> [Neg (And (Pred ''B'' []) (Pred ''A'' [])), Pred ''A'' [], Pred ''B'' []]
[PROOF STEP]
apply (rule BetaNegAnd)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<stileturn> [Neg (Pred ''B'' []), Pred ''A'' [], Pred ''B'' []]
 2. \<stileturn> [Neg (Pred ''A'' []), Pred ''A'' [], Pred ''B'' []]
[PROOF STEP]
apply (rule Shift, rule Shift, simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<stileturn> [Pred ''B'' [], Neg (Pred ''B'' []), Pred ''A'' []]
 2. \<stileturn> [Neg (Pred ''A'' []), Pred ''A'' [], Pred ''B'' []]
[PROOF STEP]
apply (rule Basic)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<stileturn> [Neg (Pred ''A'' []), Pred ''A'' [], Pred ''B'' []]
[PROOF STEP]
apply (rule Swap)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<stileturn> [Pred ''A'' [], Neg (Pred ''A'' []), Pred ''B'' []]
[PROOF STEP]
apply (rule Basic)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in FGModuleIso) isomorphic_to_irr_right :
  assumes "IrrFinGroupRepresentation G smult' W"
  shows   "IrrFinGroupRepresentation G smult V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. IrrFinGroupRepresentation G (\<cdot>) V
[PROOF STEP]
proof (rule FinGroupRepresentation.IrrI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. FinGroupRepresentation G (\<cdot>) V
 2. \<And>U. RModule FG (\<cdot>) U \<and> U \<subseteq> V \<Longrightarrow> U = 0 \<or> U = V
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
IrrFinGroupRepresentation G (\<star>) W
[PROOF STEP]
show "FinGroupRepresentation G (\<cdot>) V"
[PROOF STATE]
proof (prove)
using this:
IrrFinGroupRepresentation G (\<star>) W

goal (1 subgoal):
 1. FinGroupRepresentation G (\<cdot>) V
[PROOF STEP]
using IrrFinGroupRepresentation.axioms(1) isomorphic_sym
          FinGroupRepresentation.isomorphic_imp_GRep
[PROOF STATE]
proof (prove)
using this:
IrrFinGroupRepresentation G (\<star>) W
IrrFinGroupRepresentation ?G ?smult ?V \<Longrightarrow> FinGroupRepresentation ?G ?smult ?V
\<exists>T. FGModuleIso G (\<star>) W (\<cdot>) T V
\<lbrakk>FinGroupRepresentation ?G ?smult ?V; \<exists>T. FGModuleIso ?G ?smult ?V ?smult' T ?W\<rbrakk> \<Longrightarrow> FinGroupRepresentation ?G ?smult' ?W

goal (1 subgoal):
 1. FinGroupRepresentation G (\<cdot>) V
[PROOF STEP]
by    fast
[PROOF STATE]
proof (state)
this:
FinGroupRepresentation G (\<cdot>) V

goal (1 subgoal):
 1. \<And>U. RModule FG (\<cdot>) U \<and> U \<subseteq> V \<Longrightarrow> U = 0 \<or> U = V
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
IrrFinGroupRepresentation G (\<star>) W
[PROOF STEP]
show "\<And>U. GSubspace U \<Longrightarrow> U = 0 \<or> U = V"
[PROOF STATE]
proof (prove)
using this:
IrrFinGroupRepresentation G (\<star>) W

goal (1 subgoal):
 1. \<And>U. RModule FG (\<cdot>) U \<and> U \<subseteq> V \<Longrightarrow> U = 0 \<or> U = V
[PROOF STEP]
using IrrFinGroupRepresentation.irr isomorphic_to_irr_right'
[PROOF STATE]
proof (prove)
using this:
IrrFinGroupRepresentation G (\<star>) W
\<lbrakk>IrrFinGroupRepresentation ?G ?smult ?V; RModule (aezfun_setspan ?G) ?smult ?U \<and> ?U \<subseteq> ?V\<rbrakk> \<Longrightarrow> ?U = 0 \<or> ?U = ?V
\<lbrakk>\<And>U. RModule FG (\<star>) U \<and> U \<subseteq> W \<Longrightarrow> U = 0 \<or> U = W; RModule FG (\<cdot>) ?U \<and> ?U \<subseteq> V\<rbrakk> \<Longrightarrow> ?U = 0 \<or> ?U = V

goal (1 subgoal):
 1. \<And>U. RModule FG (\<cdot>) U \<and> U \<subseteq> V \<Longrightarrow> U = 0 \<or> U = V
[PROOF STEP]
by fast
[PROOF STATE]
proof (state)
this:
RModule FG (\<cdot>) ?U3 \<and> ?U3 \<subseteq> V \<Longrightarrow> ?U3 = 0 \<or> ?U3 = V

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sumA_ub2:
assumes "a' < n" "A!a' \<le> n-1" "\<forall>a < n. a \<noteq> a' \<longrightarrow> A!a \<le> n-2"
shows "(\<Sum>a<n. A!a) \<le> (n-1)*(n-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
have "(\<Sum>a<n. A!a) = (\<Sum>a \<in> ({<n}-{a'}) \<union> {a'}. A!a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) A) {..<n} = sum ((!) A) ({<n} - {a'} \<union> {a'})
[PROOF STEP]
by (simp add: assms(1) atLeast0LessThan insert_absorb)
[PROOF STATE]
proof (state)
this:
sum ((!) A) {..<n} = sum ((!) A) ({<n} - {a'} \<union> {a'})

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((!) A) {..<n} = sum ((!) A) ({<n} - {a'} \<union> {a'})

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
have "\<dots> =(\<Sum>a \<in> {<n}-{a'}. A!a) + A!a'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) A) ({<n} - {a'} \<union> {a'}) = sum ((!) A) ({<n} - {a'}) + A ! a'
[PROOF STEP]
by (simp add: sum.insert_remove)
[PROOF STATE]
proof (state)
this:
sum ((!) A) ({<n} - {a'} \<union> {a'}) = sum ((!) A) ({<n} - {a'}) + A ! a'

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((!) A) ({<n} - {a'} \<union> {a'}) = sum ((!) A) ({<n} - {a'}) + A ! a'

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
have "\<dots> \<le> (\<Sum>a \<in> {<n}-{a'}. A!a) + (n-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) A) ({<n} - {a'}) + A ! a' \<le> sum ((!) A) ({<n} - {a'}) + (n - 1)
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
A ! a' \<le> n - 1

goal (1 subgoal):
 1. sum ((!) A) ({<n} - {a'}) + A ! a' \<le> sum ((!) A) ({<n} - {a'}) + (n - 1)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
sum ((!) A) ({<n} - {a'}) + A ! a' \<le> sum ((!) A) ({<n} - {a'}) + (n - 1)

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((!) A) ({<n} - {a'}) + A ! a' \<le> sum ((!) A) ({<n} - {a'}) + (n - 1)

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
have "\<dots> \<le> (n-1)*(n-2) + (n-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((!) A) ({<n} - {a'}) + (n - 1) \<le> (n - 1) * (n - 2) + (n - 1)
[PROOF STEP]
using sum_bounded_above[of "{..<n}-{a'}" "((!) A)" "n-2"] assms(1,3)
[PROOF STATE]
proof (prove)
using this:
(\<And>i. i \<in> {..<n} - {a'} \<Longrightarrow> A ! i \<le> n - 2) \<Longrightarrow> sum ((!) A) ({..<n} - {a'}) \<le> of_nat (card ({..<n} - {a'})) * (n - 2)
a' < n
\<forall>a<n. a \<noteq> a' \<longrightarrow> A ! a \<le> n - 2

goal (1 subgoal):
 1. sum ((!) A) ({<n} - {a'}) + (n - 1) \<le> (n - 1) * (n - 2) + (n - 1)
[PROOF STEP]
by (simp add: atLeast0LessThan)
[PROOF STATE]
proof (state)
this:
sum ((!) A) ({<n} - {a'}) + (n - 1) \<le> (n - 1) * (n - 2) + (n - 1)

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((!) A) ({<n} - {a'}) + (n - 1) \<le> (n - 1) * (n - 2) + (n - 1)

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
have "\<dots> = (n-1)*(n-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n - 1) * (n - 2) + (n - 1) = (n - 1) * (n - 1)
[PROOF STEP]
by (metis Suc_diff_Suc Suc_eq_plus1 add.commute diff_is_0_eq' linorder_not_le mult_Suc_right mult_cancel_left nat_1_add_1)
[PROOF STATE]
proof (state)
this:
(n - 1) * (n - 2) + (n - 1) = (n - 1) * (n - 1)

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)

goal (1 subgoal):
 1. sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sum ((!) A) {..<n} \<le> (n - 1) * (n - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma incratseq_0_gt [simp]: "x - 1 < of_rat(incratseq x 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x - 1 < real_of_rat (incratseq x 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x - 1 < real_of_rat (incratseq x 0)
[PROOF STEP]
have "x - 1 < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x - 1 < x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x - 1 < x

goal (1 subgoal):
 1. x - 1 < real_of_rat (incratseq x 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x - 1 < x
[PROOF STEP]
have "\<exists>q. x - 1 < real_of_rat q \<and> real_of_rat q < x"
[PROOF STATE]
proof (prove)
using this:
x - 1 < x

goal (1 subgoal):
 1. \<exists>q. x - 1 < real_of_rat q \<and> real_of_rat q < x
[PROOF STEP]
using of_rat_dense
[PROOF STATE]
proof (prove)
using this:
x - 1 < x
?x < ?y \<Longrightarrow> \<exists>q. ?x < real_of_rat q \<and> real_of_rat q < ?y

goal (1 subgoal):
 1. \<exists>q. x - 1 < real_of_rat q \<and> real_of_rat q < x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>q. x - 1 < real_of_rat q \<and> real_of_rat q < x

goal (1 subgoal):
 1. x - 1 < real_of_rat (incratseq x 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>q. x - 1 < real_of_rat q \<and> real_of_rat q < x
[PROOF STEP]
obtain q where " x - 1 < real_of_rat q \<and> real_of_rat q < x"
[PROOF STATE]
proof (prove)
using this:
\<exists>q. x - 1 < real_of_rat q \<and> real_of_rat q < x

goal (1 subgoal):
 1. (\<And>q. x - 1 < real_of_rat q \<and> real_of_rat q < x \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
x - 1 < real_of_rat q \<and> real_of_rat q < x

goal (1 subgoal):
 1. x - 1 < real_of_rat (incratseq x 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x - 1 < real_of_rat q \<and> real_of_rat q < x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x - 1 < real_of_rat q \<and> real_of_rat q < x

goal (1 subgoal):
 1. x - 1 < real_of_rat (incratseq x 0)
[PROOF STEP]
by (auto intro: someI2)
[PROOF STATE]
proof (state)
this:
x - 1 < real_of_rat (incratseq x 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma choose_mult_lemma:
  "((m + r + k) choose (m + k)) * ((m + k) choose k) = ((m + r + k) choose k) * ((m + r) choose m)"
  (is "?lhs = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
have "?lhs =
      fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m))
[PROOF STEP]
by (simp add: binomial_altdef_nat)
[PROOF STATE]
proof (state)
this:
(m + r + k choose (m + k)) * (m + k choose k) = fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(m + r + k choose (m + k)) * (m + k choose k) = fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
have "... = fact (m + r + k) * fact (m + k) div
                 (fact (m + k) * fact (m + r - m) * (fact k * fact m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m)) = fact (m + r + k) * fact (m + k) div (fact (m + k) * fact (m + r - m) * (fact k * fact m))
[PROOF STEP]
by (metis add_implies_diff add_le_mono1 choose_dvd diff_cancel2 div_mult_div_if_dvd le_add1 le_add2)
[PROOF STATE]
proof (state)
this:
fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m)) = fact (m + r + k) * fact (m + k) div (fact (m + k) * fact (m + r - m) * (fact k * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fact (m + r + k) div (fact (m + k) * fact (m + r - m)) * (fact (m + k) div (fact k * fact m)) = fact (m + r + k) * fact (m + k) div (fact (m + k) * fact (m + r - m) * (fact k * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
have "\<dots> = fact (m + r + k) div (fact r * (fact k * fact m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact (m + r + k) * fact (m + k) div (fact (m + k) * fact (m + r - m) * (fact k * fact m)) = fact (m + r + k) div (fact r * (fact k * fact m))
[PROOF STEP]
by (auto simp: algebra_simps fact_fact_dvd_fact)
[PROOF STATE]
proof (state)
this:
fact (m + r + k) * fact (m + k) div (fact (m + k) * fact (m + r - m) * (fact k * fact m)) = fact (m + r + k) div (fact r * (fact k * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fact (m + r + k) * fact (m + k) div (fact (m + k) * fact (m + r - m) * (fact k * fact m)) = fact (m + r + k) div (fact r * (fact k * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
have "\<dots> = (fact (m + r + k) * fact (m + r)) div (fact r * (fact k * fact m) * fact (m + r))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact (m + r + k) div (fact r * (fact k * fact m)) = fact (m + r + k) * fact (m + r) div (fact r * (fact k * fact m) * fact (m + r))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
fact (m + r + k) div (fact r * (fact k * fact m)) = fact (m + r + k) * fact (m + r) div (fact r * (fact k * fact m) * fact (m + r))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
fact (m + r + k) div (fact r * (fact k * fact m)) = fact (m + r + k) * fact (m + r) div (fact r * (fact k * fact m) * fact (m + r))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
have "\<dots> =
      (fact (m + r + k) div (fact k * fact (m + r)) * (fact (m + r) div (fact r * fact m)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fact (m + r + k) * fact (m + r) div (fact r * (fact k * fact m) * fact (m + r)) = fact (m + r + k) div (fact k * fact (m + r)) * (fact (m + r) div (fact r * fact m))
[PROOF STEP]
by (auto simp: div_mult_div_if_dvd fact_fact_dvd_fact algebra_simps)
[PROOF STATE]
proof (state)
this:
fact (m + r + k) * fact (m + r) div (fact r * (fact k * fact m) * fact (m + r)) = fact (m + r + k) div (fact k * fact (m + r)) * (fact (m + r) div (fact r * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(m + r + k choose (m + k)) * (m + k choose k) = fact (m + r + k) div (fact k * fact (m + r)) * (fact (m + r) div (fact r * fact m))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(m + r + k choose (m + k)) * (m + k choose k) = fact (m + r + k) div (fact k * fact (m + r)) * (fact (m + r) div (fact r * fact m))

goal (1 subgoal):
 1. (m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)
[PROOF STEP]
by (simp add: binomial_altdef_nat mult.commute)
[PROOF STATE]
proof (state)
this:
(m + r + k choose (m + k)) * (m + k choose k) = (m + r + k choose k) * (m + r choose m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma LIMSEQ_inverse_real_of_nat: "(\<lambda>n. inverse (real (Suc n))) \<longlonglongrightarrow> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. inverse (real (Suc n))) \<longlonglongrightarrow> 0
[PROOF STEP]
by (metis filterlim_compose tendsto_inverse_0 filterlim_mono order_refl filterlim_Suc
      filterlim_compose[OF filterlim_real_sequentially] at_top_le_at_infinity)


[STATEMENT]
lemma inv_BijGroup:
     "f \<in> Bij S \<Longrightarrow> m_inv (BijGroup S) f = (\<lambda>x \<in> S. (inv_into S f) x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> Bij S \<Longrightarrow> inv\<^bsub>BijGroup S\<^esub> f = restrict (inv_into S f) S
[PROOF STEP]
apply (rule group.inv_equality [OF group_BijGroup])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. f \<in> Bij S \<Longrightarrow> restrict (inv_into S f) S \<otimes>\<^bsub>BijGroup S\<^esub> f = \<one>\<^bsub>BijGroup S\<^esub>
 2. f \<in> Bij S \<Longrightarrow> f \<in> carrier (BijGroup S)
 3. f \<in> Bij S \<Longrightarrow> restrict (inv_into S f) S \<in> carrier (BijGroup S)
[PROOF STEP]
apply (simp_all add:BijGroup_def restrict_inv_into_Bij Bij_compose_restrict_eq)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma pcr_fset_cr_fset:
  "pcr_fset cr_fset = (\<lambda> x y. x = fset (fset |`| y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pcr_fset cr_fset = (\<lambda>x y. x = fset (fset |`| y))
[PROOF STEP]
unfolding pcr_fset_def rel_set_cr_fset
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>A B. A = fset ` B) OO cr_fset = (\<lambda>x y. x = fset (fset |`| y))
[PROOF STEP]
unfolding cr_fset_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>A B. A = fset ` B) OO (\<lambda>x y. x = fset y) = (\<lambda>x y. x = fset (fset |`| y))
[PROOF STEP]
by (auto simp: image_def relcompp_apply)


[STATEMENT]
lemma sdrop_stl: "sdrop n (stl s) = stl (sdrop n s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sdrop n (stl s) = stl (sdrop n s)
[PROOF STEP]
by (induct n) auto


[STATEMENT]
lemma "(\<forall>x. P(x) \<and> (Q(x)\<or>R(x))\<longrightarrow>S(x)) \<and>
        (\<forall>x. S(x) \<and> R(x) \<longrightarrow> L(x)) \<and>
        (\<forall>x. M(x) \<longrightarrow> R(x))
    \<longrightarrow> (\<forall>x. P(x) \<and> M(x) \<longrightarrow> L(x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x. P x \<and> (Q x \<or> R x) \<longrightarrow> S x) \<and> (\<forall>x. S x \<and> R x \<longrightarrow> L x) \<and> (\<forall>x. M x \<longrightarrow> R x) \<longrightarrow> (\<forall>x. P x \<and> M x \<longrightarrow> L x)
[PROOF STEP]
by blast


[STATEMENT]
lemma numeral_eq_eSuc: "numeral k = eSuc (epred_numeral k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. numeral k = eSuc (epred_numeral k)
[PROOF STEP]
by(simp add: numeral_eq_Suc eSuc_def epred_numeral_def numeral_eq_enat)