[STATEMENT]
lemma newton_interpolation_poly_int: assumes dist: "distinct (map fst xs_ys)"
  shows "newton_interpolation_poly_int xs_ys = (let
     rxs_ys = map (\<lambda> (x,y). (rat_of_int x, rat_of_int y)) xs_ys;
     rp = newton_interpolation_poly rxs_ys
     in if (\<forall> x \<in> set (coeffs rp). is_int_rat x) then
       Some (map_poly int_of_rat rp) else None)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)
[PROOF STEP]
have id1: "map fst (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys) = map rat_of_int (map fst xs_ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map fst (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys) = map rat_of_int (map fst xs_ys)
[PROOF STEP]
by (induct xs_ys, auto)
[PROOF STATE]
proof (state)
this:
map fst (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys) = map rat_of_int (map fst xs_ys)

goal (1 subgoal):
 1. newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)
[PROOF STEP]
have id2: "map snd (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys) = map rat_of_int (map snd xs_ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map snd (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys) = map rat_of_int (map snd xs_ys)
[PROOF STEP]
by (induct xs_ys, auto)
[PROOF STATE]
proof (state)
this:
map snd (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys) = map rat_of_int (map snd xs_ys)

goal (1 subgoal):
 1. newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)
[PROOF STEP]
have id3: "length (map fst xs_ys) = length (map snd xs_ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map fst xs_ys) = length (map snd xs_ys)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
length (map fst xs_ys) = length (map snd xs_ys)

goal (1 subgoal):
 1. newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)
[PROOF STEP]
unfolding newton_interpolation_poly_def  newton_interpolation_poly_int_def Let_def newton_poly_impl_int[OF id3 dist]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if set (coeffs (newton_poly_impl (map rat_of_int (map fst xs_ys)) (map rat_of_int (map snd xs_ys)))) \<subseteq> \<int> then Some (map_poly int_of_rat (newton_poly_impl (map rat_of_int (map fst xs_ys)) (map rat_of_int (map snd xs_ys)))) else None) = (if Ball (set (coeffs (newton_poly_impl (map fst (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys)) (map snd (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys))))) is_int_rat then Some (map_poly int_of_rat (newton_poly_impl (map fst (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys)) (map snd (map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys)))) else None)
[PROOF STEP]
unfolding id1 id2
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if set (coeffs (newton_poly_impl (map rat_of_int (map fst xs_ys)) (map rat_of_int (map snd xs_ys)))) \<subseteq> \<int> then Some (map_poly int_of_rat (newton_poly_impl (map rat_of_int (map fst xs_ys)) (map rat_of_int (map snd xs_ys)))) else None) = (if Ball (set (coeffs (newton_poly_impl (map rat_of_int (map fst xs_ys)) (map rat_of_int (map snd xs_ys))))) is_int_rat then Some (map_poly int_of_rat (newton_poly_impl (map rat_of_int (map fst xs_ys)) (map rat_of_int (map snd xs_ys)))) else None)
[PROOF STEP]
by (rule sym, rule if_cong, auto simp: is_int_rat[abs_def])
[PROOF STATE]
proof (state)
this:
newton_interpolation_poly_int xs_ys = (let rxs_ys = map (\<lambda>(x, y). (rat_of_int x, rat_of_int y)) xs_ys; rp = newton_interpolation_poly rxs_ys in if \<forall>x\<in>set (coeffs rp). is_int_rat x then Some (map_poly int_of_rat rp) else None)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma not_dep_disj_imp_not_dep:
  fixes PROB vs_1 vs_2 vs_3
  assumes "((vs_1 \<inter> vs_2) = {})" "(vs_3 \<subseteq> vs_2)" "\<not>(dep_var_set PROB vs_1 vs_2)"
  shows "\<not>(dep_var_set PROB vs_1 vs_3)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> dep_var_set PROB vs_1 vs_3
[PROOF STEP]
using assms subset_eq
[PROOF STATE]
proof (prove)
using this:
vs_1 \<inter> vs_2 = {}
vs_3 \<subseteq> vs_2
\<not> dep_var_set PROB vs_1 vs_2
(?A \<subseteq> ?B) = (\<forall>x\<in>?A. x \<in> ?B)

goal (1 subgoal):
 1. \<not> dep_var_set PROB vs_1 vs_3
[PROOF STEP]
unfolding dep_var_set_def disjnt_def
[PROOF STATE]
proof (prove)
using this:
vs_1 \<inter> vs_2 = {}
vs_3 \<subseteq> vs_2
\<not> (vs_1 \<inter> vs_2 = {} \<and> (\<exists>v1 v2. v1 \<in> vs_1 \<and> v2 \<in> vs_2 \<and> dep PROB v1 v2))
(?A \<subseteq> ?B) = (\<forall>x\<in>?A. x \<in> ?B)

goal (1 subgoal):
 1. \<not> (vs_1 \<inter> vs_3 = {} \<and> (\<exists>v1 v2. v1 \<in> vs_1 \<and> v2 \<in> vs_3 \<and> dep PROB v1 v2))
[PROOF STEP]
by blast


[STATEMENT]
lemma card_one[elim]:
    assumes "card A = 1"
    obtains a
    where "A = {a}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. A = {a} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
card A = 1

goal (1 subgoal):
 1. (\<And>a. A = {a} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis One_nat_def card_Suc_eq)


[STATEMENT]
lemma B_in_orthogonal_complement_of_orthogonal_complement:
  shows "B \<subseteq> orthogonal_complement (orthogonal_complement B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<subseteq> orthogonal_complement (orthogonal_complement B)
[PROOF STEP]
by (auto simp add: orthogonal_complement_def orthogonal_def inner_commute)


[STATEMENT]
lemma real_root_one [simp]: "0 < n \<Longrightarrow> root n 1 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n \<Longrightarrow> root n 1 = 1
[PROOF STEP]
by (simp add: real_root_pos_unique)


[STATEMENT]
lemma poly_scalar_mult_iter:
  assumes "\<one> \<noteq>\<zero>"
  assumes "P \<in> Pring_set R I"
  assumes "k \<in> carrier R"
  assumes "n \<in> carrier R"
  shows "poly_scalar_mult R k (poly_scalar_mult R n P) = poly_scalar_mult R (k \<otimes> n) P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_scalar_mult R k (poly_scalar_mult R n P) = poly_scalar_mult R (k \<otimes> n) P
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<one> \<noteq> \<zero>
P \<in> carrier R [\<X>\<^bsub>I\<^esub>]
k \<in> carrier R
n \<in> carrier R

goal (1 subgoal):
 1. poly_scalar_mult R k (poly_scalar_mult R n P) = poly_scalar_mult R (k \<otimes> n) P
[PROOF STEP]
unfolding poly_scalar_mult_def
[PROOF STATE]
proof (prove)
using this:
\<one> \<noteq> \<zero>
P \<in> carrier R [\<X>\<^bsub>I\<^esub>]
k \<in> carrier R
n \<in> carrier R

goal (1 subgoal):
 1. (\<lambda>m. k \<otimes> (n \<otimes> P m)) = (\<lambda>m. k \<otimes> n \<otimes> P m)
[PROOF STEP]
by (metis Pring_cfs_closed m_assoc)


[STATEMENT]
theorem quasi_isometric_euclidean:
  assumes "quasi_isometric (UNIV::'a::euclidean_space set) (UNIV::'b::euclidean_space set)"
  shows "DIM('a) = DIM('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
obtain lambda C and f::"'a \<Rightarrow>'b" where "lambda C-quasi_isometry_on UNIV f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>lambda C f. lambda C -quasi_isometry f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
quasi_isometric UNIV UNIV

