[STATEMENT]
lemma Schwartz_inequality_abs:
  assumes "f square_integrable S" "g square_integrable S"
  shows "\<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
have "\<bar>l2product S f g\<bar> \<le> l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>)
[PROOF STEP]
unfolding l2product_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>LINT x|lebesgue_on S. f x * g x\<bar> \<le> LINT x|lebesgue_on S. \<bar>f x\<bar> * \<bar>g x\<bar>
[PROOF STEP]
proof (rule integral_abs_bound_integral)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. integrable (lebesgue_on S) (\<lambda>x. f x * g x)
 2. integrable (lebesgue_on S) (\<lambda>x. \<bar>f x\<bar> * \<bar>g x\<bar>)
 3. \<And>x. x \<in> space (lebesgue_on S) \<Longrightarrow> \<bar>f x * g x\<bar> \<le> \<bar>f x\<bar> * \<bar>g x\<bar>
[PROOF STEP]
show "integrable (lebesgue_on S) (\<lambda>x. f x * g x)" "integrable (lebesgue_on S) (\<lambda>x. \<bar>f x\<bar> * \<bar>g x\<bar>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integrable (lebesgue_on S) (\<lambda>x. f x * g x) &&& integrable (lebesgue_on S) (\<lambda>x. \<bar>f x\<bar> * \<bar>g x\<bar>)
[PROOF STEP]
by (simp_all add: assms square_integrable_imp_integrable_product)
[PROOF STATE]
proof (state)
this:
integrable (lebesgue_on S) (\<lambda>x. f x * g x)
integrable (lebesgue_on S) (\<lambda>x. \<bar>f x\<bar> * \<bar>g x\<bar>)

goal (1 subgoal):
 1. \<And>x. x \<in> space (lebesgue_on S) \<Longrightarrow> \<bar>f x * g x\<bar> \<le> \<bar>f x\<bar> * \<bar>g x\<bar>
[PROOF STEP]
qed (simp add: abs_mult)
[PROOF STATE]
proof (state)
this:
\<bar>l2product S f g\<bar> \<le> l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>)

goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>l2product S f g\<bar> \<le> l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>)

goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
have "\<dots> \<le> l2norm S f * l2norm S g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>) \<le> l2norm S f * l2norm S g
[PROOF STEP]
by (simp add: Schwartz_inequality_strong assms)
[PROOF STATE]
proof (state)
this:
l2product S (\<lambda>x. \<bar>f x\<bar>) (\<lambda>x. \<bar>g x\<bar>) \<le> l2norm S f * l2norm S g

goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g

goal (1 subgoal):
 1. \<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<bar>l2product S f g\<bar> \<le> l2norm S f * l2norm S g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prime_factorization_subset_iff_dvd:
  assumes [simp]: "x \<noteq> 0" "y \<noteq> 0"
  shows   "prime_factorization x \<subseteq># prime_factorization y \<longleftrightarrow> x dvd y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)
