[STATEMENT]
theorem "\<forall>(x::int). 2 dvd x \<longleftrightarrow> (\<exists>(y::int). x = 2*y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. even x = (\<exists>y. x = 2 * y)
[PROOF STEP]
by cooper


[STATEMENT]
lemma nat_int1: "\<forall>(w::nat) (u::int).u>0 \<Longrightarrow> (w mod nat u = 2 mod nat u \<Longrightarrow> int w mod u = 2 mod u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>w u. 0 < u; w mod nat u = 2 mod nat u\<rbrakk> \<Longrightarrow> int w mod u = 2 mod u
[PROOF STEP]
by blast


[STATEMENT]
lemma derivation_times_eq_zeroI: "X (f * g) = 0" if X:"X \<in> tangent_space p"
  and d: "f \<in> diff_fun_space" "g \<in> diff_fun_space"
  and z: "f p = 0" "g p = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. X (f * g) = 0
[PROOF STEP]
using tangent_space_derivation[OF X d]
[PROOF STATE]
proof (prove)
using this:
X (f * g) = f p * X g + g p * X f

goal (1 subgoal):
 1. X (f * g) = 0
[PROOF STEP]
by (simp add: z)


[STATEMENT]
lemma supp_of_subset:
  fixes G::"('a::fs set)"
  assumes "finite G" and "finite G'" and "G \<subseteq> G'"
  shows "supp G \<subseteq> supp G'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. supp G \<subseteq> supp G'
[PROOF STEP]
using supp_of_finite_sets assms
[PROOF STATE]
proof (prove)
using this:
finite ?S \<Longrightarrow> supp ?S = \<Union> (supp ` ?S)
finite G
finite G'
G \<subseteq> G'

goal (1 subgoal):
 1. supp G \<subseteq> supp G'
[PROOF STEP]
by (metis subset_Un_eq supp_of_finite_union)


[STATEMENT]
lemma fls_pow_subdegree_eqI:
  "(f $$ fls_subdegree f) ^ n \<noteq> 0 \<Longrightarrow> fls_subdegree (f^n) = n * fls_subdegree f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f $$ fls_subdegree f) ^ n \<noteq> (0::'a) \<Longrightarrow> fls_subdegree (f ^ n) = int n * fls_subdegree f
[PROOF STEP]
using fls_pow_nth_below_subdegree
[PROOF STATE]
proof (prove)
using this:
?k < int ?n * fls_subdegree ?f \<Longrightarrow> ?f ^ ?n $$ ?k = (0::?'a)

goal (1 subgoal):
 1. (f $$ fls_subdegree f) ^ n \<noteq> (0::'a) \<Longrightarrow> fls_subdegree (f ^ n) = int n * fls_subdegree f
[PROOF STEP]
by (fastforce intro: fls_subdegree_eqI)


[STATEMENT]
lemma inverts_mat_symm:
  fixes A B :: "'a::field mat"
  assumes dim: "A \<in> carrier_mat n n" "B \<in> carrier_mat n n"
    and AB: "inverts_mat A B"
  shows "inverts_mat B A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverts_mat B A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inverts_mat B A
[PROOF STEP]
have "A * B = 1\<^sub>m n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A * B = 1\<^sub>m n
[PROOF STEP]
using dim AB
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n
inverts_mat A B

goal (1 subgoal):
 1. A * B = 1\<^sub>m n
[PROOF STEP]
unfolding inverts_mat_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n
A * B = 1\<^sub>m (dim_row A)

goal (1 subgoal):
 1. A * B = 1\<^sub>m n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A * B = 1\<^sub>m n

goal (1 subgoal):
 1. inverts_mat B A
[PROOF STEP]
with dim
[PROOF STATE]
proof (chain)
picking this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n
A * B = 1\<^sub>m n
[PROOF STEP]
have "B * A = 1\<^sub>m n"
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
B \<in> carrier_mat n n
A * B = 1\<^sub>m n

goal (1 subgoal):
 1. B * A = 1\<^sub>m n
[PROOF STEP]
by (rule mat_mult_left_right_inverse)
[PROOF STATE]
proof (state)
this:
B * A = 1\<^sub>m n

goal (1 subgoal):
 1. inverts_mat B A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
B * A = 1\<^sub>m n
[PROOF STEP]
show "inverts_mat B A"
[PROOF STATE]
proof (prove)
using this:
B * A = 1\<^sub>m n

goal (1 subgoal):
 1. inverts_mat B A
[PROOF STEP]
using dim inverts_mat_def
[PROOF STATE]
proof (prove)
using this:
B * A = 1\<^sub>m n
A \<in> carrier_mat n n
B \<in> carrier_mat n n
inverts_mat ?A ?B \<equiv> ?A * ?B = 1\<^sub>m (dim_row ?A)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in aGroup) nsumElmTail:
  "\<forall>i. f i \<in> carrier A
        \<Longrightarrow> nsum A f (Suc n) = (nsum A (\<lambda> i. (f (Suc i))) n) \<plusminus> (f 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. f i \<in> carrier A \<Longrightarrow> \<Sigma>\<^sub>e A f Suc n = \<Sigma>\<^sub>e A (\<lambda>i. f (Suc i)) n \<plusminus> f 0
[PROOF STEP]
apply (cut_tac n = n and f = f in nsumTail,
         rule allI, simp, simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma L2_set_infinite [simp]: "\<not> finite A \<Longrightarrow> L2_set f A = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite A \<Longrightarrow> L2_set f A = 0
[PROOF STEP]
unfolding L2_set_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite A \<Longrightarrow> sqrt (\<Sum>i\<in>A. (f i)\<^sup>2) = 0
[PROOF STEP]
by simp


[STATEMENT]
lemma ennreal_0[simp]: "ennreal 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennreal 0 = 0
[PROOF STEP]
by (simp add: ennreal_def max.absorb1 zero_ennreal.abs_eq)


[STATEMENT]
lemma partition3_code [code]:
  "partition3 x [] = ([], [], [])"
  "partition3 x (y # ys) =
     (case partition3 x ys of (ls, es, gs) \<Rightarrow>
        if y < x then (y # ls, es, gs) else if x = y then (ls, y # es, gs) else (ls, es, y # gs))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. partition3 x [] = ([], [], []) &&& partition3 x (y # ys) = (case partition3 x ys of (ls, es, gs) \<Rightarrow> if y < x then (y # ls, es, gs) else if x = y then (ls, y # es, gs) else (ls, es, y # gs))
[PROOF STEP]
by (auto simp: partition3_def)


[STATEMENT]
lemma uwellformed_alt_fst:
  assumes "uwellformed G" "{x, y} \<in> uedges G"
  shows "x \<in> uverts G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> uverts G
[PROOF STEP]
using uwellformed_def assms
[PROOF STATE]
proof (prove)
using this:
uwellformed ?G \<equiv> \<forall>e\<in>uedges ?G. card e = 2 \<and> (\<forall>u\<in>e. u \<in> uverts ?G)
uwellformed G
{x, y} \<in> uedges G

goal (1 subgoal):
 1. x \<in> uverts G
[PROOF STEP]
by simp


[STATEMENT]
lemma finite_countable_subset:
"finite {X. X \<subseteq> A \<and> countable X} \<longleftrightarrow> finite A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {X. X \<subseteq> A \<and> countable X} = finite A
[PROOF STEP]
apply (rule iffI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. finite {X. X \<subseteq> A \<and> countable X} \<Longrightarrow> finite A
 2. finite A \<Longrightarrow> finite {X. X \<subseteq> A \<and> countable X}
[PROOF STEP]
apply (erule contrapos_pp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. infinite A \<Longrightarrow> infinite {X. X \<subseteq> A \<and> countable X}
 2. finite A \<Longrightarrow> finite {X. X \<subseteq> A \<and> countable X}
[PROOF STEP]
apply (rule card_of_ordLeq_infinite)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. infinite A \<Longrightarrow> ordLeq3 (card_of ?A5) (card_of {X. X \<subseteq> A \<and> countable X})
 2. infinite A \<Longrightarrow> infinite ?A5
 3. finite A \<Longrightarrow> finite {X. X \<subseteq> A \<and> countable X}
[PROOF STEP]
apply (rule ordLeq_countable_subsets)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. infinite A \<Longrightarrow> infinite A
 2. finite A \<Longrightarrow> finite {X. X \<subseteq> A \<and> countable X}
[PROOF STEP]
apply assumption
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> finite {X. X \<subseteq> A \<and> countable X}
[PROOF STEP]
apply (rule finite_Collect_conjI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> finite {X. X \<subseteq> A} \<or> finite {X. countable X}
[PROOF STEP]
apply (rule disjI1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> finite {X. X \<subseteq> A}
[PROOF STEP]
apply (erule finite_Collect_subsets)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sum_moebius_mu_aux2: "((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top
[PROOF STEP]
have "(\<lambda>x. M x / x - H x / (x * ln x)) \<in> O(\<lambda>x. 1 / ln x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. M x / x - H x / (x * ln x)) \<in> O(\<lambda>x. 1 / ln x)
[PROOF STEP]
by (rule sum_moebius_mu_aux1)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. M x / x - H x / (x * ln x)) \<in> O(\<lambda>x. 1 / ln x)

goal (1 subgoal):
 1. ((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>x. M x / x - H x / (x * ln x)) \<in> O(\<lambda>x. 1 / ln x)

goal (1 subgoal):
 1. ((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top
[PROOF STEP]
have "(\<lambda>x. 1 / ln x) \<in> o(\<lambda>_. 1 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. 1 / ln x) \<in> o(\<lambda>_. 1)
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. 1 / ln x) \<in> o(\<lambda>_. 1)

goal (1 subgoal):
 1. ((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. M x / x - H x / (x * ln x)) \<in> o(\<lambda>_. 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. M x / x - H x / (x * ln x)) \<in> o(\<lambda>_. 1)

goal (1 subgoal):
 1. ((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top
[PROOF STEP]
by (auto dest!: smalloD_tendsto)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. M x / x - H x / (x * ln x)) \<longlongrightarrow> 0) at_top

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma take_Suc:
  "\<forall>n. n < length l \<longrightarrow> take (Suc n) l = (take n l)@[l!n]" (is "?P l")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<length l. take (Suc n) l = take n l @ [l ! n]
[PROOF STEP]
proof (induct l)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>n<length []. take (Suc n) [] = take n [] @ [[] ! n]
 2. \<And>a l. \<forall>n<length l. take (Suc n) l = take n l @ [l ! n] \<Longrightarrow> \<forall>n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]
[PROOF STEP]
show "?P []"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<length []. take (Suc n) [] = take n [] @ [[] ! n]
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>n<length []. take (Suc n) [] = take n [] @ [[] ! n]

goal (1 subgoal):
 1. \<And>a l. \<forall>n<length l. take (Suc n) l = take n l @ [l ! n] \<Longrightarrow> \<forall>n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a l. \<forall>n<length l. take (Suc n) l = take n l @ [l ! n] \<Longrightarrow> \<forall>n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]
[PROOF STEP]
fix x xs
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a l. \<forall>n<length l. take (Suc n) l = take n l @ [l ! n] \<Longrightarrow> \<forall>n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]
[PROOF STEP]
assume IH: "?P xs"
[PROOF STATE]
proof (state)
this:
\<forall>n<length xs. take (Suc n) xs = take n xs @ [xs ! n]

goal (1 subgoal):
 1. \<And>a l. \<forall>n<length l. take (Suc n) l = take n l @ [l ! n] \<Longrightarrow> \<forall>n<length (a # l). take (Suc n) (a # l) = take n (a # l) @ [(a # l) ! n]
[PROOF STEP]
show "?P (x#xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>n<length (x # xs). take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]
[PROOF STEP]
proof (intro strip)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. n < length (x # xs) \<Longrightarrow> take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. n < length (x # xs) \<Longrightarrow> take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]
[PROOF STEP]
assume "n < length (x#xs)"
[PROOF STATE]
proof (state)
this:
n < length (x # xs)

goal (1 subgoal):
 1. \<And>n. n < length (x # xs) \<Longrightarrow> take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]
[PROOF STEP]
with IH
[PROOF STATE]
proof (chain)
picking this:
\<forall>n<length xs. take (Suc n) xs = take n xs @ [xs ! n]
n < length (x # xs)
[PROOF STEP]
show "take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]"
[PROOF STATE]
proof (prove)
using this:
\<forall>n<length xs. take (Suc n) xs = take n xs @ [xs ! n]
n < length (x # xs)

goal (1 subgoal):
 1. take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]
[PROOF STEP]
by (cases n, auto)
[PROOF STATE]
proof (state)
this:
take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>n<length (x # xs). take (Suc n) (x # xs) = take n (x # xs) @ [(x # xs) ! n]

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma remove_nth_take_drop:
  "remove_nth i xs = take i xs @ drop (Suc i) xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. remove_nth i xs = take i xs @ drop (Suc i) xs
[PROOF STEP]
proof (induct xs arbitrary: i)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. remove_nth i [] = take i [] @ drop (Suc i) []
 2. \<And>a xs i. (\<And>i. remove_nth i xs = take i xs @ drop (Suc i) xs) \<Longrightarrow> remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>i. remove_nth i [] = take i [] @ drop (Suc i) []
 2. \<And>a xs i. (\<And>i. remove_nth i xs = take i xs @ drop (Suc i) xs) \<Longrightarrow> remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. remove_nth i [] = take i [] @ drop (Suc i) []
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
remove_nth i [] = take i [] @ drop (Suc i) []

goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. remove_nth i xs = take i xs @ drop (Suc i) xs) \<Longrightarrow> remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. remove_nth i xs = take i xs @ drop (Suc i) xs) \<Longrightarrow> remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)
[PROOF STEP]
case (Cons a xs)
[PROOF STATE]
proof (state)
this:
remove_nth ?i xs = take ?i xs @ drop (Suc ?i) xs

goal (1 subgoal):
 1. \<And>a xs i. (\<And>i. remove_nth i xs = take i xs @ drop (Suc i) xs) \<Longrightarrow> remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
remove_nth ?i xs = take ?i xs @ drop (Suc ?i) xs
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
remove_nth ?i xs = take ?i xs @ drop (Suc ?i) xs

goal (1 subgoal):
 1. remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)
[PROOF STEP]
by (cases i) auto
[PROOF STATE]
proof (state)
this:
remove_nth i (a # xs) = take i (a # xs) @ drop (Suc i) (a # xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma poly_zero:
  fixes p :: "'a :: comm_ring_1 poly"
  assumes x: "poly p x = 0" shows "p = 0 \<longleftrightarrow> degree p = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p = 0) = (degree p = 0)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<Longrightarrow> degree p = 0
 2. degree p = 0 \<Longrightarrow> p = 0
[PROOF STEP]
assume degp: "degree p = 0"
[PROOF STATE]
proof (state)
this:
degree p = 0

goal (2 subgoals):
 1. p = 0 \<Longrightarrow> degree p = 0
 2. degree p = 0 \<Longrightarrow> p = 0
[PROOF STEP]
hence "poly p x = coeff p (degree p)"
[PROOF STATE]
proof (prove)
using this:
degree p = 0

goal (1 subgoal):
 1. poly p x = lead_coeff p
[PROOF STEP]
by(subst degree_0_id[OF degp,symmetric], simp)
[PROOF STATE]
proof (state)
this:
poly p x = lead_coeff p

goal (2 subgoals):
 1. p = 0 \<Longrightarrow> degree p = 0
 2. degree p = 0 \<Longrightarrow> p = 0
[PROOF STEP]
hence "coeff p (degree p) = 0"
[PROOF STATE]
proof (prove)
using this:
poly p x = lead_coeff p

goal (1 subgoal):
 1. lead_coeff p = (0::'a)
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
poly p x = lead_coeff p
poly p x = (0::'a)

goal (1 subgoal):
 1. lead_coeff p = (0::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lead_coeff p = (0::'a)

goal (2 subgoals):
 1. p = 0 \<Longrightarrow> degree p = 0
 2. degree p = 0 \<Longrightarrow> p = 0
[PROOF STEP]
thus "p = 0"
[PROOF STATE]
proof (prove)
using this:
lead_coeff p = (0::'a)

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

goal (1 subgoal):
 1. p = 0 \<Longrightarrow> degree p = 0
[PROOF STEP]
qed auto


[STATEMENT]
lemma dim_tangent_space_src_dest_eq2: "dim (src.tangent_space p) = dim (dest.tangent_space (f p))"
  if p: "p \<in> src.carrier" and "dim (src.tangent_space p) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim (src.tangent_space p) = dim (dest.tangent_space (f p))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dim (src.tangent_space p) = dim (dest.tangent_space (f p))
[PROOF STEP]
interpret rev: diffeomorphism k charts2 charts1 f' f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Differentiable_Manifold.diffeomorphism k charts2 charts1 f' f
[PROOF STEP]
by unfold_locales auto
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dim (src.tangent_space p) = dim (dest.tangent_space (f p))
[PROOF STEP]
from that rev.dim_tangent_space_src_dest_eq[of "f p"]
[PROOF STATE]
proof (chain)
picking this:
p \<in> src.carrier
0 < dim (src.tangent_space p)
\<lbrakk>f p \<in> dest.carrier; 0 < dim (src.tangent_space (f' (f p)))\<rbrakk> \<Longrightarrow> dim (dest.tangent_space (f p)) = dim (src.tangent_space (f' (f p)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p \<in> src.carrier
0 < dim (src.tangent_space p)
\<lbrakk>f p \<in> dest.carrier; 0 < dim (src.tangent_space (f' (f p)))\<rbrakk> \<Longrightarrow> dim (dest.tangent_space (f p)) = dim (src.tangent_space (f' (f p)))

goal (1 subgoal):
 1. dim (src.tangent_space p) = dim (dest.tangent_space (f p))
[PROOF STEP]
by auto (metis contra_subsetD defined image_eqI)
[PROOF STATE]
proof (state)
this:
dim (src.tangent_space p) = dim (dest.tangent_space (f p))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma UNIV_word_eq_word_of_nat:
  \<open>(UNIV :: 'a::len word set) = word_of_nat ` {0..<2 ^ LENGTH('a)}\<close> (is \<open>_ = ?A\<close>)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV = word_of_nat ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. UNIV \<subseteq> word_of_nat ` {0..<2 ^ LENGTH('a)}
 2. word_of_nat ` {0..<2 ^ LENGTH('a)} \<subseteq> UNIV
[PROOF STEP]
show \<open>word_of_nat ` {0..<2 ^ LENGTH('a)} \<subseteq> UNIV\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. word_of_nat ` {0..<2 ^ LENGTH('a)} \<subseteq> UNIV
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
word_of_nat ` {0..<2 ^ LENGTH('a)} \<subseteq> UNIV

goal (1 subgoal):
 1. UNIV \<subseteq> word_of_nat ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
show \<open>UNIV \<subseteq> ?A\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. UNIV \<subseteq> word_of_nat ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> UNIV \<Longrightarrow> x \<in> word_of_nat ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
fix w :: \<open>'a word\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> UNIV \<Longrightarrow> x \<in> word_of_nat ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
show \<open>w \<in> (word_of_nat ` {0..<2 ^ LENGTH('a)} :: 'a word set)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. w \<in> word_of_nat ` {0..<2 ^ LENGTH('a)}
[PROOF STEP]
by (rule image_eqI [of _ _ \<open>unat w\<close>]; transfer) simp_all
[PROOF STATE]
proof (state)
this:
w \<in> word_of_nat ` {0..<2 ^ LENGTH('a)}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
UNIV \<subseteq> word_of_nat ` {0..<2 ^ LENGTH('a)}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_nat_in_ball:
  fixes x :: nat
  fixes q :: real
  assumes "q \<ge> 0"
  defines "A \<equiv> {k. abs (real x - real k) \<le> q \<and> k \<noteq> x}"
  shows "real (card A) \<le> 2 * q" and "finite A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (card A) \<le> 2 * q &&& finite A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have a: "of_nat x \<in> {\<lceil>real x-q\<rceil>..\<lfloor>real x+q\<rfloor>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int x \<in> {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> q
A \<equiv> {k. \<bar>real x - real k\<bar> \<le> q \<and> k \<noteq> x}

goal (1 subgoal):
 1. int x \<in> {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}
[PROOF STEP]
by (simp add: ceiling_le_iff)
[PROOF STATE]
proof (state)
this:
int x \<in> {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have "card A = card (int ` A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card A = card (int ` A)
[PROOF STEP]
by (rule card_image[symmetric], simp)
[PROOF STATE]
proof (state)
this:
card A = card (int ` A)

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card A = card (int ` A)

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have "... \<le> card ({\<lceil>real x-q\<rceil>..\<lfloor>real x+q\<rfloor>} - {of_nat x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (int ` A) \<le> card ({\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - {int x})
[PROOF STEP]
by (intro card_mono image_subsetI, simp_all add:A_def abs_le_iff, linarith)
[PROOF STATE]
proof (state)
this:
card (int ` A) \<le> card ({\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - {int x})

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (int ` A) \<le> card ({\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - {int x})

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have "... = card {\<lceil>real x-q\<rceil>..\<lfloor>real x+q\<rfloor>} - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - {int x}) = card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - 1
[PROOF STEP]
by (rule card_Diff_singleton, rule a)
[PROOF STATE]
proof (state)
this:
card ({\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - {int x}) = card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - 1

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - {int x}) = card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - 1

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have "... = int (card {\<lceil>real x-q\<rceil>..\<lfloor>real x+q\<rfloor>}) - int 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - 1) = int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1
[PROOF STEP]
by (intro of_nat_diff)
     (metis a card_0_eq empty_iff finite_atLeastAtMost_int less_one linorder_not_le)
[PROOF STATE]
proof (state)
this:
int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - 1) = int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>} - 1) = int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have "... \<le> \<lfloor>q+real x\<rfloor>+1 -\<lceil>real x-q\<rceil> - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1 \<le> \<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 \<le> q
A \<equiv> {k. \<bar>real x - real k\<bar> \<le> q \<and> k \<noteq> x}

goal (1 subgoal):
 1. int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1 \<le> \<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1
[PROOF STEP]
by (simp, linarith)
[PROOF STATE]
proof (state)
this:
int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1 \<le> \<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1 \<le> \<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
have "... \<le> 2*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int (\<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1) \<le> 2 * q
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
real_of_int (\<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1) \<le> 2 * q

goal (2 subgoals):
 1. real (card A) \<le> 2 * q
 2. finite A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> int x \<le> int y; int (card A) \<in> UNIV; int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1 \<in> UNIV; \<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1 \<in> UNIV; \<And>x y. x \<le> y \<Longrightarrow> real_of_int x \<le> real_of_int y\<rbrakk> \<Longrightarrow> real_of_int (int (card A)) \<le> 2 * q
[PROOF STEP]
show "card A \<le> 2 * q"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x y. x \<le> y \<Longrightarrow> int x \<le> int y; int (card A) \<in> UNIV; int (card {\<lceil>real x - q\<rceil>..\<lfloor>real x + q\<rfloor>}) - int 1 \<in> UNIV; \<lfloor>q + real x\<rfloor> + 1 - \<lceil>real x - q\<rceil> - 1 \<in> UNIV; \<And>x y. x \<le> y \<Longrightarrow> real_of_int x \<le> real_of_int y\<rbrakk> \<Longrightarrow> real_of_int (int (card A)) \<le> 2 * q

goal (1 subgoal):
 1. real (card A) \<le> 2 * q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real (card A) \<le> 2 * q

goal (1 subgoal):
 1. finite A
[PROOF STEP]
have "A \<subseteq> {..x + nat \<lceil>q\<rceil>}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> {..x + nat \<lceil>q\<rceil>}
[PROOF STEP]
by (rule subsetI, simp add:A_def abs_le_iff, linarith)
[PROOF STATE]
proof (state)
this:
A \<subseteq> {..x + nat \<lceil>q\<rceil>}

goal (1 subgoal):
 1. finite A
[PROOF STEP]
thus "finite A"
[PROOF STATE]
proof (prove)
using this:
A \<subseteq> {..x + nat \<lceil>q\<rceil>}

goal (1 subgoal):
 1. finite A
[PROOF STEP]
by (rule finite_subset, simp)
[PROOF STATE]
proof (state)
this:
finite A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma size_gt_1: "1 < size f \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> f = finsert e1 (finsert e2 f')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < size f \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> f = finsert e1 (finsert e2 f')
[PROOF STEP]
apply (induct f)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. 1 < size {||} \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> {||} = finsert e1 (finsert e2 f')
 2. \<And>x f. \<lbrakk>x |\<notin>| f; 1 < size f \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> f = finsert e1 (finsert e2 f'); 1 < size (finsert x f)\<rbrakk> \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> finsert x f = finsert e1 (finsert e2 f')
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x f. \<lbrakk>x |\<notin>| f; 1 < size f \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> f = finsert e1 (finsert e2 f'); 1 < size (finsert x f)\<rbrakk> \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> finsert x f = finsert e1 (finsert e2 f')
[PROOF STEP]
apply (rule_tac x=x in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x f. \<lbrakk>x |\<notin>| f; 1 < size f \<Longrightarrow> \<exists>e1 e2 f'. e1 \<noteq> e2 \<and> f = finsert e1 (finsert e2 f'); 1 < size (finsert x f)\<rbrakk> \<Longrightarrow> \<exists>e2 f'. x \<noteq> e2 \<and> finsert x f = finsert x (finsert e2 f')
[PROOF STEP]
by (metis finsertCI leD not_le_imp_less size_le_1)


[STATEMENT]
lemma ln_2_le: "ln 2 \<le> 355 / (512 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln 2 \<le> 355 / 512
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ln 2 \<le> 355 / 512
[PROOF STEP]
have "ln 2 \<le> real_of_float (ub_ln2 12)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln 2 \<le> real_of_float (ub_ln2 12)
[PROOF STEP]
by (rule ub_ln2)
[PROOF STATE]
proof (state)
this:
ln 2 \<le> real_of_float (ub_ln2 12)

goal (1 subgoal):
 1. ln 2 \<le> 355 / 512
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ln 2 \<le> real_of_float (ub_ln2 12)

goal (1 subgoal):
 1. ln 2 \<le> 355 / 512
[PROOF STEP]
have "ub_ln2 12 = Float 5680 (- 13)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ub_ln2 12 = Float 5680 (- 13)
[PROOF STEP]
by code_simp
[PROOF STATE]
proof (state)
this:
ub_ln2 12 = Float 5680 (- 13)

goal (1 subgoal):
 1. ln 2 \<le> 355 / 512
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
ln 2 \<le> real_of_float (Float 5680 (- 13))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ln 2 \<le> real_of_float (Float 5680 (- 13))

goal (1 subgoal):
 1. ln 2 \<le> 355 / 512
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ln 2 \<le> 355 / 512

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ceiling_of_nat [simp]: "\<lceil>of_nat n\<rceil> = int n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>of_nat n\<rceil> = int n
[PROOF STEP]
using ceiling_of_int [of "of_nat n"]
[PROOF STATE]
proof (prove)
using this:
\<lceil>of_int (int n)\<rceil> = int n

goal (1 subgoal):
 1. \<lceil>of_nat n\<rceil> = int n
[PROOF STEP]
by simp


[STATEMENT]
lemma acyclic_path_length_limit :
  assumes "path M q p"
  and     "distinct (visited_states q p)"
shows "length p < size M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length p < FSM.size M
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
assume *: "\<not> length p < size M"
[PROOF STATE]
proof (state)
this:
\<not> length p < FSM.size M

goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> length p < FSM.size M
[PROOF STEP]
have "length p \<ge> card (states M)"
[PROOF STATE]
proof (prove)
using this:
\<not> length p < FSM.size M

goal (1 subgoal):
 1. card (FSM.states M) \<le> length p
[PROOF STEP]
using size_def
[PROOF STATE]
proof (prove)
using this:
\<not> length p < FSM.size M
FSM.size ?m = card (FSM.states ?m)

goal (1 subgoal):
 1. card (FSM.states M) \<le> length p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (FSM.states M) \<le> length p

goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (FSM.states M) \<le> length p
[PROOF STEP]
have "length (visited_states q p) > card (states M)"
[PROOF STATE]
proof (prove)
using this:
card (FSM.states M) \<le> length p

goal (1 subgoal):
 1. card (FSM.states M) < length (visited_states q p)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (FSM.states M) < length (visited_states q p)

goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card (FSM.states M) < length (visited_states q p)

goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
have "set (visited_states q p) \<subseteq> states M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (visited_states q p) \<subseteq> FSM.states M
[PROOF STEP]
by (metis assms(1) path_prefix path_target_is_state subsetI visited_states_prefix)
[PROOF STATE]
proof (state)
this:
set (visited_states q p) \<subseteq> FSM.states M

goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card (FSM.states M) < length (visited_states q p)
set (visited_states q p) \<subseteq> FSM.states M
[PROOF STEP]
have "\<not> distinct (visited_states q p)"
[PROOF STATE]
proof (prove)
using this:
card (FSM.states M) < length (visited_states q p)
set (visited_states q p) \<subseteq> FSM.states M

goal (1 subgoal):
 1. \<not> distinct (visited_states q p)
[PROOF STEP]
using distinct_card[OF assms(2)]
[PROOF STATE]
proof (prove)
using this:
card (FSM.states M) < length (visited_states q p)
set (visited_states q p) \<subseteq> FSM.states M
card (set (visited_states q p)) = length (visited_states q p)

goal (1 subgoal):
 1. \<not> distinct (visited_states q p)
[PROOF STEP]
using List.finite_set[of "visited_states q p"]
[PROOF STATE]
proof (prove)
using this:
card (FSM.states M) < length (visited_states q p)
set (visited_states q p) \<subseteq> FSM.states M
card (set (visited_states q p)) = length (visited_states q p)
finite (set (visited_states q p))

goal (1 subgoal):
 1. \<not> distinct (visited_states q p)
[PROOF STEP]
by (metis card_mono fsm_states_finite leD)
[PROOF STATE]
proof (state)
this:
\<not> distinct (visited_states q p)

goal (1 subgoal):
 1. \<not> length p < FSM.size M \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> distinct (visited_states q p)
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
\<not> distinct (visited_states q p)

goal (1 subgoal):
 1. False
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
\<not> distinct (visited_states q p)
distinct (visited_states q p)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem qs_cost_average_conv_rqs_cost:
  assumes "finite A" and "linorder_on B R" and "A \<subseteq> B"
  shows   "map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
using assms(1,3)
[PROOF STATE]
proof (prove)
using this:
finite A
A \<subseteq> B

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
proof (induction A rule: finite_psubset_induct)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>Ba. \<lbrakk>Ba \<subset> A; Ba \<subseteq> B\<rbrakk> \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set Ba)) = rqs_cost (card Ba); A \<subseteq> B\<rbrakk> \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
case (psubset A)
[PROOF STATE]
proof (state)
this:
finite A
\<lbrakk>?B \<subset> A; ?B \<subseteq> B\<rbrakk> \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set ?B)) = rqs_cost (card ?B)
A \<subseteq> B