goal (1 subgoal):
 1. (\<And>lambda C f. lambda C -quasi_isometry f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding quasi_isometric_def quasi_isometry_between_def
[PROOF STATE]
proof (prove)
using this:
\<exists>lambda C f. lambda C -quasi_isometry f \<and> range f \<subseteq> UNIV \<and> (\<forall>y\<in>UNIV. \<exists>x\<in>UNIV. dist (f x) y \<le> C)

goal (1 subgoal):
 1. (\<And>lambda C f. lambda C -quasi_isometry f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lambda C -quasi_isometry f

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
lambda C -quasi_isometry f
[PROOF STEP]
have *: "DIM('a) \<le> DIM('b)"
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry f

goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
using quasi_isometry_on_euclidean
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry f
?lambda ?C -quasi_isometry ?f \<Longrightarrow> DIM(?'a) \<le> DIM(?'b)

goal (1 subgoal):
 1. DIM('a) \<le> DIM('b)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
DIM('a) \<le> DIM('b)

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
have "quasi_isometric (UNIV::'b::euclidean_space set) (UNIV::'a::euclidean_space set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. quasi_isometric UNIV UNIV
[PROOF STEP]
using quasi_isometric_equiv_rel(3)[OF assms]
[PROOF STATE]
proof (prove)
using this:
quasi_isometric UNIV UNIV

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

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
quasi_isometric UNIV UNIV
[PROOF STEP]
obtain lambda C and f::"'b \<Rightarrow>'a" where "lambda C-quasi_isometry_on UNIV f"
[PROOF STATE]
proof (prove)
using this:
quasi_isometric UNIV UNIV

goal (1 subgoal):
 1. (\<And>lambda C f. lambda C -quasi_isometry f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding quasi_isometric_def quasi_isometry_between_def
[PROOF STATE]
proof (prove)
using this:
\<exists>lambda C f. lambda C -quasi_isometry f \<and> range f \<subseteq> UNIV \<and> (\<forall>y\<in>UNIV. \<exists>x\<in>UNIV. dist (f x) y \<le> C)

goal (1 subgoal):
 1. (\<And>lambda C f. lambda C -quasi_isometry f \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
lambda C -quasi_isometry f

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
lambda C -quasi_isometry f
[PROOF STEP]
have "DIM('b) \<le> DIM('a)"
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry f

goal (1 subgoal):
 1. DIM('b) \<le> DIM('a)
[PROOF STEP]
using quasi_isometry_on_euclidean
[PROOF STATE]
proof (prove)
using this:
lambda C -quasi_isometry f
?lambda ?C -quasi_isometry ?f \<Longrightarrow> DIM(?'a) \<le> DIM(?'b)

goal (1 subgoal):
 1. DIM('b) \<le> DIM('a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
DIM('b) \<le> DIM('a)

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
DIM('b) \<le> DIM('a)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
DIM('b) \<le> DIM('a)

goal (1 subgoal):
 1. DIM('a) = DIM('b)
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
DIM('b) \<le> DIM('a)
DIM('a) \<le> DIM('b)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem is_ord_insert:
  "\<lbrakk> avl t; is_ord t \<rbrakk> \<Longrightarrow> is_ord(insert (x::'a::linorder) t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>avl t; is_ord t\<rbrakk> \<Longrightarrow> is_ord (AVL.insert x t)
[PROOF STEP]
by (induct t) (simp_all add:is_ord_mkt_bal_l is_ord_mkt_bal_r avl_insert set_of_insert
                linorder_not_less order_neq_le_trans del:mkt_bal_l.simps mkt_bal_r.simps)


[STATEMENT]
lemma aux_powertwo_digits:
  fixes k c :: nat
  assumes "k < c"
  shows "nth_bit (2^c) k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (2 ^ c) \<exclamdown> k = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (2 ^ c) \<exclamdown> k = 0
[PROOF STEP]
have h: "(2::nat) ^ c div 2 ^ k = 2 ^ (c - k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ c div 2 ^ k = 2 ^ (c - k)
[PROOF STEP]
by (simp add: assms less_imp_le power_diff)
[PROOF STATE]
proof (state)
this:
2 ^ c div 2 ^ k = 2 ^ (c - k)

goal (1 subgoal):
 1. (2 ^ c) \<exclamdown> k = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
2 ^ c div 2 ^ k = 2 ^ (c - k)

goal (1 subgoal):
 1. (2 ^ c) \<exclamdown> k = 0
[PROOF STEP]
by (auto simp: h nth_bit_def assms)
[PROOF STATE]
proof (state)
this:
(2 ^ c) \<exclamdown> k = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Zn_iso_DirProds_prime_powers:
  assumes "n \<noteq> 0"
  shows "Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)" (is "Z n \<cong> ?DP")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
proof (cases "n = 1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
 2. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 1

goal (2 subgoals):
 1. n = 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
 2. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
by (intro triv_iso[OF group_integer_mod_group DirProds_is_group],
                   use DirProds_empty carrier_integer_mod_group True in auto)
[PROOF STATE]
proof (state)
this:
Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
case nno: False
[PROOF STATE]
proof (state)
this:
n \<noteq> 1

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
interpret DP: group ?DP
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Group.group (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
by (intro DirProds_is_group, use group_integer_mod_group in blast)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
have "order ?DP = prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n)
[PROOF STEP]
by (intro DirProds_order, blast)
[PROOF STATE]
proof (state)
this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n)

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n)

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
have "\<dots> = prod (\<lambda>p. p ^ multiplicity p n) (prime_factors n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n) = (\<Prod>p\<in>prime_factors n. p ^ multiplicity p n)
[PROOF STEP]
using Zn_order
[PROOF STATE]
proof (prove)
using this:
order (Z ?n) = ?n

goal (1 subgoal):
 1. prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n) = (\<Prod>p\<in>prime_factors n. p ^ multiplicity p n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n) = (\<Prod>p\<in>prime_factors n. p ^ multiplicity p n)

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
prod (order \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) (prime_factors n) = (\<Prod>p\<in>prime_factors n. p ^ multiplicity p n)

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
have n: "\<dots> = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors n. p ^ multiplicity p n) = n
[PROOF STEP]
using prod_prime_factors[OF assms]
[PROOF STATE]
proof (prove)
using this:
(\<Prod>p\<in>prime_factors n. p ^ multiplicity p n) = normalize n

goal (1 subgoal):
 1. (\<Prod>p\<in>prime_factors n. p ^ multiplicity p n) = n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Prod>p\<in>prime_factors n. p ^ multiplicity p n) = n

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n
[PROOF STEP]
have oDP: "order ?DP = n"
[PROOF STATE]
proof (prove)
using this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n

goal (1 subgoal):
 1. order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n
[PROOF STEP]
interpret DP: finite_group ?DP
[PROOF STATE]
proof (prove)
using this:
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n

goal (1 subgoal):
 1. finite_group (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
by (unfold_locales, unfold order_def, metis assms card.infinite)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
let ?f = "\<lambda>p\<in>(prime_factors n). 1"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
have fc: "?f \<in> carrier ?DP"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
have p: "0 < multiplicity p n" if "p \<in> prime_factors n" for p
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < multiplicity p n
[PROOF STEP]
using prime_factors_multiplicity that
[PROOF STATE]
proof (prove)
using this:
prime_factors ?n = {p. prime p \<and> 0 < multiplicity p ?n}
p \<in># prime_factorization n

goal (1 subgoal):
 1. 0 < multiplicity p n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?p2 \<in># prime_factorization n \<Longrightarrow> 0 < multiplicity ?p2 n

goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
have pk: "1 < p ^ k" if "Factorial_Ring.prime p" "0 < k" for p k::nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 < p ^ k
[PROOF STEP]
using that one_less_power prime_gt_1_nat
[PROOF STATE]
proof (prove)
using this:
prime p
0 < k
\<lbrakk>(1::?'a) < ?a; 0 < ?n\<rbrakk> \<Longrightarrow> (1::?'a) < ?a ^ ?n
prime ?p \<Longrightarrow> 1 < ?p

goal (1 subgoal):
 1. 1 < p ^ k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<lbrakk>prime ?p2; 0 < ?k2\<rbrakk> \<Longrightarrow> 1 < ?p2 ^ ?k2

goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
[PROOF STEP]
unfolding DirProds_def PiE_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) \<in> carrier \<lparr>carrier = Pi (prime_factors n) (carrier \<circ> (\<lambda>p. Z (p ^ multiplicity p n))) \<inter> extensional (prime_factors n), monoid.mult = \<lambda>x y. \<lambda>i\<in>prime_factors n. x i \<otimes>\<^bsub>Z (i ^ multiplicity i n)\<^esub> y i, one = \<lambda>i\<in>prime_factors n. \<one>\<^bsub>Z (i ^ multiplicity i n)\<^esub>\<rparr>
[PROOF STEP]
by(use carrier_integer_mod_group assms nno pk p in auto,
         metis in_prime_factors_iff nat_int of_nat_power one_less_nat_eq)
[PROOF STATE]
proof (state)
this:
(\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
have of: "DP.ord ?f = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DP.ord (\<lambda>p\<in>prime_factors n. 1) = n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. DP.ord (\<lambda>p\<in>prime_factors n. 1) = n
[PROOF STEP]
have "n dvd j" if j: "?f [^]\<^bsub>?DP\<^esub> j = \<one>\<^bsub>?DP\<^esub>" for j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n dvd j
[PROOF STEP]
proof (intro pairwise_coprime_dvd'[OF _ _ n[symmetric]])
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. finite (prime_factors n)
 2. \<And>i j. \<lbrakk>i \<in># prime_factorization n; j \<in># prime_factorization n; i \<noteq> j\<rbrakk> \<Longrightarrow> coprime (i ^ multiplicity i n) (j ^ multiplicity j n)
 3. \<forall>a\<in>#prime_factorization n. a ^ multiplicity a n dvd j
[PROOF STEP]
show "finite (prime_factors n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (prime_factors n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (prime_factors n)

goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i \<in># prime_factorization n; j \<in># prime_factorization n; i \<noteq> j\<rbrakk> \<Longrightarrow> coprime (i ^ multiplicity i n) (j ^ multiplicity j n)
 2. \<forall>a\<in>#prime_factorization n. a ^ multiplicity a n dvd j
[PROOF STEP]
show "\<forall>a\<in>#prime_factorization n. a ^ multiplicity a n dvd j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>a\<in>#prime_factorization n. a ^ multiplicity a n dvd j
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a. a \<in># prime_factorization n \<Longrightarrow> a ^ multiplicity a n dvd j
[PROOF STEP]
show "p ^ multiplicity p n dvd j" if "p \<in> prime_factors n" for p
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
from j
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j = \<one>\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub>
[PROOF STEP]
have "(?f [^]\<^bsub>?DP\<^esub> j) p = 0"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j = \<one>\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub>

goal (1 subgoal):
 1. ((\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j) p = 0
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j = \<one>\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub>
p \<in># prime_factorization n

goal (1 subgoal):
 1. ((\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j) p = 0
[PROOF STEP]
unfolding DirProds_def one_integer_mod_group
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>\<lparr>carrier = Pi\<^sub>E (prime_factors n) (carrier \<circ> (\<lambda>p. Z (p ^ multiplicity p n))), monoid.mult = \<lambda>x y. \<lambda>i\<in>prime_factors n. x i \<otimes>\<^bsub>Z (i ^ multiplicity i n)\<^esub> y i, one = \<lambda>i\<in>prime_factors n. 0\<rparr>\<^esub> j = \<one>\<^bsub>\<lparr>carrier = Pi\<^sub>E (prime_factors n) (carrier \<circ> (\<lambda>p. Z (p ^ multiplicity p n))), monoid.mult = \<lambda>x y. \<lambda>i\<in>prime_factors n. x i \<otimes>\<^bsub>Z (i ^ multiplicity i n)\<^esub> y i, one = \<lambda>i\<in>prime_factors n. 0\<rparr>\<^esub>
p \<in># prime_factorization n

goal (1 subgoal):
 1. ((\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>\<lparr>carrier = Pi\<^sub>E (prime_factors n) (carrier \<circ> (\<lambda>p. Z (p ^ multiplicity p n))), monoid.mult = \<lambda>x y. \<lambda>i\<in>prime_factors n. x i \<otimes>\<^bsub>Z (i ^ multiplicity i n)\<^esub> y i, one = \<lambda>i\<in>prime_factors n. 0\<rparr>\<^esub> j) p = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
((\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j) p = 0

goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
hence "?f p [^]\<^bsub>Z (p ^ multiplicity p n)\<^esub> j = 0"
[PROOF STATE]
proof (prove)
using this:
((\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j) p = 0

goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) p [^]\<^bsub>Z (p ^ multiplicity p n)\<^esub> j = 0
[PROOF STEP]
using comp_exp_nat[OF that]
[PROOF STATE]
proof (prove)
using this:
((\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> j) p = 0
(?x [^]\<^bsub>DirProds ?G (prime_factors n)\<^esub> ?k) p = ?x p [^]\<^bsub>?G p\<^esub> ?k

goal (1 subgoal):
 1. (\<lambda>p\<in>prime_factors n. 1) p [^]\<^bsub>Z (p ^ multiplicity p n)\<^esub> j = 0
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
(\<lambda>p\<in>prime_factors n. 1) p [^]\<^bsub>Z (p ^ multiplicity p n)\<^esub> j = 0

goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
hence "group.ord (Z (p ^ multiplicity p n)) (?f p) dvd j"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) p [^]\<^bsub>Z (p ^ multiplicity p n)\<^esub> j = 0

goal (1 subgoal):
 1. group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) dvd j
[PROOF STEP]
using comp_in_carr[OF fc that]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) p [^]\<^bsub>Z (p ^ multiplicity p n)\<^esub> j = 0
(\<lambda>p\<in>prime_factors n. 1) p \<in> carrier (Z (p ^ multiplicity p n))

goal (1 subgoal):
 1. group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) dvd j
[PROOF STEP]
by (metis group.pow_eq_id group_integer_mod_group one_integer_mod_group)
[PROOF STATE]
proof (state)
this:
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) dvd j

goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) dvd j

goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
have "group.ord (Z (p ^ multiplicity p n)) (?f p) = p ^ multiplicity p n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) = p ^ multiplicity p n
[PROOF STEP]
by (metis (no_types, lifting) Zn_neq1_cyclic_group Zn_order comp_in_carr
                                          cyclic_group.ord_gen_is_group_order fc integer_mod_group_1
                                          restrict_apply' that)
[PROOF STATE]
proof (state)
this:
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) = p ^ multiplicity p n

goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) dvd j
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) = p ^ multiplicity p n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) dvd j
group.ord (Z (p ^ multiplicity p n)) ((\<lambda>p\<in>prime_factors n. 1) p) = p ^ multiplicity p n

goal (1 subgoal):
 1. p ^ multiplicity p n dvd j
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p ^ multiplicity p n dvd j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?p2 \<in># prime_factorization n \<Longrightarrow> ?p2 ^ multiplicity ?p2 n dvd j

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<forall>a\<in>#prime_factorization n. a ^ multiplicity a n dvd j

goal (1 subgoal):
 1. \<And>i j. \<lbrakk>i \<in># prime_factorization n; j \<in># prime_factorization n; i \<noteq> j\<rbrakk> \<Longrightarrow> coprime (i ^ multiplicity i n) (j ^ multiplicity j n)
[PROOF STEP]
show "coprime (i ^ multiplicity i n) (j ^ multiplicity j n)"
        if "i \<in># prime_factorization n" "j \<in># prime_factorization n" "i \<noteq> j" for i j
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (i ^ multiplicity i n) (j ^ multiplicity j n)
[PROOF STEP]
using that diff_prime_power_imp_coprime
[PROOF STATE]
proof (prove)
using this:
i \<in># prime_factorization n
j \<in># prime_factorization n
i \<noteq> j
\<lbrakk>?p \<noteq> ?q; prime ?p; prime ?q\<rbrakk> \<Longrightarrow> coprime (?p ^ ?n) (?q ^ ?m)

goal (1 subgoal):
 1. coprime (i ^ multiplicity i n) (j ^ multiplicity j n)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<lbrakk>?i2 \<in># prime_factorization n; ?j2 \<in># prime_factorization n; ?i2 \<noteq> ?j2\<rbrakk> \<Longrightarrow> coprime (?i2 ^ multiplicity ?i2 n) (?j2 ^ multiplicity ?j2 n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> ?j2 = \<one>\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> \<Longrightarrow> n dvd ?j2

goal (1 subgoal):
 1. DP.ord (\<lambda>p\<in>prime_factors n. 1) = n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> ?j2 = \<one>\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> \<Longrightarrow> n dvd ?j2

goal (1 subgoal):
 1. DP.ord (\<lambda>p\<in>prime_factors n. 1) = n
[PROOF STEP]
using fc DP.ord_dvd_group_order gcd_nat.asym oDP
[PROOF STATE]
proof (prove)
using this:
(\<lambda>p\<in>prime_factors n. 1) [^]\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> ?j2 = \<one>\<^bsub>DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)\<^esub> \<Longrightarrow> n dvd ?j2
(\<lambda>p\<in>prime_factors n. 1) \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
?a \<in> carrier (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) \<Longrightarrow> DP.ord ?a dvd order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n))
\<lbrakk>?a dvd ?b \<and> ?a \<noteq> ?b; ?b dvd ?a \<and> ?b \<noteq> ?a\<rbrakk> \<Longrightarrow> False
order (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) = n

goal (1 subgoal):
 1. DP.ord (\<lambda>p\<in>prime_factors n. 1) = n
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
DP.ord (\<lambda>p\<in>prime_factors n. 1) = n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
DP.ord (\<lambda>p\<in>prime_factors n. 1) = n

goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
interpret DP: cyclic_group ?DP ?f
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Finite_And_Cyclic_Groups.cyclic_group (DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)) (\<lambda>p\<in>prime_factors n. 1)
[PROOF STEP]
by (intro DP.element_ord_generates_cyclic, use of oDP fc in auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 1 \<Longrightarrow> Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
using DP.iso_sym[OF DP.Zn_iso[OF oDP]]
[PROOF STATE]
proof (prove)
using this:
Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)

goal (1 subgoal):
 1. Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Z n \<cong> DirProds (\<lambda>p. Z (p ^ multiplicity p n)) (prime_factors n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma prod_list_power: fixes xs :: "'a :: comm_monoid_mult list"
  shows "prod_list xs ^ n = (\<Prod>x\<leftarrow>xs. x ^ n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list xs ^ n = (\<Prod>x\<leftarrow>xs. x ^ n)
[PROOF STEP]
by (induct xs, auto simp: power_mult_distrib)


[STATEMENT]
lemma (in prob_space) expectation_condition_card_1:
  fixes X::"'a set"  and f::"'a \<Rightarrow> real" and \<delta>::real
  assumes "finite X" and "\<forall> x \<in> X. f x \<le> 1" and "M = uniform_count_measure X" and "expectation f \<ge> \<delta>"
  shows "card {x \<in> X. (f x \<ge> \<delta> / 2)} \<ge> \<delta> * card X / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
proof (cases "\<delta> \<ge> 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
assume h\<delta>: "\<delta> \<ge> 0"
[PROOF STATE]
proof (state)
this:
0 \<le> \<delta>

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
have ineq1: "real (card (X - {x \<in> X. \<delta> \<le> f x * 2})) * \<delta> \<le> real (card X) * \<delta>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (card (X - {x \<in> X. \<delta> \<le> f x * 2})) * \<delta> \<le> real (card X) * \<delta>
[PROOF STEP]
using card_mono assms Diff_subset h\<delta> mult_le_cancel_right nat_le_linear of_nat_le_iff
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?B; ?A \<subseteq> ?B\<rbrakk> \<Longrightarrow> card ?A \<le> card ?B
finite X
\<forall>x\<in>X. f x \<le> 1
M = uniform_count_measure X
\<delta> \<le> expectation f
?A - ?B \<subseteq> ?A
0 \<le> \<delta>
(?a * ?c \<le> ?b * ?c) = (((0::?'a) < ?c \<longrightarrow> ?a \<le> ?b) \<and> (?c < (0::?'a) \<longrightarrow> ?b \<le> ?a))
?m \<le> ?n \<or> ?n \<le> ?m
(of_nat ?m \<le> of_nat ?n) = (?m \<le> ?n)

goal (1 subgoal):
 1. real (card (X - {x \<in> X. \<delta> \<le> f x * 2})) * \<delta> \<le> real (card X) * \<delta>
[PROOF STEP]
by (smt (verit, best))
[PROOF STATE]
proof (state)
this:
real (card (X - {x \<in> X. \<delta> \<le> f x * 2})) * \<delta> \<le> real (card X) * \<delta>

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
have ineq2: "\<forall> x \<in> X - {x. x \<in> X \<and> (f x \<ge> \<delta>/2)}. f x \<le> \<delta> / 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. f x \<le> \<delta> / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. f x \<le> \<delta> / 2

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
have "expectation f * card X = (\<Sum>x \<in> X. f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. expectation f * real (card X) = sum f X
[PROOF STEP]
using assms(1) expectation_uniform_count assms(3)
[PROOF STATE]
proof (prove)
using this:
finite X
\<lbrakk>M = uniform_count_measure ?X; finite ?X\<rbrakk> \<Longrightarrow> expectation ?f = sum ?f ?X / real (card ?X)
M = uniform_count_measure X

goal (1 subgoal):
 1. expectation f * real (card X) = sum f X
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
expectation f * real (card X) = sum f X

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
expectation f * real (card X) = sum f X

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
have "... = (\<Sum> x \<in>{x. x \<in> X \<and> (f x \<ge> \<delta>/2)}. f x)
    +(\<Sum> x \<in> X - {x. x \<in> X \<and> (f x \<ge> \<delta>/2)}. f x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f X = (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite X
\<forall>x\<in>X. f x \<le> 1
M = uniform_count_measure X
\<delta> \<le> expectation f

goal (1 subgoal):
 1. sum f X = (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
by (metis (no_types, lifting) add.commute mem_Collect_eq subsetI sum.subset_diff)
[PROOF STATE]
proof (state)
this:
sum f X = (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x})

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum f X = (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x})

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
have "... \<le> (\<Sum> x \<in>  {x. x \<in> X \<and> (f x \<ge> \<delta>/2)}. 1) +
    (\<Sum> x \<in> X - {x. x \<in> X \<and> (f x \<ge> \<delta>/2)} . \<delta> / 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x}) \<le> (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2)
[PROOF STEP]
using assms sum_mono ineq2
[PROOF STATE]
proof (prove)
using this:
finite X
\<forall>x\<in>X. f x \<le> 1
M = uniform_count_measure X
\<delta> \<le> expectation f
(\<And>i. i \<in> ?K \<Longrightarrow> ?f i \<le> ?g i) \<Longrightarrow> sum ?f ?K \<le> sum ?g ?K
\<forall>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. f x \<le> \<delta> / 2

goal (1 subgoal):
 1. (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x}) \<le> (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2)
[PROOF STEP]
by (smt (verit, ccfv_SIG) mem_Collect_eq)
[PROOF STATE]
proof (state)
this:
(\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x}) \<le> (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2)

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. f x) + sum f (X - {x \<in> X. \<delta> / 2 \<le> f x}) \<le> (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2)

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
have "... \<le> card ({x. x \<in> X \<and> (f x \<ge> \<delta>/2)}) + (card X) * \<delta> / 2 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + real (card X) * \<delta> / 2
[PROOF STEP]
using ineq1
[PROOF STATE]
proof (prove)
using this:
real (card (X - {x \<in> X. \<delta> \<le> f x * 2})) * \<delta> \<le> real (card X) * \<delta>

goal (1 subgoal):
 1. (\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + real (card X) * \<delta> / 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x | x \<in> X \<and> \<delta> / 2 \<le> f x. 1) + (\<Sum>x\<in>X - {x \<in> X. \<delta> / 2 \<le> f x}. \<delta> / 2) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + real (card X) * \<delta> / 2

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
expectation f * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + real (card X) * \<delta> / 2
[PROOF STEP]
have "\<delta> * card X \<le> card  {x. x \<in> X \<and> (f x \<ge> \<delta>/2)}+ (\<delta>/2)*(card X)"
[PROOF STATE]
proof (prove)
using this:
expectation f * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + real (card X) * \<delta> / 2

goal (1 subgoal):
 1. \<delta> * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + \<delta> / 2 * real (card X)
[PROOF STEP]
using ineq1 mult_of_nat_commute assms(4) mult_right_mono le_trans
[PROOF STATE]
proof (prove)
using this:
expectation f * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + real (card X) * \<delta> / 2
real (card (X - {x \<in> X. \<delta> \<le> f x * 2})) * \<delta> \<le> real (card X) * \<delta>
of_nat ?x * ?y = ?y * of_nat ?x
\<delta> \<le> expectation f
\<lbrakk>?a \<le> ?b; (0::?'a) \<le> ?c\<rbrakk> \<Longrightarrow> ?a * ?c \<le> ?b * ?c
\<lbrakk>?i \<le> ?j; ?j \<le> ?k\<rbrakk> \<Longrightarrow> ?i \<le> ?k

goal (1 subgoal):
 1. \<delta> * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + \<delta> / 2 * real (card X)
[PROOF STEP]
by (smt (verit, del_insts) of_nat_0_le_iff times_divide_eq_left)
[PROOF STATE]
proof (state)
this:
\<delta> * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + \<delta> / 2 * real (card X)

goal (2 subgoals):
 1. 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
 2. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<delta> * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + \<delta> / 2 * real (card X)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<delta> * real (card X) \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x}) + \<delta> / 2 * real (card X)

goal (1 subgoal):
 1. \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})

goal (1 subgoal):
 1. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
assume "\<not> \<delta> \<ge> 0"
[PROOF STATE]
proof (state)
this:
\<not> 0 \<le> \<delta>

goal (1 subgoal):
 1. \<not> 0 \<le> \<delta> \<Longrightarrow> \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> \<delta>

goal (1 subgoal):
 1. \<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})
[PROOF STEP]
by (smt (verit, del_insts) divide_nonpos_nonneg mult_nonpos_nonneg of_nat_0_le_iff)
[PROOF STATE]
proof (state)
this:
\<delta> * real (card X) / 2 \<le> real (card {x \<in> X. \<delta> / 2 \<le> f x})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma transpose_cond_index_vals:
  assumes "M * (M\<^sup>T) = \<Lambda> \<cdot>\<^sub>m (J\<^sub>m (dim_row M)) + (r - \<Lambda>) \<cdot>\<^sub>m (1\<^sub>m (dim_row M))"
  assumes "i < dim_row (M * (M\<^sup>T))"
  assumes "j < dim_col (M * (M\<^sup>T))"
  shows "i = j \<Longrightarrow> (M * (M\<^sup>T)) $$ (i, j) = r" "i \<noteq> j \<Longrightarrow> (M * (M\<^sup>T)) $$ (i, j) = \<Lambda>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i = j \<Longrightarrow> (M * M\<^sup>T) $$ (i, j) = r) &&& (i \<noteq> j \<Longrightarrow> (M * M\<^sup>T) $$ (i, j) = \<Lambda>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
M * M\<^sup>T = \<Lambda> \<cdot>\<^sub>m J\<^sub>m (dim_row M) + (r - \<Lambda>) \<cdot>\<^sub>m 1\<^sub>m (dim_row M)
i < dim_row (M * M\<^sup>T)
j < dim_col (M * M\<^sup>T)

goal (1 subgoal):
 1. (i = j \<Longrightarrow> (M * M\<^sup>T) $$ (i, j) = r) &&& (i \<noteq> j \<Longrightarrow> (M * M\<^sup>T) $$ (i, j) = \<Lambda>)
[PROOF STEP]
by auto


[STATEMENT]
lemma  density_collapse_operator:
  assumes "projector P"
  and "density_operator R"
  and "0 < dim_row R"
  and "P \<in> carrier_mat n n"
  and "R \<in> carrier_mat n n"
shows "density_operator (density_collapse R P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. density_operator (density_collapse R P)
[PROOF STEP]
proof (cases "(Complex_Matrix.trace (R * P)) = 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Complex_Matrix.trace (R * P) = 0 \<Longrightarrow> density_operator (density_collapse R P)
 2. Complex_Matrix.trace (R * P) \<noteq> 0 \<Longrightarrow> density_operator (density_collapse R P)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (R * P) = 0

goal (2 subgoals):
 1. Complex_Matrix.trace (R * P) = 0 \<Longrightarrow> density_operator (density_collapse R P)
 2. Complex_Matrix.trace (R * P) \<noteq> 0 \<Longrightarrow> density_operator (density_collapse R P)
[PROOF STEP]
hence "density_collapse R P = max_mix_density (dim_row R)"
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.trace (R * P) = 0

goal (1 subgoal):
 1. density_collapse R P = max_mix_density (dim_row R)
[PROOF STEP]
unfolding density_collapse_def
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.trace (R * P) = 0

goal (1 subgoal):
 1. (if Complex_Matrix.trace (R * P) = 0 then max_mix_density (dim_row R) else complex_of_real 1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P)) = max_mix_density (dim_row R)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
density_collapse R P = max_mix_density (dim_row R)

goal (2 subgoals):
 1. Complex_Matrix.trace (R * P) = 0 \<Longrightarrow> density_operator (density_collapse R P)
 2. Complex_Matrix.trace (R * P) \<noteq> 0 \<Longrightarrow> density_operator (density_collapse R P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
density_collapse R P = max_mix_density (dim_row R)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
density_collapse R P = max_mix_density (dim_row R)

goal (1 subgoal):
 1. density_operator (density_collapse R P)
[PROOF STEP]
using max_mix_is_density assms
[PROOF STATE]
proof (prove)
using this:
density_collapse R P = max_mix_density (dim_row R)
0 < ?n \<Longrightarrow> density_operator (max_mix_density ?n)
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n

goal (1 subgoal):
 1. density_operator (density_collapse R P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
density_operator (density_collapse R P)

goal (1 subgoal):
 1. Complex_Matrix.trace (R * P) \<noteq> 0 \<Longrightarrow> density_operator (density_collapse R P)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Complex_Matrix.trace (R * P) \<noteq> 0 \<Longrightarrow> density_operator (density_collapse R P)
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. Complex_Matrix.trace (R * P) \<noteq> 0 \<Longrightarrow> density_operator (density_collapse R P)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. density_operator (density_collapse R P)
[PROOF STEP]
unfolding density_operator_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.positive (density_collapse R P) \<and> Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
proof (intro conjI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Complex_Matrix.positive (density_collapse R P)
 2. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
have "Complex_Matrix.positive ((1 / (Complex_Matrix.trace (R * P))) \<cdot>\<^sub>m (P * R * P))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.positive (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
[PROOF STEP]
proof (rule positive_smult)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. P * R * P \<in> carrier_mat ?n ?n
 2. Complex_Matrix.positive (P * R * P)
 3. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
show "P * R * P \<in> carrier_mat n n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P * R * P \<in> carrier_mat n n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n

goal (1 subgoal):
 1. P * R * P \<in> carrier_mat n n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
P * R * P \<in> carrier_mat n n

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
have "Complex_Matrix.positive R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.positive R
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n

goal (1 subgoal):
 1. Complex_Matrix.positive R
[PROOF STEP]
unfolding density_operator_def
[PROOF STATE]
proof (prove)
using this:
projector P
Complex_Matrix.positive R \<and> Complex_Matrix.trace R = 1
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n

goal (1 subgoal):
 1. Complex_Matrix.positive R
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.positive R

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
hence "0 \<le> (Complex_Matrix.trace (R * P))"
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.positive R

goal (1 subgoal):
 1. 0 \<le> Complex_Matrix.trace (R * P)
[PROOF STEP]
using  positive_proj_trace[of P R n] assms
          False
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.positive R
\<lbrakk>projector P; Complex_Matrix.positive R; P \<in> carrier_mat n n; R \<in> carrier_mat n n\<rbrakk> \<Longrightarrow> 0 \<le> Complex_Matrix.trace (R * P)
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. 0 \<le> Complex_Matrix.trace (R * P)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 \<le> Complex_Matrix.trace (R * P)

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
hence "0 \<le> Re (Complex_Matrix.trace (R * P))"
[PROOF STATE]
proof (prove)
using this:
0 \<le> Complex_Matrix.trace (R * P)

goal (1 subgoal):
 1. 0 \<le> Re (Complex_Matrix.trace (R * P))
[PROOF STEP]
by (simp add: less_eq_complex_def)
[PROOF STATE]
proof (state)
this:
0 \<le> Re (Complex_Matrix.trace (R * P))

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
hence "0 \<le> 1/(Re (Complex_Matrix.trace (R * P)))"
[PROOF STATE]
proof (prove)
using this:
0 \<le> Re (Complex_Matrix.trace (R * P))

goal (1 subgoal):
 1. 0 \<le> 1 / Re (Complex_Matrix.trace (R * P))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> 1 / Re (Complex_Matrix.trace (R * P))

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
have "Re (Complex_Matrix.trace (R * P)) = Complex_Matrix.trace (R * P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (Complex_Matrix.trace (R * P))) = Complex_Matrix.trace (R * P)
[PROOF STEP]
using assms \<open>Complex_Matrix.positive R\<close> trace_proj_pos_real
[PROOF STATE]
proof (prove)
using this:
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n
Complex_Matrix.positive R
\<lbrakk>projector ?P; Complex_Matrix.positive ?R; ?P \<in> carrier_mat ?n ?n; ?R \<in> carrier_mat ?n ?n\<rbrakk> \<Longrightarrow> complex_of_real (Re (Complex_Matrix.trace (?R * ?P))) = Complex_Matrix.trace (?R * ?P)

goal (1 subgoal):
 1. complex_of_real (Re (Complex_Matrix.trace (R * P))) = Complex_Matrix.trace (R * P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (Complex_Matrix.trace (R * P))) = Complex_Matrix.trace (R * P)

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
hence inv: "1/ (Complex_Matrix.trace (R * P)) = 1/(Re (Complex_Matrix.trace (R * P)))"
[PROOF STATE]
proof (prove)
using this:
complex_of_real (Re (Complex_Matrix.trace (R * P))) = Complex_Matrix.trace (R * P)

goal (1 subgoal):
 1. 1 / Complex_Matrix.trace (R * P) = complex_of_real (1 / Re (Complex_Matrix.trace (R * P)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / Complex_Matrix.trace (R * P) = complex_of_real (1 / Re (Complex_Matrix.trace (R * P)))

goal (2 subgoals):
 1. Complex_Matrix.positive (P * R * P)
 2. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
thus "0 \<le> 1/ (Complex_Matrix.trace (R * P))"
[PROOF STATE]
proof (prove)
using this:
1 / Complex_Matrix.trace (R * P) = complex_of_real (1 / Re (Complex_Matrix.trace (R * P)))

goal (1 subgoal):
 1. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
using \<open>0 \<le> 1/(Re (Complex_Matrix.trace (R * P)))\<close>
[PROOF STATE]
proof (prove)
using this:
1 / Complex_Matrix.trace (R * P) = complex_of_real (1 / Re (Complex_Matrix.trace (R * P)))
0 \<le> 1 / Re (Complex_Matrix.trace (R * P))

goal (1 subgoal):
 1. 0 \<le> 1 / Complex_Matrix.trace (R * P)
[PROOF STEP]
by (simp add: inv less_eq_complex_def)
[PROOF STATE]
proof (state)
this:
0 \<le> 1 / Complex_Matrix.trace (R * P)

goal (1 subgoal):
 1. Complex_Matrix.positive (P * R * P)
[PROOF STEP]
show "Complex_Matrix.positive (P * R * P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.positive (P * R * P)
[PROOF STEP]
using assms
          positive_close_under_left_right_mult_adjoint[of P n R]
[PROOF STATE]
proof (prove)
using this:
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n
\<lbrakk>P \<in> carrier_mat n n; R \<in> carrier_mat n n; Complex_Matrix.positive R\<rbrakk> \<Longrightarrow> Complex_Matrix.positive (P * R * Complex_Matrix.adjoint P)

goal (1 subgoal):
 1. Complex_Matrix.positive (P * R * P)
[PROOF STEP]
by (simp add: \<open>Complex_Matrix.positive R\<close> hermitian_def projector_def)
[PROOF STATE]
proof (state)
this:
Complex_Matrix.positive (P * R * P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Complex_Matrix.positive (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))

goal (2 subgoals):
 1. Complex_Matrix.positive (density_collapse R P)
 2. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
thus "Complex_Matrix.positive (density_collapse R P)"
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.positive (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))

goal (1 subgoal):
 1. Complex_Matrix.positive (density_collapse R P)
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.positive (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. Complex_Matrix.positive (density_collapse R P)
[PROOF STEP]
unfolding density_collapse_def
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.positive (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. Complex_Matrix.positive (if Complex_Matrix.trace (R * P) = 0 then max_mix_density (dim_row R) else complex_of_real 1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.positive (density_collapse R P)

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
have "Complex_Matrix.trace (density_collapse R P) =
      Complex_Matrix.trace ((1/ (Complex_Matrix.trace (R * P))) \<cdot>\<^sub>m (P * R * P))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
[PROOF STEP]
unfolding density_collapse_def
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. Complex_Matrix.trace (if Complex_Matrix.trace (R * P) = 0 then max_mix_density (dim_row R) else complex_of_real 1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P)) = Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (density_collapse R P) = Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (density_collapse R P) = Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P))

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
have "... = 1/ (Complex_Matrix.trace (R * P)) * Complex_Matrix.trace (P * R * P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P)) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P)
[PROOF STEP]
using trace_smult[of "P * R * P" n] assms
[PROOF STATE]
proof (prove)
using this:
P * R * P \<in> carrier_mat n n \<Longrightarrow> Complex_Matrix.trace (?c \<cdot>\<^sub>m (P * R * P)) = ?c * Complex_Matrix.trace (P * R * P)
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n

goal (1 subgoal):
 1. Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P)) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P)) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P)

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (1 / Complex_Matrix.trace (R * P) \<cdot>\<^sub>m (P * R * P)) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P)

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
have "... = 1/ (Complex_Matrix.trace (R * P)) * Complex_Matrix.trace (R * P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P)
[PROOF STEP]
using projector_collapse_trace assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>projector ?P; ?P \<in> carrier_mat ?n ?n; ?R \<in> carrier_mat ?n ?n\<rbrakk> \<Longrightarrow> Complex_Matrix.trace (?P * ?R * ?P) = Complex_Matrix.trace (?R * ?P)
projector P
density_operator R
0 < dim_row R
P \<in> carrier_mat n n
R \<in> carrier_mat n n

goal (1 subgoal):
 1. 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P)

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (P * R * P) = 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P)

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
have "... = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P) = 1
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.trace (R * P) \<noteq> 0

goal (1 subgoal):
 1. 1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 / Complex_Matrix.trace (R * P) * Complex_Matrix.trace (R * P) = 1

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
show "Complex_Matrix.trace (density_collapse R P) = 1"
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.trace (density_collapse R P) = 1

goal (1 subgoal):
 1. Complex_Matrix.trace (density_collapse R P) = 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Complex_Matrix.trace (density_collapse R P) = 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
density_operator (density_collapse R P)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma least_power_le:
  assumes "(f ^^ n) x = x" and "n > 0" shows "least_power f x \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. least_power f x \<le> n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(f ^^ n) x = x
0 < n

goal (1 subgoal):
 1. least_power f x \<le> n
[PROOF STEP]
unfolding least_power_def
[PROOF STATE]
proof (prove)
using this:
(f ^^ n) x = x
0 < n

goal (1 subgoal):
 1. (LEAST n. (f ^^ n) x = x \<and> 0 < n) \<le> n
[PROOF STEP]
by (simp add: Least_le)


[STATEMENT]
lemma rel_interior_sum:
  fixes S T :: "'n::euclidean_space set"
  assumes "convex S"
    and "convex T"
  shows "rel_interior (S + T) = rel_interior S + rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
have "rel_interior S + rel_interior T = (\<lambda>(x,y). x + y) ` (rel_interior S \<times> rel_interior T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior S + rel_interior T = (\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T)
[PROOF STEP]
by (simp add: set_plus_image)
[PROOF STATE]
proof (state)
this:
rel_interior S + rel_interior T = (\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T)

goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rel_interior S + rel_interior T = (\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T)

goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
have "\<dots> = (\<lambda>(x,y). x + y) ` rel_interior (S \<times> T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T) = (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T)
[PROOF STEP]
using rel_interior_Times assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>convex ?S; convex ?T\<rbrakk> \<Longrightarrow> rel_interior (?S \<times> ?T) = rel_interior ?S \<times> rel_interior ?T
convex S
convex T

goal (1 subgoal):
 1. (\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T) = (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T) = (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T)

goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>(x, y). x + y) ` (rel_interior S \<times> rel_interior T) = (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T)

goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
have "\<dots> = rel_interior (S + T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T) = rel_interior (S + T)
[PROOF STEP]
using fst_snd_linear convex_Times assms
      rel_interior_convex_linear_image[of "(\<lambda>(x,y). x + y)" "S \<times> T"]
[PROOF STATE]
proof (prove)
using this:
linear (\<lambda>(x, y). x + y)
\<lbrakk>convex ?s; convex ?t\<rbrakk> \<Longrightarrow> convex (?s \<times> ?t)
convex S
convex T
\<lbrakk>linear (\<lambda>(x, y). x + y); convex (S \<times> T)\<rbrakk> \<Longrightarrow> (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T) = rel_interior ((\<lambda>(x, y). x + y) ` (S \<times> T))

goal (1 subgoal):
 1. (\<lambda>(x, y). x + y) ` rel_interior (S \<times> T) = rel_interior (S + T)
[PROOF STEP]
by (auto simp add: set_plus_image)
[PROOF STATE]
proof (state)
this:
(\<lambda>(x, y). x + y) ` rel_interior (S \<times> T) = rel_interior (S + T)

goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rel_interior S + rel_interior T = rel_interior (S + T)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rel_interior S + rel_interior T = rel_interior (S + T)

goal (1 subgoal):
 1. rel_interior (S + T) = rel_interior S + rel_interior T
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
rel_interior (S + T) = rel_interior S + rel_interior T

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma output_match_symmetry: "(outputMatch t1 t2) = (outputMatch t2 t1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. outputMatch t1 t2 = outputMatch t2 t1
[PROOF STEP]
apply (simp add: outputMatch_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<exists>m. Outputs t1 = [L (Num m)]) \<and> (\<exists>m'. Outputs t2 = [L (Num m')])) = ((\<exists>m. Outputs t2 = [L (Num m)]) \<and> (\<exists>m'. Outputs t1 = [L (Num m')]))
[PROOF STEP]
by auto


[STATEMENT]
lemma predtrans_UNIV:
  assumes "mono (\<tau> :: ('a set \<Rightarrow> 'a set))"
  shows "\<forall> i. (\<tau> ^^ i) (UNIV) \<supseteq> (\<tau> ^^(i + 1))(UNIV)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. (\<tau> ^^ (i + 1)) UNIV \<subseteq> (\<tau> ^^ i) UNIV
[PROOF STEP]
proof (rule allI, induct_tac i)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. (\<tau> ^^ (0 + 1)) UNIV \<subseteq> (\<tau> ^^ 0) UNIV
 2. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
show "(\<tau> ^^ ((0) + (1))) UNIV \<subseteq> (\<tau> ^^ (0)) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<tau> ^^ (0 + 1)) UNIV \<subseteq> (\<tau> ^^ 0) UNIV
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ (0 + 1)) UNIV \<subseteq> (\<tau> ^^ 0) UNIV

goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
show "\<And>(i) n.
       (\<tau> ^^ (n + (1))) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + (1))) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
fix i n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
assume a: "(\<tau> ^^ (n + (1))) UNIV \<subseteq> (\<tau> ^^ n) UNIV"
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV

goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
have "(\<tau> ((\<tau> ^^ n) UNIV)) \<supseteq> (\<tau> ((\<tau> ^^ (n + (1 :: nat))) UNIV))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<tau> ((\<tau> ^^ (n + 1)) UNIV) \<subseteq> \<tau> ((\<tau> ^^ n) UNIV)
[PROOF STEP]
using assms a
[PROOF STATE]
proof (prove)
using this:
mono \<tau>
(\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV

goal (1 subgoal):
 1. \<tau> ((\<tau> ^^ (n + 1)) UNIV) \<subseteq> \<tau> ((\<tau> ^^ n) UNIV)
[PROOF STEP]
by (rule monoE)
[PROOF STATE]
proof (state)
this:
\<tau> ((\<tau> ^^ (n + 1)) UNIV) \<subseteq> \<tau> ((\<tau> ^^ n) UNIV)

goal (1 subgoal):
 1. \<And>i n. (\<tau> ^^ (n + 1)) UNIV \<subseteq> (\<tau> ^^ n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
thus "(\<tau> ^^ (Suc n + (1))) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV"
[PROOF STATE]
proof (prove)
using this:
\<tau> ((\<tau> ^^ (n + 1)) UNIV) \<subseteq> \<tau> ((\<tau> ^^ n) UNIV)

goal (1 subgoal):
 1. (\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ (Suc n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc n) UNIV

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<tau> ^^ (?n + 1)) UNIV \<subseteq> (\<tau> ^^ ?n) UNIV \<Longrightarrow> (\<tau> ^^ (Suc ?n + 1)) UNIV \<subseteq> (\<tau> ^^ Suc ?n) UNIV

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_card_of_iff_card3:
assumes FIN: "finite A" and FIN': "finite B"
shows "( |A| <o |B| ) = (card A < card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
have "( |A| <o |B| ) = (~ ( |B| \<le>o |A| ))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (|A| <o |B|) = ((|B|, |A|) \<notin> ordLeq)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(|A| <o |B|) = ((|B|, |A|) \<notin> ordLeq)

goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(|A| <o |B|) = ((|B|, |A|) \<notin> ordLeq)

goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
have "... = (~ (card B \<le> card A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((|B|, |A|) \<notin> ordLeq) = (\<not> card B \<le> card A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
finite B

goal (1 subgoal):
 1. ((|B|, |A|) \<notin> ordLeq) = (\<not> card B \<le> card A)
[PROOF STEP]
by(simp add: finite_card_of_iff_card2)
[PROOF STATE]
proof (state)
this:
((|B|, |A|) \<notin> ordLeq) = (\<not> card B \<le> card A)

goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((|B|, |A|) \<notin> ordLeq) = (\<not> card B \<le> card A)

goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
have "... = (card A < card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<not> card B \<le> card A) = (card A < card B)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<not> card B \<le> card A) = (card A < card B)

goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(|A| <o |B|) = (card A < card B)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(|A| <o |B|) = (card A < card B)

goal (1 subgoal):
 1. (|A| <o |B|) = (card A < card B)
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(|A| <o |B|) = (card A < card B)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hmsetmset_empty_iff[simp]: "hmsetmset n = {#} \<longleftrightarrow> n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (hmsetmset n = {#}) = (n = 0)
[PROOF STEP]
unfolding zero_hmultiset_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (hmsetmset n = {#}) = (n = HMSet {#})
[PROOF STEP]
by (cases n) simp


[STATEMENT]
lemma (in prime_number_theorem) mertens_third_theorem_asymp_equiv':
  "(\<lambda>n. (\<Prod>k<n. 1 - 1 / nth_prime k)) \<sim>[at_top] (\<lambda>x. third_mertens_const / ln x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
have lim: "filterlim (\<lambda>n. real (nth_prime (n - 1))) at_top at_top"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. LIM n sequentially. real (nth_prime (n - 1)) :> at_top
[PROOF STEP]
by (intro filterlim_compose[OF filterlim_real_sequentially]
              filterlim_compose[OF nth_prime_at_top]) real_asymp
[PROOF STATE]
proof (state)
this:
LIM n sequentially. real (nth_prime (n - 1)) :> at_top

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
have "(\<lambda>n. (\<Prod>k<n. 1 - 1 / nth_prime k)) \<sim>[at_top]
          (\<lambda>n. (\<Prod>p | prime p \<and> real p \<le> real (nth_prime (n - 1)). 1 - 1 / p))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>n. \<Prod>x\<in>{p. prime p \<and> real p \<le> real (nth_prime (n - 1))}. 1 - 1 / real x)
[PROOF STEP]
by (intro asymp_equiv_refl_ev eventually_mono[OF eventually_gt_at_top[of 0]])
       (subst mertens_third_convert, auto)
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>n. \<Prod>x\<in>{p. prime p \<and> real p \<le> real (nth_prime (n - 1))}. 1 - 1 / real x)

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>n. \<Prod>x\<in>{p. prime p \<and> real p \<le> real (nth_prime (n - 1))}. 1 - 1 / real x)

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. \<Prod>x\<in>{p. prime p \<and> real p \<le> real (nth_prime (n - 1))}. 1 - 1 / real x) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1))))
[PROOF STEP]
by (intro asymp_equiv_compose'[OF mertens_third_theorem_asymp_equiv lim])
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>x\<in>{p. prime p \<and> real p \<le> real (nth_prime (n - 1))}. 1 - 1 / real x) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1))))

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>x\<in>{p. prime p \<and> real p \<le> real (nth_prime (n - 1))}. 1 - 1 / real x) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1))))

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>n. third_mertens_const / ln (real (n - 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1)))) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real (n - 1)))
[PROOF STEP]
by (intro asymp_equiv_intros asymp_equiv_compose'[OF ln_nth_prime_asymp_equiv]) real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1)))) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real (n - 1)))

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<lambda>n. third_mertens_const / ln (real (nth_prime (n - 1)))) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real (n - 1)))

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
have "\<dots> \<sim>[at_top] (\<lambda>n. third_mertens_const / ln (real n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. third_mertens_const / ln (real (n - 1))) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real n))
[PROOF STEP]
using third_mertens_const_pos
[PROOF STATE]
proof (prove)
using this:
0 < third_mertens_const

goal (1 subgoal):
 1. (\<lambda>n. third_mertens_const / ln (real (n - 1))) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real n))
[PROOF STEP]
by real_asymp
[PROOF STATE]
proof (state)
this:
(\<lambda>n. third_mertens_const / ln (real (n - 1))) \<sim>[sequentially] (\<lambda>n. third_mertens_const / ln (real n))

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d; \<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d; \<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d\<rbrakk> \<Longrightarrow> (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>a. third_mertens_const / ln (real a))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d; \<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d; \<And>c d. c \<sim>[sequentially] d \<Longrightarrow> c \<sim>[sequentially] d\<rbrakk> \<Longrightarrow> (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>a. third_mertens_const / ln (real a))

goal (1 subgoal):
 1. (\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<lambda>n. \<Prod>k<n. 1 - 1 / real (nth_prime k)) \<sim>[sequentially] (\<lambda>x. third_mertens_const / ln (real x))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Gauss_Jordan_in_ij_det_P_iarrays_code[code]: "Gauss_Jordan_in_ij_det_P_iarrays A i j
    = (let n = least_non_zero_position_of_vector_from_index (column_iarray j A) i;
           interchange_A = interchange_rows_iarray A i n;
           A' = mult_row_iarray interchange_A i (1 / interchange_A !! i !! j)
       in (if i = n then 1 / A !! i !! j else - 1 / A !! n !! j, IArray.of_fun (\<lambda>s. if s = i then A' !! s else row_add_iarray A' s i (- interchange_A !! s !! j) !! s) (nrows_iarray A)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Gauss_Jordan_in_ij_det_P_iarrays A i j = (let n = least_non_zero_position_of_vector_from_index (column_iarray j A) i; interchange_A = interchange_rows_iarray A i n; A' = mult_row_iarray interchange_A i ((1::'a) / interchange_A !! i !! j) in (if i = n then (1::'a) / A !! i !! j else - (1::'a) / A !! n !! j, IArray.of_fun (\<lambda>s. if s = i then A' !! s else row_add_iarray A' s i (- interchange_A !! s !! j) !! s) (nrows_iarray A)))
[PROOF STEP]
unfolding Gauss_Jordan_in_ij_det_P_iarrays_def Gauss_Jordan_in_ij_iarrays_def Let_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if i = least_non_zero_position_of_vector_from_index (column_iarray j A) i then (1::'a) / A !! i !! j else - (1::'a) / A !! least_non_zero_position_of_vector_from_index (column_iarray j A) i !! j, IArray.of_fun (\<lambda>s. if s = i then mult_row_iarray (interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i)) i ((1::'a) / interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i) !! i !! j) !! s else row_add_iarray (mult_row_iarray (interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i)) i ((1::'a) / interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i) !! i !! j)) s i (- interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i) !! s !! j) !! s) (nrows_iarray A)) = (if i = least_non_zero_position_of_vector_from_index (column_iarray j A) i then (1::'a) / A !! i !! j else - (1::'a) / A !! least_non_zero_position_of_vector_from_index (column_iarray j A) i !! j, IArray.of_fun (\<lambda>s. if s = i then mult_row_iarray (interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i)) i ((1::'a) / interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i) !! i !! j) !! s else row_add_iarray (mult_row_iarray (interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i)) i ((1::'a) / interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i) !! i !! j)) s i (- interchange_rows_iarray A i (least_non_zero_position_of_vector_from_index (column_iarray j A) i) !! s !! j) !! s) (nrows_iarray A))
[PROOF STEP]
..


