[STATEMENT]
theorem p51: "\<exists>z w. \<forall>x y. F(x,y) \<longleftrightarrow> x = z \<and> y = w \<Longrightarrow>
  \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F(x,y) \<longleftrightarrow> y = w) \<longleftrightarrow> x = z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@proof
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@obtain z w where "\<forall>x y. F(x,y) \<longleftrightarrow> x = z \<and> y = w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@have "\<forall>x. (\<exists>w. \<forall>y. F(x,y) \<longleftrightarrow> y = w) \<longleftrightarrow> x = z" @with
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@case "x = z" @with
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@have "\<forall>y. F(x,y) \<longleftrightarrow> y = w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@end
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@end
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>z w. \<forall>x y. F (x, y) = (x = z \<and> y = w) \<Longrightarrow> \<exists>z. \<forall>x. (\<exists>w. \<forall>y. F (x, y) = (y = w)) = (x = z)
[PROOF STEP]
@qed


[STATEMENT]
lemma normf_least: "S \<noteq> {} \<Longrightarrow> (\<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<le> M) \<Longrightarrow> normf f \<le> M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>S \<noteq> {}; \<And>x. x \<in> S \<Longrightarrow> \<bar>f x\<bar> \<le> M\<rbrakk> \<Longrightarrow> normf f \<le> M
[PROOF STEP]
by (simp add: normf_def cSUP_least)


[STATEMENT]
lemma freeIn_list_conj : "(\<forall>f\<in>set(F). freeIn var f) \<Longrightarrow> freeIn var (list_conj F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>f\<in>set F. freeIn var f \<Longrightarrow> freeIn var (list_conj F)
[PROOF STEP]
proof(induct F)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Ball (set []) (freeIn var) \<Longrightarrow> freeIn var (list_conj [])
 2. \<And>a F. \<lbrakk>Ball (set F) (freeIn var) \<Longrightarrow> freeIn var (list_conj F); Ball (set (a # F)) (freeIn var)\<rbrakk> \<Longrightarrow> freeIn var (list_conj (a # F))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
\<forall>a\<in>set []. freeIn var a

goal (2 subgoals):
 1. Ball (set []) (freeIn var) \<Longrightarrow> freeIn var (list_conj [])
 2. \<And>a F. \<lbrakk>Ball (set F) (freeIn var) \<Longrightarrow> freeIn var (list_conj F); Ball (set (a # F)) (freeIn var)\<rbrakk> \<Longrightarrow> freeIn var (list_conj (a # F))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>a\<in>set []. freeIn var a
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<forall>a\<in>set []. freeIn var a

goal (1 subgoal):
 1. freeIn var (list_conj [])
[PROOF STEP]
by(simp add: list_conj_def)
[PROOF STATE]
proof (state)
this:
freeIn var (list_conj [])

goal (1 subgoal):
 1. \<And>a F. \<lbrakk>Ball (set F) (freeIn var) \<Longrightarrow> freeIn var (list_conj F); Ball (set (a # F)) (freeIn var)\<rbrakk> \<Longrightarrow> freeIn var (list_conj (a # F))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a F. \<lbrakk>Ball (set F) (freeIn var) \<Longrightarrow> freeIn var (list_conj F); Ball (set (a # F)) (freeIn var)\<rbrakk> \<Longrightarrow> freeIn var (list_conj (a # F))
[PROOF STEP]
case (Cons a F)
[PROOF STATE]
proof (state)
this:
\<forall>a\<in>set F. freeIn var a \<Longrightarrow> freeIn var (list_conj F)
\<forall>a\<in>set (a # F). freeIn var a

goal (1 subgoal):
 1. \<And>a F. \<lbrakk>Ball (set F) (freeIn var) \<Longrightarrow> freeIn var (list_conj F); Ball (set (a # F)) (freeIn var)\<rbrakk> \<Longrightarrow> freeIn var (list_conj (a # F))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>a\<in>set F. freeIn var a \<Longrightarrow> freeIn var (list_conj F)
\<forall>a\<in>set (a # F). freeIn var a
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<forall>a\<in>set F. freeIn var a \<Longrightarrow> freeIn var (list_conj F)
\<forall>a\<in>set (a # F). freeIn var a

goal (1 subgoal):
 1. freeIn var (list_conj (a # F))
[PROOF STEP]
by (simp add: PolyAtoms.and_def list_conj_def)
[PROOF STATE]
proof (state)
this:
freeIn var (list_conj (a # F))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Lcm_fin_1_iff:
  "Lcm\<^sub>f\<^sub>i\<^sub>n A = 1 \<longleftrightarrow> (\<forall>a\<in>A. is_unit a) \<and> finite A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Lcm\<^sub>f\<^sub>i\<^sub>n A = (1::'a)) = ((\<forall>a\<in>A. is_unit a) \<and> finite A)
[PROOF STEP]
by (induct A rule: infinite_finite_induct) simp_all


[STATEMENT]
lemma prod_pow[simp]: "(\<Prod>i = 0..<n. p) = (p :: 'a :: comm_monoid_mult) ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i = 0..<n. p) = p ^ n
[PROOF STEP]
by (induct n, auto simp: set_upt_Suc)


[STATEMENT]
lemma lower_triangular_mult:
  assumes "lower_triangular_mat X" "lower_triangular_mat Y"
  shows "lower_triangular_mat (X ** Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lower_triangular_mat (X ** Y)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
lower_triangular_mat X
lower_triangular_mat Y

goal (1 subgoal):
 1. lower_triangular_mat (X ** Y)
[PROOF STEP]
unfolding matrix_matrix_mult_def lower_triangular_mat_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i j. i < j \<longrightarrow> X $ i $ j = (0::'a)
\<forall>i j. i < j \<longrightarrow> Y $ i $ j = (0::'a)

goal (1 subgoal):
 1. \<forall>i j. i < j \<longrightarrow> (\<chi>i j. \<Sum>k\<in>UNIV. X $ i $ k * Y $ k $ j) $ i $ j = (0::'a)
[PROOF STEP]
by (auto intro!: sum.neutral) (metis mult_not_zero neqE less_trans)


[STATEMENT]
lemma (in Group) tOp_assocTr45:"\<lbrakk>a \<in> carrier G; b \<in> carrier G; c \<in> carrier G;
d \<in> carrier G\<rbrakk> \<Longrightarrow> a \<cdot> b \<cdot> c \<cdot> d = a \<cdot> (b \<cdot> (c \<cdot> d))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier G; b \<in> carrier G; c \<in> carrier G; d \<in> carrier G\<rbrakk> \<Longrightarrow> a \<cdot> b \<cdot> c \<cdot> d = a \<cdot> (b \<cdot> (c \<cdot> d))
[PROOF STEP]
apply (frule mult_closed[of "c" "d"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier G; b \<in> carrier G; c \<in> carrier G; d \<in> carrier G; c \<cdot> d \<in> carrier G\<rbrakk> \<Longrightarrow> a \<cdot> b \<cdot> c \<cdot> d = a \<cdot> (b \<cdot> (c \<cdot> d))
[PROOF STEP]
apply (simp add:tassoc[of "a" "b" "c \<cdot> d", THEN sym])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a \<in> carrier G; b \<in> carrier G; c \<in> carrier G; d \<in> carrier G; c \<cdot> d \<in> carrier G\<rbrakk> \<Longrightarrow> a \<cdot> b \<cdot> c \<cdot> d = a \<cdot> b \<cdot> (c \<cdot> d)
[PROOF STEP]
apply (simp add:tOp_assocTr41)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma below_val_zero:
  assumes "prime p"
  assumes "x \<in> (padic_set p)"
  assumes "x (Suc n) \<noteq>  \<zero>\<^bsub>residue_ring (p^(Suc n))\<^esub>"
  shows  "int n \<ge> (padic_val p x )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. padic_val p x \<le> int n
[PROOF STEP]
proof(cases "x = padic_zero p")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x = padic_zero p \<Longrightarrow> padic_val p x \<le> int n
 2. x \<noteq> padic_zero p \<Longrightarrow> padic_val p x \<le> int n
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
x = padic_zero p

goal (2 subgoals):
 1. x = padic_zero p \<Longrightarrow> padic_val p x \<le> int n
 2. x \<noteq> padic_zero p \<Longrightarrow> padic_val p x \<le> int n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x = padic_zero p
[PROOF STEP]
show  ?thesis
[PROOF STATE]
proof (prove)
using this:
x = padic_zero p

goal (1 subgoal):
 1. padic_val p x \<le> int n
[PROOF STEP]
using assms(3) padic_zero_simp
[PROOF STATE]
proof (prove)
using this:
x = padic_zero p
x (Suc n) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc n)\<^esub>
padic_zero ?p ?n = \<zero>\<^bsub>residue_ring (?p ^ ?n)\<^esub>
padic_zero ?p ?n = 0

goal (1 subgoal):
 1. padic_val p x \<le> int n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
padic_val p x \<le> int n

goal (1 subgoal):
 1. x \<noteq> padic_zero p \<Longrightarrow> padic_val p x \<le> int n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<noteq> padic_zero p \<Longrightarrow> padic_val p x \<le> int n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
x \<noteq> padic_zero p

goal (1 subgoal):
 1. x \<noteq> padic_zero p \<Longrightarrow> padic_val p x \<le> int n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<noteq> padic_zero p
[PROOF STEP]
have "padic_val p x = int (LEAST k::nat. x (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc k)\<^esub>)"
[PROOF STATE]
proof (prove)
using this:
x \<noteq> padic_zero p

goal (1 subgoal):
 1. padic_val p x = int (LEAST k. x (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc k)\<^esub>)
[PROOF STEP]
using padic_val_def
[PROOF STATE]
proof (prove)
using this:
x \<noteq> padic_zero p
padic_val ?p ?f \<equiv> if ?f = padic_zero ?p then - 1 else int (LEAST k. ?f (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (?p ^ Suc k)\<^esub>)

goal (1 subgoal):
 1. padic_val p x = int (LEAST k. x (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc k)\<^esub>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
padic_val p x = int (LEAST k. x (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc k)\<^esub>)

goal (1 subgoal):
 1. x \<noteq> padic_zero p \<Longrightarrow> padic_val p x \<le> int n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
padic_val p x = int (LEAST k. x (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc k)\<^esub>)
[PROOF STEP]
show "of_nat n \<ge> (padic_val p x )"
[PROOF STATE]
proof (prove)
using this:
padic_val p x = int (LEAST k. x (Suc k) \<noteq> \<zero>\<^bsub>residue_ring (p ^ Suc k)\<^esub>)

goal (1 subgoal):
 1. padic_val p x \<le> int n
[PROOF STEP]
by (metis (mono_tags, lifting) Least_le assms(3) nat_int nat_le_iff)
[PROOF STATE]
proof (state)
this:
padic_val p x \<le> int n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma euler_mascheroni_sum_real:
  "(\<lambda>n. inverse (of_nat (n+1)) + ln (of_nat (n+1)) - ln (of_nat (n+2)) :: real)
       sums euler_mascheroni"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. inverse (real (n + 1)) + ln (real (n + 1)) - ln (real (n + 2))) sums euler_mascheroni
[PROOF STEP]
using sums_add[OF telescope_sums[OF LIMSEQ_Suc[OF euler_mascheroni_LIMSEQ]]
                   telescope_sums'[OF LIMSEQ_inverse_real_of_nat]]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. harm (Suc (Suc n)) - ln (real (Suc (Suc n))) - (harm (Suc n) - ln (real (Suc n))) + (inverse (real (Suc n)) - inverse (real (Suc (Suc n))))) sums (euler_mascheroni - (harm (Suc 0) - ln (real (Suc 0))) + (inverse (real (Suc 0)) - 0))

goal (1 subgoal):
 1. (\<lambda>n. inverse (real (n + 1)) + ln (real (n + 1)) - ln (real (n + 2))) sums euler_mascheroni
[PROOF STEP]
by (simp_all add: harm_def algebra_simps)


[STATEMENT]
lemma has_integral_interval_reverse: fixes f :: "real \<Rightarrow> real" and a b :: real
  assumes "a \<le> b"
    and "continuous_on {a..b} f"
  shows "((\<lambda>x. f (a+b-x)) has_integral (integral {a..b} f)) {a..b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
let ?g = "\<lambda>x. a + b - x"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
let ?g' = "\<lambda>x. -1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
have g_C0: "continuous_on {a..b} ?g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on {a..b} ((-) (a + b))
[PROOF STEP]
using continuous_on_op_minus
[PROOF STATE]
proof (prove)
using this:
continuous_on ?s ((-) ?x)

goal (1 subgoal):
 1. continuous_on {a..b} ((-) (a + b))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
continuous_on {a..b} ((-) (a + b))

goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
have Dg_g': "\<And>x. x\<in>{a..b} \<Longrightarrow> (?g has_field_derivative ?g' x) (at x within {a..b})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {a..b} \<Longrightarrow> ((-) (a + b) has_real_derivative - 1) (at x within {a..b})
[PROOF STEP]
by (auto intro!: derivative_eq_intros)
[PROOF STATE]
proof (state)
this:
?x1 \<in> {a..b} \<Longrightarrow> ((-) (a + b) has_real_derivative - 1) (at ?x1 within {a..b})

goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
using has_integral_substitution_general
      [of "{}" a b ?g a b f, simplified, OF assms g_C0 Dg_g', simplified]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>x. - f (a + b - x)) has_integral integral {b..a} f - integral {a..b} f) {a..b}

goal (1 subgoal):
 1. ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
apply (simp add: has_integral_null_interval[OF assms(1), THEN integral_unique])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. - f (a + b - x)) has_integral - integral {a..b} f) {a..b} \<Longrightarrow> ((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}
[PROOF STEP]
by (simp add: has_integral_neg_iff)
[PROOF STATE]
proof (state)
this:
((\<lambda>x. f (a + b - x)) has_integral integral {a..b} f) {a..b}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma uints_mono_iff: "uints l \<subseteq> uints m \<longleftrightarrow> l \<le> m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (uints l \<subseteq> uints m) = (l \<le> m)
[PROOF STEP]
using power_increasing_iff[of "2::int" l m]
[PROOF STATE]
proof (prove)
using this:
1 < 2 \<Longrightarrow> (2 ^ l \<le> 2 ^ m) = (l \<le> m)

goal (1 subgoal):
 1. (uints l \<subseteq> uints m) = (l \<le> m)
[PROOF STEP]
apply (auto simp: uints_num subset_iff simp del: power_increasing_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<not> 2 ^ l \<le> 2 ^ m; \<not> l \<le> m; \<forall>t. 0 \<le> t \<and> t < 2 ^ l \<longrightarrow> t < 2 ^ m\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
apply (meson less_irrefl not_le zero_le_numeral zero_le_power)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma infsum_Sigma:
  fixes A :: "'a set" and B :: "'a \<Rightarrow> 'b set"
    and f :: \<open>'a \<times> 'b \<Rightarrow> 'c::{comm_monoid_add, t2_space, uniform_space}\<close>
  assumes plus_cont: \<open>uniformly_continuous_on UNIV (\<lambda>(x::'c,y). x+y)\<close>
  assumes summableAB: "f summable_on (Sigma A B)"
  assumes summableB: \<open>\<And>x. x\<in>A \<Longrightarrow> (\<lambda>y. f (x, y)) summable_on (B x)\<close>
  shows "infsum f (Sigma A B) = infsum (\<lambda>x. infsum (\<lambda>y. f (x, y)) (B x)) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
from summableAB
[PROOF STATE]
proof (chain)
picking this:
f summable_on Sigma A B
[PROOF STEP]
have a: \<open>has_sum f (Sigma A B) (infsum f (Sigma A B))\<close>
[PROOF STATE]
proof (prove)
using this:
f summable_on Sigma A B

goal (1 subgoal):
 1. has_sum f (Sigma A B) (infsum f (Sigma A B))
[PROOF STEP]
using has_sum_infsum
[PROOF STATE]
proof (prove)
using this:
f summable_on Sigma A B
?f summable_on ?S \<Longrightarrow> has_sum ?f ?S (infsum ?f ?S)

goal (1 subgoal):
 1. has_sum f (Sigma A B) (infsum f (Sigma A B))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
has_sum f (Sigma A B) (infsum f (Sigma A B))

goal (1 subgoal):
 1. infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
from summableB
[PROOF STATE]
proof (chain)
picking this:
?x \<in> A \<Longrightarrow> (\<lambda>y. f (?x, y)) summable_on B ?x
[PROOF STEP]
have b: \<open>\<And>x. x\<in>A \<Longrightarrow> has_sum (\<lambda>y. f (x, y)) (B x) (infsum (\<lambda>y. f (x, y)) (B x))\<close>
[PROOF STATE]
proof (prove)
using this:
?x \<in> A \<Longrightarrow> (\<lambda>y. f (?x, y)) summable_on B ?x

goal (1 subgoal):
 1. \<And>x. x \<in> A \<Longrightarrow> has_sum (\<lambda>y. f (x, y)) (B x) (\<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
by (auto intro!: has_sum_infsum)
[PROOF STATE]
proof (state)
this:
?x \<in> A \<Longrightarrow> has_sum (\<lambda>y. f (?x, y)) (B ?x) (\<Sum>\<^sub>\<infinity>y\<in>B ?x. f (?x, y))

goal (1 subgoal):
 1. infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
using plus_cont a b
[PROOF STATE]
proof (prove)
using this:
uniformly_continuous_on UNIV (\<lambda>(x, y). x + y)
has_sum f (Sigma A B) (infsum f (Sigma A B))
?x \<in> A \<Longrightarrow> has_sum (\<lambda>y. f (?x, y)) (B ?x) (\<Sum>\<^sub>\<infinity>y\<in>B ?x. f (?x, y))

goal (1 subgoal):
 1. infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))
[PROOF STEP]
by (auto intro: infsumI[symmetric] has_sum_Sigma simp: summable_on_def)
[PROOF STATE]
proof (state)
this:
infsum f (Sigma A B) = (\<Sum>\<^sub>\<infinity>x\<in>A. \<Sum>\<^sub>\<infinity>y\<in>B x. f (x, y))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Max_le_iMin_imp_singleton: "\<lbrakk> finite I; I \<noteq> {}; Max I \<le> iMin I \<rbrakk> \<Longrightarrow> I = {iMin I}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; Max I \<le> iMin I\<rbrakk> \<Longrightarrow> I = {iMin I}
[PROOF STEP]
by (simp add: iMin_Min_conv Max_le_Min_imp_singleton)


[STATEMENT]
lemma imirror_bounds_iMin: "
  \<lbrakk> finite I; I \<noteq> {}; iMin I \<le> l + r \<rbrakk> \<Longrightarrow>
  iMin (imirror_bounds I l r) = l + r - Max I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; iMin I \<le> l + r\<rbrakk> \<Longrightarrow> iMin (imirror_bounds I l r) = l + r - Max I
[PROOF STEP]
apply (unfold imirror_bounds_def nat_mirror_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite I; I \<noteq> {}; iMin I \<le> l + r\<rbrakk> \<Longrightarrow> iMin ((-) (l + r) ` I) = l + r - Max I
[PROOF STEP]
apply (rule iMin_equality)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>finite I; I \<noteq> {}; iMin I \<le> l + r\<rbrakk> \<Longrightarrow> l + r - Max I \<in> (-) (l + r) ` I
 2. \<And>x. \<lbrakk>finite I; I \<noteq> {}; iMin I \<le> l + r; x \<in> (-) (l + r) ` I\<rbrakk> \<Longrightarrow> l + r - Max I \<le> x
[PROOF STEP]
apply (blast intro: Max_in)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>finite I; I \<noteq> {}; iMin I \<le> l + r; x \<in> (-) (l + r) ` I\<rbrakk> \<Longrightarrow> l + r - Max I \<le> x
[PROOF STEP]
apply (blast intro: Max_ge diff_le_mono2)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma card_injective_functions_domain_permutation:
  assumes "finite A" "finite B"
  shows "card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
have "bij_betw (subset_of A) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) {X. X \<subseteq> B \<and> card X = card A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw (subset_of A) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) {X. X \<subseteq> B \<and> card X = card A}
[PROOF STEP]
using \<open>finite A\<close> \<open>finite B\<close>
[PROOF STATE]
proof (prove)
using this:
finite A
finite B

goal (1 subgoal):
 1. bij_betw (subset_of A) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) {X. X \<subseteq> B \<and> card X = card A}
[PROOF STEP]
by (rule bij_betw_subset_of)
[PROOF STATE]
proof (state)
this:
bij_betw (subset_of A) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) {X. X \<subseteq> B \<and> card X = card A}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
bij_betw (subset_of A) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) {X. X \<subseteq> B \<and> card X = card A}
[PROOF STEP]
have "card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card {X. X \<subseteq> B \<and> card X = card A}"
[PROOF STATE]
proof (prove)
using this:
bij_betw (subset_of A) ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) {X. X \<subseteq> B \<and> card X = card A}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card {X. X \<subseteq> B \<and> card X = card A}
[PROOF STEP]
by (rule bij_betw_same_card)
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card {X. X \<subseteq> B \<and> card X = card A}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card {X. X \<subseteq> B \<and> card X = card A}

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
have "card {X. X \<subseteq> B \<and> card X = card A} = card B choose card A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {X. X \<subseteq> B \<and> card X = card A} = card B choose card A
[PROOF STEP]
using \<open>finite B\<close>
[PROOF STATE]
proof (prove)
using this:
finite B

goal (1 subgoal):
 1. card {X. X \<subseteq> B \<and> card X = card A} = card B choose card A
[PROOF STEP]
by (rule n_subsets)
[PROOF STATE]
proof (state)
this:
card {X. X \<subseteq> B \<and> card X = card A} = card B choose card A

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A

goal (1 subgoal):
 1. card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card ({f \<in> A \<rightarrow>\<^sub>E B. inj_on f A} // domain_permutation A B) = card B choose card A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matpow_scaleR: "matpow (c *\<^sub>R (X :: 'b :: real_algebra_1^_^_)) n = (c^n) *\<^sub>R (matpow X) n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matpow (c *\<^sub>R X) n = c ^ n *\<^sub>R matpow X n
[PROOF STEP]
proof (induction n arbitrary: X c)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>X c. matpow (c *\<^sub>R X) 0 = c ^ 0 *\<^sub>R matpow X 0
 2. \<And>n X c. (\<And>X c. matpow (c *\<^sub>R X) n = c ^ n *\<^sub>R matpow X n) \<Longrightarrow> matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
matpow (?c *\<^sub>R ?X) n = ?c ^ n *\<^sub>R matpow ?X n

goal (2 subgoals):
 1. \<And>X c. matpow (c *\<^sub>R X) 0 = c ^ 0 *\<^sub>R matpow X 0
 2. \<And>n X c. (\<And>X c. matpow (c *\<^sub>R X) n = c ^ n *\<^sub>R matpow X n) \<Longrightarrow> matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)
[PROOF STEP]
have "matpow (c *\<^sub>R X) (Suc n) = (c^n)*\<^sub>R (matpow X) n ** c *\<^sub>R X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matpow (c *\<^sub>R X) (Suc n) = c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
matpow (?c *\<^sub>R ?X) n = ?c ^ n *\<^sub>R matpow ?X n

goal (1 subgoal):
 1. matpow (c *\<^sub>R X) (Suc n) = c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
matpow (c *\<^sub>R X) (Suc n) = c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X

goal (2 subgoals):
 1. \<And>X c. matpow (c *\<^sub>R X) 0 = c ^ 0 *\<^sub>R matpow X 0
 2. \<And>n X c. (\<And>X c. matpow (c *\<^sub>R X) n = c ^ n *\<^sub>R matpow X n) \<Longrightarrow> matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
matpow (c *\<^sub>R X) (Suc n) = c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X

goal (2 subgoals):
 1. \<And>X c. matpow (c *\<^sub>R X) 0 = c ^ 0 *\<^sub>R matpow X 0
 2. \<And>n X c. (\<And>X c. matpow (c *\<^sub>R X) n = c ^ n *\<^sub>R matpow X n) \<Longrightarrow> matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)
[PROOF STEP]
have "\<dots> = c *\<^sub>R ((c^n) *\<^sub>R (matpow X) n ** X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X = c *\<^sub>R (c ^ n *\<^sub>R matpow X n ** X)
[PROOF STEP]
using scalar_matrix_assoc'
[PROOF STATE]
proof (prove)
using this:
?k *\<^sub>R (?C ** ?D) = ?C ** ?k *\<^sub>R ?D

goal (1 subgoal):
 1. c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X = c *\<^sub>R (c ^ n *\<^sub>R matpow X n ** X)
[PROOF STEP]
by (auto simp: scalar_matrix_assoc')
[PROOF STATE]
proof (state)
this:
c ^ n *\<^sub>R matpow X n ** c *\<^sub>R X = c *\<^sub>R (c ^ n *\<^sub>R matpow X n ** X)

goal (2 subgoals):
 1. \<And>X c. matpow (c *\<^sub>R X) 0 = c ^ 0 *\<^sub>R matpow X 0
 2. \<And>n X c. (\<And>X c. matpow (c *\<^sub>R X) n = c ^ n *\<^sub>R matpow X n) \<Longrightarrow> matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
matpow (c *\<^sub>R X) (Suc n) = c *\<^sub>R (c ^ n *\<^sub>R matpow X n ** X)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
matpow (c *\<^sub>R X) (Suc n) = c *\<^sub>R (c ^ n *\<^sub>R matpow X n ** X)

goal (1 subgoal):
 1. matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)
[PROOF STEP]
by (simp add: scalar_matrix_assoc)
[PROOF STATE]
proof (state)
this:
matpow (c *\<^sub>R X) (Suc n) = c ^ Suc n *\<^sub>R matpow X (Suc n)

goal (1 subgoal):
 1. \<And>X c. matpow (c *\<^sub>R X) 0 = c ^ 0 *\<^sub>R matpow X 0
[PROOF STEP]
qed auto


[STATEMENT]
lemma sum_list_log:
  fixes b::real
  fixes xs::"nat list"
  assumes b: "b > 0" "b \<noteq> 1"
  assumes xs:"\<forall> x \<in> set xs . x \<ge> b"
  shows "(\<Sum>x\<leftarrow>xs. log b x) = log b (prod_list xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map (log b) (map real xs)) = log b (real (prod_list xs))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < b
b \<noteq> 1
\<forall>x\<in>set xs. b \<le> real x

goal (1 subgoal):
 1. sum_list (map (log b) (map real xs)) = log b (real (prod_list xs))
[PROOF STEP]
proof (induction xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set []. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real [])) = log b (real (prod_list []))
 2. \<And>a xs. \<lbrakk>\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set xs. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real xs)) = log b (real (prod_list xs)); 0 < b; b \<noteq> 1; \<forall>x\<in>set (a # xs). b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real (a # xs))) = log b (real (prod_list (a # xs)))
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
0 < b
b \<noteq> 1
\<forall>x\<in>set []. b \<le> real x

goal (2 subgoals):
 1. \<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set []. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real [])) = log b (real (prod_list []))
 2. \<And>a xs. \<lbrakk>\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set xs. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real xs)) = log b (real (prod_list xs)); 0 < b; b \<noteq> 1; \<forall>x\<in>set (a # xs). b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real (a # xs))) = log b (real (prod_list (a # xs)))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
0 < b
b \<noteq> 1
\<forall>x\<in>set []. b \<le> real x

goal (1 subgoal):
 1. sum_list (map (log b) (map real [])) = log b (real (prod_list []))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum_list (map (log b) (map real [])) = log b (real (prod_list []))

goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set xs. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real xs)) = log b (real (prod_list xs)); 0 < b; b \<noteq> 1; \<forall>x\<in>set (a # xs). b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real (a # xs))) = log b (real (prod_list (a # xs)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set xs. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real xs)) = log b (real (prod_list xs)); 0 < b; b \<noteq> 1; \<forall>x\<in>set (a # xs). b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real (a # xs))) = log b (real (prod_list (a # xs)))
[PROOF STEP]
case (Cons y ys)
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set ys. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real ys)) = log b (real (prod_list ys))
0 < b
b \<noteq> 1
\<forall>x\<in>set (y # ys). b \<le> real x

goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set xs. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real xs)) = log b (real (prod_list xs)); 0 < b; b \<noteq> 1; \<forall>x\<in>set (a # xs). b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real (a # xs))) = log b (real (prod_list (a # xs)))
[PROOF STEP]
have "real (prod_list ys) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < real (prod_list ys)
[PROOF STEP]
using prod_list_ge Cons.prems
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>set ?xs. 1 \<le> x \<Longrightarrow> 1 \<le> prod_list ?xs
0 < b
b \<noteq> 1
\<forall>x\<in>set (y # ys). b \<le> real x

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

goal (1 subgoal):
 1. \<And>a xs. \<lbrakk>\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set xs. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real xs)) = log b (real (prod_list xs)); 0 < b; b \<noteq> 1; \<forall>x\<in>set (a # xs). b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real (a # xs))) = log b (real (prod_list (a # xs)))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
0 < real (prod_list ys)

goal (1 subgoal):
 1. sum_list (map (log b) (map real (y # ys))) = log b (real (prod_list (y # ys)))
[PROOF STEP]
using log_mult[OF Cons.prems(1-2)] Cons
[PROOF STATE]
proof (prove)
using this:
0 < real (prod_list ys)
\<lbrakk>0 < ?x; 0 < ?y\<rbrakk> \<Longrightarrow> log b (?x * ?y) = log b ?x + log b ?y
\<lbrakk>0 < b; b \<noteq> 1; \<forall>x\<in>set ys. b \<le> real x\<rbrakk> \<Longrightarrow> sum_list (map (log b) (map real ys)) = log b (real (prod_list ys))
0 < b
b \<noteq> 1
\<forall>x\<in>set (y # ys). b \<le> real x

goal (1 subgoal):
 1. sum_list (map (log b) (map real (y # ys))) = log b (real (prod_list (y # ys)))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
sum_list (map (log b) (map real (y # ys))) = log b (real (prod_list (y # ys)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma orthogonal_spaces_sym: \<open>orthogonal_spaces S T \<Longrightarrow> orthogonal_spaces T S\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_spaces S T \<Longrightarrow> orthogonal_spaces T S
[PROOF STEP]
unfolding orthogonal_spaces_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>space_as_set S. \<forall>y\<in>space_as_set T. is_orthogonal x y \<Longrightarrow> \<forall>x\<in>space_as_set T. \<forall>y\<in>space_as_set S. is_orthogonal x y
[PROOF STEP]
using is_orthogonal_sym
[PROOF STATE]
proof (prove)
using this:
is_orthogonal ?\<psi> ?\<phi> = is_orthogonal ?\<phi> ?\<psi>

goal (1 subgoal):
 1. \<forall>x\<in>space_as_set S. \<forall>y\<in>space_as_set T. is_orthogonal x y \<Longrightarrow> \<forall>x\<in>space_as_set T. \<forall>y\<in>space_as_set S. is_orthogonal x y
[PROOF STEP]
by blast


[STATEMENT]
lemma cos_eq_1:
  fixes z::complex
  shows "cos z = 1 \<longleftrightarrow> (\<exists>n::int. z = complex_of_real(2 * n * pi))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
have "cos z = cos (2*(z/2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos z = cos (2 * (z / 2))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
cos z = cos (2 * (z / 2))

goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
cos z = cos (2 * (z / 2))

goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
have "\<dots> = 1 - 2 * sin (z/2) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos (2 * (z / 2)) = 1 - 2 * (sin (z / 2))\<^sup>2
[PROOF STEP]
by (simp only: cos_double_sin)
[PROOF STATE]
proof (state)
this:
cos (2 * (z / 2)) = 1 - 2 * (sin (z / 2))\<^sup>2

goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cos z = 1 - 2 * (sin (z / 2))\<^sup>2
[PROOF STEP]
have [simp]: "cos z = 1 \<longleftrightarrow> sin (z/2) = 0"
[PROOF STATE]
proof (prove)
using this:
cos z = 1 - 2 * (sin (z / 2))\<^sup>2

goal (1 subgoal):
 1. (cos z = 1) = (sin (z / 2) = 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(cos z = 1) = (sin (z / 2) = 0)

goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))
[PROOF STEP]
by (auto simp: sin_eq_0)
[PROOF STATE]
proof (state)
this:
(cos z = 1) = (\<exists>x. z = complex_of_real (2 * real_of_int x * pi))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mergesort_by_rel_merge_simps[simp] :
  "mergesort_by_rel_merge R (x#xs) (y#ys) =
     (if R x y then x # mergesort_by_rel_merge R xs (y#ys) else y # mergesort_by_rel_merge R (x#xs) ys)"
  "mergesort_by_rel_merge R xs [] = xs"
  "mergesort_by_rel_merge R [] ys = ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mergesort_by_rel_merge R (x # xs) (y # ys) = (if R x y then x # mergesort_by_rel_merge R xs (y # ys) else y # mergesort_by_rel_merge R (x # xs) ys) &&& mergesort_by_rel_merge R xs [] = xs &&& mergesort_by_rel_merge R [] ys = ys
[PROOF STEP]
apply (simp_all add: mergesort_by_rel_merge.simps)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mergesort_by_rel_merge R [] ys = ys
[PROOF STEP]
apply (cases ys)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. ys = [] \<Longrightarrow> mergesort_by_rel_merge R [] ys = ys
 2. \<And>a list. ys = a # list \<Longrightarrow> mergesort_by_rel_merge R [] ys = ys
[PROOF STEP]
apply (simp_all add: mergesort_by_rel_merge.simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma compact_closed_differences:
  fixes S T :: "'a::real_normed_vector set"
  assumes "compact S" "closed T"
  shows "closed (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. closed (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
have "(\<Union>x\<in> S. \<Union>y \<in> uminus ` T. {x + y}) = (\<Union>x\<in> S. \<Union>y \<in> T. {x - y})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y}) = (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y}) = (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})

goal (1 subgoal):
 1. closed (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y}) = (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y}) = (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})

goal (1 subgoal):
 1. closed (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
by (metis assms closed_negations compact_closed_sums)
[PROOF STATE]
proof (state)
this:
closed (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vec_norm_geq_0:
  fixes v :: "complex vec"
  shows "vec_norm v \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> vec_norm v
[PROOF STEP]
unfolding vec_norm_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> csqrt (inner_prod v v)
[PROOF STEP]
by (insert self_cscalar_prod_geq_0[of v], simp add: less_eq_complex_def)


[STATEMENT]
lemma mat_plus_right_mono: "B \<ge>\<^sub>m (C :: 'a :: ordered_ab_semigroup mat)
  \<Longrightarrow> A \<in> carrier_mat nr nc \<Longrightarrow> B \<in> carrier_mat nr nc \<Longrightarrow> C \<in> carrier_mat nr nc
  \<Longrightarrow> A + B \<ge>\<^sub>m A + C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>B \<ge>\<^sub>m C; A \<in> carrier_mat nr nc; B \<in> carrier_mat nr nc; C \<in> carrier_mat nr nc\<rbrakk> \<Longrightarrow> A + B \<ge>\<^sub>m A + C
[PROOF STEP]
by (intro mat_geI[of _ nr nc], auto simp: plus_right_mono)


[STATEMENT]
lemma rtranclp_imp_eq_image: "(\<forall>x y. R x y \<longrightarrow> f x = f y) \<Longrightarrow> R\<^sup>*\<^sup>* x y \<Longrightarrow> f x = f y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>x y. R x y \<longrightarrow> f x = f y; R\<^sup>*\<^sup>* x y\<rbrakk> \<Longrightarrow> f x = f y
[PROOF STEP]
by (erule rtranclp.induct) auto


[STATEMENT]
theorem vcgaAlgDefinedness:
  assumes "distinct \<Omega>" "set \<Omega> \<noteq> {}" "finite N"
  shows "card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1
[PROOF STEP]
have "card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
distinct \<Omega>
set \<Omega> \<noteq> {}
finite N

goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1
[PROOF STEP]
by (rule tiebreakingGivesSingleton)
[PROOF STATE]
proof (state)
this:
card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1

goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1

goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1
[PROOF STEP]
have "maximalStrictAllocations N (set \<Omega>) b = maximalStrictAllocationsAlg N \<Omega> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. maximalStrictAllocations N (set \<Omega>) b = maximalStrictAllocationsAlg N \<Omega> b
[PROOF STEP]
using assms(3,1)
[PROOF STATE]
proof (prove)
using this:
finite N
distinct \<Omega>

goal (1 subgoal):
 1. maximalStrictAllocations N (set \<Omega>) b = maximalStrictAllocationsAlg N \<Omega> b
[PROOF STEP]
by (rule maximalAllocationBridgingTheorem)
[PROOF STATE]
proof (state)
this:
maximalStrictAllocations N (set \<Omega>) b = maximalStrictAllocationsAlg N \<Omega> b

goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1
maximalStrictAllocations N (set \<Omega>) b = maximalStrictAllocationsAlg N \<Omega> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocations N (set \<Omega>) b)) = 1
maximalStrictAllocations N (set \<Omega>) b = maximalStrictAllocationsAlg N \<Omega> b

goal (1 subgoal):
 1. card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
card (argmax (sum (randomBidsAlg N \<Omega> b r)) (maximalStrictAllocationsAlg N \<Omega> b)) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cis_Arg_power[simp]: assumes "x \<noteq> 0"
  shows "cis (Arg (x ^ n)) = cis (Arg x * real n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg (x ^ n)) = cis (Arg x * real n)
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. cis (Arg (x ^ 0)) = cis (Arg x * real 0)
 2. \<And>n. cis (Arg (x ^ n)) = cis (Arg x * real n) \<Longrightarrow> cis (Arg (x ^ Suc n)) = cis (Arg x * real (Suc n))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
cis (Arg (x ^ n)) = cis (Arg x * real n)

goal (2 subgoals):
 1. cis (Arg (x ^ 0)) = cis (Arg x * real 0)
 2. \<And>n. cis (Arg (x ^ n)) = cis (Arg x * real n) \<Longrightarrow> cis (Arg (x ^ Suc n)) = cis (Arg x * real (Suc n))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg (x ^ Suc n)) = cis (Arg x * real (Suc n))
[PROOF STEP]
unfolding power.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg (x * x ^ n)) = cis (Arg x * real (Suc n))
[PROOF STEP]
proof (subst cis_arg_mult)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x * x ^ n \<noteq> 0
 2. cis (Arg x + Arg (x ^ n)) = cis (Arg x * real (Suc n))
[PROOF STEP]
show "cis (Arg x + Arg (x ^ n)) = cis (Arg x * real (Suc n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg x + Arg (x ^ n)) = cis (Arg x * real (Suc n))
[PROOF STEP]
unfolding mult.commute[of "Arg x"] DeMoivre[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg x + Arg (x ^ n)) = cis (Arg x) ^ Suc n
[PROOF STEP]
unfolding power.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (Arg x + Arg (x ^ n)) = cis (Arg x) * cis (Arg x) ^ n
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
cis (Arg (x ^ n)) = cis (Arg x * real n)

goal (1 subgoal):
 1. cis (Arg x + Arg (x ^ n)) = cis (Arg x) * cis (Arg x) ^ n
[PROOF STEP]
by (metis DeMoivre cis_mult mult.commute)
[PROOF STATE]
proof (state)
this:
cis (Arg x + Arg (x ^ n)) = cis (Arg x * real (Suc n))

goal (1 subgoal):
 1. x * x ^ n \<noteq> 0
[PROOF STEP]
show "x * x ^ n \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x * x ^ n \<noteq> 0
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<noteq> 0

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
cis (Arg (x ^ Suc n)) = cis (Arg x * real (Suc n))

goal (1 subgoal):
 1. cis (Arg (x ^ 0)) = cis (Arg x * real 0)
[PROOF STEP]
qed simp


[STATEMENT]
lemma card_lists_distinct_length_eq_union:
  assumes "finite X" "finite Y" "X \<inter> Y = {}"
  shows "card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} =
    (\<Sum>k=0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))"
  (is "card ?S = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let ?expr = "do {
    k \<leftarrow> {0..n};
    xs \<leftarrow> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X};
    ys \<leftarrow> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y};
    {zs. interleavings xs ys zs}
  }"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
from \<open>X \<inter> Y = {}\<close>
[PROOF STATE]
proof (chain)
picking this:
X \<inter> Y = {}
[PROOF STEP]
have "card ?S = card ?expr"
[PROOF STATE]
proof (prove)
using this:
X \<inter> Y = {}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))))
[PROOF STEP]
by (simp add: lists_distinct_union_by_interleavings)
[PROOF STATE]
proof (state)
this:
card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))))

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let "?S \<bind> ?comp" = "?expr"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
fix k
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
assume "k \<in> ?S"
[PROOF STATE]
proof (state)
this:
k \<in> {0..n}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let "?expr" = "?comp k"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let "?S \<bind> ?comp" = "?expr"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
from \<open>finite X\<close>
[PROOF STATE]
proof (chain)
picking this:
finite X
[PROOF STEP]
have "finite ?S"
[PROOF STATE]
proof (prove)
using this:
finite X

goal (1 subgoal):
 1. finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
fix xs
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
assume xs: "xs \<in> ?S"
[PROOF STATE]
proof (state)
this:
xs \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let ?expr = "?comp xs"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let "?S \<bind> ?comp" = ?expr
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
from \<open>finite Y\<close>
[PROOF STATE]
proof (chain)
picking this:
finite Y
[PROOF STEP]
have "finite ?S"
[PROOF STATE]
proof (prove)
using this:
finite Y

goal (1 subgoal):
 1. finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
fix ys
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
assume ys: "ys \<in> ?S"
[PROOF STATE]
proof (state)
this:
ys \<in> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
let ?expr = "?comp ys"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "finite ?expr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {zs. interleavings xs ys zs}
[PROOF STEP]
by (simp add: finite_interleavings)
[PROOF STATE]
proof (state)
this:
finite {zs. interleavings xs ys zs}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite {zs. interleavings xs ys zs}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "card ?expr = (n choose k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {zs. interleavings xs ys zs} = n choose k
[PROOF STEP]
using xs ys \<open>X \<inter> Y = {}\<close> \<open>k \<in> _\<close>
[PROOF STATE]
proof (prove)
using this:
xs \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
ys \<in> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
X \<inter> Y = {}
k \<in> {0..n}

goal (1 subgoal):
 1. card {zs. interleavings xs ys zs} = n choose k
[PROOF STEP]
by (subst card_interleavings) auto
[PROOF STATE]
proof (state)
this:
card {zs. interleavings xs ys zs} = n choose k

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {zs. interleavings xs ys zs}
card {zs. interleavings xs ys zs} = n choose k
[PROOF STEP]
have "finite ?expr \<and> card ?expr = (n choose k)"
[PROOF STATE]
proof (prove)
using this:
finite {zs. interleavings xs ys zs}
card {zs. interleavings xs ys zs} = n choose k

goal (1 subgoal):
 1. finite {zs. interleavings xs ys zs} \<and> card {zs. interleavings xs ys zs} = n choose k
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
finite {zs. interleavings xs ys zs} \<and> card {zs. interleavings xs ys zs} = n choose k

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?ys2 \<in> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<Longrightarrow> finite {zs. interleavings xs ?ys2 zs} \<and> card {zs. interleavings xs ?ys2 zs} = n choose k

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?ys2 \<in> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<Longrightarrow> finite {zs. interleavings xs ?ys2 zs} \<and> card {zs. interleavings xs ?ys2 zs} = n choose k

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "disjoint_family_on ?comp ?S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjoint_family_on (\<lambda>ys. {zs. interleavings xs ys zs}) {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
[PROOF STEP]
using \<open>k \<in> {0..n}\<close> \<open>xs \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}\<close>
[PROOF STATE]
proof (prove)
using this:
k \<in> {0..n}
xs \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. disjoint_family_on (\<lambda>ys. {zs. interleavings xs ys zs}) {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
[PROOF STEP]
by (injectivity_solver rule: injectivity(3)[OF \<open>X \<inter> Y = {}\<close>])
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>ys. {zs. interleavings xs ys zs}) {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>ys. {zs. interleavings xs ys zs}) {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "card ?S = ffact (n - k) (card Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} = ffact (n - k) (card Y)
[PROOF STEP]
using \<open>finite Y\<close>
[PROOF STATE]
proof (prove)
using this:
finite Y

goal (1 subgoal):
 1. card {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} = ffact (n - k) (card Y)
[PROOF STEP]
by (simp add: card_lists_distinct_length_eq)
[PROOF STATE]
proof (state)
this:
card {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} = ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
?ys2 \<in> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<Longrightarrow> finite {zs. interleavings xs ?ys2 zs} \<and> card {zs. interleavings xs ?ys2 zs} = n choose k
disjoint_family_on (\<lambda>ys. {zs. interleavings xs ys zs}) {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
card {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} = ffact (n - k) (card Y)
[PROOF STEP]
have "card ?expr = (n choose k) * ffact (n - k) (card Y)"
[PROOF STATE]
proof (prove)
using this:
finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
?ys2 \<in> {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<Longrightarrow> finite {zs. interleavings xs ?ys2 zs} \<and> card {zs. interleavings xs ?ys2 zs} = n choose k
disjoint_family_on (\<lambda>ys. {zs. interleavings xs ys zs}) {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}
card {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} = ffact (n - k) (card Y)

goal (1 subgoal):
 1. card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)
[PROOF STEP]
by (subst card_bind_constant) auto
[PROOF STATE]
proof (state)
this:
card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "finite ?expr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))
[PROOF STEP]
using \<open>finite ?S\<close>
[PROOF STATE]
proof (prove)
using this:
finite {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y}

goal (1 subgoal):
 1. finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))
[PROOF STEP]
by (auto intro!: finite_bind finite_interleavings)
[PROOF STATE]
proof (state)
this:
finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)
finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))
[PROOF STEP]
have "finite ?expr \<and> card ?expr = (n choose k) * ffact (n - k) (card Y)"
[PROOF STATE]
proof (prove)
using this:
card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)
finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))

goal (1 subgoal):
 1. finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) \<and> card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) \<and> card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) = (n choose k) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?xs2 \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<Longrightarrow> finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) \<and> card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) = (n choose k) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?xs2 \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<Longrightarrow> finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) \<and> card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) = (n choose k) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "disjoint_family_on ?comp ?S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjoint_family_on (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