goal (1 subgoal):
 1. \<And>A. \<lbrakk>finite A; \<And>Ba. \<lbrakk>Ba \<subset> A; Ba \<subseteq> B\<rbrakk> \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set Ba)) = rqs_cost (card Ba); A \<subseteq> B\<rbrakk> \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
proof (cases "A = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. A = {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
 2. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
A = {}

goal (2 subgoals):
 1. A = {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
 2. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
A = {}

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
by (simp add: pmf_of_set_singleton)
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
A \<noteq> {}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
note A = \<open>finite A\<close> \<open>A \<noteq> {}\<close>
[PROOF STATE]
proof (state)
this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
define n where "n = card A - 1"
[PROOF STATE]
proof (state)
this:
n = card A - 1

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
finite A
A \<noteq> {}
[PROOF STEP]
have "pmf_of_set (permutations_of_set A) =
      do {x \<leftarrow> pmf_of_set A; xs \<leftarrow> pmf_of_set (permutations_of_set (A - {x})); return_pmf (x#xs)}"
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. pmf_of_set (permutations_of_set A) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (x # xs)))
[PROOF STEP]
by (rule random_permutation_of_set)
[PROOF STATE]
proof (state)
this:
pmf_of_set (permutations_of_set A) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (x # xs)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set (permutations_of_set A) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (x # xs)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "map_pmf (qs_cost R) \<dots> =
                 do {
                   x \<leftarrow> pmf_of_set A;
                   xs \<leftarrow> pmf_of_set (permutations_of_set (A - {x}));
                   return_pmf (length xs + qs_cost R [y\<leftarrow>xs. (y,x)\<in>R] + qs_cost R [y\<leftarrow>xs. (y,x)\<notin>R])
                 }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs))))
[PROOF STEP]
by (simp add: map_bind_pmf)
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs))))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (x # xs)))) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs))))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "\<dots> = map_pmf (\<lambda>m. n + m) (
          do {
            x \<leftarrow> pmf_of_set A;
            xs \<leftarrow> pmf_of_set (permutations_of_set (A - {x}));
            return_pmf (qs_cost R [y\<leftarrow>xs. (y,x)\<in>R] + qs_cost R [y\<leftarrow>xs. (y,x)\<notin>R])
          })" (is "_ = map_pmf _ ?X")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = map_pmf ((+) n) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))))
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = map_pmf ((+) n) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))))
[PROOF STEP]
unfolding n_def map_bind_pmf
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xa. map_pmf ((+) (card A - 1)) (return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xa) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xa)))))
[PROOF STEP]
by (intro bind_pmf_cong map_pmf_cong refl) (auto simp: length_finite_permutations_of_set)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = map_pmf ((+) n) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (length xs + qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = map_pmf ((+) n) (pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "?X = do {
                      x \<leftarrow> pmf_of_set A;
                      (ls,rs) \<leftarrow> map_pmf (partition (\<lambda>y. (y,x)\<in>R))
                                   (pmf_of_set (permutations_of_set (A - {x})));
                      return_pmf (qs_cost R ls + qs_cost R rs)
                    }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)))