[STATEMENT]
lemma bdd_above_plus:
  fixes f::\<open>'a \<Rightarrow> real\<close>
  assumes \<open>bdd_above (f ` S)\<close> and \<open>bdd_above (g ` S)\<close>
  shows \<open>bdd_above ((\<lambda> x. f x + g x) ` S)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
text \<open>
  Explanation: If the images of two real-valued functions \<^term>\<open>f\<close>,\<^term>\<open>g\<close> are bounded above on a
  set \<^term>\<open>S\<close>, then the image of their sum is bounded on \<^term>\<open>S\<close>.
\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
obtain M where \<open>\<And> x. x\<in>S \<Longrightarrow> f x \<le> M\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>M. (\<And>x. x \<in> S \<Longrightarrow> f x \<le> M) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>bdd_above (f ` S)\<close>
[PROOF STATE]
proof (prove)
using this:
bdd_above (f ` S)

goal (1 subgoal):
 1. (\<And>M. (\<And>x. x \<in> S \<Longrightarrow> f x \<le> M) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding bdd_above_def
[PROOF STATE]
proof (prove)
using this:
\<exists>M. \<forall>x\<in>f ` S. x \<le> M

goal (1 subgoal):
 1. (\<And>M. (\<And>x. x \<in> S \<Longrightarrow> f x \<le> M) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?x \<in> S \<Longrightarrow> f ?x \<le> M

goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
obtain N where \<open>\<And> x. x\<in>S \<Longrightarrow> g x \<le> N\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>N. (\<And>x. x \<in> S \<Longrightarrow> g x \<le> N) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>bdd_above (g ` S)\<close>
[PROOF STATE]
proof (prove)
using this:
bdd_above (g ` S)

goal (1 subgoal):
 1. (\<And>N. (\<And>x. x \<in> S \<Longrightarrow> g x \<le> N) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding bdd_above_def
[PROOF STATE]
proof (prove)
using this:
\<exists>M. \<forall>x\<in>g ` S. x \<le> M

goal (1 subgoal):
 1. (\<And>N. (\<And>x. x \<in> S \<Longrightarrow> g x \<le> N) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?x \<in> S \<Longrightarrow> g ?x \<le> N

goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
have \<open>\<And> x. x\<in>S \<Longrightarrow> f x + g x \<le> M + N\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> S \<Longrightarrow> f x + g x \<le> M + N
[PROOF STEP]
using \<open>\<And>x. x \<in> S \<Longrightarrow> f x \<le> M\<close> \<open>\<And>x. x \<in> S \<Longrightarrow> g x \<le> N\<close>
[PROOF STATE]
proof (prove)
using this:
?x \<in> S \<Longrightarrow> f ?x \<le> M
?x \<in> S \<Longrightarrow> g ?x \<le> N

goal (1 subgoal):
 1. \<And>x. x \<in> S \<Longrightarrow> f x + g x \<le> M + N
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?x \<in> S \<Longrightarrow> f ?x + g ?x \<le> M + N

goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?x \<in> S \<Longrightarrow> f ?x + g ?x \<le> M + N

goal (1 subgoal):
 1. bdd_above ((\<lambda>x. f x + g x) ` S)
[PROOF STEP]
unfolding bdd_above_def
[PROOF STATE]
proof (prove)
using this:
?x \<in> S \<Longrightarrow> f ?x + g ?x \<le> M + N

goal (1 subgoal):
 1. \<exists>M. \<forall>x\<in>(\<lambda>x. f x + g x) ` S. x \<le> M
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
bdd_above ((\<lambda>x. f x + g x) ` S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma integral_Dirichlet_kernel_half [simp]:
  "integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi/2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2
[PROOF STEP]
have "integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) +
        integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) + integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi
[PROOF STEP]
using integral_combine [OF integrable_Dirichlet_kernel] integral_Dirichlet_kernel
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>- pi \<le> ?c; ?c \<le> pi\<rbrakk> \<Longrightarrow> integral\<^sup>L (lebesgue_on {- pi..pi}) (Dirichlet_kernel ?n1) = integral\<^sup>L (lebesgue_on {- pi..?c}) (Dirichlet_kernel ?n1) + integral\<^sup>L (lebesgue_on {?c..pi}) (Dirichlet_kernel ?n1)
integral\<^sup>L (lebesgue_on {- pi..pi}) (Dirichlet_kernel ?n) = pi

goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) + integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) + integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi

goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) + integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi

goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2
[PROOF STEP]
have "integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)
[PROOF STEP]
using integral_reflect_real [of pi 0 "Dirichlet_kernel n"]
[PROOF STATE]
proof (prove)
using this:
LINT x|lebesgue_on {- pi..- 0}. Dirichlet_kernel n (- x) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)

goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)

goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) + integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) + integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi
integral\<^sup>L (lebesgue_on {- pi..0}) (Dirichlet_kernel n) = integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n)

goal (1 subgoal):
 1. integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
integral\<^sup>L (lebesgue_on {0..pi}) (Dirichlet_kernel n) = pi / 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cis_times_2pi[simp]: "cis (of_nat n * 2 * pi) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (real n * 2 * pi) = 1
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. cis (real 0 * 2 * pi) = 1
 2. \<And>n. cis (real n * 2 * pi) = 1 \<Longrightarrow> cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
cis (real n * 2 * pi) = 1

goal (2 subgoals):
 1. cis (real 0 * 2 * pi) = 1
 2. \<And>n. cis (real n * 2 * pi) = 1 \<Longrightarrow> cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
have "of_nat (Suc n) * 2 * pi = of_nat n * 2 * pi + 2 * pi"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (Suc n) * 2 * pi = real n * 2 * pi + 2 * pi
[PROOF STEP]
by (simp add: distrib_right)
[PROOF STATE]
proof (state)
this:
real (Suc n) * 2 * pi = real n * 2 * pi + 2 * pi

goal (2 subgoals):
 1. cis (real 0 * 2 * pi) = 1
 2. \<And>n. cis (real n * 2 * pi) = 1 \<Longrightarrow> cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real (Suc n) * 2 * pi = real n * 2 * pi + 2 * pi

goal (2 subgoals):
 1. cis (real 0 * 2 * pi) = 1
 2. \<And>n. cis (real n * 2 * pi) = 1 \<Longrightarrow> cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
have "cis \<dots> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cis (real n * 2 * pi + 2 * pi) = 1
[PROOF STEP]
unfolding cis_plus_2pi Suc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = 1
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
cis (real n * 2 * pi + 2 * pi) = 1

goal (2 subgoals):
 1. cis (real 0 * 2 * pi) = 1
 2. \<And>n. cis (real n * 2 * pi) = 1 \<Longrightarrow> cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
cis (real (Suc n) * 2 * pi) = 1

goal (1 subgoal):
 1. cis (real (Suc n) * 2 * pi) = 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
cis (real (Suc n) * 2 * pi) = 1

goal (1 subgoal):
 1. cis (real 0 * 2 * pi) = 1
[PROOF STEP]
qed simp


[STATEMENT]
lemma is_basis_imp_full_rank:
  fixes A::"'a::{field}^'cols::{mod_type}^'rows::{mod_type}"
  assumes b: "is_basis (columns A)"
  and c: "card (columns A) = ncols A"
  shows "rank A = ncols A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
have "rank A = col_rank A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rank A = col_rank A
[PROOF STEP]
unfolding rank_col_rank
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col_rank A = col_rank A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
rank A = col_rank A

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
rank A = col_rank A

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
have "... = vec.dim (col_space A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. col_rank A = vec.dim (col_space A)
[PROOF STEP]
unfolding col_rank_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.dim (col_space A) = vec.dim (col_space A)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
col_rank A = vec.dim (col_space A)

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
col_rank A = vec.dim (col_space A)

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
have "... = card (columns A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec.dim (col_space A) = card (columns A)
[PROOF STEP]
by (metis b col_space_def independent_is_basis vec.dim_eq_card_independent vec.dim_span)
[PROOF STATE]
proof (state)
this:
vec.dim (col_space A) = card (columns A)

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
vec.dim (col_space A) = card (columns A)

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
have "... = ncols A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (columns A) = ncols A
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
card (columns A) = ncols A

goal (1 subgoal):
 1. card (columns A) = ncols A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
card (columns A) = ncols A

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
rank A = ncols A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
rank A = ncols A

goal (1 subgoal):
 1. rank A = ncols A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
rank A = ncols A

goal:
No subgoals!
[PROOF STEP]
qed