[PROOF STEP]
using \<open>k \<in> {0..n}\<close>
[PROOF STATE]
proof (prove)
using this:
k \<in> {0..n}

goal (1 subgoal):
 1. disjoint_family_on (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
[PROOF STEP]
by (injectivity_solver rule: injectivity(2)[OF \<open>X \<inter> Y = {}\<close>])
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "card ?S = ffact k (card X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} = ffact k (card X)
[PROOF STEP]
using \<open>finite X\<close>
[PROOF STATE]
proof (prove)
using this:
finite X

goal (1 subgoal):
 1. card {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} = ffact k (card X)
[PROOF STEP]
by (simp add: card_lists_distinct_length_eq)
[PROOF STATE]
proof (state)
this:
card {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} = ffact k (card X)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
?xs2 \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<Longrightarrow> finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) \<and> card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) = (n choose k) * ffact (n - k) (card Y)
disjoint_family_on (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
card {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} = ffact k (card X)
[PROOF STEP]
have "card ?expr = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)"
[PROOF STATE]
proof (prove)
using this:
finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
?xs2 \<in> {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<Longrightarrow> finite ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) \<and> card ({ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings ?xs2 ys zs})) = (n choose k) * ffact (n - k) (card Y)
disjoint_family_on (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})) {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
card {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} = ffact k (card X)

goal (1 subgoal):
 1. card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)
[PROOF STEP]
by (subst card_bind_constant) auto
[PROOF STATE]
proof (state)
this:
card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "finite ?expr"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))
[PROOF STEP]
using \<open>finite ?S\<close> \<open>finite Y\<close>
[PROOF STATE]
proof (prove)
using this:
finite {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X}
finite Y

goal (1 subgoal):
 1. finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))
[PROOF STEP]
by (auto intro!: finite_bind finite_interleavings)
[PROOF STATE]
proof (state)
this:
finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)
finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))
[PROOF STEP]
have "finite ?expr \<and> card ?expr = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)"
[PROOF STATE]
proof (prove)
using this:
card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)
finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))

goal (1 subgoal):
 1. finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) \<and> card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) \<and> card ({xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose k) * ffact k (card X) * ffact (n - k) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?k2 \<in> {0..n} \<Longrightarrow> finite ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) \<and> card ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose ?k2) * ffact ?k2 (card X) * ffact (n - ?k2) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?k2 \<in> {0..n} \<Longrightarrow> finite ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) \<and> card ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose ?k2) * ffact ?k2 (card X) * ffact (n - ?k2) (card Y)

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
have "disjoint_family_on ?comp ?S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjoint_family_on (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) {0..n}
[PROOF STEP]
by (injectivity_solver rule: injectivity(1)[OF \<open>X \<inter> Y = {}\<close>])
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) {0..n}

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?k2 \<in> {0..n} \<Longrightarrow> finite ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) \<and> card ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose ?k2) * ffact ?k2 (card X) * ffact (n - ?k2) (card Y)
disjoint_family_on (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) {0..n}
[PROOF STEP]
have "card ?expr = (\<Sum>k=0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))"
[PROOF STATE]
proof (prove)
using this:
?k2 \<in> {0..n} \<Longrightarrow> finite ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) \<and> card ({xs. length xs = ?k2 \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - ?k2 \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) = (n choose ?k2) * ffact ?k2 (card X) * ffact (n - ?k2) (card Y)
disjoint_family_on (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))) {0..n}