[PROOF STEP]
have "x dvd y \<longleftrightarrow>
    normalize (prod_mset (prime_factorization x)) dvd normalize (prod_mset (prime_factorization y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x dvd y) = (normalize (\<Prod>\<^sub># (prime_factorization x)) dvd normalize (\<Prod>\<^sub># (prime_factorization y)))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<noteq> (0::'a)
y \<noteq> (0::'a)

goal (1 subgoal):
 1. (x dvd y) = (normalize (\<Prod>\<^sub># (prime_factorization x)) dvd normalize (\<Prod>\<^sub># (prime_factorization y)))
[PROOF STEP]
by (subst (1 2) prod_mset_prime_factorization_weak) auto
[PROOF STATE]
proof (state)
this:
(x dvd y) = (normalize (\<Prod>\<^sub># (prime_factorization x)) dvd normalize (\<Prod>\<^sub># (prime_factorization y)))

goal (1 subgoal):
 1. (prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(x dvd y) = (normalize (\<Prod>\<^sub># (prime_factorization x)) dvd normalize (\<Prod>\<^sub># (prime_factorization y)))

goal (1 subgoal):
 1. (prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)
[PROOF STEP]
have "\<dots> \<longleftrightarrow> prime_factorization x \<subseteq># prime_factorization y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (normalize (\<Prod>\<^sub># (prime_factorization x)) dvd normalize (\<Prod>\<^sub># (prime_factorization y))) = (prime_factorization x \<subseteq># prime_factorization y)
[PROOF STEP]
by (auto intro!: prod_mset_primes_dvd_imp_subset prod_mset_subset_imp_dvd)
[PROOF STATE]
proof (state)
this:
(normalize (\<Prod>\<^sub># (prime_factorization x)) dvd normalize (\<Prod>\<^sub># (prime_factorization y))) = (prime_factorization x \<subseteq># prime_factorization y)

goal (1 subgoal):
 1. (prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(x dvd y) = (prime_factorization x \<subseteq># prime_factorization y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(x dvd y) = (prime_factorization x \<subseteq># prime_factorization y)

goal (1 subgoal):
 1. (prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(prime_factorization x \<subseteq># prime_factorization y) = (x dvd y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma orthogonal_complement_antimono_iff[simp]:
  fixes  A B :: \<open>('a::chilbert_space) set\<close>
  assumes \<open>closed_csubspace A\<close> and  \<open>closed_csubspace B\<close>
  shows \<open>orthogonal_complement A \<subseteq> orthogonal_complement B \<longleftrightarrow> A \<supseteq> B\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (orthogonal_complement A \<subseteq> orthogonal_complement B) = (B \<subseteq> A)
[PROOF STEP]
proof (rule iffI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. orthogonal_complement A \<subseteq> orthogonal_complement B \<Longrightarrow> B \<subseteq> A
 2. B \<subseteq> A \<Longrightarrow> orthogonal_complement A \<subseteq> orthogonal_complement B
[PROOF STEP]
show \<open>orthogonal_complement A \<subseteq> orthogonal_complement B\<close> if \<open>A \<supseteq> B\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. orthogonal_complement A \<subseteq> orthogonal_complement B
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
B \<subseteq> A

goal (1 subgoal):
 1. orthogonal_complement A \<subseteq> orthogonal_complement B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
B \<subseteq> A \<Longrightarrow> orthogonal_complement A \<subseteq> orthogonal_complement B

goal (1 subgoal):
 1. orthogonal_complement A \<subseteq> orthogonal_complement B \<Longrightarrow> B \<subseteq> A
[PROOF STEP]
assume \<open>orthogonal_complement A \<subseteq> orthogonal_complement B\<close>
[PROOF STATE]
proof (state)
this:
orthogonal_complement A \<subseteq> orthogonal_complement B

goal (1 subgoal):
 1. orthogonal_complement A \<subseteq> orthogonal_complement B \<Longrightarrow> B \<subseteq> A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
orthogonal_complement A \<subseteq> orthogonal_complement B
[PROOF STEP]
have \<open>orthogonal_complement (orthogonal_complement A) \<supseteq> orthogonal_complement (orthogonal_complement B)\<close>
[PROOF STATE]
proof (prove)
using this:
orthogonal_complement A \<subseteq> orthogonal_complement B

goal (1 subgoal):
 1. orthogonal_complement (orthogonal_complement B) \<subseteq> orthogonal_complement (orthogonal_complement A)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
orthogonal_complement (orthogonal_complement B) \<subseteq> orthogonal_complement (orthogonal_complement A)

goal (1 subgoal):
 1. orthogonal_complement A \<subseteq> orthogonal_complement B \<Longrightarrow> B \<subseteq> A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
orthogonal_complement (orthogonal_complement B) \<subseteq> orthogonal_complement (orthogonal_complement A)
[PROOF STEP]
show \<open>A \<supseteq> B\<close>
[PROOF STATE]
proof (prove)
using this:
orthogonal_complement (orthogonal_complement B) \<subseteq> orthogonal_complement (orthogonal_complement A)

goal (1 subgoal):
 1. B \<subseteq> A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
orthogonal_complement (orthogonal_complement B) \<subseteq> orthogonal_complement (orthogonal_complement A)
closed_csubspace A
closed_csubspace B

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma length_of_bin_rep:
  fixes n m:: nat
  assumes "m < 2^n"
  shows "length (bin_rep n m) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (bin_rep n m) = n
[PROOF STEP]
using assms length_of_bin_rep_aux bin_rep_def
[PROOF STATE]
proof (prove)
using this:
m < 2 ^ n
?m < 2 ^ ?n \<Longrightarrow> length (bin_rep_aux ?n ?m) = ?n + 1
bin_rep ?n ?m = butlast (bin_rep_aux ?n ?m)

goal (1 subgoal):
 1. length (bin_rep n m) = n
[PROOF STEP]
by simp


[STATEMENT]
lemma  trace_1:
  shows "Complex_Matrix.trace ((1\<^sub>m n)::complex Matrix.mat) =(n::complex)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.trace (1\<^sub>m n) = of_nat n
[PROOF STEP]
using one_mat_def
[PROOF STATE]
proof (prove)
using this:
1\<^sub>m ?n \<equiv> Matrix.mat ?n ?n (\<lambda>(i, j). if i = j then 1::?'a else (0::?'a))

goal (1 subgoal):
 1. Complex_Matrix.trace (1\<^sub>m n) = of_nat n
[PROOF STEP]
by (simp add: Complex_Matrix.trace_def Matrix.mat_def)


[STATEMENT]
lemma le_Suc_eq: "(\<forall>a. (a < Suc n) = (a < Suc m)) = (\<forall>a. (a < n) = (a < m))"
 (is "(\<forall>a. ?A a) = (\<forall> a. ?B a)")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>a. (a < Suc n) = (a < Suc m)) = (\<forall>a. (a < n) = (a < m))
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<forall>a. (a < Suc n) = (a < Suc m) \<Longrightarrow> \<forall>a. (a < n) = (a < m)
 2. \<forall>a. (a < n) = (a < m) \<Longrightarrow> \<forall>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
assume "\<forall>a. ?A a"
[PROOF STATE]
proof (state)
this:
\<forall>a. (a < Suc n) = (a < Suc m)

goal (2 subgoals):
 1. \<forall>a. (a < Suc n) = (a < Suc m) \<Longrightarrow> \<forall>a. (a < n) = (a < m)
 2. \<forall>a. (a < n) = (a < m) \<Longrightarrow> \<forall>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
thus "\<forall> a. ?B a"
[PROOF STATE]
proof (prove)
using this:
\<forall>a. (a < Suc n) = (a < Suc m)

goal (1 subgoal):
 1. \<forall>a. (a < n) = (a < m)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>a. (a < n) = (a < m)

goal (1 subgoal):
 1. \<forall>a. (a < n) = (a < m) \<Longrightarrow> \<forall>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>a. (a < n) = (a < m) \<Longrightarrow> \<forall>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
assume B: "\<forall> a. ?B a"
[PROOF STATE]
proof (state)
this:
\<forall>a. (a < n) = (a < m)

goal (1 subgoal):
 1. \<forall>a. (a < n) = (a < m) \<Longrightarrow> \<forall>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
show "\<forall>a. ?A a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. (a < Suc n) = (a < Suc m)
[PROOF STEP]
from B
[PROOF STATE]
proof (chain)
picking this:
\<forall>a. (a < n) = (a < m)
[PROOF STEP]
show "?A a"
[PROOF STATE]
proof (prove)
using this:
\<forall>a. (a < n) = (a < m)

goal (1 subgoal):
 1. (a < Suc n) = (a < Suc m)
[PROOF STEP]
by (cases a) simp_all
[PROOF STATE]
proof (state)
this:
(a < Suc n) = (a < Suc m)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>a. (a < Suc n) = (a < Suc m)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homotopic_with_linear:
  fixes f g :: "_ \<Rightarrow> 'b::real_normed_vector"
  assumes contf: "continuous_on S f"
      and contg:"continuous_on S g"
      and sub: "\<And>x. x \<in> S \<Longrightarrow> closed_segment (f x) (g x) \<subseteq> t"
    shows "homotopic_with_canon (\<lambda>z. True) S t f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homotopic_with_canon (\<lambda>z. True) S t f g
[PROOF STEP]
unfolding homotopic_with_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>h. continuous_map (prod_topology (top_of_set {0..1}) (top_of_set S)) (top_of_set t) h \<and> (\<forall>x. h (0, x) = f x) \<and> (\<forall>x. h (1, x) = g x) \<and> (\<forall>t\<in>{0..1}. True)
[PROOF STEP]
apply (rule_tac x="\<lambda>y. ((1 - (fst y)) *\<^sub>R f(snd y) + (fst y) *\<^sub>R g(snd y))" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_map (prod_topology (top_of_set {0..1}) (top_of_set S)) (top_of_set t) (\<lambda>y. (1 - fst y) *\<^sub>R f (snd y) + fst y *\<^sub>R g (snd y)) \<and> (\<forall>x. (1 - fst (0, x)) *\<^sub>R f (snd (0, x)) + fst (0, x) *\<^sub>R g (snd (0, x)) = f x) \<and> (\<forall>x. (1 - fst (1, x)) *\<^sub>R f (snd (1, x)) + fst (1, x) *\<^sub>R g (snd (1, x)) = g x) \<and> (\<forall>t\<in>{0..1}. True)
[PROOF STEP]
using sub closed_segment_def
[PROOF STATE]
proof (prove)
using this:
?x \<in> S \<Longrightarrow> closed_segment (f ?x) (g ?x) \<subseteq> t
closed_segment ?a ?b = {(1 - u) *\<^sub>R ?a + u *\<^sub>R ?b |u. 0 \<le> u \<and> u \<le> 1}

goal (1 subgoal):
 1. continuous_map (prod_topology (top_of_set {0..1}) (top_of_set S)) (top_of_set t) (\<lambda>y. (1 - fst y) *\<^sub>R f (snd y) + fst y *\<^sub>R g (snd y)) \<and> (\<forall>x. (1 - fst (0, x)) *\<^sub>R f (snd (0, x)) + fst (0, x) *\<^sub>R g (snd (0, x)) = f x) \<and> (\<forall>x. (1 - fst (1, x)) *\<^sub>R f (snd (1, x)) + fst (1, x) *\<^sub>R g (snd (1, x)) = g x) \<and> (\<forall>t\<in>{0..1}. True)
[PROOF STEP]
by (fastforce intro: continuous_intros continuous_on_subset [OF contf] continuous_on_compose2 [where g=f]
            continuous_on_subset [OF contg] continuous_on_compose2 [where g=g])


[STATEMENT]
lemma index_tensor_vec[simp]:
  assumes "0 < dim_vec v"
  and "i < dim_vec u * dim_vec v"
shows "vec_index (tensor_vec u v) i =
  vec_index u (i div (dim_vec v)) * vec_index v (i mod dim_vec v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
have m: "Matrix_Tensor.mult (1::complex) (*)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix_Tensor.mult 1 (*)
[PROOF STEP]
by (simp add: Matrix_Tensor.mult_def)
[PROOF STATE]
proof (state)
this:
Matrix_Tensor.mult 1 (*)

goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
have "length (list_of_vec v) = dim_vec v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (list_of_vec v) = dim_vec v
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < dim_vec v
i < dim_vec u * dim_vec v

goal (1 subgoal):
 1. length (list_of_vec v) = dim_vec v
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length (list_of_vec v) = dim_vec v

goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
hence "vec_index (tensor_vec u v) i = (*) (vec_index u (i div dim_vec v)) (vec_index v (i mod dim_vec v))"
[PROOF STATE]
proof (prove)
using this:
length (list_of_vec v) = dim_vec v

goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
unfolding tensor_vec_def
[PROOF STATE]
proof (prove)
using this:
length (list_of_vec v) = dim_vec v

goal (1 subgoal):
 1. vec_of_list (mult.vec_vec_Tensor (*) (list_of_vec u) (list_of_vec v)) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
using mult.vec_vec_Tensor_elements assms m
[PROOF STATE]
proof (prove)
using this:
length (list_of_vec v) = dim_vec v
\<lbrakk>Matrix_Tensor.mult ?id ?f; ?y \<noteq> []\<rbrakk> \<Longrightarrow> \<forall>i<length ?x * length ?y. mult.vec_vec_Tensor ?f ?x ?y ! i = ?f (?x ! (i div length ?y)) (?y ! (i mod length ?y))
0 < dim_vec v
i < dim_vec u * dim_vec v
Matrix_Tensor.mult 1 (*)

goal (1 subgoal):
 1. vec_of_list (mult.vec_vec_Tensor (*) (list_of_vec u) (list_of_vec v)) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
by (metis (mono_tags, lifting) length_greater_0_conv length_list_of_vec list_of_vec_index
        mult.vec_vec_Tensor_elements vec_of_list_index)
[PROOF STATE]
proof (state)
this:
(u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)

goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)

goal (1 subgoal):
 1. (u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(u \<otimes> v) $ i = u $ (i div dim_vec v) * v $ (i mod dim_vec v)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tensor_mat_unitary:
  assumes "m1 \<in> carrier_mat d1 d1"
    and "m2 \<in> carrier_mat d2 d2"
    and "unitary m1"
    and "unitary m2"
  shows "unitary (tensor_mat m1 m2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unitary (tensor_mat m1 m2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m1 \<in> carrier_mat d1 d1
m2 \<in> carrier_mat d2 d2
unitary m1
unitary m2

goal (1 subgoal):
 1. unitary (tensor_mat m1 m2)
[PROOF STEP]
apply (auto simp add: unitary_def tensor_mat_adjoint)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m1 \<in> carrier_mat d1 d1; m2 \<in> carrier_mat d2 d2; inverts_mat m1 (adjoint m1); inverts_mat m2 (adjoint m2)\<rbrakk> \<Longrightarrow> inverts_mat (tensor_mat m1 m2) (tensor_mat (adjoint m1) (adjoint m2))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m1 \<in> carrier_mat d1 d1
m2 \<in> carrier_mat d2 d2
unitary m1
unitary m2

goal (1 subgoal):
 1. \<lbrakk>m1 \<in> carrier_mat d1 d1; m2 \<in> carrier_mat d2 d2; inverts_mat m1 (adjoint m1); inverts_mat m2 (adjoint m2)\<rbrakk> \<Longrightarrow> inverts_mat (tensor_mat m1 m2) (tensor_mat (adjoint m1) (adjoint m2))
[PROOF STEP]
unfolding inverts_mat_def
[PROOF STATE]
proof (prove)
using this:
m1 \<in> carrier_mat d1 d1
m2 \<in> carrier_mat d2 d2
unitary m1
unitary m2

goal (1 subgoal):
 1. \<lbrakk>m1 \<in> carrier_mat d1 d1; m2 \<in> carrier_mat d2 d2; m1 * adjoint m1 = 1\<^sub>m (dim_row m1); m2 * adjoint m2 = 1\<^sub>m (dim_row m2)\<rbrakk> \<Longrightarrow> tensor_mat m1 m2 * tensor_mat (adjoint m1) (adjoint m2) = 1\<^sub>m (dim_row (tensor_mat m1 m2))
[PROOF STEP]
apply (subst tensor_mat_mult[symmetric], auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>m1 \<in> carrier_mat d1 d1; m2 \<in> carrier_mat d2 d2; unitary m1; unitary m2\<rbrakk> \<Longrightarrow> tensor_mat (1\<^sub>m d1) (1\<^sub>m d2) = 1\<^sub>m d
[PROOF STEP]
by (rule tensor_mat_id)


[STATEMENT]
lemma set_incr_disjnt:
  assumes "disjnt A B"
  shows "disjnt (set_incr n A) (set_incr n B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjnt (set_incr n A) (set_incr n B)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
disjnt A B

goal (1 subgoal):
 1. disjnt (set_incr n A) (set_incr n B)
[PROOF STEP]
unfolding disjnt_def set_incr_def
[PROOF STATE]
proof (prove)
using this:
A \<inter> B = {}

goal (1 subgoal):
 1. (\<lambda>a. a + n) ` A \<inter> (\<lambda>a. a + n) ` B = {}
[PROOF STEP]
by force


[STATEMENT]
lemma set_of_distrib_right_left:
  "set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)"
  for A1 :: "'a::{linordered_idom, real_normed_algebra, linear_continuum_topology} interval"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
have "set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * (B1 + B2) + A2 * (B1 + B2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * (B1 + B2) + A2 * (B1 + B2))
[PROOF STEP]
by (rule set_of_distrib_right)
[PROOF STATE]
proof (state)
this:
set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * (B1 + B2) + A2 * (B1 + B2))

goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * (B1 + B2) + A2 * (B1 + B2))

goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
have "... \<subseteq> set_of ((A1 * B1 + A1 * B2) + A2 * (B1 + B2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_of (A1 * (B1 + B2) + A2 * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * (B1 + B2))
[PROOF STEP]
by (rule set_of_add_inc_left[OF set_of_distrib_left])
[PROOF STATE]
proof (state)
this:
set_of (A1 * (B1 + B2) + A2 * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * (B1 + B2))

goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
set_of (A1 * (B1 + B2) + A2 * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * (B1 + B2))

goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
have "... \<subseteq> set_of ((A1 * B1 + A1 * B2) + (A2 * B1 + A2 * B2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_of (A1 * B1 + A1 * B2 + A2 * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + (A2 * B1 + A2 * B2))
[PROOF STEP]
by (rule set_of_add_inc_right[OF set_of_distrib_left])
[PROOF STATE]
proof (state)
this:
set_of (A1 * B1 + A1 * B2 + A2 * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + (A2 * B1 + A2 * B2))

goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + (A2 * B1 + A2 * B2))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + (A2 * B1 + A2 * B2))

goal (1 subgoal):
 1. set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)
[PROOF STEP]
by (simp add: add.assoc)
[PROOF STATE]
proof (state)
this:
set_of ((A1 + A2) * (B1 + B2)) \<subseteq> set_of (A1 * B1 + A1 * B2 + A2 * B1 + A2 * B2)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eucl_of_list_append_zeroes[simp]: "eucl_of_list (xs @ replicate n 0) = eucl_of_list xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eucl_of_list (xs @ replicate n 0) = eucl_of_list xs
[PROOF STEP]
unfolding eucl_of_list_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (map2 (*\<^sub>R) (xs @ replicate n 0) Basis_list) = sum_list (map2 (*\<^sub>R) xs Basis_list)
[PROOF STEP]
apply (auto simp: sum_list_sum_nth)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<min (length xs + n) DIM('a). (xs @ replicate n 0) ! i *\<^sub>R Basis_list ! i) = (\<Sum>i = 0..<min (length xs) DIM('a). xs ! i *\<^sub>R Basis_list ! i)
[PROOF STEP]
apply (rule sum.mono_neutral_cong_right)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. finite {0..<min (length xs + n) DIM('a)}
 2. {0..<min (length xs) DIM('a)} \<subseteq> {0..<min (length xs + n) DIM('a)}
 3. \<forall>i\<in>{0..<min (length xs + n) DIM('a)} - {0..<min (length xs) DIM('a)}. (xs @ replicate n 0) ! i *\<^sub>R Basis_list ! i = (0::'a)
 4. \<And>x. x \<in> {0..<min (length xs) DIM('a)} \<Longrightarrow> (xs @ replicate n 0) ! x *\<^sub>R Basis_list ! x = xs ! x *\<^sub>R Basis_list ! x
[PROOF STEP]
by (auto simp: nth_append)


[STATEMENT]
lemma arcsin_le_iff:
  assumes "x \<ge> -1" "x \<le> 1" "y \<ge> -pi/2" "y \<le> pi/2"
  shows   "arcsin x \<le> y \<longleftrightarrow> x \<le> sin y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
have "arcsin x \<le> y \<longleftrightarrow> sin (arcsin x) \<le> sin y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (arcsin x \<le> y) = (sin (arcsin x) \<le> sin y)
[PROOF STEP]
using arcsin_bounded[of x] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>- 1 \<le> x; x \<le> 1\<rbrakk> \<Longrightarrow> - (pi / 2) \<le> arcsin x \<and> arcsin x \<le> pi / 2
- 1 \<le> x
x \<le> 1
- pi / 2 \<le> y
y \<le> pi / 2

goal (1 subgoal):
 1. (arcsin x \<le> y) = (sin (arcsin x) \<le> sin y)
[PROOF STEP]
by (subst sin_mono_le_eq) auto
[PROOF STATE]
proof (state)
this:
(arcsin x \<le> y) = (sin (arcsin x) \<le> sin y)

goal (1 subgoal):
 1. (arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(arcsin x \<le> y) = (sin (arcsin x) \<le> sin y)

goal (1 subgoal):
 1. (arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
- 1 \<le> x
x \<le> 1
- pi / 2 \<le> y
y \<le> pi / 2
[PROOF STEP]
have "sin (arcsin x) = x"
[PROOF STATE]
proof (prove)
using this:
- 1 \<le> x
x \<le> 1
- pi / 2 \<le> y
y \<le> pi / 2

goal (1 subgoal):
 1. sin (arcsin x) = x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sin (arcsin x) = x

goal (1 subgoal):
 1. (arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(arcsin x \<le> y) = (x \<le> sin y)

goal (1 subgoal):
 1. (arcsin x \<le> y) = (x \<le> sin y)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(arcsin x \<le> y) = (x \<le> sin y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma CARD_INJ_IMAGE_2:
  fixes f s
  assumes "finite s" "(\<forall>x y. ((x \<in> s) \<and> (y \<in> s)) \<longrightarrow> ((f x = f y) \<longleftrightarrow> (x = y)))"
  shows "(card (f ` s) = card s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
fix x y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
assume "x \<in> s" "y \<in> s"
[PROOF STATE]
proof (state)
this:
x \<in> s
y \<in> s

goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> s
y \<in> s
[PROOF STEP]
have "f x = f y \<longrightarrow> x = y"
[PROOF STATE]
proof (prove)
using this:
x \<in> s
y \<in> s

goal (1 subgoal):
 1. f x = f y \<longrightarrow> x = y
[PROOF STEP]
using assms(2)
[PROOF STATE]
proof (prove)
using this:
x \<in> s
y \<in> s
\<forall>x y. x \<in> s \<and> y \<in> s \<longrightarrow> (f x = f y) = (x = y)

goal (1 subgoal):
 1. f x = f y \<longrightarrow> x = y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
f x = f y \<longrightarrow> x = y

goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x2 \<in> s; ?y2 \<in> s\<rbrakk> \<Longrightarrow> f ?x2 = f ?y2 \<longrightarrow> ?x2 = ?y2

goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?x2 \<in> s; ?y2 \<in> s\<rbrakk> \<Longrightarrow> f ?x2 = f ?y2 \<longrightarrow> ?x2 = ?y2
[PROOF STEP]
have "inj_on f s"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x2 \<in> s; ?y2 \<in> s\<rbrakk> \<Longrightarrow> f ?x2 = f ?y2 \<longrightarrow> ?x2 = ?y2

goal (1 subgoal):
 1. inj_on f s
[PROOF STEP]
by (simp add: inj_onI)
[PROOF STATE]
proof (state)
this:
inj_on f s

goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
inj_on f s
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inj_on f s

goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
using assms(1) inj_on_iff_eq_card
[PROOF STATE]
proof (prove)
using this:
inj_on f s
finite s
finite ?A \<Longrightarrow> inj_on ?f ?A = (card (?f ` ?A) = card ?A)

goal (1 subgoal):
 1. card (f ` s) = card s
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (f ` s) = card s

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tendsto_rabs_zero_iff: "((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> (0::real)) F \<longleftrightarrow> (f \<longlongrightarrow> 0) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. \<bar>f x\<bar>) \<longlongrightarrow> 0) F = (f \<longlongrightarrow> 0) F
[PROOF STEP]
by (fold real_norm_def) (rule tendsto_norm_zero_iff)


[STATEMENT]
lemma A_inv_aux: "b>2 \<Longrightarrow> n>0 \<Longrightarrow> \<alpha> b n * \<alpha> b n - \<alpha> b (Suc n) * \<alpha> b (n - Suc 0) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>2 < b; 0 < n\<rbrakk> \<Longrightarrow> \<alpha> b n * \<alpha> b n - \<alpha> b (Suc n) * \<alpha> b (n - Suc 0) = 1
[PROOF STEP]
apply (induction n, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>0 < n \<Longrightarrow> \<alpha> b n * \<alpha> b n - \<alpha> b (Suc n) * \<alpha> b (n - Suc 0) = 1; 2 < b\<rbrakk> \<Longrightarrow> \<alpha> b (Suc n) * \<alpha> b (Suc n) - (int b * \<alpha> b (Suc n) - \<alpha> b n) * \<alpha> b n = 1
[PROOF STEP]
subgoal for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < n \<Longrightarrow> \<alpha> b n * \<alpha> b n - \<alpha> b (Suc n) * \<alpha> b (n - Suc 0) = 1; 2 < b\<rbrakk> \<Longrightarrow> \<alpha> b (Suc n) * \<alpha> b (Suc n) - (int b * \<alpha> b (Suc n) - \<alpha> b n) * \<alpha> b n = 1
[PROOF STEP]
using alpha_det1[of b n]
[PROOF STATE]
proof (prove)
using this:
2 < b \<Longrightarrow> (\<alpha> b (Suc n))\<^sup>2 - int b * \<alpha> b (Suc n) * \<alpha> b n + (\<alpha> b n)\<^sup>2 = 1

goal (1 subgoal):
 1. \<lbrakk>0 < n \<Longrightarrow> \<alpha> b n * \<alpha> b n - \<alpha> b (Suc n) * \<alpha> b (n - Suc 0) = 1; 2 < b\<rbrakk> \<Longrightarrow> \<alpha> b (Suc n) * \<alpha> b (Suc n) - (int b * \<alpha> b (Suc n) - \<alpha> b n) * \<alpha> b n = 1
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < n \<Longrightarrow> \<alpha> b n * \<alpha> b n - \<alpha> b (Suc n) * \<alpha> b (n - Suc 0) = 1; 2 < b; (\<alpha> b (Suc n))\<^sup>2 - int b * \<alpha> b (Suc n) * \<alpha> b n + (\<alpha> b n)\<^sup>2 = 1\<rbrakk> \<Longrightarrow> \<alpha> b (Suc n) * \<alpha> b (Suc n) - (int b * \<alpha> b (Suc n) - \<alpha> b n) * \<alpha> b n = 1
[PROOF STEP]
by algebra
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
theorem sum_of_two_squares_prime: assumes "prime p"
  shows "is_sum2sq_nat p = [p\<noteq>3] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
proof (cases "[p=3] (mod 4)")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. [p = 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
 2. [p \<noteq> 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
[p = 3] (mod 4)

goal (2 subgoals):
 1. [p = 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
 2. [p \<noteq> 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
have "odd (multiplicity p p)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd (multiplicity p p)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
prime p

goal (1 subgoal):
 1. odd (multiplicity p p)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
odd (multiplicity p p)

goal (2 subgoals):
 1. [p = 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
 2. [p \<noteq> 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
hence "\<not> (is_sum2sq_nat p)"
[PROOF STATE]
proof (prove)
using this:
odd (multiplicity p p)

goal (1 subgoal):
 1. \<not> is_sum2sq_nat p
[PROOF STEP]
using assms True sum_of_two_squares'
[PROOF STATE]
proof (prove)
using this:
odd (multiplicity p p)
prime p
[p = 3] (mod 4)
is_sum2sq_nat ?n = (\<forall>p. prime p \<and> [p = 3] (mod 4) \<longrightarrow> even (multiplicity p ?n))

goal (1 subgoal):
 1. \<not> is_sum2sq_nat p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<not> is_sum2sq_nat p

goal (2 subgoals):
 1. [p = 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
 2. [p \<noteq> 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
with True
[PROOF STATE]
proof (chain)
picking this:
[p = 3] (mod 4)
\<not> is_sum2sq_nat p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[p = 3] (mod 4)
\<not> is_sum2sq_nat p

goal (1 subgoal):
 1. is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
is_sum2sq_nat p = [p \<noteq> 3] (mod 4)

goal (1 subgoal):
 1. [p \<noteq> 3] (mod 4) \<Longrightarrow> is_sum2sq_nat p = [p \<noteq> 3] (mod 4)
[PROOF STEP]
qed (simp add: fermat_two_squares assms)


[STATEMENT]
lemma "filterlim (\<lambda>n. (1 + (2 / 3 :: real) ^ (n + 1)) ^ 2 ^ n / 2 powr (4 / 3) ^ (n - 1))
         at_top at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM n sequentially. (1 + (2 / 3) ^ (n + 1)) ^ 2 ^ n / 2 powr (4 / 3) ^ (n - 1) :> at_top
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. LIM n sequentially. (1 + (2 / 3) ^ (n + 1)) ^ 2 ^ n / 2 powr (4 / 3) ^ (n - 1) :> at_top
[PROOF STEP]
have [simp]: "ln 4 = 2 * ln (2 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ln 4 = 2 * ln 2
[PROOF STEP]
using ln_realpow[of 2 2]
[PROOF STATE]
proof (prove)
using this:
0 < 2 \<Longrightarrow> ln (2\<^sup>2) = real 2 * ln 2

goal (1 subgoal):
 1. ln 4 = 2 * ln 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ln 4 = 2 * ln 2

goal (1 subgoal):
 1. LIM n sequentially. (1 + (2 / 3) ^ (n + 1)) ^ 2 ^ n / 2 powr (4 / 3) ^ (n - 1) :> at_top
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM n sequentially. (1 + (2 / 3) ^ (n + 1)) ^ 2 ^ n / 2 powr (4 / 3) ^ (n - 1) :> at_top
[PROOF STEP]
by (real_asymp simp: field_simps ln_div)
[PROOF STATE]
proof (state)
this:
LIM n sequentially. (1 + (2 / 3) ^ (n + 1)) ^ 2 ^ n / 2 powr (4 / 3) ^ (n - 1) :> at_top

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma base_case_invertible_mat:
  shows "invertible_mat (matrix_A [[1], [- 1]] [[], [0]])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invertible_mat (M_mat [[1], [- 1]] [[], [0]])
[PROOF STEP]
unfolding invertible_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. square_mat (M_mat [[1], [- 1]] [[], [0]]) \<and> (\<exists>B. inverts_mat (M_mat [[1], [- 1]] [[], [0]]) B \<and> inverts_mat B (M_mat [[1], [- 1]] [[], [0]]))
[PROOF STEP]
using inverse_mat_base_case inverse_mat_base_case_2
[PROOF STATE]
proof (prove)
using this:
inverts_mat (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]]) (mat_of_rows_list 2 [[1, 1], [1, - 1]])
inverts_mat (mat_of_rows_list 2 [[1, 1], [1, - 1]]) (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]])

goal (1 subgoal):
 1. square_mat (M_mat [[1], [- 1]] [[], [0]]) \<and> (\<exists>B. inverts_mat (M_mat [[1], [- 1]] [[], [0]]) B \<and> inverts_mat B (M_mat [[1], [- 1]] [[], [0]]))
[PROOF STEP]
apply (auto)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>inverts_mat (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]]) (mat_of_rows_list 2 [[1, 1], [1, - 1]]); inverts_mat (mat_of_rows_list 2 [[1, 1], [1, - 1]]) (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]])\<rbrakk> \<Longrightarrow> dim_col (M_mat [[1], [- 1]] [[], [0]]) = dim_row (M_mat [[1], [- 1]] [[], [0]])
 2. \<lbrakk>inverts_mat (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]]) (mat_of_rows_list 2 [[1, 1], [1, - 1]]); inverts_mat (mat_of_rows_list 2 [[1, 1], [1, - 1]]) (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]])\<rbrakk> \<Longrightarrow> \<exists>B. inverts_mat (M_mat [[1], [- 1]] [[], [0]]) B \<and> inverts_mat B (M_mat [[1], [- 1]] [[], [0]])
[PROOF STEP]
apply (simp add: mat_base_case mat_of_rows_list_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>inverts_mat (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]]) (mat_of_rows_list 2 [[1, 1], [1, - 1]]); inverts_mat (mat_of_rows_list 2 [[1, 1], [1, - 1]]) (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]])\<rbrakk> \<Longrightarrow> \<exists>B. inverts_mat (M_mat [[1], [- 1]] [[], [0]]) B \<and> inverts_mat B (M_mat [[1], [- 1]] [[], [0]])
[PROOF STEP]
using mat_base_case
[PROOF STATE]
proof (prove)
using this:
M_mat [[1], [- 1]] [[], [0]] = mat_of_rows_list 2 [[1, 1], [1, - 1]]

goal (1 subgoal):
 1. \<lbrakk>inverts_mat (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]]) (mat_of_rows_list 2 [[1, 1], [1, - 1]]); inverts_mat (mat_of_rows_list 2 [[1, 1], [1, - 1]]) (mat_of_rows_list 2 [[1 / 2, 1 / 2], [1 / 2, - (1 / 2)]])\<rbrakk> \<Longrightarrow> \<exists>B. inverts_mat (M_mat [[1], [- 1]] [[], [0]]) B \<and> inverts_mat B (M_mat [[1], [- 1]] [[], [0]])
[PROOF STEP]
by auto


[STATEMENT]
lemma card_permutations_of_multiset_aux:
  "card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
proof (induction A rule: multiset_remove_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
case (remove A)
[PROOF STATE]
proof (state)
this:
A \<noteq> {#}
?x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#?x#})) * (\<Prod>x\<in>set_mset (A - {#?x#}). fact (count (A - {#?x#}) x)) = fact (size (A - {#?x#}))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
have "card (permutations_of_multiset A) =
          card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#}))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (permutations_of_multiset A) = card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#}))
[PROOF STEP]
by (simp add: permutations_of_multiset_nonempty remove.hyps)
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset A) = card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#}))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset A) = card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#}))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
have "\<dots> = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#})) = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})))
[PROOF STEP]
by (subst card_UN_disjoint) (auto simp: card_image)
[PROOF STATE]
proof (state)
this:
card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#})) = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (\<Union>x\<in>set_mset A. (#) x ` permutations_of_multiset (A - {#x#})) = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
have "\<dots> * (\<Prod>x\<in>set_mset A. fact (count A x)) =
               (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) *
                 (\<Prod>y\<in>set_mset A. fact (count A y)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#}))) * (\<Prod>x\<in>set_mset A. fact (count A x)) = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)))
[PROOF STEP]
by (subst sum_distrib_right) simp_all
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#}))) * (\<Prod>x\<in>set_mset A. fact (count A x)) = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#}))) * (\<Prod>x\<in>set_mset A. fact (count A x)) = (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
have "\<dots> = (\<Sum>x\<in>set_mset A. count A x * fact (size A - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y))) = (\<Sum>x\<in>set_mset A. count A x * fact (size A - 1))
[PROOF STEP]
proof (intro sum.cong refl)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
assume x: "x \<in># A"
[PROOF STATE]
proof (state)
this:
x \<in># A

goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
have "card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) =
            count A x * (card (permutations_of_multiset (A - {#x#})) *
              (\<Prod>y\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) y)))" (is "?lhs = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * (card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) y)))
[PROOF STEP]
by (subst multiset_prod_fact_remove[OF x]) simp_all
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * (card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) y)))

goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * (card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) y)))

goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
note remove.IH[OF x]
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))

goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))

goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
from x
[PROOF STATE]
proof (chain)
picking this:
x \<in># A
[PROOF STEP]
have "size (A - {#x#}) = size A - 1"
[PROOF STATE]
proof (prove)
using this:
x \<in># A

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

goal (1 subgoal):
 1. \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
show "?lhs = count A x * fact (size A - 1)"
[PROOF STATE]
proof (prove)
using this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)

goal (1 subgoal):
 1. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y)) = count A x * fact (size A - 1)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y))) = (\<Sum>x\<in>set_mset A. count A x * fact (size A - 1))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. card (permutations_of_multiset (A - {#x#})) * (\<Prod>y\<in>set_mset A. fact (count A y))) = (\<Sum>x\<in>set_mset A. count A x * fact (size A - 1))

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
have "(\<Sum>x\<in>set_mset A. count A x * fact (size A - 1)) =
                size A * fact (size A - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x\<in>set_mset A. count A x * fact (size A - 1)) = size A * fact (size A - 1)
[PROOF STEP]
by (simp add: sum_distrib_right size_multiset_overloaded_eq)
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. count A x * fact (size A - 1)) = size A * fact (size A - 1)

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x\<in>set_mset A. count A x * fact (size A - 1)) = size A * fact (size A - 1)

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
from remove.hyps
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> {#}
[PROOF STEP]
have "\<dots> = fact (size A)"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> {#}

goal (1 subgoal):
 1. size A * fact (size A - 1) = fact (size A)
[PROOF STEP]
by (cases "size A") auto
[PROOF STATE]
proof (state)
this:
size A * fact (size A - 1) = fact (size A)

goal (2 subgoals):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
 2. \<And>A. \<lbrakk>A \<noteq> {#}; \<And>x. x \<in># A \<Longrightarrow> card (permutations_of_multiset (A - {#x#})) * (\<Prod>xa\<in>set_mset (A - {#x#}). fact (count (A - {#x#}) xa)) = fact (size (A - {#x#}))\<rbrakk> \<Longrightarrow> card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)

goal (1 subgoal):
 1. card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (permutations_of_multiset A) * (\<Prod>x\<in>set_mset A. fact (count A x)) = fact (size A)

goal (1 subgoal):
 1. card (permutations_of_multiset {#}) * (\<Prod>x\<in>set_mset {#}. fact (count {#} x)) = fact (size {#})
[PROOF STEP]
qed simp_all


[STATEMENT]
lemma sum_splice_other_way_round: " (\<Sum>j=(0::nat)..<i. f (2*j)) + (\<Sum>j=0..<i. f (2*j+1)) =
        (\<Sum>j=(0::nat)..<2*i. f j )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>j = 0..<i. f (2 * j)) + (\<Sum>j = 0..<i. f (2 * j + 1)) = sum f {0..<2 * i}
[PROOF STEP]
by (metis sum_splice)


[STATEMENT]
lemma column_QR_decomposition':
  fixes A::"real^'n::{mod_type}^'m::{mod_type}"
  assumes r: "rank A = ncols A"
  shows "(column k A) = column k ((Gram_Schmidt_matrix A))
  + (\<Sum>x\<in>{column i (fst (QR_decomposition A))|i. i < k}. (x \<bullet> (column k A) / (x \<bullet> x)) *\<^sub>R x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column k A = column k (Gram_Schmidt_matrix A) + (\<Sum>x\<in>{column i (fst (QR_decomposition A)) |i. i < k}. (x \<bullet> column k A / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
using column_QR_decomposition[OF r]
[PROOF STATE]
proof (prove)
using this:
column ?k (Gram_Schmidt_matrix A) = column ?k A - (\<Sum>x\<in>{column i (fst (QR_decomposition A)) |i. i < ?k}. (x \<bullet> column ?k A / (x \<bullet> x)) *\<^sub>R x)

goal (1 subgoal):
 1. column k A = column k (Gram_Schmidt_matrix A) + (\<Sum>x\<in>{column i (fst (QR_decomposition A)) |i. i < k}. (x \<bullet> column k A / (x \<bullet> x)) *\<^sub>R x)
[PROOF STEP]
by simp


[STATEMENT]
lemma polar_identity_minus:
  includes notation_norm
  shows \<open>\<parallel>x - y\<parallel>^2 = \<parallel>x\<parallel>^2 + \<parallel>y\<parallel>^2 - 2 * Re (x \<bullet>\<^sub>C y)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)
[PROOF STEP]
have \<open>\<parallel>x + (-y)\<parallel>^2 = \<parallel>x\<parallel>^2 + \<parallel>-y\<parallel>^2 + 2 * Re (x \<bullet>\<^sub>C -y)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<parallel>x + - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>- y\<parallel>\<^sup>2 + 2 * Re (x \<bullet>\<^sub>C - y)
[PROOF STEP]
using polar_identity
[PROOF STATE]
proof (prove)
using this:
\<parallel>?x + ?y\<parallel>\<^sup>2 = \<parallel>?x\<parallel>\<^sup>2 + \<parallel>?y\<parallel>\<^sup>2 + 2 * Re (?x \<bullet>\<^sub>C ?y)

goal (1 subgoal):
 1. \<parallel>x + - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>- y\<parallel>\<^sup>2 + 2 * Re (x \<bullet>\<^sub>C - y)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<parallel>x + - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>- y\<parallel>\<^sup>2 + 2 * Re (x \<bullet>\<^sub>C - y)

goal (1 subgoal):
 1. \<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)
[PROOF STEP]
hence \<open>\<parallel>x - y\<parallel>^2 = \<parallel>x\<parallel>^2 + \<parallel>y\<parallel>^2 - 2*Re (x \<bullet>\<^sub>C y)\<close>
[PROOF STATE]
proof (prove)
using this:
\<parallel>x + - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>- y\<parallel>\<^sup>2 + 2 * Re (x \<bullet>\<^sub>C - y)

goal (1 subgoal):
 1. \<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)

goal (1 subgoal):
 1. \<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)

goal (1 subgoal):
 1. \<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<parallel>x - y\<parallel>\<^sup>2 = \<parallel>x\<parallel>\<^sup>2 + \<parallel>y\<parallel>\<^sup>2 - 2 * Re (x \<bullet>\<^sub>C y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma all_Suc_split: "(\<forall>i. P i) \<longleftrightarrow> (P 0 \<and> (\<forall>i. P (Suc i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>i. P i) = (P 0 \<and> (\<forall>i. P (Suc i)))
[PROOF STEP]
using nat_induct
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?P 0; \<And>n. ?P n \<Longrightarrow> ?P (Suc n)\<rbrakk> \<Longrightarrow> ?P ?n

goal (1 subgoal):
 1. (\<forall>i. P i) = (P 0 \<and> (\<forall>i. P (Suc i)))
[PROOF STEP]
by auto


[STATEMENT]
lemma two_powr_div:
  assumes "j < (i::nat) "
  shows "((2^i) div ((2::nat)^j)) =  2^(i-j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ i div 2 ^ j = 2 ^ (i - j)
[PROOF STEP]
by (simp add: assms less_or_eq_imp_le power_diff)


[STATEMENT]
lemma submatrix_carrier_first:
  assumes H: "H \<in> carrier_mat m n"
  and k1: "k1 \<le> m" and k2: "k2 \<le> n"
  shows"submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2
[PROOF STEP]
have km: "k1\<le>m" and kn: "k2\<le>n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k1 \<le> m &&& k2 \<le> n
[PROOF STEP]
using k1 k2
[PROOF STATE]
proof (prove)
using this:
k1 \<le> m
k2 \<le> n

goal (1 subgoal):
 1. k1 \<le> m &&& k2 \<le> n
[PROOF STEP]
by simp+
[PROOF STATE]
proof (state)
this:
k1 \<le> m
k2 \<le> n

goal (1 subgoal):
 1. submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2
[PROOF STEP]
have card_mk: "card {i. i < m \<and> i < k1} = k1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {i. i < m \<and> i < k1} = k1
[PROOF STEP]
using km
[PROOF STATE]
proof (prove)
using this:
k1 \<le> m

goal (1 subgoal):
 1. card {i. i < m \<and> i < k1} = k1
[PROOF STEP]
by (smt Collect_cong card_Collect_less_nat le_eq_less_or_eq nat_less_induct nat_neq_iff)
[PROOF STATE]
proof (state)
this:
card {i. i < m \<and> i < k1} = k1

goal (1 subgoal):
 1. submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2
[PROOF STEP]
have card_nk: "card {i. i < n \<and> i < k2} = k2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {i. i < n \<and> i < k2} = k2
[PROOF STEP]
using kn
[PROOF STATE]
proof (prove)
using this:
k2 \<le> n

goal (1 subgoal):
 1. card {i. i < n \<and> i < k2} = k2
[PROOF STEP]
by (smt Collect_cong card_Collect_less_nat le_eq_less_or_eq nat_less_induct nat_neq_iff)
[PROOF STATE]
proof (state)
this:
card {i. i < n \<and> i < k2} = k2

goal (1 subgoal):
 1. submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2
[PROOF STEP]
by (smt Collect_cong H atLeastLessThan_iff card_mk card_nk carrier_matD
        carrier_matI dim_submatrix zero_order(1))
[PROOF STATE]
proof (state)
this:
submatrix H {0..<k1} {0..<k2} \<in> carrier_mat k1 k2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma powr_less_mono':
  assumes "(x::real) > 0" "x < 1" "a < b"
  shows   "x powr b < x powr a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x powr b < x powr a
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x powr b < x powr a
[PROOF STEP]
have "inverse x powr a < inverse x powr b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inverse x powr a < inverse x powr b
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < x
x < 1
a < b

goal (1 subgoal):
 1. inverse x powr a < inverse x powr b
[PROOF STEP]
by (intro powr_less_mono) (simp_all add: field_simps)
[PROOF STATE]
proof (state)
this:
inverse x powr a < inverse x powr b

goal (1 subgoal):
 1. x powr b < x powr a
[PROOF STEP]
hence "inverse (x powr a) < inverse (x powr b)"
[PROOF STATE]
proof (prove)
using this:
inverse x powr a < inverse x powr b

goal (1 subgoal):
 1. inverse (x powr a) < inverse (x powr b)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
inverse x powr a < inverse x powr b
0 < x
x < 1
a < b

goal (1 subgoal):
 1. inverse (x powr a) < inverse (x powr b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inverse (x powr a) < inverse (x powr b)

goal (1 subgoal):
 1. x powr b < x powr a
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < x
x < 1
a < b
inverse (x powr a) < inverse (x powr b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < x
x < 1
a < b
inverse (x powr a) < inverse (x powr b)

goal (1 subgoal):
 1. x powr b < x powr a
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
x powr b < x powr a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mat_det_left_def: assumes A: "A \<in> carrier_mat n n"
  shows "det A = (\<Sum>p\<in>{p. p permutes {0..<dim_row A}}. signof p * (\<Prod>i = 0 ..< dim_row A. A $$ (p i, i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. det A = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
have cong: "\<And> a b c. b = c \<Longrightarrow> a * b = a * c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a b c. b = c \<Longrightarrow> a * b = a * c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?b = ?c \<Longrightarrow> ?a * ?b = ?a * ?c

goal (1 subgoal):
 1. det A = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
unfolding det_transpose[OF A, symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. det A\<^sup>T = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
unfolding det_def index_transpose_mat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if dim_col A = dim_row A then \<Sum>p | p permutes {0..<dim_col A}. of_int (sign p) * (\<Prod>i = 0..<dim_col A. A\<^sup>T $$ (i, p i)) else (0::'a)) = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n

goal (1 subgoal):
 1. (if dim_col A = dim_row A then \<Sum>p | p permutes {0..<dim_col A}. of_int (sign p) * (\<Prod>i = 0..<dim_col A. A\<^sup>T $$ (i, p i)) else (0::'a)) = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
det A = (\<Sum>p | p permutes {0..<dim_row A}. of_int (sign p) * (\<Prod>i = 0..<dim_row A. A $$ (p i, i)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tensor_mat_trace:
  assumes "m1 \<in> carrier_mat d1 d1"
    and "m2 \<in> carrier_mat d2 d2"
  shows "trace (tensor_mat m1 m2) = trace m1 * trace m2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (tensor_mat m1 m2) = trace m1 * trace m2
[PROOF STEP]
apply (auto simp add: tensor_mat_carrier trace_def tensor_mat_eval)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<d. m1 $$ (encode1 i, encode1 i) * m2 $$ (encode2 i, encode2 i)) = (\<Sum>i = 0..<dim_row m1. m1 $$ (i, i)) * (\<Sum>i = 0..<dim_row m2. m2 $$ (i, i))
[PROOF STEP]
apply (subst Groups_Big.sum_product)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<d. m1 $$ (encode1 i, encode1 i) * m2 $$ (encode2 i, encode2 i)) = (\<Sum>i = 0..<dim_row m1. \<Sum>j = 0..<dim_row m2. m1 $$ (i, i) * m2 $$ (j, j))
[PROOF STEP]
apply (subst sum_encode[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>i = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (i, i) * m2 $$ (j, j)) = (\<Sum>i = 0..<dim_row m1. \<Sum>j = 0..<dim_row m2. m1 $$ (i, i) * m2 $$ (j, j))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
m1 \<in> carrier_mat d1 d1
m2 \<in> carrier_mat d2 d2

goal (1 subgoal):
 1. (\<Sum>i = 0..<d1. \<Sum>j = 0..<d2. m1 $$ (i, i) * m2 $$ (j, j)) = (\<Sum>i = 0..<dim_row m1. \<Sum>j = 0..<dim_row m2. m1 $$ (i, i) * m2 $$ (j, j))
[PROOF STEP]
by auto


[STATEMENT]
lemma homotopic_with_compose_continuous_map_left:
  "\<lbrakk>homotopic_with p X1 X2 f g; continuous_map X2 X3 h; \<And>j. p j \<Longrightarrow> q(h \<circ> j)\<rbrakk>
   \<Longrightarrow> homotopic_with q X1 X3 (h \<circ> f) (h \<circ> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>homotopic_with p X1 X2 f g; continuous_map X2 X3 h; \<And>j. p j \<Longrightarrow> q (h \<circ> j)\<rbrakk> \<Longrightarrow> homotopic_with q X1 X3 (h \<circ> f) (h \<circ> g)
[PROOF STEP]
unfolding homotopic_with_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>h. continuous_map (prod_topology (top_of_set {0..1}) X1) X2 h \<and> (\<forall>x. h (0, x) = f x) \<and> (\<forall>x. h (1, x) = g x) \<and> (\<forall>t\<in>{0..1}. p (\<lambda>x. h (t, x))); continuous_map X2 X3 h; \<And>j. p j \<Longrightarrow> q (h \<circ> j)\<rbrakk> \<Longrightarrow> \<exists>ha. continuous_map (prod_topology (top_of_set {0..1}) X1) X3 ha \<and> (\<forall>x. ha (0, x) = (h \<circ> f) x) \<and> (\<forall>x. ha (1, x) = (h \<circ> g) x) \<and> (\<forall>t\<in>{0..1}. q (\<lambda>x. ha (t, x)))
[PROOF STEP]
apply clarify
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ha. \<lbrakk>continuous_map X2 X3 h; \<And>j. p j \<Longrightarrow> q (h \<circ> j); continuous_map (prod_topology (top_of_set {0..1}) X1) X2 ha; \<forall>x. ha (0, x) = f x; \<forall>x. ha (1, x) = g x; \<forall>t\<in>{0..1}. p (\<lambda>x. ha (t, x))\<rbrakk> \<Longrightarrow> \<exists>ha. continuous_map (prod_topology (top_of_set {0..1}) X1) X3 ha \<and> (\<forall>x. ha (0, x) = (h \<circ> f) x) \<and> (\<forall>x. ha (1, x) = (h \<circ> g) x) \<and> (\<forall>t\<in>{0..1}. q (\<lambda>x. ha (t, x)))
[PROOF STEP]
subgoal for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>continuous_map X2 X3 h; \<And>j. p j \<Longrightarrow> q (h \<circ> j); continuous_map (prod_topology (top_of_set {0..1}) X1) X2 k; \<forall>x. k (0, x) = f x; \<forall>x. k (1, x) = g x; \<forall>t\<in>{0..1}. p (\<lambda>x. k (t, x))\<rbrakk> \<Longrightarrow> \<exists>ha. continuous_map (prod_topology (top_of_set {0..1}) X1) X3 ha \<and> (\<forall>x. ha (0, x) = (h \<circ> f) x) \<and> (\<forall>x. ha (1, x) = (h \<circ> g) x) \<and> (\<forall>t\<in>{0..1}. q (\<lambda>x. ha (t, x)))
[PROOF STEP]
by (rule_tac x="h \<circ> k" in exI) (rule conjI continuous_map_compose | simp add: o_def)+
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma prodinf_exp:
  assumes "summable f"
  shows "prodinf (\<lambda>i. exp (f i)) = exp (suminf f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>i. exp (f i)) = exp (suminf f)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Prod>i. exp (f i)) = exp (suminf f)
[PROOF STEP]
have "f sums suminf f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f sums suminf f
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
summable f

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

goal (1 subgoal):
 1. (\<Prod>i. exp (f i)) = exp (suminf f)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f sums suminf f
[PROOF STEP]
have "(\<lambda>i. exp (f i)) has_prod exp (suminf f)"
[PROOF STATE]
proof (prove)
using this:
f sums suminf f

goal (1 subgoal):
 1. (\<lambda>i. exp (f i)) has_prod exp (suminf f)
[PROOF STEP]
by (simp add: has_prod_def sums_imp_has_prod_exp)
[PROOF STATE]
proof (state)
this:
(\<lambda>i. exp (f i)) has_prod exp (suminf f)

goal (1 subgoal):
 1. (\<Prod>i. exp (f i)) = exp (suminf f)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>i. exp (f i)) has_prod exp (suminf f)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>i. exp (f i)) has_prod exp (suminf f)

goal (1 subgoal):
 1. (\<Prod>i. exp (f i)) = exp (suminf f)
[PROOF STEP]
by (rule has_prod_unique [symmetric])
[PROOF STATE]
proof (state)
this:
(\<Prod>i. exp (f i)) = exp (suminf f)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma docking_station_arith:
  assumes "(d::real) > x" and "v > 0"
  shows "(v = v\<^sup>2 * t / (2 * d - 2 * x)) \<longleftrightarrow> (v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v = v\<^sup>2 * t / (2 * d - 2 * x)) = (v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x) \<Longrightarrow> v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
 2. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
assume "v = v\<^sup>2 * t / (2 * d - 2 * x)"
[PROOF STATE]
proof (state)
this:
v = v\<^sup>2 * t / (2 * d - 2 * x)

goal (2 subgoals):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x) \<Longrightarrow> v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
 2. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
hence "v * t = 2 * (d - x)"
[PROOF STATE]
proof (prove)
using this:
v = v\<^sup>2 * t / (2 * d - 2 * x)

goal (1 subgoal):
 1. v * t = 2 * (d - x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
v = v\<^sup>2 * t / (2 * d - 2 * x)
x < d
0 < v

goal (1 subgoal):
 1. v * t = 2 * (d - x)
[PROOF STEP]
by (simp add: eq_divide_eq power2_eq_square)
[PROOF STATE]
proof (state)
this:
v * t = 2 * (d - x)

goal (2 subgoals):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x) \<Longrightarrow> v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
 2. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
hence "v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = 2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x"
[PROOF STATE]
proof (prove)
using this:
v * t = 2 * (d - x)

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = 2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x
[PROOF STEP]
apply(subst power_mult_distrib[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v * t = 2 * (d - x) \<Longrightarrow> v * t - (v * t)\<^sup>2 / (4 * d - 4 * x) + x = 2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x
[PROOF STEP]
by (erule ssubst, subst power_mult_distrib, simp)
[PROOF STATE]
proof (state)
this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = 2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x

goal (2 subgoals):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x) \<Longrightarrow> v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
 2. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = 2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x

goal (2 subgoals):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x) \<Longrightarrow> v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
 2. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
have "... = d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x = d
[PROOF STEP]
apply(simp only: mult_divide_mult_cancel_left_if)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * (d - x) - (if 4 = 0 then 0 else (d - x)\<^sup>2 / (d - x)) + x = d
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x < d
0 < v

goal (1 subgoal):
 1. 2 * (d - x) - (if 4 = 0 then 0 else (d - x)\<^sup>2 / (d - x)) + x = d
[PROOF STEP]
by (auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
2 * (d - x) - 4 * (d - x)\<^sup>2 / (4 * (d - x)) + x = d

goal (2 subgoals):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x) \<Longrightarrow> v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
 2. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
[PROOF STEP]
show "v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d"
[PROOF STATE]
proof (prove)
using this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
assume "v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d"
[PROOF STATE]
proof (state)
this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
hence "0 = v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t"
[PROOF STATE]
proof (prove)
using this:
v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d

goal (1 subgoal):
 1. 0 = v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 = v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
hence "0 = (4 * (d - x)) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t)"
[PROOF STATE]
proof (prove)
using this:
0 = v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t

goal (1 subgoal):
 1. 0 = 4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 = 4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t)

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
0 = 4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t)

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
have "... = v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2  - (4 * (d - x)) * (v * t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t) = v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2 - 4 * (d - x) * (v * t)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x < d
0 < v

goal (1 subgoal):
 1. 4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t) = v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2 - 4 * (d - x) * (v * t)
[PROOF STEP]
apply(simp add: distrib_left right_diff_distrib)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x < d; 0 < v\<rbrakk> \<Longrightarrow> (4 * d - 4 * x) * d - (4 * d - 4 * x) * x = 4 * (d - x)\<^sup>2
[PROOF STEP]
apply(subst right_diff_distrib[symmetric])+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x < d; 0 < v\<rbrakk> \<Longrightarrow> 4 * (d - x) * (d - x) = 4 * (d - x)\<^sup>2
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t) = v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2 - 4 * (d - x) * (v * t)

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
4 * (d - x) * (v\<^sup>2 * t\<^sup>2 / (4 * (d - x)) + (d - x) - v * t) = v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2 - 4 * (d - x) * (v * t)

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
have "... = (v * t - 2 * (d - x))\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2 - 4 * (d - x) * (v * t) = (v * t - 2 * (d - x))\<^sup>2
[PROOF STEP]
by (simp only: power2_diff, auto simp: field_simps power2_diff)
[PROOF STATE]
proof (state)
this:
v\<^sup>2 * t\<^sup>2 + 4 * (d - x)\<^sup>2 - 4 * (d - x) * (v * t) = (v * t - 2 * (d - x))\<^sup>2

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
0 = (v * t - 2 * (d - x))\<^sup>2
[PROOF STEP]
have "0 = (v * t - 2 * (d - x))\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
0 = (v * t - 2 * (d - x))\<^sup>2

goal (1 subgoal):
 1. 0 = (v * t - 2 * (d - x))\<^sup>2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
0 = (v * t - 2 * (d - x))\<^sup>2

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
hence "v * t = 2 * (d - x)"
[PROOF STATE]
proof (prove)
using this:
0 = (v * t - 2 * (d - x))\<^sup>2

goal (1 subgoal):
 1. v * t = 2 * (d - x)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v * t = 2 * (d - x)

goal (1 subgoal):
 1. v * t - v\<^sup>2 * t\<^sup>2 / (4 * d - 4 * x) + x = d \<Longrightarrow> v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
thus "v = v\<^sup>2 * t / (2 * d - 2 * x)"
[PROOF STATE]
proof (prove)
using this:
v * t = 2 * (d - x)

goal (1 subgoal):
 1. v = v\<^sup>2 * t / (2 * d - 2 * x)
[PROOF STEP]
apply(subst power2_eq_square, subst mult.assoc)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>v * t = 2 * (d - x); v * t = 2 * (d - x)\<rbrakk> \<Longrightarrow> v = v * (v * t) / (2 * d - 2 * x)
[PROOF STEP]
apply(erule ssubst, subst right_diff_distrib[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v * t = 2 * (d - x) \<Longrightarrow> v = v * (2 * (d - x)) / (2 * (d - x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x < d
0 < v

goal (1 subgoal):
 1. v * t = 2 * (d - x) \<Longrightarrow> v = v * (2 * (d - x)) / (2 * (d - x))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
v = v\<^sup>2 * t / (2 * d - 2 * x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma image_affinity_interval:
  fixes c :: "'a::ordered_real_vector"
  shows "((\<lambda>x. m *\<^sub>R x + c) ` {a..b}) =
           (if {a..b}={} then {}
            else if 0 \<le> m then {m *\<^sub>R a + c .. m  *\<^sub>R b + c}
            else {m *\<^sub>R b + c .. m *\<^sub>R a + c})"
         (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
proof (cases "m=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. m = 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
 2. m \<noteq> 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
m = 0

goal (2 subgoals):
 1. m = 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
 2. m \<noteq> 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m = 0

goal (1 subgoal):
 1. (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})

goal (1 subgoal):
 1. m \<noteq> 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. m \<noteq> 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
m \<noteq> 0

goal (1 subgoal):
 1. m \<noteq> 0 \<Longrightarrow> (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<lambda>x. m *\<^sub>R x + c) ` {a..b} \<subseteq> (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
 2. (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c}) \<subseteq> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
show "?lhs \<subseteq> ?rhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. m *\<^sub>R x + c) ` {a..b} \<subseteq> (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})
[PROOF STEP]
by (auto simp: scaleR_left_mono scaleR_left_mono_neg)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. m *\<^sub>R x + c) ` {a..b} \<subseteq> (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})

goal (1 subgoal):
 1. (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c}) \<subseteq> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
show "?rhs \<subseteq> ?lhs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c}) \<subseteq> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
proof (clarsimp, intro conjI impI subsetI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
 2. \<And>x. \<lbrakk>\<not> 0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R b + c..m *\<^sub>R a + c}\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
show "\<lbrakk>0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}\<rbrakk>
            \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. \<lbrakk>0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
by (rule_tac x="inverse m *\<^sub>R (x-c)" in image_eqI)
           (auto simp: pos_le_divideR_eq pos_divideR_le_eq le_diff_eq diff_le_eq)
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 \<le> m; a \<le> b; ?x \<in> {m *\<^sub>R a + c..m *\<^sub>R b + c}\<rbrakk> \<Longrightarrow> ?x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}

goal (1 subgoal):
 1. \<And>x. \<lbrakk>\<not> 0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R b + c..m *\<^sub>R a + c}\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
show "\<lbrakk>\<not> 0 \<le> m; a \<le> b;  x \<in> {m *\<^sub>R b + c..m *\<^sub>R a + c}\<rbrakk>
            \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}" for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<not> 0 \<le> m; a \<le> b; x \<in> {m *\<^sub>R b + c..m *\<^sub>R a + c}\<rbrakk> \<Longrightarrow> x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}
[PROOF STEP]
by (rule_tac x="inverse m *\<^sub>R (x-c)" in image_eqI)
           (auto simp add: neg_le_divideR_eq neg_divideR_le_eq le_diff_eq diff_le_eq)
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<not> 0 \<le> m; a \<le> b; ?x \<in> {m *\<^sub>R b + c..m *\<^sub>R a + c}\<rbrakk> \<Longrightarrow> ?x \<in> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c}) \<subseteq> (\<lambda>x. m *\<^sub>R x + c) ` {a..b}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. m *\<^sub>R x + c) ` {a..b} = (if {a..b} = {} then {} else if 0 \<le> m then {m *\<^sub>R a + c..m *\<^sub>R b + c} else {m *\<^sub>R b + c..m *\<^sub>R a + c})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma index_outer_prod:
  fixes v w :: "'a::conjugatable_field vec"
  assumes v: "v \<in> carrier_vec n" and w: "w \<in> carrier_vec m"
    and ij: "i < n" "j < m"
  shows "(outer_prod v w)$$(i, j) = v $ i * conjugate (w $ j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outer_prod v w $$ (i, j) = v $ i * conjugate (w $ j)
[PROOF STEP]
unfolding outer_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) = v $ i * conjugate (w $ j)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
v \<in> carrier_vec n
w \<in> carrier_vec m
i < n
j < m

goal (1 subgoal):
 1. (mat (dim_vec v) 1 (\<lambda>(i, j). v $ i) * mat 1 (dim_vec w) (\<lambda>(i, y). conjugate w $ y)) $$ (i, j) = v $ i * conjugate (w $ j)
[PROOF STEP]
by (simp add: scalar_prod_def)


[STATEMENT]
lemma list_sum_mean:
  fixes xs::"real list"
  shows "\<Sum>:xs = ((mean xs) * (real (length xs)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list xs = mean xs * real (length xs)
[PROOF STEP]
apply (induct_tac xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. sum_list [] = mean [] * real (length [])
 2. \<And>a list. sum_list list = mean list * real (length list) \<Longrightarrow> sum_list (a # list) = mean (a # list) * real (length (a # list))
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a list. sum_list list = mean list * real (length list) \<Longrightarrow> sum_list (a # list) = mean (a # list) * real (length (a # list))
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a list. sum_list list = mean list * real (length list) \<Longrightarrow> a + mean list * real (length list) = mean (a # list) * (1 + real (length list))
[PROOF STEP]
apply (unfold mean_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>a list. sum_list list = sum_list list / real (length list) * real (length list) \<Longrightarrow> a + sum_list list / real (length list) * real (length list) = sum_list (a # list) / real (length (a # list)) * (1 + real (length list))
[PROOF STEP]
apply clarsimp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma norm_diff_triangle_less: "norm (x - z) < e1 + e2"
  if "norm (x - y) < e1"  "norm (y - z) < e2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (x - z) < e1 + e2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (x - z) < e1 + e2
[PROOF STEP]
have "norm (x - z) \<le> norm (x - y) + norm (y - z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (x - z) \<le> norm (x - y) + norm (y - z)
[PROOF STEP]
by (metis norm_diff_triangle_ineq add_diff_cancel_left' diff_diff_eq2)
[PROOF STATE]
proof (state)
this:
norm (x - z) \<le> norm (x - y) + norm (y - z)

goal (1 subgoal):
 1. norm (x - z) < e1 + e2
[PROOF STEP]
with that
[PROOF STATE]
proof (chain)
picking this:
norm (x - y) < e1
norm (y - z) < e2
norm (x - z) \<le> norm (x - y) + norm (y - z)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
norm (x - y) < e1
norm (y - z) < e2
norm (x - z) \<le> norm (x - y) + norm (y - z)

goal (1 subgoal):
 1. norm (x - z) < e1 + e2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
norm (x - z) < e1 + e2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_range_plus:
  assumes "finite (range f)"
          "finite (range g)"
  shows "finite (range (\<lambda>x. f x + g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
have subs: "range (\<lambda>x. (f x, g x)) \<subseteq> range f \<times> range g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (\<lambda>x. (f x, g x)) \<subseteq> range f \<times> range g
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
range (\<lambda>x. (f x, g x)) \<subseteq> range f \<times> range g

goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
have cart: "finite (range f \<times> range g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (range f \<times> range g)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite (range f)
finite (range g)

goal (1 subgoal):
 1. finite (range f \<times> range g)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (range f \<times> range g)

goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
have finite: "finite (range (\<lambda>x. (f x, g x)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (range (\<lambda>x. (f x, g x)))
[PROOF STEP]
using rev_finite_subset[OF cart subs]
[PROOF STATE]
proof (prove)
using this:
finite (range (\<lambda>x. (f x, g x)))

goal (1 subgoal):
 1. finite (range (\<lambda>x. (f x, g x)))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
finite (range (\<lambda>x. (f x, g x)))

goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
have "range (\<lambda>x. f x + g x) = (\<lambda>(a,b). a+b) ` range (\<lambda>x. (f x, g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (\<lambda>x. f x + g x) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))
[PROOF STEP]
using range_composition[of "(\<lambda>(a,b). a+b)" "(\<lambda>x. (f x, g x))"]
[PROOF STATE]
proof (prove)
using this:
range (\<lambda>x. case (f x, g x) of (a, b) \<Rightarrow> a + b) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))

goal (1 subgoal):
 1. range (\<lambda>x. f x + g x) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
range (\<lambda>x. f x + g x) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))

goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
range (\<lambda>x. f x + g x) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
range (\<lambda>x. f x + g x) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))

goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
using finite finite_image_set[where f = "(\<lambda>(a,b). a+b)"]
[PROOF STATE]
proof (prove)
using this:
range (\<lambda>x. f x + g x) = (\<lambda>(a, b). a + b) ` range (\<lambda>x. (f x, g x))
finite (range (\<lambda>x. (f x, g x)))
finite {x. ?P x} \<Longrightarrow> finite {case x of (a, b) \<Rightarrow> a + b |x. ?P x}

goal (1 subgoal):
 1. finite (range (\<lambda>x. f x + g x))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (range (\<lambda>x. f x + g x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_lucas_lehmer_Units:
  assumes "m > 1"
  shows   "card (Units (lucas_lehmer_ring_mod m)) < m ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
interpret cring "lucas_lehmer_ring_mod m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cring (lucas_lehmer_ring_mod m)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 < m

goal (1 subgoal):
 1. cring (lucas_lehmer_ring_mod m)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
have "m ^ 2 > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < m\<^sup>2
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 < m

goal (1 subgoal):
 1. 0 < m\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < m\<^sup>2

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
1 < m
[PROOF STEP]
have "card (Units (lucas_lehmer_ring_mod m)) \<le> card ({..<m} \<times> {..<m} - {(0, 0)})"
[PROOF STATE]
proof (prove)
using this:
1 < m

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) \<le> card ({..<m} \<times> {..<m} - {(0, 0)})
[PROOF STEP]
by (intro card_mono) (auto simp: Units_def lucas_lehmer_ring_mod_def lucas_lehmer_mult_def)
[PROOF STATE]
proof (state)
this:
card (Units (lucas_lehmer_ring_mod m)) \<le> card ({..<m} \<times> {..<m} - {(0, 0)})

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card (Units (lucas_lehmer_ring_mod m)) \<le> card ({..<m} \<times> {..<m} - {(0, 0)})

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
have "\<dots> = m ^ 2 - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ({..<m} \<times> {..<m} - {(0, 0)}) = m\<^sup>2 - 1
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
1 < m

goal (1 subgoal):
 1. card ({..<m} \<times> {..<m} - {(0, 0)}) = m\<^sup>2 - 1
[PROOF STEP]
by (subst card_Diff_subset) (auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
card ({..<m} \<times> {..<m} - {(0, 0)}) = m\<^sup>2 - 1

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
card (Units (lucas_lehmer_ring_mod m)) \<le> m\<^sup>2 - 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (Units (lucas_lehmer_ring_mod m)) \<le> m\<^sup>2 - 1

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
using \<open>m ^ 2 > 0\<close>
[PROOF STATE]
proof (prove)
using this:
card (Units (lucas_lehmer_ring_mod m)) \<le> m\<^sup>2 - 1
0 < m\<^sup>2

goal (1 subgoal):
 1. card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
card (Units (lucas_lehmer_ring_mod m)) < m\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed