[STATEMENT]
lemma per_col_mult_unitary:
  fixes A::"complex Matrix.mat"
  assumes "A \<in> carrier_mat n n"
  and "unitary A"
  and "D\<in> carrier_mat n n"
  and "diagonal_mat D"
  and "0 < n"
  and "bij_betw f {..< n} {..< n}"
shows "A * D * (Complex_Matrix.adjoint A) =
  (per_col A f) * (per_diag D f) * (Complex_Matrix.adjoint (per_col A f))"
  (is "?L = ?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
proof  -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have row: "dim_row ?L = dim_row ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_row (A * D * Complex_Matrix.adjoint A) = dim_row (per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f))
[PROOF STEP]
using per_col_carrier assms
[PROOF STATE]
proof (prove)
using this:
?A \<in> carrier_mat ?n ?m \<Longrightarrow> per_col ?A ?f \<in> carrier_mat ?n ?m
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. dim_row (A * D * Complex_Matrix.adjoint A) = dim_row (per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f))
[PROOF STEP]
by (metis carrier_matD(1) index_mult_mat(2))
[PROOF STATE]
proof (state)
this:
dim_row (A * D * Complex_Matrix.adjoint A) = dim_row (per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f))

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have col: "dim_col ?L = dim_col ?R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_col (A * D * Complex_Matrix.adjoint A) = dim_col (per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f))
[PROOF STEP]
using per_col_carrier assms
[PROOF STATE]
proof (prove)
using this:
?A \<in> carrier_mat ?n ?m \<Longrightarrow> per_col ?A ?f \<in> carrier_mat ?n ?m
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. dim_col (A * D * Complex_Matrix.adjoint A) = dim_col (per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f))
[PROOF STEP]
by (metis adjoint_dim carrier_matD(2) index_mult_mat(3))
[PROOF STATE]
proof (state)
this:
dim_col (A * D * Complex_Matrix.adjoint A) = dim_col (per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f))

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
define fc::"complex Matrix.mat set" where "fc = carrier_mat n n"
[PROOF STATE]
proof (state)
this:
fc = carrier_mat n n

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
interpret cpx_sq_mat n n fc
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cpx_sq_mat n n fc
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. fc = carrier_mat n n
 2. n = n
 3. 0 < n
[PROOF STEP]
show "0 < n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

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

goal (2 subgoals):
 1. fc = carrier_mat n n
 2. n = n
[PROOF STEP]
qed (auto simp add: fc_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
define h where
    "h = (\<lambda>i. (if i < n then diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)
      else (0\<^sub>m n n)))"
[PROOF STATE]
proof (state)
this:
h = (\<lambda>i. if i < n then diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) else 0\<^sub>m n n)

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
define g where
    "g = (\<lambda>i. (if i < n
      then diag_mat D ! (f i) \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
      else (0\<^sub>m n n)))"
[PROOF STATE]
proof (state)
this:
g = (\<lambda>i. if i < n then diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) else 0\<^sub>m n n)

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "f ` {..<n} = {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` {..<n} = {..<n}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. f ` {..<n} = {..<n}
[PROOF STEP]
by (simp add: bij_betw_imp_surj_on)
[PROOF STATE]
proof (state)
this:
f ` {..<n} = {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have g: "\<forall>i. g i \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. g i \<in> fc
[PROOF STEP]
unfolding g_def fc_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. (if i < n then diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) else 0\<^sub>m n n) \<in> carrier_mat n n
[PROOF STEP]
by (metis adjoint_dim_col assms(1) carrier_matD(1) carrier_matI
        dim_col fc_mats_carrier rank_1_proj_adjoint rank_1_proj_dim
        smult_carrier_mat zero_mem)
[PROOF STATE]
proof (state)
this:
\<forall>i. g i \<in> fc

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>i. g i \<in> fc

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have h:"\<forall>i. h i \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. h i \<in> fc
[PROOF STEP]
unfolding h_def fc_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. (if i < n then diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) else 0\<^sub>m n n) \<in> carrier_mat n n
[PROOF STEP]
by (metis assms(1) carrier_matD(1) dim_col fc_mats_carrier
        rank_1_proj_carrier smult_carrier_mat zero_mem)
[PROOF STATE]
proof (state)
this:
\<forall>i. h i \<in> fc

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>i. h i \<in> fc

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "inj_on f {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on f {..<n}
[PROOF STEP]
using assms(6) bij_betw_def
[PROOF STATE]
proof (prove)
using this:
bij_betw f {..<n} {..<n}
bij_betw ?f ?A ?B = (inj_on ?f ?A \<and> ?f ` ?A = ?B)

goal (1 subgoal):
 1. inj_on f {..<n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inj_on f {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
inj_on f {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "\<And>x. x \<in> {..<n} \<Longrightarrow> h (f x) = g x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {..<n} \<Longrightarrow> h (f x) = g x
[PROOF STEP]
unfolding h_def g_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> {..<n} \<Longrightarrow> (if f x < n then diag_mat D ! f x \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f x)) else 0\<^sub>m n n) = (if x < n then diag_mat D ! f x \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f x)) else 0\<^sub>m n n)
[PROOF STEP]
by (meson assms(6) bij_betwE lessThan_iff)
[PROOF STATE]
proof (state)
this:
?x1 \<in> {..<n} \<Longrightarrow> h (f ?x1) = g ?x1

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>i. g i \<in> fc
\<forall>i. h i \<in> fc
inj_on f {..<n}
?x1 \<in> {..<n} \<Longrightarrow> h (f ?x1) = g ?x1
[PROOF STEP]
have "sum_mat g {..<n} = sum_mat h (f`{..<n})"
[PROOF STATE]
proof (prove)
using this:
\<forall>i. g i \<in> fc
\<forall>i. h i \<in> fc
inj_on f {..<n}
?x1 \<in> {..<n} \<Longrightarrow> h (f ?x1) = g ?x1

goal (1 subgoal):
 1. local.sum_mat g {..<n} = local.sum_mat h (f ` {..<n})
[PROOF STEP]
using sum_with_reindex_cong[of h g f "{..<n}"]
[PROOF STATE]
proof (prove)
using this:
\<forall>i. g i \<in> fc
\<forall>i. h i \<in> fc
inj_on f {..<n}
?x1 \<in> {..<n} \<Longrightarrow> h (f ?x1) = g ?x1
\<lbrakk>\<forall>x. h x \<in> fc; \<forall>x. g x \<in> fc; inj_on f {..<n}; ?A = f ` {..<n}; \<And>x. x \<in> {..<n} \<Longrightarrow> h (f x) = g x\<rbrakk> \<Longrightarrow> sum_with (+) (0\<^sub>m n n) h (f ` {..<n}) = sum_with (+) (0\<^sub>m n n) g {..<n}

goal (1 subgoal):
 1. local.sum_mat g {..<n} = local.sum_mat h (f ` {..<n})
[PROOF STEP]
unfolding  sum_mat_def
[PROOF STATE]
proof (prove)
using this:
\<forall>i. g i \<in> fc
\<forall>i. h i \<in> fc
inj_on f {..<n}
?x1 \<in> {..<n} \<Longrightarrow> h (f ?x1) = g ?x1
\<lbrakk>\<forall>x. h x \<in> fc; \<forall>x. g x \<in> fc; inj_on f {..<n}; ?A = f ` {..<n}; \<And>x. x \<in> {..<n} \<Longrightarrow> h (f x) = g x\<rbrakk> \<Longrightarrow> sum_with (+) (0\<^sub>m n n) h (f ` {..<n}) = sum_with (+) (0\<^sub>m n n) g {..<n}