goal (1 subgoal):
 1. card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))) = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
by (auto simp add: card_bind)
[PROOF STATE]
proof (state)
this:
card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))) = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
from \<open>card _ = card ?expr\<close> this
[PROOF STATE]
proof (chain)
picking this:
card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))))
card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))) = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs}))))
card ({0..n} \<bind> (\<lambda>k. {xs. length xs = k \<and> distinct xs \<and> set xs \<subseteq> X} \<bind> (\<lambda>xs. {ys. length ys = n - k \<and> distinct ys \<and> set ys \<subseteq> Y} \<bind> (\<lambda>ys. {zs. interleavings xs ys zs})))) = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))

goal (1 subgoal):
 1. card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {zs. length zs = n \<and> distinct zs \<and> set zs \<subseteq> X \<union> Y} = (\<Sum>k = 0..n. (n choose k) * ffact k (card X) * ffact (n - k) (card Y))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lin_indpt_id:
  shows "lin_indpt (set (cols (1\<^sub>m n)::'a vec list))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lin_indpt (set (cols (1\<^sub>m n)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lin_indpt (set (cols (1\<^sub>m n)))
[PROOF STEP]
have *: "set (cols (1\<^sub>m n)) = set (rows (1\<^sub>m n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (cols (1\<^sub>m n)) = set (rows (1\<^sub>m n))
[PROOF STEP]
by (metis cols_transpose transpose_one)
[PROOF STATE]
proof (state)
this:
set (cols (1\<^sub>m n)) = set (rows (1\<^sub>m n))