[PROOF STEP]
by (simp add: bind_map_pmf o_def)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pmf_of_set (permutations_of_set (A - {x})) \<bind> (\<lambda>xs. return_pmf (qs_cost R (filter (\<lambda>y. (y, x) \<in> R) xs) + qs_cost R (filter (\<lambda>y. (y, x) \<notin> R) xs)))) = pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "\<dots> = do {
                      x \<leftarrow> pmf_of_set A;
                      (n1, n2) \<leftarrow> pair_pmf
                        (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x));
                      return_pmf (n1 + n2)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs))) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))
[PROOF STEP]
proof (intro bind_pmf_cong refl, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
case (1 x)
[PROOF STATE]
proof (state)
this:
x \<in> set_pmf (pmf_of_set A)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "map_pmf (partition (\<lambda>y. (y,x)\<in>R)) (pmf_of_set (permutations_of_set (A - {x})))
              \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) =
            map_pmf (\<lambda>(n1, n2). n1 + n2) (pair_pmf
              (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})))
              (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R}))))"
        (is "_ = map_pmf _ (pair_pmf ?X ?Y)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = map_pmf (\<lambda>(n1, n2). n1 + n2) (pair_pmf (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R}))) (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R}))))
[PROOF STEP]
by (subst partition_random_permutations)
           (simp_all add: map_pmf_def case_prod_unfold bind_return_pmf bind_assoc_pmf pair_pmf_def A)
[PROOF STATE]
proof (state)
this:
map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = map_pmf (\<lambda>(n1, n2). n1 + n2) (pair_pmf (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R}))) (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R}))))

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = map_pmf (\<lambda>(n1, n2). n1 + n2) (pair_pmf (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R}))) (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R}))))

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = map_pmf (\<lambda>(n1, n2). n1 + n2) (pair_pmf (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R}))) (map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R}))))

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "{xa \<in> A - {x}. (xa, x) \<in> R} \<subseteq> A - {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xa \<in> A - {x}. (xa, x) \<in> R} \<subseteq> A - {x}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subseteq> A - {x}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subseteq> A - {x}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "\<dots> \<subset> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A - {x} \<subset> A
[PROOF STEP]
using 1 A
[PROOF STATE]
proof (prove)
using this:
x \<in> set_pmf (pmf_of_set A)
finite A
A \<noteq> {}

goal (1 subgoal):
 1. A - {x} \<subset> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A - {x} \<subset> A

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A
[PROOF STEP]
have subset: "{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A"
[PROOF STATE]
proof (prove)
using this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A

goal (1 subgoal):
 1. {xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "\<dots> \<subseteq> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> B
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
A \<subseteq> B

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> B
[PROOF STEP]
have "?X = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<in> R})"
[PROOF STATE]
proof (prove)
using this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> B

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<in> R})
[PROOF STEP]
using subset
[PROOF STATE]
proof (prove)
using this:
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> B
{xa \<in> A - {x}. (xa, x) \<in> R} \<subset> A

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<in> R})
[PROOF STEP]
by (intro psubset.IH) auto
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<in> R})

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<in> R})

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "card {xa \<in> A - {x}. (xa, x) \<in> R} = linorder_rank R A x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {xa \<in> A - {x}. (xa, x) \<in> R} = linorder_rank R A x
[PROOF STEP]
by (simp add: linorder_rank_def)
[PROOF STATE]
proof (state)
this:
card {xa \<in> A - {x}. (xa, x) \<in> R} = linorder_rank R A x

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)
[PROOF STEP]
have "?X = rqs_cost \<dots>"
[PROOF STATE]
proof (prove)
using this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<in> R})) = rqs_cost (linorder_rank R A x)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "{xa \<in> A - {x}. (xa, x) \<notin> R} \<subseteq> A - {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {xa \<in> A - {x}. (xa, x) \<notin> R} \<subseteq> A - {x}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subseteq> A - {x}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subseteq> A - {x}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "\<dots> \<subset> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A - {x} \<subset> A
[PROOF STEP]
using 1 A
[PROOF STATE]
proof (prove)
using this:
x \<in> set_pmf (pmf_of_set A)
finite A
A \<noteq> {}

goal (1 subgoal):
 1. A - {x} \<subset> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A - {x} \<subset> A

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A
[PROOF STEP]
have subset: "{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A"
[PROOF STATE]
proof (prove)
using this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A

goal (1 subgoal):
 1. {xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "\<dots> \<subseteq> B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<subseteq> B
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
this:
A \<subseteq> B

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> B
[PROOF STEP]
have "?Y = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<notin> R})"
[PROOF STATE]
proof (prove)
using this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> B

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<notin> R})
[PROOF STEP]
using subset
[PROOF STATE]
proof (prove)
using this:
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> B
{xa \<in> A - {x}. (xa, x) \<notin> R} \<subset> A

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<notin> R})
[PROOF STEP]
by (intro psubset.IH) auto
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<notin> R})

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<notin> R})

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (card {xa \<in> A - {x}. (xa, x) \<notin> R})

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "card ({y\<in>A-{x}. (y,x)\<in>R} \<union> {y\<in>A-{x}. (y,x)\<notin>R}) =
                  linorder_rank R A x + card {xa \<in> A - {x}. (xa, x) \<notin> R}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R}) = linorder_rank R A x + card {xa \<in> A - {x}. (xa, x) \<notin> R}
[PROOF STEP]
unfolding linorder_rank_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R}) = card {y \<in> A - {x}. (y, x) \<in> R} + card {xa \<in> A - {x}. (xa, x) \<notin> R}
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. card ({y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R}) = card {y \<in> A - {x}. (y, x) \<in> R} + card {xa \<in> A - {x}. (xa, x) \<notin> R}
[PROOF STEP]
by (intro card_Un_disjoint) auto
[PROOF STATE]
proof (state)
this:
card ({y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R}) = linorder_rank R A x + card {xa \<in> A - {x}. (xa, x) \<notin> R}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R}) = linorder_rank R A x + card {xa \<in> A - {x}. (xa, x) \<notin> R}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "{y\<in>A-{x}. (y,x)\<in>R} \<union> {y\<in>A-{x}. (y,x)\<notin>R} = A - {x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R} = A - {x}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R} = A - {x}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{y \<in> A - {x}. (y, x) \<in> R} \<union> {y \<in> A - {x}. (y, x) \<notin> R} = A - {x}

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
have "card \<dots> = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (A - {x}) = n
[PROOF STEP]
using A 1
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}
x \<in> set_pmf (pmf_of_set A)

goal (1 subgoal):
 1. card (A - {x}) = n
[PROOF STEP]
by (simp add: n_def)
[PROOF STATE]
proof (state)
this:
card (A - {x}) = n

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
n = linorder_rank R A x + card {xa \<in> A - {x}. (xa, x) \<notin> R}
[PROOF STEP]
have "card {xa \<in> A - {x}. (xa, x) \<notin> R} = n - linorder_rank R A x"
[PROOF STATE]
proof (prove)
using this:
n = linorder_rank R A x + card {xa \<in> A - {x}. (xa, x) \<notin> R}

goal (1 subgoal):
 1. card {xa \<in> A - {x}. (xa, x) \<notin> R} = n - linorder_rank R A x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {xa \<in> A - {x}. (xa, x) \<notin> R} = n - linorder_rank R A x

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
card {xa \<in> A - {x}. (xa, x) \<notin> R} = n - linorder_rank R A x

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (n - linorder_rank R A x)
[PROOF STEP]
have "?Y = rqs_cost (n - linorder_rank R A x)"
[PROOF STATE]
proof (prove)
using this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (n - linorder_rank R A x)

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (n - linorder_rank R A x)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (n - linorder_rank R A x)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set {xa \<in> A - {x}. (xa, x) \<notin> R})) = rqs_cost (n - linorder_rank R A x)

goal (1 subgoal):
 1. \<And>x. x \<in> set_pmf (pmf_of_set A) \<Longrightarrow> map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>a. case a of (ls, rs) \<Rightarrow> return_pmf (qs_cost R ls + qs_cost R rs)) = map_pmf (\<lambda>a. case a of (n1, n2) \<Rightarrow> n1 + n2) (pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>a. case a of (ls, rs) \<Rightarrow> return_pmf (qs_cost R ls + qs_cost R rs)) = map_pmf (\<lambda>a. case a of (n1, n2) \<Rightarrow> n1 + n2) (pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)))

goal (1 subgoal):
 1. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))
[PROOF STEP]
by (simp add: case_prod_unfold map_pmf_def)
[PROOF STATE]
proof (state)
this:
map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs)) = pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs))) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. map_pmf (partition (\<lambda>y. (y, x) \<in> R)) (pmf_of_set (permutations_of_set (A - {x}))) \<bind> (\<lambda>(ls, rs). return_pmf (qs_cost R ls + qs_cost R rs))) = pmf_of_set A \<bind> (\<lambda>x. pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "\<dots> = do {
                      i \<leftarrow> map_pmf (linorder_rank R A) (pmf_of_set A);
                      (n1, n2) \<leftarrow> pair_pmf (rqs_cost i) (rqs_cost (n - i));
                      return_pmf (n1 + n2)
                    }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pmf_of_set A \<bind> (\<lambda>x. pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))) = map_pmf (linorder_rank R A) (pmf_of_set A) \<bind> (\<lambda>i. pair_pmf (rqs_cost i) (rqs_cost (n - i)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))
[PROOF STEP]
by (simp add: bind_map_pmf)
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))) = map_pmf (linorder_rank R A) (pmf_of_set A) \<bind> (\<lambda>i. pair_pmf (rqs_cost i) (rqs_cost (n - i)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
pmf_of_set A \<bind> (\<lambda>x. pair_pmf (rqs_cost (linorder_rank R A x)) (rqs_cost (n - linorder_rank R A x)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2))) = map_pmf (linorder_rank R A) (pmf_of_set A) \<bind> (\<lambda>i. pair_pmf (rqs_cost i) (rqs_cost (n - i)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "map_pmf (linorder_rank R A) (pmf_of_set A) = pmf_of_set {..<card A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf (linorder_rank R A) (pmf_of_set A) = pmf_of_set {..<card A}
[PROOF STEP]
by (intro map_pmf_of_set_bij_betw bij_betw_linorder_rank[OF assms(2)] A psubset.prems)
[PROOF STATE]
proof (state)
this:
map_pmf (linorder_rank R A) (pmf_of_set A) = pmf_of_set {..<card A}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf (linorder_rank R A) (pmf_of_set A) = pmf_of_set {..<card A}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
finite A
A \<noteq> {}
[PROOF STEP]
have "card A > 0"
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. 0 < card A
[PROOF STEP]
by (intro Nat.gr0I) auto
[PROOF STATE]
proof (state)
this:
0 < card A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
hence "{..<card A} = {..n}"
[PROOF STATE]
proof (prove)
using this:
0 < card A

goal (1 subgoal):
 1. {..<card A} = {..n}
[PROOF STEP]
by (auto simp: n_def)
[PROOF STATE]
proof (state)
this:
{..<card A} = {..n}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
{..<card A} = {..n}

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
have "map_pmf (\<lambda>m. n + m) (
                 do {
                      i \<leftarrow> pmf_of_set {..n};
                      (n1, n2) \<leftarrow> pair_pmf (rqs_cost i) (rqs_cost (n - i));
                      return_pmf (n1 + n2)
                    }) = rqs_cost (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_pmf ((+) n) (pmf_of_set {..n} \<bind> (\<lambda>i. pair_pmf (rqs_cost i) (rqs_cost (n - i)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))) = rqs_cost (Suc n)
[PROOF STEP]
by (simp add: pair_pmf_def map_bind_pmf case_prod_unfold
                    bind_assoc_pmf bind_return_pmf add_ac)
[PROOF STATE]
proof (state)
this:
map_pmf ((+) n) (pmf_of_set {..n} \<bind> (\<lambda>i. pair_pmf (rqs_cost i) (rqs_cost (n - i)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))) = rqs_cost (Suc n)

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
map_pmf ((+) n) (pmf_of_set {..n} \<bind> (\<lambda>i. pair_pmf (rqs_cost i) (rqs_cost (n - i)) \<bind> (\<lambda>(n1, n2). return_pmf (n1 + n2)))) = rqs_cost (Suc n)

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
from A
[PROOF STATE]
proof (chain)
picking this:
finite A
A \<noteq> {}
[PROOF STEP]
have "card A > 0"
[PROOF STATE]
proof (prove)
using this:
finite A
A \<noteq> {}

goal (1 subgoal):
 1. 0 < card A
[PROOF STEP]
by (intro Nat.gr0I) auto
[PROOF STATE]
proof (state)
this:
0 < card A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
hence "Suc n = card A"
[PROOF STATE]
proof (prove)
using this:
0 < card A

goal (1 subgoal):
 1. Suc n = card A
[PROOF STEP]
by (simp add: n_def)
[PROOF STATE]
proof (state)
this:
Suc n = card A

goal (1 subgoal):
 1. A \<noteq> {} \<Longrightarrow> map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)

goal (1 subgoal):
 1. map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
map_pmf (qs_cost R) (pmf_of_set (permutations_of_set A)) = rqs_cost (card A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma orthogonal:
  assumes "i < m" "j < m" "i \<noteq> j"
  shows "gso i \<bullet> gso j = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gso i \<bullet> gso j = (0::'a)
[PROOF STEP]
using assms mn orthogonal_gso[unfolded orthogonal_def]
[PROOF STATE]
proof (prove)
using this:
i < length fs
j < length fs
i \<noteq> j
length fs \<le> n
\<forall>i j. i < length (map gso [0..<length fs]) \<longrightarrow> j < length (map gso [0..<length fs]) \<longrightarrow> (map gso [0..<length fs] ! i \<bullet> map gso [0..<length fs] ! j = (0::'a)) = (i \<noteq> j)

goal (1 subgoal):
 1. gso i \<bullet> gso j = (0::'a)
[PROOF STEP]
by auto


[STATEMENT]
lemma surj_adjoint_iff_inj [simp]:
  fixes f :: "'m::euclidean_space \<Rightarrow> 'n::euclidean_space"
  assumes "linear f"
  shows  "surj (adjoint f) \<longleftrightarrow> inj f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. surj (adjoint f) = inj f
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. surj (adjoint f) \<Longrightarrow> inj f
 2. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
assume "surj (adjoint f)"
[PROOF STATE]
proof (state)
this:
surj (adjoint f)

goal (2 subgoals):
 1. surj (adjoint f) \<Longrightarrow> inj f
 2. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
surj (adjoint f)
[PROOF STEP]
show "inj f"
[PROOF STATE]
proof (prove)
using this:
surj (adjoint f)

goal (1 subgoal):
 1. inj f
[PROOF STEP]
by (simp add: assms linear_surj_adj_imp_inj)
[PROOF STATE]
proof (state)
this:
inj f

goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
assume "inj f"
[PROOF STATE]
proof (state)
this:
inj f

goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
have "f -` {0} = {0}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f -` {0::'n} = {0::'m}
[PROOF STEP]
using assms \<open>inj f\<close> linear_0 linear_injective_0
[PROOF STATE]
proof (prove)
using this:
linear f
inj f
linear ?f \<Longrightarrow> ?f (0::?'a) = (0::?'b)
linear ?f \<Longrightarrow> inj ?f = (\<forall>x. ?f x = (0::?'b) \<longrightarrow> x = (0::?'a))

goal (1 subgoal):
 1. f -` {0::'n} = {0::'m}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
f -` {0::'n} = {0::'m}

goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f -` {0::'n} = {0::'m}

goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
have "f -` {0} = range (adjoint f)\<^sup>\<bottom>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f -` {0::'n} = range (adjoint f)\<^sup>\<bottom>
[PROOF STEP]
by (intro ker_orthogonal_comp_adjoint assms)
[PROOF STATE]
proof (state)
this:
f -` {0::'n} = range (adjoint f)\<^sup>\<bottom>

goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f -` {0::'n} = {0::'m}
f -` {0::'n} = range (adjoint f)\<^sup>\<bottom>
[PROOF STEP]
have "range (adjoint f)\<^sup>\<bottom>\<^sup>\<bottom> = UNIV"
[PROOF STATE]
proof (prove)
using this:
f -` {0::'n} = {0::'m}
f -` {0::'n} = range (adjoint f)\<^sup>\<bottom>

goal (1 subgoal):
 1. range (adjoint f)\<^sup>\<bottom>\<^sup>\<bottom> = UNIV
[PROOF STEP]
by (metis orthogonal_comp_null)
[PROOF STATE]
proof (state)
this:
range (adjoint f)\<^sup>\<bottom>\<^sup>\<bottom> = UNIV

goal (1 subgoal):
 1. inj f \<Longrightarrow> surj (adjoint f)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
range (adjoint f)\<^sup>\<bottom>\<^sup>\<bottom> = UNIV
[PROOF STEP]
show "surj (adjoint f)"
[PROOF STATE]
proof (prove)
using this:
range (adjoint f)\<^sup>\<bottom>\<^sup>\<bottom> = UNIV

goal (1 subgoal):
 1. surj (adjoint f)
[PROOF STEP]
using adjoint_linear \<open>linear f\<close>
[PROOF STATE]
proof (prove)
using this:
range (adjoint f)\<^sup>\<bottom>\<^sup>\<bottom> = UNIV
linear ?f \<Longrightarrow> linear (adjoint ?f)
linear f

goal (1 subgoal):
 1. surj (adjoint f)
[PROOF STEP]
by (subst (asm) orthogonal_comp_self)
      (simp add: adjoint_linear linear_subspace_image)
[PROOF STATE]
proof (state)
this:
surj (adjoint f)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma normalize_eq_imp_smult:
  fixes p :: "'b :: {euclidean_ring_gcd} poly"
  assumes n: "normalize p = normalize q"
  shows "\<exists> c. c \<noteq> 0 \<and> q = smult c p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
proof(cases "p = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. p = 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
 2. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
p = 0

goal (2 subgoals):
 1. p = 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
 2. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
with n
[PROOF STATE]
proof (chain)
picking this:
normalize p = normalize q
p = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
normalize p = normalize q
p = 0

goal (1 subgoal):
 1. \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
by (auto intro:exI[of _ 1])
[PROOF STATE]
proof (state)
this:
\<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
case p0: False
[PROOF STATE]
proof (state)
this:
p \<noteq> 0

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
have degree_eq: "degree p = degree q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. degree p = degree q
[PROOF STEP]
using n degree_normalize
[PROOF STATE]
proof (prove)
using this:
normalize p = normalize q
degree (normalize ?f) = degree ?f

goal (1 subgoal):
 1. degree p = degree q
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
degree p = degree q

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
hence q0:  "q \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
degree p = degree q

goal (1 subgoal):
 1. q \<noteq> 0
[PROOF STEP]
using p0 n
[PROOF STATE]
proof (prove)
using this:
degree p = degree q
p \<noteq> 0
normalize p = normalize q

goal (1 subgoal):
 1. q \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q \<noteq> 0

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
have p_dvd_q: "p dvd q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p dvd q
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
normalize p = normalize q

goal (1 subgoal):
 1. p dvd q
[PROOF STEP]
by (simp add: associatedD1)
[PROOF STATE]
proof (state)
this:
p dvd q

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
from p_dvd_q
[PROOF STATE]
proof (chain)
picking this:
p dvd q
[PROOF STEP]
obtain k where q: "q = k * p"
[PROOF STATE]
proof (prove)
using this:
p dvd q

goal (1 subgoal):
 1. (\<And>k. q = k * p \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. q = p * k

goal (1 subgoal):
 1. (\<And>k. q = k * p \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: ac_simps)
[PROOF STATE]
proof (state)
this:
q = k * p

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
with q0
[PROOF STATE]
proof (chain)
picking this:
q \<noteq> 0
q = k * p
[PROOF STEP]
have "k \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
q \<noteq> 0
q = k * p

goal (1 subgoal):
 1. k \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
k \<noteq> 0

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<noteq> 0
[PROOF STEP]
have "degree k = 0"
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0

goal (1 subgoal):
 1. degree k = 0
[PROOF STEP]
using degree_eq degree_mult_eq p0 q
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0
degree p = degree q
\<lbrakk>?p \<noteq> 0; ?q \<noteq> 0\<rbrakk> \<Longrightarrow> degree (?p * ?q) = degree ?p + degree ?q
p \<noteq> 0
q = k * p

goal (1 subgoal):
 1. degree k = 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
degree k = 0

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
degree k = 0
[PROOF STEP]
obtain c where k: "k = [: c :]"
[PROOF STATE]
proof (prove)
using this:
degree k = 0

goal (1 subgoal):
 1. (\<And>c. k = [:c:] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis degree_0_id)
[PROOF STATE]
proof (state)
this:
k = [:c:]

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
with \<open>k \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
k \<noteq> 0
k = [:c:]
[PROOF STEP]
have "c \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0
k = [:c:]

goal (1 subgoal):
 1. c \<noteq> (0::'b)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c \<noteq> (0::'b)

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
have "q = smult c p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q = Polynomial.smult c p
[PROOF STEP]
unfolding q k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [:c:] * p = Polynomial.smult c p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
q = Polynomial.smult c p

goal (1 subgoal):
 1. p \<noteq> 0 \<Longrightarrow> \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
with \<open>c \<noteq> 0\<close>
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> (0::'b)
q = Polynomial.smult c p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c \<noteq> (0::'b)
q = Polynomial.smult c p

goal (1 subgoal):
 1. \<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>c. c \<noteq> (0::'b) \<and> q = Polynomial.smult c p

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cnj_rGamma: "cnj (rGamma z) = rGamma (cnj z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cnj (rGamma z) = rGamma (cnj z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. cnj (rGamma z) = rGamma (cnj z)
[PROOF STEP]
have "rGamma_series (cnj z) = (\<lambda>n. cnj (rGamma_series z n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rGamma_series (cnj z) = (\<lambda>n. cnj (rGamma_series z n))
[PROOF STEP]
by (intro ext) (simp_all add: rGamma_series_def exp_cnj)
[PROOF STATE]
proof (state)
this:
rGamma_series (cnj z) = (\<lambda>n. cnj (rGamma_series z n))

goal (1 subgoal):
 1. cnj (rGamma z) = rGamma (cnj z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rGamma_series (cnj z) = (\<lambda>n. cnj (rGamma_series z n))

goal (1 subgoal):
 1. cnj (rGamma z) = rGamma (cnj z)
[PROOF STEP]
have "... \<longlonglongrightarrow> cnj (rGamma z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. cnj (rGamma_series z n)) \<longlonglongrightarrow> cnj (rGamma z)
[PROOF STEP]
by (intro tendsto_cnj tendsto_intros)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. cnj (rGamma_series z n)) \<longlonglongrightarrow> cnj (rGamma z)

goal (1 subgoal):
 1. cnj (rGamma z) = rGamma (cnj z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rGamma_series (cnj z) \<longlonglongrightarrow> cnj (rGamma z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rGamma_series (cnj z) \<longlonglongrightarrow> cnj (rGamma z)

goal (1 subgoal):
 1. cnj (rGamma z) = rGamma (cnj z)
[PROOF STEP]
unfolding rGamma_complex_def
[PROOF STATE]
proof (prove)
using this:
rGamma_series (cnj z) \<longlonglongrightarrow> cnj (lim (rGamma_series z))

goal (1 subgoal):
 1. cnj (lim (rGamma_series z)) = lim (rGamma_series (cnj z))
[PROOF STEP]
by (intro sym[OF limI])
[PROOF STATE]
proof (state)
this:
cnj (rGamma z) = rGamma (cnj z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma algebraic_divide_cancel_left [simp]:
  assumes "algebraic x" "x \<noteq> 0"
  shows   "algebraic (x / y) \<longleftrightarrow> algebraic y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (x / y) = algebraic y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. algebraic (x / y) = algebraic y
[PROOF STEP]
have "algebraic (x * inverse y) \<longleftrightarrow> algebraic (inverse y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (x * inverse y) = algebraic (inverse y)
[PROOF STEP]
by (intro algebraic_mult_cancel_left assms)
[PROOF STATE]
proof (state)
this:
algebraic (x * inverse y) = algebraic (inverse y)

goal (1 subgoal):
 1. algebraic (x / y) = algebraic y
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
algebraic (x * inverse y) = algebraic (inverse y)

goal (1 subgoal):
 1. algebraic (x / y) = algebraic y
[PROOF STEP]
have "\<dots> \<longleftrightarrow> algebraic y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (inverse y) = algebraic y
[PROOF STEP]
by (intro algebraic_inverse_iff)
[PROOF STATE]
proof (state)
this:
algebraic (inverse y) = algebraic y

goal (1 subgoal):
 1. algebraic (x / y) = algebraic y
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
algebraic (x * inverse y) = algebraic y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
algebraic (x * inverse y) = algebraic y

goal (1 subgoal):
 1. algebraic (x / y) = algebraic y
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
algebraic (x / y) = algebraic y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma size_baliL[simp]: "size (rbt_baliL t1 a b t2) = Suc (size t1 + size t2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. size (rbt_baliL t1 a b t2) = Suc (size t1 + size t2)
[PROOF STEP]
by (induction t1 a b t2 rule: rbt_baliL.induct) auto


[STATEMENT]
lemma partition_by_append2:
  "partition_by xs (ys @ zs) = partition_by (take (sum_list ys) xs) ys @ partition_by (drop (sum_list ys) xs) zs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. partition_by xs (ys @ zs) = partition_by (take (sum_list ys) xs) ys @ partition_by (drop (sum_list ys) xs) zs
[PROOF STEP]
by (induct ys arbitrary: xs) (auto simp: drop_take ac_simps split: split_min)


[STATEMENT]
lemma Sum_any_lookup: "finite {x. g x \<noteq> 0} \<Longrightarrow> Sum_any (\<lambda>x. lookup (g x) y) = lookup (Sum_any g) y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {x. g x \<noteq> 0} \<Longrightarrow> (\<Sum>x. lookup (g x) y) = lookup (Sum_any g) y
[PROOF STEP]
by (auto simp: Sum_any.expand_set lookup_sum intro!: sum.mono_neutral_left)