goal (1 subgoal):
 1. sum_with (+) (0\<^sub>m n n) g {..<n} = sum_with (+) (0\<^sub>m n n) h (f ` {..<n})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.sum_mat g {..<n} = local.sum_mat h (f ` {..<n})

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat g {..<n} = local.sum_mat h (f ` {..<n})

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "... = sum_mat h {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat h (f ` {..<n}) = local.sum_mat h {..<n}
[PROOF STEP]
using \<open>f ` {..<n} = {..<n}\<close>
[PROOF STATE]
proof (prove)
using this:
f ` {..<n} = {..<n}

goal (1 subgoal):
 1. local.sum_mat h (f ` {..<n}) = local.sum_mat h {..<n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.sum_mat h (f ` {..<n}) = local.sum_mat h {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat h (f ` {..<n}) = local.sum_mat h {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "... =sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i))
    {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat h {..<n} = local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n}
[PROOF STEP]
proof (rule sum_mat_cong, (auto simp add:h h_def))
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
 2. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> carrier_mat n n
[PROOF STEP]
by (metis fc_mats_carrier h h_def)
[PROOF STATE]
proof (state)
this:
?i1 < n \<Longrightarrow> diag_mat D ! ?i1 \<cdot>\<^sub>m rank_1_proj (Matrix.col A ?i1) \<in> fc

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i) \<in> carrier_mat n n
[PROOF STEP]
by (metis fc_mats_carrier h h_def)
[PROOF STATE]
proof (state)
this:
?i1 < n \<Longrightarrow> diag_mat D ! ?i1 \<cdot>\<^sub>m rank_1_proj (Matrix.col A ?i1) \<in> fc

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.sum_mat h {..<n} = local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat h {..<n} = local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "... = A * D * (Complex_Matrix.adjoint A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
using weighted_sum_rank_1_proj_unitary assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<in> fc; ?B \<in> fc; diagonal_mat ?B; Complex_Matrix.unitary ?A\<rbrakk> \<Longrightarrow> local.sum_mat (\<lambda>i. diag_mat ?B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col ?A i)) {..<n} = ?A * ?B * Complex_Matrix.adjoint ?A
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<in> carrier_mat n n; ?B \<in> carrier_mat n n; diagonal_mat ?B; Complex_Matrix.unitary ?A\<rbrakk> \<Longrightarrow> local.sum_mat (\<lambda>i. diag_mat ?B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col ?A i)) {..<n} = ?A * ?B * Complex_Matrix.adjoint ?A
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat D ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col A i)) {..<n} = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
have sg: "sum_mat g {..<n} = A * D * (Complex_Matrix.adjoint A)"
[PROOF STATE]
proof (prove)
using this:
local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "(per_col A f) * (per_diag D f) *
    (Complex_Matrix.adjoint (per_col A f)) =
    sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m
    rank_1_proj (Matrix.col (per_col A f) i)) {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = local.sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i)) {..<n}
[PROOF STEP]
proof (rule weighted_sum_rank_1_proj_unitary[symmetric])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. per_col A f \<in> fc
 2. per_diag D f \<in> fc
 3. diagonal_mat (per_diag D f)
 4. Complex_Matrix.unitary (per_col A f)
[PROOF STEP]
show "per_col A f \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. per_col A f \<in> fc
[PROOF STEP]
using per_col_carrier[of A] assms
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat ?n ?m \<Longrightarrow> per_col A ?f \<in> carrier_mat ?n ?m
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. per_col A f \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat ?n ?m \<Longrightarrow> per_col A ?f \<in> carrier_mat ?n ?m
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. per_col A f \<in> carrier_mat n n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
per_col A f \<in> fc

goal (3 subgoals):
 1. per_diag D f \<in> fc
 2. diagonal_mat (per_diag D f)
 3. Complex_Matrix.unitary (per_col A f)
[PROOF STEP]
show "per_diag D f \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. per_diag D f \<in> fc
[PROOF STEP]
using per_diag_carrier[of D] assms
[PROOF STATE]
proof (prove)
using this:
per_diag D ?f \<in> carrier_mat (dim_row D) (dim_col D)
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. per_diag D f \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
per_diag D ?f \<in> carrier_mat (dim_row D) (dim_col D)
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. per_diag D f \<in> carrier_mat n n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
per_diag D f \<in> fc

goal (2 subgoals):
 1. diagonal_mat (per_diag D f)
 2. Complex_Matrix.unitary (per_col A f)
[PROOF STEP]
show "diagonal_mat (per_diag D f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_mat (per_diag D f)
[PROOF STEP]
using assms per_diag_diagonal[of D]
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}
\<lbrakk>D \<in> carrier_mat ?n ?n; diagonal_mat D; bij_betw ?f {..<?n} {..<?n}\<rbrakk> \<Longrightarrow> diagonal_mat (per_diag D ?f)

goal (1 subgoal):
 1. diagonal_mat (per_diag D f)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
diagonal_mat (per_diag D f)

goal (1 subgoal):
 1. Complex_Matrix.unitary (per_col A f)
[PROOF STEP]
show "unitary (per_col A f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.unitary (per_col A f)
[PROOF STEP]
using per_col_unitary[of A] assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>A \<in> carrier_mat ?n ?n; Complex_Matrix.unitary A; bij_betw ?f {..<?n} {..<?n}\<rbrakk> \<Longrightarrow> Complex_Matrix.unitary (per_col A ?f)
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. Complex_Matrix.unitary (per_col A f)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.unitary (per_col A f)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = local.sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i)) {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = local.sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i)) {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "... = sum_mat g {..<n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i)) {..<n} = local.sum_mat g {..<n}
[PROOF STEP]
proof (rule sum_mat_cong, (auto simp add: g_def))
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
 2. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
 3. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m
      rank_1_proj (Matrix.col (per_col A f) i) \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
assume "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
have "dim_vec (Matrix.col (per_col A f) i) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (Matrix.col (per_col A f) i) = n
[PROOF STEP]
using assms per_col_col
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}
\<lbrakk>?A \<in> carrier_mat ?n ?m; ?j < ?m\<rbrakk> \<Longrightarrow> Matrix.col (per_col ?A ?f) ?j = Matrix.col ?A (?f ?j)

goal (1 subgoal):
 1. dim_vec (Matrix.col (per_col A f) i) = n
[PROOF STEP]
by (metis carrier_matD(1) dim_col)
[PROOF STATE]
proof (state)
this:
dim_vec (Matrix.col (per_col A f) i) = n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
hence "rank_1_proj (Matrix.col (per_col A f) i) \<in> fc"
[PROOF STATE]
proof (prove)
using this:
dim_vec (Matrix.col (per_col A f) i) = n

goal (1 subgoal):
 1. rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
dim_vec (Matrix.col (per_col A f) i) = n

goal (1 subgoal):
 1. rank_1_proj (Matrix.col (per_col A f) i) \<in> carrier_mat n n
[PROOF STEP]
using rank_1_proj_carrier
[PROOF STATE]
proof (prove)
using this:
dim_vec (Matrix.col (per_col A f) i) = n
rank_1_proj ?v \<in> carrier_mat (dim_vec ?v) (dim_vec ?v)

goal (1 subgoal):
 1. rank_1_proj (Matrix.col (per_col A f) i) \<in> carrier_mat n n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
rank_1_proj (Matrix.col (per_col A f) i) \<in> fc

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
thus "diag_mat (per_diag D f) ! i \<cdot>\<^sub>m
        rank_1_proj (Matrix.col (per_col A f) i) \<in> fc"
[PROOF STATE]
proof (prove)
using this:
rank_1_proj (Matrix.col (per_col A f) i) \<in> fc

goal (1 subgoal):
 1. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
rank_1_proj (Matrix.col (per_col A f) i) \<in> carrier_mat n n

goal (1 subgoal):
 1. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> carrier_mat n n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) \<in> fc

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i1 < n \<Longrightarrow> diag_mat (per_diag D f) ! ?i1 \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) ?i1) \<in> fc

goal (2 subgoals):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
 2. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m
      rank_1_proj (Matrix.col A (f i)) \<in> fc"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
assume "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
hence "f i < n"
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. f i < n
[PROOF STEP]
using \<open>f ` {..<n} = {..<n}\<close>
[PROOF STATE]
proof (prove)
using this:
i < n
f ` {..<n} = {..<n}

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

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
hence "dim_vec (Matrix.col A (f i)) = n"
[PROOF STATE]
proof (prove)
using this:
f i < n

goal (1 subgoal):
 1. dim_vec (Matrix.col A (f i)) = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f i < n
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}

goal (1 subgoal):
 1. dim_vec (Matrix.col A (f i)) = n
[PROOF STEP]
by (metis carrier_matD(1) dim_col)
[PROOF STATE]
proof (state)
this:
dim_vec (Matrix.col A (f i)) = n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
hence "rank_1_proj (Matrix.col A (f i)) \<in> fc"
[PROOF STATE]
proof (prove)
using this:
dim_vec (Matrix.col A (f i)) = n

goal (1 subgoal):
 1. rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
dim_vec (Matrix.col A (f i)) = n

goal (1 subgoal):
 1. rank_1_proj (Matrix.col A (f i)) \<in> carrier_mat n n
[PROOF STEP]
using rank_1_proj_carrier
[PROOF STATE]
proof (prove)
using this:
dim_vec (Matrix.col A (f i)) = n
rank_1_proj ?v \<in> carrier_mat (dim_vec ?v) (dim_vec ?v)

goal (1 subgoal):
 1. rank_1_proj (Matrix.col A (f i)) \<in> carrier_mat n n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
rank_1_proj (Matrix.col A (f i)) \<in> fc

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
thus "diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc"
[PROOF STATE]
proof (prove)
using this:
rank_1_proj (Matrix.col A (f i)) \<in> fc

goal (1 subgoal):
 1. diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc
[PROOF STEP]
unfolding fc_def
[PROOF STATE]
proof (prove)
using this:
rank_1_proj (Matrix.col A (f i)) \<in> carrier_mat n n

goal (1 subgoal):
 1. diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> carrier_mat n n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i)) \<in> fc

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i1 < n \<Longrightarrow> diag_mat D ! f ?i1 \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f ?i1)) \<in> fc

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
show "\<And>i. i < n \<Longrightarrow>
         diag_mat (per_diag D f) ! i \<cdot>\<^sub>m
           rank_1_proj (Matrix.col (per_col A f) i) =
         diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
assume "i < n"
[PROOF STATE]
proof (state)
this:
i < n

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
hence "f i < n"
[PROOF STATE]
proof (prove)
using this:
i < n

goal (1 subgoal):
 1. f i < n
[PROOF STEP]
using \<open>f ` {..<n} = {..<n}\<close>
[PROOF STATE]
proof (prove)
using this:
i < n
f ` {..<n} = {..<n}

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

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
have "Matrix.col (per_col A f) i = Matrix.col A (f i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Matrix.col (per_col A f) i = Matrix.col A (f i)
[PROOF STEP]
using per_col_col assms \<open>i < n\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<in> carrier_mat ?n ?m; ?j < ?m\<rbrakk> \<Longrightarrow> Matrix.col (per_col ?A ?f) ?j = Matrix.col ?A (?f ?j)
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}
i < n

goal (1 subgoal):
 1. Matrix.col (per_col A f) i = Matrix.col A (f i)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Matrix.col (per_col A f) i = Matrix.col A (f i)

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
hence "rank_1_proj (Matrix.col (per_col A f) i) =
        rank_1_proj (Matrix.col A (f i))"
[PROOF STATE]
proof (prove)
using this:
Matrix.col (per_col A f) i = Matrix.col A (f i)

goal (1 subgoal):
 1. rank_1_proj (Matrix.col (per_col A f) i) = rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
rank_1_proj (Matrix.col (per_col A f) i) = rank_1_proj (Matrix.col A (f i))

goal (1 subgoal):
 1. \<And>i. i < n \<Longrightarrow> diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
thus "diag_mat (per_diag D f) ! i \<cdot>\<^sub>m
        rank_1_proj (Matrix.col (per_col A f) i) =
        diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))"
[PROOF STATE]
proof (prove)
using this:
rank_1_proj (Matrix.col (per_col A f) i) = rank_1_proj (Matrix.col A (f i))

goal (1 subgoal):
 1. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
using assms per_diag_diag_mat[of D] \<open>i < n\<close> \<open>f i < n\<close>
[PROOF STATE]
proof (prove)
using this:
rank_1_proj (Matrix.col (per_col A f) i) = rank_1_proj (Matrix.col A (f i))
A \<in> carrier_mat n n
Complex_Matrix.unitary A
D \<in> carrier_mat n n
diagonal_mat D
0 < n
bij_betw f {..<n} {..<n}
\<lbrakk>D \<in> carrier_mat ?n ?n; ?i < ?n; ?f ?i < ?n\<rbrakk> \<Longrightarrow> diag_mat (per_diag D ?f) ! ?i = diag_mat D ! ?f ?i
i < n
f i < n

goal (1 subgoal):
 1. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i) = diag_mat D ! f i \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f i))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i1 < n \<Longrightarrow> diag_mat (per_diag D f) ! ?i1 \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) ?i1) = diag_mat D ! f ?i1 \<cdot>\<^sub>m rank_1_proj (Matrix.col A (f ?i1))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i)) {..<n} = local.sum_mat g {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat (per_diag D f) ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col (per_col A f) i)) {..<n} = local.sum_mat g {..<n}

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
have "... = A * D * (Complex_Matrix.adjoint A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
using sg
[PROOF STATE]
proof (prove)
using this:
local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.sum_mat g {..<n} = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
have "(per_col A f) * (per_diag D f) *
    (Complex_Matrix.adjoint (per_col A f)) =
    A * D * (Complex_Matrix.adjoint A)"
[PROOF STATE]
proof (prove)
using this:
per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = A * D * Complex_Matrix.adjoint A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f) = A * D * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
A * D * Complex_Matrix.adjoint A = per_col A f * per_diag D f * Complex_Matrix.adjoint (per_col A f)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma catalan_Suc_aux:
  "(n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n
[PROOF STEP]
have "real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
[PROOF STEP]
proof (cases n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 0 \<Longrightarrow> real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
 2. \<And>nat. n = Suc nat \<Longrightarrow> real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
n = Suc n

goal (2 subgoals):
 1. n = 0 \<Longrightarrow> real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
 2. \<And>nat. n = Suc nat \<Longrightarrow> real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = Suc n

goal (1 subgoal):
 1. real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
[PROOF STEP]
by (subst (1 2) of_nat_catalan_closed_form, subst (1 2) binomial_fact)
         (simp_all add: divide_simps)
[PROOF STATE]
proof (state)
this:
real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)

goal (1 subgoal):
 1. n = 0 \<Longrightarrow> real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)
[PROOF STEP]
qed simp_all
[PROOF STATE]
proof (state)
this:
real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)

goal (1 subgoal):
 1. (n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n
[PROOF STEP]
hence "real ((n + 2) * catalan (Suc n)) = real (2 * (2 * n + 1) * catalan n)"
[PROOF STATE]
proof (prove)
using this:
real (catalan (Suc n)) * real (n + 2) = real (catalan n) * 2 * real (2 * n + 1)

goal (1 subgoal):
 1. real ((n + 2) * catalan (Suc n)) = real (2 * (2 * n + 1) * catalan n)
[PROOF STEP]
by (simp only: mult_ac of_nat_mult)
[PROOF STATE]
proof (state)
this:
real ((n + 2) * catalan (Suc n)) = real (2 * (2 * n + 1) * catalan n)

goal (1 subgoal):
 1. (n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
real ((n + 2) * catalan (Suc n)) = real (2 * (2 * n + 1) * catalan n)

goal (1 subgoal):
 1. (n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n
[PROOF STEP]
by (simp only: of_nat_eq_iff)
[PROOF STATE]
proof (state)
this:
(n + 2) * catalan (Suc n) = 2 * (2 * n + 1) * catalan n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem (in group) l_lagrange:
     "\<lbrakk>finite(carrier G); subgroup H G\<rbrakk>
      \<Longrightarrow> card(lcosets H) * card(H) = order(G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite (carrier G); subgroup H G\<rbrakk> \<Longrightarrow> card (lcosets H) * card H = order G
[PROOF STEP]
apply (simp (no_asm_simp) add: order_def lcosets_part_G [symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite (carrier G); subgroup H G\<rbrakk> \<Longrightarrow> card (lcosets H) * card H = card (\<Union> (lcosets H))
[PROOF STEP]
apply (subst mult.commute)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite (carrier G); subgroup H G\<rbrakk> \<Longrightarrow> card H * card (lcosets H) = card (\<Union> (lcosets H))
[PROOF STEP]
apply (rule card_partition)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<lbrakk>finite (carrier G); subgroup H G\<rbrakk> \<Longrightarrow> finite (lcosets H)
 2. \<lbrakk>finite (carrier G); subgroup H G\<rbrakk> \<Longrightarrow> finite (\<Union> (lcosets H))
 3. \<And>c. \<lbrakk>finite (carrier G); subgroup H G; c \<in> lcosets H\<rbrakk> \<Longrightarrow> card c = card H
 4. \<And>c1 c2. \<lbrakk>finite (carrier G); subgroup H G; c1 \<in> lcosets H; c2 \<in> lcosets H; c1 \<noteq> c2\<rbrakk> \<Longrightarrow> c1 \<inter> c2 = {}
[PROOF STEP]
apply (simp add: lcosets_subset_PowG [THEN finite_subset])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<lbrakk>finite (carrier G); subgroup H G\<rbrakk> \<Longrightarrow> finite (\<Union> (lcosets H))
 2. \<And>c. \<lbrakk>finite (carrier G); subgroup H G; c \<in> lcosets H\<rbrakk> \<Longrightarrow> card c = card H
 3. \<And>c1 c2. \<lbrakk>finite (carrier G); subgroup H G; c1 \<in> lcosets H; c2 \<in> lcosets H; c1 \<noteq> c2\<rbrakk> \<Longrightarrow> c1 \<inter> c2 = {}
[PROOF STEP]
apply (simp add: lcosets_part_G)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>c. \<lbrakk>finite (carrier G); subgroup H G; c \<in> lcosets H\<rbrakk> \<Longrightarrow> card c = card H
 2. \<And>c1 c2. \<lbrakk>finite (carrier G); subgroup H G; c1 \<in> lcosets H; c2 \<in> lcosets H; c1 \<noteq> c2\<rbrakk> \<Longrightarrow> c1 \<inter> c2 = {}
[PROOF STEP]
apply (simp add: l_card_cosets_equal subgroup.subset)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>c1 c2. \<lbrakk>finite (carrier G); subgroup H G; c1 \<in> lcosets H; c2 \<in> lcosets H; c1 \<noteq> c2\<rbrakk> \<Longrightarrow> c1 \<inter> c2 = {}
[PROOF STEP]
apply (simp add: lcos_disjoint)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma liminf_subseq_mono:
  fixes X :: "nat \<Rightarrow> 'a :: complete_linorder"
  assumes "strict_mono r"
  shows "liminf X \<le> liminf (X \<circ> r) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. liminf X \<le> liminf (X \<circ> r)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. liminf X \<le> liminf (X \<circ> r)
[PROOF STEP]
have "\<And>n. (INF m\<in>{n..}. X m) \<le> (INF m\<in>{n..}. (X \<circ> r) m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. Inf (X ` {n..}) \<le> Inf ((X \<circ> r) ` {n..})
[PROOF STEP]
proof (safe intro!: INF_mono)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n m. n \<le> m \<Longrightarrow> \<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m
[PROOF STEP]
fix n m :: nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n m. n \<le> m \<Longrightarrow> \<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m
[PROOF STEP]
assume "n \<le> m"
[PROOF STATE]
proof (state)
this:
n \<le> m

goal (1 subgoal):
 1. \<And>n m. n \<le> m \<Longrightarrow> \<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<le> m
[PROOF STEP]
show "\<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m"
[PROOF STATE]
proof (prove)
using this:
n \<le> m

goal (1 subgoal):
 1. \<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m
[PROOF STEP]
using seq_suble[OF \<open>strict_mono r\<close>, of m]
[PROOF STATE]
proof (prove)
using this:
n \<le> m
m \<le> r m

goal (1 subgoal):
 1. \<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m
[PROOF STEP]
by (intro bexI[of _ "r m"]) auto
[PROOF STATE]
proof (state)
this:
\<exists>ma\<in>{n..}. X ma \<le> (X \<circ> r) m

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Inf (X ` {?n..}) \<le> Inf ((X \<circ> r) ` {?n..})

goal (1 subgoal):
 1. liminf X \<le> liminf (X \<circ> r)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Inf (X ` {?n..}) \<le> Inf ((X \<circ> r) ` {?n..})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Inf (X ` {?n..}) \<le> Inf ((X \<circ> r) ` {?n..})

goal (1 subgoal):
 1. liminf X \<le> liminf (X \<circ> r)
[PROOF STEP]
by (auto intro!: SUP_mono simp: liminf_SUP_INF comp_def)
[PROOF STATE]
proof (state)
this:
liminf X \<le> liminf (X \<circ> r)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sin_double: "sin(2 * x) = 2 * sin x * cos x"
  for x :: "'a::{real_normed_field,banach}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sin ((2::'a) * x) = (2::'a) * sin x * cos x
[PROOF STEP]
using sin_add [where x=x and y=x]
[PROOF STATE]
proof (prove)
using this:
sin (x + x) = sin x * cos x + cos x * sin x

goal (1 subgoal):
 1. sin ((2::'a) * x) = (2::'a) * sin x * cos x
[PROOF STEP]
by simp


[STATEMENT]
lemma exponential_order_add:
  assumes "exponential_order M a f" "exponential_order M a g"
  shows "exponential_order (2 * M) a (\<lambda>x. f x + g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. exponential_order (2 * M) a (\<lambda>x. f x + g x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
exponential_order M a f
exponential_order M a g

goal (1 subgoal):
 1. exponential_order (2 * M) a (\<lambda>x. f x + g x)
[PROOF STEP]
apply (auto simp: exponential_order_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>\<^sub>F t in at_top. norm (g t) \<le> M * exp (a * t); 0 < M; \<forall>\<^sub>F t in at_top. norm (f t) \<le> M * exp (a * t)\<rbrakk> \<Longrightarrow> \<forall>\<^sub>F t in at_top. norm (f t + g t) \<le> 2 * M * exp (a * t)
[PROOF STEP]
subgoal premises prems
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F t in at_top. norm (f t + g t) \<le> 2 * M * exp (a * t)
[PROOF STEP]
using prems(1,3)
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F t in at_top. norm (g t) \<le> M * exp (a * t)
\<forall>\<^sub>F t in at_top. norm (f t) \<le> M * exp (a * t)

goal (1 subgoal):
 1. \<forall>\<^sub>F t in at_top. norm (f t + g t) \<le> 2 * M * exp (a * t)
[PROOF STEP]
apply (eventually_elim)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>t. \<lbrakk>norm (g t) \<le> M * exp (a * t); norm (f t) \<le> M * exp (a * t)\<rbrakk> \<Longrightarrow> norm (f t + g t) \<le> 2 * M * exp (a * t)
[PROOF STEP]
apply (rule norm_triangle_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>t. \<lbrakk>norm (g t) \<le> M * exp (a * t); norm (f t) \<le> M * exp (a * t)\<rbrakk> \<Longrightarrow> norm (f t) + norm (g t) \<le> 2 * M * exp (a * t)
[PROOF STEP]
by linarith
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma contour_integrable_linepath_Reals_iff:
  fixes a b :: complex and f :: "complex \<Rightarrow> complex"
  assumes "a \<in> Reals" "b \<in> Reals" "Re a < Re b"
  shows   "(f contour_integrable_on linepath a b) \<longleftrightarrow>
             (\<lambda>x. f (of_real x)) integrable_on {Re a..Re b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f contour_integrable_on linepath a b) = ((\<lambda>x. f (complex_of_real x)) integrable_on {Re a..Re b})
[PROOF STEP]
using has_contour_integral_linepath_Reals_iff[OF assms, of f]
[PROOF STATE]
proof (prove)
using this:
(f has_contour_integral ?I) (linepath a b) = ((\<lambda>x. f (complex_of_real x)) has_integral ?I) {Re a..Re b}

goal (1 subgoal):
 1. (f contour_integrable_on linepath a b) = ((\<lambda>x. f (complex_of_real x)) integrable_on {Re a..Re b})
[PROOF STEP]
by (auto simp: contour_integrable_on_def integrable_on_def)


[STATEMENT]
lemma cos_plus_cos: "cos w + cos z = 2 * cos ((w + z) / 2) * cos ((w - z) / 2)"
  for w :: "'a::{real_normed_field,banach,field}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos w + cos z = (2::'a) * cos ((w + z) / (2::'a)) * cos ((w - z) / (2::'a))
[PROOF STEP]
apply (simp add: mult.assoc cos_times_cos)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos w * (2::'a) + cos z * (2::'a) = (2::'a) * cos ((w + z) / (2::'a) - (w - z) / (2::'a)) + (2::'a) * cos ((w + z) / (2::'a) + (w - z) / (2::'a))
[PROOF STEP]
apply (simp add: field_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma card_multiset_only_sets':
  assumes "finite A"
  shows "card {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = card A choose k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = card A choose k
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = card A choose k
[PROOF STEP]
from \<open>finite A\<close>
[PROOF STATE]
proof (chain)
picking this:
finite A
[PROOF STEP]
have "{M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} =
    {M. M \<subseteq># mset_set A \<and> size M = k}"
[PROOF STATE]
proof (prove)
using this:
finite A

goal (1 subgoal):
 1. {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = {M. M \<subseteq># mset_set A \<and> size M = k}
[PROOF STEP]
using msubset_mset_set_iff
[PROOF STATE]
proof (prove)
using this:
finite A
finite ?A \<Longrightarrow> (set_mset ?M \<subseteq> ?A \<and> (\<forall>x. count ?M x \<le> 1)) = (?M \<subseteq># mset_set ?A)

goal (1 subgoal):
 1. {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = {M. M \<subseteq># mset_set A \<and> size M = k}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = {M. M \<subseteq># mset_set A \<and> size M = k}

goal (1 subgoal):
 1. card {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = card A choose k
[PROOF STEP]
from this \<open>finite A\<close> card_multiset_only_sets
[PROOF STATE]
proof (chain)
picking this:
{M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = {M. M \<subseteq># mset_set A \<and> size M = k}
finite A
finite ?A \<Longrightarrow> card {M. M \<subseteq># mset_set ?A \<and> size M = ?k} = card ?A choose ?k
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = {M. M \<subseteq># mset_set A \<and> size M = k}
finite A
finite ?A \<Longrightarrow> card {M. M \<subseteq># mset_set ?A \<and> size M = ?k} = card ?A choose ?k

goal (1 subgoal):
 1. card {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = card A choose k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {M. set_mset M \<subseteq> A \<and> size M = k \<and> (\<forall>x. count M x \<le> 1)} = card A choose k

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma hermitian_square_hermitian:
fixes A::"'a::conjugatable_field Matrix.mat"
  assumes "hermitian A"
  shows "hermitian (A * A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hermitian (A * A)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. hermitian (A * A)
[PROOF STEP]
have "Complex_Matrix.adjoint (A * A) = Complex_Matrix.adjoint A * (Complex_Matrix.adjoint A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.adjoint (A * A) = Complex_Matrix.adjoint A * Complex_Matrix.adjoint A
[PROOF STEP]
using adjoint_mult
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<in> carrier_mat ?n ?m; ?B \<in> carrier_mat ?m ?l\<rbrakk> \<Longrightarrow> Complex_Matrix.adjoint (?A * ?B) = Complex_Matrix.adjoint ?B * Complex_Matrix.adjoint ?A

goal (1 subgoal):
 1. Complex_Matrix.adjoint (A * A) = Complex_Matrix.adjoint A * Complex_Matrix.adjoint A
[PROOF STEP]
by (metis assms hermitian_square)
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint (A * A) = Complex_Matrix.adjoint A * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. hermitian (A * A)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint (A * A) = Complex_Matrix.adjoint A * Complex_Matrix.adjoint A

goal (1 subgoal):
 1. hermitian (A * A)
[PROOF STEP]
have "... = A * A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.adjoint A * Complex_Matrix.adjoint A = A * A
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
hermitian A

goal (1 subgoal):
 1. Complex_Matrix.adjoint A * Complex_Matrix.adjoint A = A * A
[PROOF STEP]
unfolding hermitian_def
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.adjoint A = A

goal (1 subgoal):
 1. Complex_Matrix.adjoint A * Complex_Matrix.adjoint A = A * A
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Complex_Matrix.adjoint A * Complex_Matrix.adjoint A = A * A

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

goal (1 subgoal):
 1. hermitian (A * A)
[PROOF STEP]
unfolding hermitian_def
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.adjoint (A * A) = A * A

goal (1 subgoal):
 1. Complex_Matrix.adjoint (A * A) = A * A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
hermitian (A * A)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma independent_card_le_aff_dim:
  fixes B :: "'n::euclidean_space set"
  assumes "B \<subseteq> V"
  assumes "\<not> affine_dependent B"
  shows "int (card B) \<le> aff_dim V + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (card B) \<le> aff_dim V + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. int (card B) \<le> aff_dim V + 1
[PROOF STEP]
obtain T where T: "\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>T. \<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis assms extend_to_affine_basis[of B V])
[PROOF STATE]
proof (state)
this:
\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V

goal (1 subgoal):
 1. int (card B) \<le> aff_dim V + 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V
[PROOF STEP]
have "of_nat (card T) = aff_dim V + 1"
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V

goal (1 subgoal):
 1. int (card T) = aff_dim V + 1
[PROOF STEP]
using aff_dim_unique
[PROOF STATE]
proof (prove)
using this:
\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V
affine hull ?B = affine hull ?V \<and> \<not> affine_dependent ?B \<Longrightarrow> int (card ?B) = aff_dim ?V + 1

goal (1 subgoal):
 1. int (card T) = aff_dim V + 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
int (card T) = aff_dim V + 1

goal (1 subgoal):
 1. int (card B) \<le> aff_dim V + 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
int (card T) = aff_dim V + 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
int (card T) = aff_dim V + 1

goal (1 subgoal):
 1. int (card B) \<le> aff_dim V + 1
[PROOF STEP]
using T card_mono[of T B] aff_independent_finite[of T]
[PROOF STATE]
proof (prove)
using this:
int (card T) = aff_dim V + 1
\<not> affine_dependent T \<and> B \<subseteq> T \<and> T \<subseteq> V \<and> affine hull T = affine hull V
\<lbrakk>finite T; B \<subseteq> T\<rbrakk> \<Longrightarrow> card B \<le> card T
\<not> affine_dependent T \<Longrightarrow> finite T

goal (1 subgoal):
 1. int (card B) \<le> aff_dim V + 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
int (card B) \<le> aff_dim V + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_Un:
  "\<lbrakk> finite A; finite B \<rbrakk> \<Longrightarrow> card (A \<union> B) = card (A) + card (B) - card(A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; finite B\<rbrakk> \<Longrightarrow> card (A \<union> B) = card A + card B - card (A \<inter> B)
[PROOF STEP]
by(subst card_Un_Int) simp_all


[STATEMENT]
lemma poincare_distance_zero_x_axis:
  assumes "x \<in> unit_disc" and "x \<in> circline_set x_axis"
  shows "poincare_distance 0\<^sub>h x = (let x' = to_complex x in abs (ln (Re ((1 - x') / (1 + x')))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poincare_distance 0\<^sub>h x = (let x' = to_complex x in \<bar>ln (Re ((1 - x') / (1 + x')))\<bar>)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
x \<in> unit_disc
x \<in> circline_set x_axis

goal (1 subgoal):
 1. poincare_distance 0\<^sub>h x = (let x' = to_complex x in \<bar>ln (Re ((1 - x') / (1 + x')))\<bar>)
[PROOF STEP]
using poincare_distance_x_axis_x_axis[of "0\<^sub>h" x]
[PROOF STATE]
proof (prove)
using this:
x \<in> unit_disc
x \<in> circline_set x_axis
\<lbrakk>0\<^sub>h \<in> unit_disc; x \<in> unit_disc; 0\<^sub>h \<in> circline_set x_axis; x \<in> circline_set x_axis\<rbrakk> \<Longrightarrow> poincare_distance 0\<^sub>h x = (let x' = to_complex 0\<^sub>h; y' = to_complex x in \<bar>ln (Re ((1 + x') * (1 - y') / ((1 - x') * (1 + y'))))\<bar>)

goal (1 subgoal):
 1. poincare_distance 0\<^sub>h x = (let x' = to_complex x in \<bar>ln (Re ((1 - x') / (1 + x')))\<bar>)
[PROOF STEP]
by (simp add: Let_def)


[STATEMENT]
lemma (in group) inter_subgroup_dvd_card:
  assumes "subgroup H G" "subgroup J G"
  shows "card (H \<inter> J) dvd card H"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (H \<inter> J) dvd card H
[PROOF STEP]
using subgroups_Inter_pair[of H J] assms sub_subgroup_dvd_card[of H "H \<inter> J"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>subgroup H G; subgroup J G\<rbrakk> \<Longrightarrow> subgroup (H \<inter> J) G
subgroup H G
subgroup J G
\<lbrakk>subgroup H G; subgroup (H \<inter> J) G; H \<inter> J \<subseteq> H\<rbrakk> \<Longrightarrow> card (H \<inter> J) dvd card H

goal (1 subgoal):
 1. card (H \<inter> J) dvd card H
[PROOF STEP]
by blast


[STATEMENT]
lemma sum_dist:
  assumes "finite (A :: 'a::dioid_one_zero set)"
  and "finite B"
  shows "(\<Sum>A) \<cdot> (\<Sum>B) = \<Sum>{x \<cdot> y |x y. x \<in> A \<and> y \<in> B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}
[PROOF STEP]
have "(\<Sum>A) \<cdot> (\<Sum>B) = \<Sum>{x \<cdot> \<Sum>B |x. x \<in> A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> \<Sum> B |x. x \<in> A}
[PROOF STEP]
by (simp add: assms sum_distr)
[PROOF STATE]
proof (state)
this:
\<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> \<Sum> B |x. x \<in> A}

goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> \<Sum> B |x. x \<in> A}

goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}
[PROOF STEP]
have "... = \<Sum>{\<Sum>{x \<cdot> y |y. y \<in> B} |x. x \<in> A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum> {x \<cdot> \<Sum> B |x. x \<in> A} = \<Sum> {\<Sum> {x \<cdot> y |y. y \<in> B} |x. x \<in> A}
[PROOF STEP]
by (simp add: assms sum_distl)
[PROOF STATE]
proof (state)
this:
\<Sum> {x \<cdot> \<Sum> B |x. x \<in> A} = \<Sum> {\<Sum> {x \<cdot> y |y. y \<in> B} |x. x \<in> A}

goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<Sum> A \<cdot> \<Sum> B = \<Sum> {\<Sum> {x \<cdot> y |y. y \<in> B} |x. x \<in> A}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<Sum> A \<cdot> \<Sum> B = \<Sum> {\<Sum> {x \<cdot> y |y. y \<in> B} |x. x \<in> A}

goal (1 subgoal):
 1. \<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}
[PROOF STEP]
by  (simp only: sum_flatten1 assms finite_cartesian_product)
[PROOF STATE]
proof (state)
this:
\<Sum> A \<cdot> \<Sum> B = \<Sum> {x \<cdot> y |x y. x \<in> A \<and> y \<in> B}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma primorial'_conv_primorial:
  assumes "n > 0"
  shows   "primorial' n = primorial (nth_prime (n - 1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primorial' n = primorial (real (nth_prime (n - 1)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. primorial' n = primorial (real (nth_prime (n - 1)))
[PROOF STEP]
have "primorial (nth_prime (n - 1)) = (\<Prod>k<nat (int (n - 1) + 1). nth_prime k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. primorial (real (nth_prime (n - 1))) = prod nth_prime {..<nat (int (n - 1) + 1)}
[PROOF STEP]
by (simp add: primorial_conv_primorial' primorial'_def)
[PROOF STATE]
proof (state)
this:
primorial (real (nth_prime (n - 1))) = prod nth_prime {..<nat (int (n - 1) + 1)}

goal (1 subgoal):
 1. primorial' n = primorial (real (nth_prime (n - 1)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
primorial (real (nth_prime (n - 1))) = prod nth_prime {..<nat (int (n - 1) + 1)}

goal (1 subgoal):
 1. primorial' n = primorial (real (nth_prime (n - 1)))
[PROOF STEP]
have "nat (int (n - 1) + 1) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nat (int (n - 1) + 1) = n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. nat (int (n - 1) + 1) = n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nat (int (n - 1) + 1) = n

goal (1 subgoal):
 1. primorial' n = primorial (real (nth_prime (n - 1)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
primorial (real (nth_prime (n - 1))) = prod nth_prime {..<n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
primorial (real (nth_prime (n - 1))) = prod nth_prime {..<n}

goal (1 subgoal):
 1. primorial' n = primorial (real (nth_prime (n - 1)))
[PROOF STEP]
by (simp add: primorial'_def)
[PROOF STATE]
proof (state)
this:
primorial' n = primorial (real (nth_prime (n - 1)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix_mult_transpose_dot_row:
  shows "A ** transpose A = (\<chi> i j. inner (row i A) (row j A))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A ** Finite_Cartesian_Product.transpose A = (\<chi>i j. inner (row i A) (row j A))
[PROOF STEP]
by (simp add: matrix_matrix_mult_def vec_eq_iff transpose_def row_def inner_vec_def)


[STATEMENT]
lemma four_block_diag_adjoint:
  shows  "(Complex_Matrix.adjoint (four_block_diag A1 A2)) =
    (four_block_diag (Complex_Matrix.adjoint A1)
    (Complex_Matrix.adjoint A2))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.adjoint (four_block_diag A1 A2) = four_block_diag (Complex_Matrix.adjoint A1) (Complex_Matrix.adjoint A2)
[PROOF STEP]
by (rule eq_matI,
        auto simp: four_block_mat_adjoint zero_adjoint adjoint_eval)


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

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

goal (1 subgoal):
 1. closed (\<Union>x\<in>S. \<Union>y\<in>T. {x - y})
[PROOF STEP]
using closed_compact_sums[OF assms(1) compact_negations[OF assms(2)]]
[PROOF STATE]
proof (prove)
using this:
(\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y}) = {x - y |x y. x \<in> S \<and> y \<in> T}
closed (\<Union>x\<in>S. \<Union>y\<in>uminus ` T. {x + y})

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma matrix'_id_eq_matrix_change_of_basis:
  fixes X::"'a::{field}^'n^'n" and Y::"'a^'n^'n"
  assumes basis_X: "is_basis (set_of_vector X)" and basis_Y: "is_basis (set_of_vector Y)"
  shows "matrix' X Y (id) = matrix_change_of_basis X Y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. matrix' X Y id = matrix_change_of_basis X Y
[PROOF STEP]
unfolding matrix'_def matrix_change_of_basis_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. coord Y (id (X $ j)) $ i) = (\<chi>i j. coord Y (X $ j) $ i)
[PROOF STEP]
unfolding id_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<chi>i j. coord Y (X $ j) $ i) = (\<chi>i j. coord Y (X $ j) $ i)
[PROOF STEP]
..


[STATEMENT]
lemma ceiling_diff_floor_le_1: "\<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
have "of_int \<lceil>x\<rceil> - 1 < x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_int \<lceil>x\<rceil> - (1::'a) < x
[PROOF STEP]
using ceiling_correct[of x]
[PROOF STATE]
proof (prove)
using this:
of_int \<lceil>x\<rceil> - (1::'a) < x \<and> x \<le> of_int \<lceil>x\<rceil>

goal (1 subgoal):
 1. of_int \<lceil>x\<rceil> - (1::'a) < x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_int \<lceil>x\<rceil> - (1::'a) < x

goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
of_int \<lceil>x\<rceil> - (1::'a) < x

goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
have "x < of_int \<lfloor>x\<rfloor> + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < of_int \<lfloor>x\<rfloor> + (1::'a)
[PROOF STEP]
using floor_correct[of x]
[PROOF STATE]
proof (prove)
using this:
of_int \<lfloor>x\<rfloor> \<le> x \<and> x < of_int (\<lfloor>x\<rfloor> + 1)

goal (1 subgoal):
 1. x < of_int \<lfloor>x\<rfloor> + (1::'a)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
x < of_int \<lfloor>x\<rfloor> + (1::'a)

goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
of_int \<lceil>x\<rceil> - (1::'a) < of_int \<lfloor>x\<rfloor> + (1::'a)
[PROOF STEP]
have "of_int (\<lceil>x\<rceil> - \<lfloor>x\<rfloor>) < (of_int 2::'a)"
[PROOF STATE]
proof (prove)
using this:
of_int \<lceil>x\<rceil> - (1::'a) < of_int \<lfloor>x\<rfloor> + (1::'a)

goal (1 subgoal):
 1. of_int (\<lceil>x\<rceil> - \<lfloor>x\<rfloor>) < of_int 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
of_int (\<lceil>x\<rceil> - \<lfloor>x\<rfloor>) < of_int 2

goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
of_int (\<lceil>x\<rceil> - \<lfloor>x\<rfloor>) < of_int 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
of_int (\<lceil>x\<rceil> - \<lfloor>x\<rfloor>) < of_int 2

goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
unfolding of_int_less_iff
[PROOF STATE]
proof (prove)
using this:
\<lceil>x\<rceil> - \<lfloor>x\<rfloor> < 2

goal (1 subgoal):
 1. \<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<lceil>x\<rceil> - \<lfloor>x\<rfloor> \<le> 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma orthogonal_matrix_norm:
  fixes A::"real^'n^'n"
  assumes o: "orthogonal_matrix A"
  shows "norm (column i A) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
have "1 = (transpose A ** A) $ i $ i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = (Finite_Cartesian_Product.transpose A ** A) $ i $ i
[PROOF STEP]
using o
[PROOF STATE]
proof (prove)
using this:
orthogonal_matrix A

goal (1 subgoal):
 1. 1 = (Finite_Cartesian_Product.transpose A ** A) $ i $ i
[PROOF STEP]
unfolding orthogonal_matrix
[PROOF STATE]
proof (prove)
using this:
Finite_Cartesian_Product.transpose A ** A = mat 1

goal (1 subgoal):
 1. 1 = (Finite_Cartesian_Product.transpose A ** A) $ i $ i
[PROOF STEP]
by (simp add: mat_1_fun)
[PROOF STATE]
proof (state)
this:
1 = (Finite_Cartesian_Product.transpose A ** A) $ i $ i

goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 = (Finite_Cartesian_Product.transpose A ** A) $ i $ i

goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
have "... = (column i A) \<bullet> (column i A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Finite_Cartesian_Product.transpose A ** A) $ i $ i = column i A \<bullet> column i A
[PROOF STEP]
unfolding matrix_matrix_mult_inner_mult row_transpose
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. column i A \<bullet> column i A = column i A \<bullet> column i A
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(Finite_Cartesian_Product.transpose A ** A) $ i $ i = column i A \<bullet> column i A

goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
1 = column i A \<bullet> column i A
[PROOF STEP]
show "norm (column i A) = 1"
[PROOF STATE]
proof (prove)
using this:
1 = column i A \<bullet> column i A

goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
using norm_eq_1
[PROOF STATE]
proof (prove)
using this:
1 = column i A \<bullet> column i A
(norm ?x = 1) = (?x \<bullet> ?x = 1)

goal (1 subgoal):
 1. norm (column i A) = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
norm (column i A) = 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_le_card_Max: "\<lbrakk> finite A; A \<noteq> {} \<rbrakk> \<Longrightarrow> sum f A \<le> card A * Max (f ` A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite A; A \<noteq> {}\<rbrakk> \<Longrightarrow> sum f A \<le> card A * Max (f ` A)
[PROOF STEP]
proof(induction A rule: finite_ne_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x. sum f {x} \<le> card {x} * Max (f ` {x})
 2. \<And>x F. \<lbrakk>finite F; F \<noteq> {}; x \<notin> F; sum f F \<le> card F * Max (f ` F)\<rbrakk> \<Longrightarrow> sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)
[PROOF STEP]
case (singleton x)
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>x. sum f {x} \<le> card {x} * Max (f ` {x})
 2. \<And>x F. \<lbrakk>finite F; F \<noteq> {}; x \<notin> F; sum f F \<le> card F * Max (f ` F)\<rbrakk> \<Longrightarrow> sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {x} \<le> card {x} * Max (f ` {x})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum f {x} \<le> card {x} * Max (f ` {x})

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; F \<noteq> {}; x \<notin> F; sum f F \<le> card F * Max (f ` F)\<rbrakk> \<Longrightarrow> sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; F \<noteq> {}; x \<notin> F; sum f F \<le> card F * Max (f ` F)\<rbrakk> \<Longrightarrow> sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)
[PROOF STEP]
case (insert x F)
[PROOF STATE]
proof (state)
this:
finite F
F \<noteq> {}
x \<notin> F
sum f F \<le> card F * Max (f ` F)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; F \<noteq> {}; x \<notin> F; sum f F \<le> card F * Max (f ` F)\<rbrakk> \<Longrightarrow> sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite F
F \<noteq> {}
x \<notin> F
sum f F \<le> card F * Max (f ` F)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
finite F
F \<noteq> {}
x \<notin> F
sum f F \<le> card F * Max (f ` F)

goal (1 subgoal):
 1. sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)
[PROOF STEP]
by (auto simp: max_def order.trans[of "sum f F" "card F * Max (f ` F)"])
[PROOF STATE]
proof (state)
this:
sum f (insert x F) \<le> card (insert x F) * Max (f ` insert x F)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem (in state_space)
  shows "\<Gamma>\<turnstile> \<lbrace>True\<rbrace>
           \<acute>S :== 0;; \<acute>I :== 1;;
           WHILE \<acute>I \<noteq> n
           INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace>
           DO
             \<acute>S :== \<acute>S + \<acute>I;;
             \<acute>I :== \<acute>I + 1
           OD
          \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>
[PROOF STEP]
let ?sum = "\<lambda>k. SUMM j<k. j"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>
[PROOF STEP]
let ?inv = "\<lambda>s i. s = ?sum i"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>
[PROOF STEP]
proof vcg
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. True \<Longrightarrow> 0 = (SUMM j<1. j)
 2. \<And>I S. \<lbrakk>S = (SUMM j<I. j); I \<noteq> n\<rbrakk> \<Longrightarrow> S + I = (SUMM j<I + 1. j)
 3. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
show "?inv 0 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 = (SUMM j<1. j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 = (SUMM j<1. j)

goal (2 subgoals):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); I \<noteq> n\<rbrakk> \<Longrightarrow> S + I = (SUMM j<I + 1. j)
 2. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); I \<noteq> n\<rbrakk> \<Longrightarrow> S + I = (SUMM j<I + 1. j)
 2. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
fix i s
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); I \<noteq> n\<rbrakk> \<Longrightarrow> S + I = (SUMM j<I + 1. j)
 2. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
assume "?inv s i" "i \<noteq> n"
[PROOF STATE]
proof (state)
this:
s = (SUMM j<i. j)
i \<noteq> n

goal (2 subgoals):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); I \<noteq> n\<rbrakk> \<Longrightarrow> S + I = (SUMM j<I + 1. j)
 2. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
thus "?inv (s + i) (i + 1)"
[PROOF STATE]
proof (prove)
using this:
s = (SUMM j<i. j)
i \<noteq> n

goal (1 subgoal):
 1. s + i = (SUMM j<i + 1. j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
s + i = (SUMM j<i + 1. j)

goal (1 subgoal):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
fix i s
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
assume x: "?inv s i" "\<not> i \<noteq> n"
[PROOF STATE]
proof (state)
this:
s = (SUMM j<i. j)
\<not> i \<noteq> n

goal (1 subgoal):
 1. \<And>I S. \<lbrakk>S = (SUMM j<I. j); \<not> I \<noteq> n\<rbrakk> \<Longrightarrow> S = (SUMM j<n. j)
[PROOF STEP]
thus "s = ?sum n"
[PROOF STATE]
proof (prove)
using this:
s = (SUMM j<i. j)
\<not> i \<noteq> n

goal (1 subgoal):
 1. s = (SUMM j<n. j)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
s = (SUMM j<n. j)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<Gamma>\<turnstile> \<lbrace>True\<rbrace> \<acute>S :== 0;; \<acute>I :== 1;; WHILE \<acute>I \<noteq> n INV \<lbrace>\<acute>S = (SUMM j<\<acute>I. j)\<rbrace> DO \<acute>S :== \<acute>S + \<acute>I;; \<acute>I :== \<acute>I + 1 OD \<lbrace>\<acute>S = (SUMM j<n. j)\<rbrace>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex_sphere_params:
  assumes "x*x + y*y + z*z = 1"
  shows "\<exists> \<alpha> \<beta>. x = cos \<alpha> * cos \<beta> \<and> y = cos \<alpha> * sin \<beta> \<and> z = sin \<alpha> \<and> -pi / 2 \<le> \<alpha> \<and> \<alpha> \<le> pi / 2 \<and> -pi \<le> \<beta> \<and> \<beta> < pi"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>\<alpha> \<beta>. x = cos \<alpha> * cos \<beta> \<and> y = cos \<alpha> * sin \<beta> \<and> z = sin \<alpha> \<and> - pi / 2 \<le> \<alpha> \<and> \<alpha> \<le> pi / 2 \<and> - pi \<le> \<beta> \<and> \<beta> < pi
[PROOF STEP]
using assms arcsin_bounded[of z] sphere_bounds[of x y z]
[PROOF STATE]
proof (prove)
using this:
x * x + y * y + z * z = 1
\<lbrakk>- 1 \<le> z; z \<le> 1\<rbrakk> \<Longrightarrow> - (pi / 2) \<le> arcsin z \<and> arcsin z \<le> pi / 2
x * x + y * y + z * z = 1 \<Longrightarrow> - 1 \<le> x \<and> x \<le> 1
x * x + y * y + z * z = 1 \<Longrightarrow> - 1 \<le> y \<and> y \<le> 1
x * x + y * y + z * z = 1 \<Longrightarrow> - 1 \<le> z \<and> z \<le> 1

goal (1 subgoal):
 1. \<exists>\<alpha> \<beta>. x = cos \<alpha> * cos \<beta> \<and> y = cos \<alpha> * sin \<beta> \<and> z = sin \<alpha> \<and> - pi / 2 \<le> \<alpha> \<and> \<alpha> \<le> pi / 2 \<and> - pi \<le> \<beta> \<and> \<beta> < pi
[PROOF STEP]
by (rule_tac x="arcsin z" in exI, rule_tac x="atan2 y x" in exI) (simp add: sphere_params arcsin_bounded atan2_bounded)