goal (1 subgoal):
 1. lin_indpt (set (cols (1\<^sub>m n)))
[PROOF STEP]
have "det (1\<^sub>m n) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det (1\<^sub>m n) \<noteq> (0::'b)
[PROOF STEP]
using det_one
[PROOF STATE]
proof (prove)
using this:
det (1\<^sub>m ?n) = (1::?'a)

goal (1 subgoal):
 1. det (1\<^sub>m n) \<noteq> (0::'b)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
det (1\<^sub>m n) \<noteq> (0::?'b3)

goal (1 subgoal):
 1. lin_indpt (set (cols (1\<^sub>m n)))
[PROOF STEP]
from det_not_0_imp_lin_indpt_rows[OF _ this]
[PROOF STATE]
proof (chain)
picking this:
1\<^sub>m n \<in> carrier_mat n n \<Longrightarrow> lin_indpt (set (rows (1\<^sub>m n)))
[PROOF STEP]
have "lin_indpt (set (rows (1\<^sub>m n)))"
[PROOF STATE]
proof (prove)
using this:
1\<^sub>m n \<in> carrier_mat n n \<Longrightarrow> lin_indpt (set (rows (1\<^sub>m n)))

goal (1 subgoal):
 1. lin_indpt (set (rows (1\<^sub>m n)))
[PROOF STEP]
using one_carrier_mat
[PROOF STATE]
proof (prove)
using this:
1\<^sub>m n \<in> carrier_mat n n \<Longrightarrow> lin_indpt (set (rows (1\<^sub>m n)))
1\<^sub>m ?n \<in> carrier_mat ?n ?n

goal (1 subgoal):
 1. lin_indpt (set (rows (1\<^sub>m n)))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
lin_indpt (set (rows (1\<^sub>m n)))

goal (1 subgoal):
 1. lin_indpt (set (cols (1\<^sub>m n)))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
lin_indpt (set (rows (1\<^sub>m n)))

goal (1 subgoal):
 1. lin_indpt (set (cols (1\<^sub>m n)))
[PROOF STEP]
by (simp add: *)
[PROOF STATE]
proof (state)
this:
lin_indpt (set (cols (1\<^sub>m n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cmod_conjugate_square_eq:
  fixes z::complex
  shows "cmod (z *  (conjugate z)) = z * (conjugate z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (cmod (z * conjugate z)) = z * conjugate z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. complex_of_real (cmod (z * conjugate z)) = z * conjugate z
[PROOF STEP]
have "0 \<le> z * (conjugate z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> z * conjugate z
[PROOF STEP]
using conjugate_square_positive less_eq_complex_def
[PROOF STATE]
proof (prove)
using this:
(0::?'a) \<le> ?a * conjugate ?a
(?x \<le> ?y) = (Re ?x \<le> Re ?y \<and> Im ?x = Im ?y)

goal (1 subgoal):
 1. 0 \<le> z * conjugate z
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> z * conjugate z

goal (1 subgoal):
 1. complex_of_real (cmod (z * conjugate z)) = z * conjugate z
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
0 \<le> z * conjugate z

goal (1 subgoal):
 1. complex_of_real (cmod (z * conjugate z)) = z * conjugate z
[PROOF STEP]
using cmod_pos
[PROOF STATE]
proof (prove)
using this:
0 \<le> z * conjugate z
0 \<le> ?z \<Longrightarrow> complex_of_real (cmod ?z) = ?z

goal (1 subgoal):
 1. complex_of_real (cmod (z * conjugate z)) = z * conjugate z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
complex_of_real (cmod (z * conjugate z)) = z * conjugate z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma rat_precision_pos:
  assumes "0 \<le> x"
    and "0 < y"
    and "2 * x < y"
  shows "rat_precision n (int x) (int y) > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < rat_precision n (int x) (int y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < rat_precision n (int x) (int y)
[PROOF STEP]
have "0 < x \<Longrightarrow> log 2 x + 1 = log 2 (2 * x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < x \<Longrightarrow> log 2 (real x) + 1 = log 2 (real (2 * x))
[PROOF STEP]
by (simp add: log_mult)
[PROOF STATE]
proof (state)
this:
0 < x \<Longrightarrow> log 2 (real x) + 1 = log 2 (real (2 * x))

goal (1 subgoal):
 1. 0 < rat_precision n (int x) (int y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < x \<Longrightarrow> log 2 (real x) + 1 = log 2 (real (2 * x))
[PROOF STEP]
have "bitlen (int x) < bitlen (int y)"
[PROOF STATE]
proof (prove)
using this:
0 < x \<Longrightarrow> log 2 (real x) + 1 = log 2 (real (2 * x))

goal (1 subgoal):
 1. bitlen (int x) < bitlen (int y)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x \<Longrightarrow> log 2 (real x) + 1 = log 2 (real (2 * x))
0 \<le> x
0 < y
2 * x < y

goal (1 subgoal):
 1. bitlen (int x) < bitlen (int y)
[PROOF STEP]
by (simp add: bitlen_alt_def)
      (auto intro!: floor_mono simp add: one_add_floor)
[PROOF STATE]
proof (state)
this:
bitlen (int x) < bitlen (int y)

goal (1 subgoal):
 1. 0 < rat_precision n (int x) (int y)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bitlen (int x) < bitlen (int y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
bitlen (int x) < bitlen (int y)

goal (1 subgoal):
 1. 0 < rat_precision n (int x) (int y)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
bitlen (int x) < bitlen (int y)
0 \<le> x
0 < y
2 * x < y

goal (1 subgoal):
 1. 0 < rat_precision n (int x) (int y)
[PROOF STEP]
by (auto intro!: pos_add_strict simp add: field_simps rat_precision_def)
[PROOF STATE]
proof (state)
this:
0 < rat_precision n (int x) (int y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sq_mtx_norm_le_sum_col: "\<parallel>A\<parallel> \<le> (\<Sum>i\<in>UNIV. \<parallel>\<c>\<o>\<l> i A\<parallel>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>A\<parallel> \<le> (\<Sum>i\<in>UNIV. \<parallel>\<c>\<o>\<l> i A\<parallel>)
[PROOF STEP]
using op_norm_le_sum_column[of "to_vec A"]
[PROOF STATE]
proof (prove)
using this:
\<parallel>to_vec A\<parallel>\<^sub>o\<^sub>p \<le> (\<Sum>i\<in>UNIV. \<parallel>column i (to_vec A)\<parallel>)

goal (1 subgoal):
 1. \<parallel>A\<parallel> \<le> (\<Sum>i\<in>UNIV. \<parallel>\<c>\<o>\<l> i A\<parallel>)
[PROOF STEP]
apply(simp add: norm_sq_mtx_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>to_vec A\<parallel>\<^sub>o\<^sub>p \<le> (\<Sum>i\<in>UNIV. \<parallel>column i (to_vec A)\<parallel>) \<Longrightarrow> \<parallel>to_vec A\<parallel>\<^sub>o\<^sub>p \<le> (\<Sum>i\<in>UNIV. \<parallel>\<c>\<o>\<l> i A\<parallel>)
[PROOF STEP]
by(transfer, simp add: op_norm_le_sum_column)


[STATEMENT]
lemma powr_minus_divide: "x powr (- a) = 1/(x powr a)"
      for a x :: "'a::{ln,real_normed_field}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x powr - a = (1::'a) / x powr a
[PROOF STEP]
by (simp add: divide_inverse powr_minus)


[STATEMENT]
lemma has_derivative_zero_unique:
  fixes f :: "'a::real_normed_vector \<Rightarrow> 'b::real_normed_vector"
  assumes "convex s"
    and "\<And>x. x \<in> s \<Longrightarrow> (f has_derivative (\<lambda>h. 0)) (at x within s)"
    and "x \<in> s" "y \<in> s"
  shows "f x = f y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f x = f y
[PROOF STEP]
using has_derivative_zero_constant[OF assms(1,2)] assms(3-)
[PROOF STATE]
proof (prove)
using this:
(\<And>x. x \<in> s \<Longrightarrow> x \<in> s) \<Longrightarrow> \<exists>c. \<forall>x\<in>s. f x = c
x \<in> s
y \<in> s

goal (1 subgoal):
 1. f x = f y
[PROOF STEP]
by force


[STATEMENT]
lemma poly_shift_monom: "poly_shift n (monom c m) = (if m \<ge> n then monom c (m - n) else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_shift n (monom c m) = (if n \<le> m then monom c (m - n) else 0)
[PROOF STEP]
by (auto simp add: poly_eq_iff coeff_poly_shift)


[STATEMENT]
lemma (in comm_semiring_0) poly_mult: "poly (p1 *** p2) x = poly p1 x * poly p2 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (p1 *** p2) x = poly p1 x * poly p2 x
[PROOF STEP]
proof (induct p1 arbitrary: p2)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>p2. poly ([] *** p2) x = poly [] x * poly p2 x
 2. \<And>a p1 p2. (\<And>p2. poly (p1 *** p2) x = poly p1 x * poly p2 x) \<Longrightarrow> poly ((a # p1) *** p2) x = poly (a # p1) x * poly p2 x
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>p2. poly ([] *** p2) x = poly [] x * poly p2 x
 2. \<And>a p1 p2. (\<And>p2. poly (p1 *** p2) x = poly p1 x * poly p2 x) \<Longrightarrow> poly ((a # p1) *** p2) x = poly (a # p1) x * poly p2 x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly ([] *** p2) x = poly [] x * poly p2 x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly ([] *** p2) x = poly [] x * poly p2 x

goal (1 subgoal):
 1. \<And>a p1 p2. (\<And>p2. poly (p1 *** p2) x = poly p1 x * poly p2 x) \<Longrightarrow> poly ((a # p1) *** p2) x = poly (a # p1) x * poly p2 x
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a p1 p2. (\<And>p2. poly (p1 *** p2) x = poly p1 x * poly p2 x) \<Longrightarrow> poly ((a # p1) *** p2) x = poly (a # p1) x * poly p2 x
[PROOF STEP]
case (Cons a as)
[PROOF STATE]
proof (state)
this:
poly (as *** ?p2.1) x = poly as x * poly ?p2.1 x

goal (1 subgoal):
 1. \<And>a p1 p2. (\<And>p2. poly (p1 *** p2) x = poly p1 x * poly p2 x) \<Longrightarrow> poly ((a # p1) *** p2) x = poly (a # p1) x * poly p2 x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
poly (as *** ?p2.1) x = poly as x * poly ?p2.1 x
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
poly (as *** ?p2.1) x = poly as x * poly ?p2.1 x

goal (1 subgoal):
 1. poly ((a # as) *** p2) x = poly (a # as) x * poly p2 x
[PROOF STEP]
by (cases as) (simp_all add: poly_cmult poly_add distrib_right distrib_left ac_simps)
[PROOF STATE]
proof (state)
this:
poly ((a # as) *** p2) x = poly (a # as) x * poly p2 x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vector_derivative_scaleR_at [simp]:
    "\<lbrakk>f differentiable at a; g differentiable at a\<rbrakk>
   \<Longrightarrow> vector_derivative (\<lambda>x. f x *\<^sub>R g x) (at a) = f a *\<^sub>R vector_derivative g (at a) + vector_derivative f (at a) *\<^sub>R g a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f differentiable at a; g differentiable at a\<rbrakk> \<Longrightarrow> vector_derivative (\<lambda>x. f x *\<^sub>R g x) (at a) = f a *\<^sub>R vector_derivative g (at a) + vector_derivative f (at a) *\<^sub>R g a
[PROOF STEP]
apply (rule vector_derivative_at)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f differentiable at a; g differentiable at a\<rbrakk> \<Longrightarrow> ((\<lambda>x. f x *\<^sub>R g x) has_vector_derivative f a *\<^sub>R vector_derivative g (at a) + vector_derivative f (at a) *\<^sub>R g a) (at a)
[PROOF STEP]
apply (rule has_vector_derivative_scaleR)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>f differentiable at a; g differentiable at a\<rbrakk> \<Longrightarrow> (f has_real_derivative vector_derivative f (at a)) (at a)
 2. \<lbrakk>f differentiable at a; g differentiable at a\<rbrakk> \<Longrightarrow> (g has_vector_derivative vector_derivative g (at a)) (at a)
[PROOF STEP]
apply (auto simp: vector_derivative_works has_vector_derivative_def has_field_derivative_def mult_commute_abs)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma mult_conj_cmod_square:
  fixes z::complex
  shows "z * conjugate z = (cmod z)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
have "z * conjugate z = (Re z)\<^sup>2 + (Im z)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2)
[PROOF STEP]
using  complex_mult_cnj
[PROOF STATE]
proof (prove)
using this:
?z * cnj ?z = complex_of_real ((Re ?z)\<^sup>2 + (Im ?z)\<^sup>2)

goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z * conjugate z = complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2)

goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
z * conjugate z = complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2)

goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
have "... = (cmod z)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2) = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
unfolding cmod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2) = complex_of_real ((sqrt ((Re z)\<^sup>2 + (Im z)\<^sup>2))\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
complex_of_real ((Re z)\<^sup>2 + (Im z)\<^sup>2) = complex_of_real ((cmod z)\<^sup>2)

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

goal (1 subgoal):
 1. z * conjugate z = complex_of_real ((cmod z)\<^sup>2)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
z * conjugate z = complex_of_real ((cmod z)\<^sup>2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ereal_Inf_cmult:
  assumes "c>(0::real)"
  shows "Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}
[PROOF STEP]
have "(\<lambda>x::ereal. c * x) (Inf {x::ereal. P x}) = Inf ((\<lambda>x::ereal. c * x)`{x::ereal. P x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ereal c * Inf {x. P x} = Inf ((*) (ereal c) ` {x. P x})
[PROOF STEP]
apply (rule mono_bij_Inf)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. mono ((*) (ereal c))
 2. bij ((*) (ereal c))
[PROOF STEP]
apply (simp add: assms ereal_mult_left_mono less_imp_le mono_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij ((*) (ereal c))
[PROOF STEP]
apply (rule bij_betw_byWitness[of _ "\<lambda>x. (x::ereal) / c"], auto simp add: assms ereal_mult_divide)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a. ereal c * a / ereal c = a
[PROOF STEP]
using assms ereal_divide_eq
[PROOF STATE]
proof (prove)
using this:
0 < c
\<lbrakk>?b \<noteq> 0; \<bar>?b\<bar> \<noteq> \<infinity>\<rbrakk> \<Longrightarrow> (?a / ?b = ?c) = (?a = ?b * ?c)

goal (1 subgoal):
 1. \<And>a. ereal c * a / ereal c = a
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
ereal c * Inf {x. P x} = Inf ((*) (ereal c) ` {x. P x})

goal (1 subgoal):
 1. Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
ereal c * Inf {x. P x} = Inf ((*) (ereal c) ` {x. P x})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
ereal c * Inf {x. P x} = Inf ((*) (ereal c) ` {x. P x})

goal (1 subgoal):
 1. Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}
[PROOF STEP]
by (simp only: setcompr_eq_image[symmetric])
[PROOF STATE]
proof (state)
this:
Inf {ereal c * x |x. P x} = ereal c * Inf {x. P x}

goal:
No subgoals!
[PROOF STEP]
qed