[STATEMENT]
lemma (in cpx_sq_mat) make_pm_sum:
  assumes "A \<in> fc_mats"
  and "hermitian A"
  and "make_pm A = (p, M)"
shows "sum_mat (\<lambda>i.  (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..< p} = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have es: "char_poly A = (\<Prod> (e :: complex) \<leftarrow> (eigvals A). [:- e, 1:])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. char_poly A = (\<Prod>e\<leftarrow>eigvals A. [:- e, 1:])
[PROOF STEP]
using assms fc_mats_carrier eigvals_poly_length dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
?M \<in> carrier_mat ?n ?n \<Longrightarrow> char_poly ?M = (\<Prod>a\<leftarrow>eigvals ?M. [:- a, 1:]) \<and> length (eigvals ?M) = dim_row ?M
dimR = dimC

goal (1 subgoal):
 1. char_poly A = (\<Prod>e\<leftarrow>eigvals A. [:- e, 1:])
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
char_poly A = (\<Prod>e\<leftarrow>eigvals A. [:- e, 1:])

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
obtain B U Q where us: "unitary_schur_decomposition A (eigvals A) = (B,U,Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>B U Q. unitary_schur_decomposition A (eigvals A) = (B, U, Q) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases "unitary_schur_decomposition A (eigvals A)", auto)
[PROOF STATE]
proof (state)
this:
unitary_schur_decomposition A (eigvals A) = (B, U, Q)

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
unitary_schur_decomposition A (eigvals A) = (B, U, Q)
[PROOF STEP]
have "similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and>
    diag_mat B = (eigvals A)
    \<and> unitary U \<and> (\<forall>i < dimR. B$$(i, i) \<in> Reals)"
[PROOF STATE]
proof (prove)
using this:
unitary_schur_decomposition A (eigvals A) = (B, U, Q)

goal (1 subgoal):
 1. similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dimR. B $$ (i, i) \<in> \<real>)
[PROOF STEP]
using hermitian_eigenvalue_real assms fc_mats_carrier es dim_eq
[PROOF STATE]
proof (prove)
using this:
unitary_schur_decomposition A (eigvals A) = (B, U, Q)
\<lbrakk>?A \<in> carrier_mat ?n ?n; hermitian ?A; char_poly ?A = (\<Prod>e\<leftarrow>?es. [:- e, 1:]); unitary_schur_decomposition ?A ?es = (?B, ?P, ?Q)\<rbrakk> \<Longrightarrow> similar_mat_wit ?A ?B ?P (Complex_Matrix.adjoint ?P) \<and> diagonal_mat ?B \<and> diag_mat ?B = ?es \<and> Complex_Matrix.unitary ?P \<and> (\<forall>i<?n. ?B $$ (i, i) \<in> \<real>)
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
char_poly A = (\<Prod>e\<leftarrow>eigvals A. [:- e, 1:])
dimR = dimC

goal (1 subgoal):
 1. similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dimR. B $$ (i, i) \<in> \<real>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dimR. B $$ (i, i) \<in> \<real>)

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
hence A: "A = U * B * (Complex_Matrix.adjoint U)" and dB: "diagonal_mat B"
    and Bii: "\<And>i. i < dimR \<Longrightarrow> B$$(i, i) \<in> Reals"
    and dimB: "B \<in> carrier_mat dimR dimR" and dimP: "U \<in> carrier_mat dimR dimR" and
    dimaP: "Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR" and unit: "unitary U"
[PROOF STATE]
proof (prove)
using this:
similar_mat_wit A B U (Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dimR. B $$ (i, i) \<in> \<real>)

goal (1 subgoal):
 1. (A = U * B * Complex_Matrix.adjoint U &&& diagonal_mat B &&& (\<And>i. i < dimR \<Longrightarrow> B $$ (i, i) \<in> \<real>)) &&& (B \<in> carrier_mat dimR dimR &&& U \<in> carrier_mat dimR dimR) &&& Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR &&& Complex_Matrix.unitary U
[PROOF STEP]
unfolding similar_mat_wit_def Let_def
[PROOF STATE]
proof (prove)
using this:
({A, B, U, Complex_Matrix.adjoint U} \<subseteq> carrier_mat (dim_row A) (dim_row A) \<and> U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row A) \<and> Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row A) \<and> A = U * B * Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dimR. B $$ (i, i) \<in> \<real>)

goal (1 subgoal):
 1. (A = U * B * Complex_Matrix.adjoint U &&& diagonal_mat B &&& (\<And>i. i < dimR \<Longrightarrow> B $$ (i, i) \<in> \<real>)) &&& (B \<in> carrier_mat dimR dimR &&& U \<in> carrier_mat dimR dimR) &&& Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR &&& Complex_Matrix.unitary U
[PROOF STEP]
using assms fc_mats_carrier
[PROOF STATE]
proof (prove)
using this:
({A, B, U, Complex_Matrix.adjoint U} \<subseteq> carrier_mat (dim_row A) (dim_row A) \<and> U * Complex_Matrix.adjoint U = 1\<^sub>m (dim_row A) \<and> Complex_Matrix.adjoint U * U = 1\<^sub>m (dim_row A) \<and> A = U * B * Complex_Matrix.adjoint U) \<and> diagonal_mat B \<and> diag_mat B = eigvals A \<and> Complex_Matrix.unitary U \<and> (\<forall>i<dimR. B $$ (i, i) \<in> \<real>)
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC

goal (1 subgoal):
 1. (A = U * B * Complex_Matrix.adjoint U &&& diagonal_mat B &&& (\<And>i. i < dimR \<Longrightarrow> B $$ (i, i) \<in> \<real>)) &&& (B \<in> carrier_mat dimR dimR &&& U \<in> carrier_mat dimR dimR) &&& Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR &&& Complex_Matrix.unitary U
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A = U * B * Complex_Matrix.adjoint U
diagonal_mat B
?i2 < dimR \<Longrightarrow> B $$ (?i2, ?i2) \<in> \<real>
B \<in> carrier_mat dimR dimR
U \<in> carrier_mat dimR dimR
Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR
Complex_Matrix.unitary U

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
hence mpeq: "make_pm A = (dist_el_card B, mk_meas_outcome B U)"
[PROOF STATE]
proof (prove)
using this:
A = U * B * Complex_Matrix.adjoint U
diagonal_mat B
?i2 < dimR \<Longrightarrow> B $$ (?i2, ?i2) \<in> \<real>
B \<in> carrier_mat dimR dimR
U \<in> carrier_mat dimR dimR
Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR
Complex_Matrix.unitary U

goal (1 subgoal):
 1. make_pm A = (dist_el_card B, mk_meas_outcome B U)
[PROOF STEP]
using us Let_def
[PROOF STATE]
proof (prove)
using this:
A = U * B * Complex_Matrix.adjoint U
diagonal_mat B
?i2 < dimR \<Longrightarrow> B $$ (?i2, ?i2) \<in> \<real>
B \<in> carrier_mat dimR dimR
U \<in> carrier_mat dimR dimR
Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR
Complex_Matrix.unitary U
unitary_schur_decomposition A (eigvals A) = (B, U, Q)
Let ?s ?f \<equiv> ?f ?s

goal (1 subgoal):
 1. make_pm A = (dist_el_card B, mk_meas_outcome B U)
[PROOF STEP]
unfolding make_pm_def
[PROOF STATE]
proof (prove)
using this:
A = U * B * Complex_Matrix.adjoint U
diagonal_mat B
?i2 < dimR \<Longrightarrow> B $$ (?i2, ?i2) \<in> \<real>
B \<in> carrier_mat dimR dimR
U \<in> carrier_mat dimR dimR
Complex_Matrix.adjoint U \<in> carrier_mat dimR dimR
Complex_Matrix.unitary U
unitary_schur_decomposition A (eigvals A) = (B, U, Q)
Let ?s ?f \<equiv> ?f ?s

goal (1 subgoal):
 1. (let (B, U, uu_) = unitary_schur_decomposition A (eigvals A) in (dist_el_card B, mk_meas_outcome B U)) = (dist_el_card B, mk_meas_outcome B U)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
make_pm A = (dist_el_card B, mk_meas_outcome B U)

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
hence "p = dist_el_card B"
[PROOF STATE]
proof (prove)
using this:
make_pm A = (dist_el_card B, mk_meas_outcome B U)

goal (1 subgoal):
 1. p = dist_el_card B
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
make_pm A = (dist_el_card B, mk_meas_outcome B U)
A \<in> fc_mats
hermitian A
make_pm A = (p, M)

goal (1 subgoal):
 1. p = dist_el_card B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p = dist_el_card B

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "M = mk_meas_outcome B U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M = mk_meas_outcome B U
[PROOF STEP]
using assms mpeq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
make_pm A = (dist_el_card B, mk_meas_outcome B U)

goal (1 subgoal):
 1. M = mk_meas_outcome B U
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
M = mk_meas_outcome B U

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "sum_mat (\<lambda>i. meas_outcome_val (M i) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..< p} =
    sum_mat (\<lambda>j. Re (diag_idx_to_el B j)\<cdot>\<^sub>m project_vecs (\<lambda>i. zero_col U i)
    (diag_elem_indices (diag_idx_to_el B j) B)) {..<(dist_el_card B)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}
[PROOF STEP]
using \<open>p = dist_el_card B\<close>
    \<open>M = mk_meas_outcome B U\<close>
[PROOF STATE]
proof (prove)
using this:
p = dist_el_card B
M = mk_meas_outcome B U

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}
[PROOF STEP]
unfolding meas_outcome_val_def meas_outcome_prj_def
      mk_meas_outcome_def
[PROOF STATE]
proof (prove)
using this:
p = dist_el_card B
M = (\<lambda>i. (Re (diag_idx_to_el B i), project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B i) B)))

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (fst (M i)) \<cdot>\<^sub>m snd (M i)) {..<p} = local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = sum_mat
     (\<lambda>j. sum_mat (\<lambda>i. (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i))
    (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}
[PROOF STEP]
unfolding project_vecs_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}
[PROOF STEP]
proof (rule sum_mat_cong)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. finite {..<dist_el_card B}
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
 3. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
 4. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
show "finite {..<dist_el_card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {..<dist_el_card B}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {..<dist_el_card B}

goal (3 subgoals):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
 3. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
show "\<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow>
         complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m
         sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B)
         \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP project_vecs_def project_vecs_dim zero_col_dim
        dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B ?i2)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B ?i2) B) \<in> fc_mats

goal (2 subgoals):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
show "\<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow>
         sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP
      project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult sum_mat_carrier)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B ?i2)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B ?i2) B) \<in> fc_mats

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
show "\<And>j. j \<in> {..<dist_el_card B} \<Longrightarrow>
          (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m  sum_mat (\<lambda>i. rank_1_proj (zero_col U i))
        (diag_elem_indices (diag_idx_to_el B j) B) =
         sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i))
          (diag_elem_indices (diag_idx_to_el B j) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>j. j \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. j \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
fix j
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>j. j \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
assume "j \<in> {..<dist_el_card B}"
[PROOF STATE]
proof (state)
this:
j \<in> {..<dist_el_card B}

goal (1 subgoal):
 1. \<And>j. j \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
show " (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m sum_mat (\<lambda>i. rank_1_proj (zero_col U i))
         (diag_elem_indices (diag_idx_to_el B j) B) =
        sum_mat (\<lambda>i. (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i))
          (diag_elem_indices (diag_idx_to_el B j) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
proof (rule smult_sum_mat)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite (diag_elem_indices (diag_idx_to_el B j) B)
 2. \<And>i. i \<in> diag_elem_indices (diag_idx_to_el B j) B \<Longrightarrow> rank_1_proj (zero_col U i) \<in> fc_mats
[PROOF STEP]
show "finite (diag_elem_indices (diag_idx_to_el B j) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
using diag_elem_indices_finite[of _ B]
[PROOF STATE]
proof (prove)
using this:
finite (diag_elem_indices ?x B)

goal (1 subgoal):
 1. finite (diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (diag_elem_indices (diag_idx_to_el B j) B)

goal (1 subgoal):
 1. \<And>i. i \<in> diag_elem_indices (diag_idx_to_el B j) B \<Longrightarrow> rank_1_proj (zero_col U i) \<in> fc_mats
[PROOF STEP]
show "\<And>i. i \<in> diag_elem_indices (diag_idx_to_el B j) B \<Longrightarrow>
          rank_1_proj (zero_col U i) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> diag_elem_indices (diag_idx_to_el B j) B \<Longrightarrow> rank_1_proj (zero_col U i) \<in> fc_mats
[PROOF STEP]
using dim_eq
[PROOF STATE]
proof (prove)
using this:
dimR = dimC

goal (1 subgoal):
 1. \<And>i. i \<in> diag_elem_indices (diag_idx_to_el B j) B \<Longrightarrow> rank_1_proj (zero_col U i) \<in> fc_mats
[PROOF STEP]
by (metis dimP local.fc_mats_carrier rank_1_proj_carrier zero_col_dim)
[PROOF STATE]
proof (state)
this:
?i2 \<in> diag_elem_indices (diag_idx_to_el B j) B \<Longrightarrow> rank_1_proj (zero_col U ?i2) \<in> fc_mats

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?j2 \<in> {..<dist_el_card B} \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B ?j2)) \<cdot>\<^sub>m local.sum_mat (\<lambda>i. rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B ?j2) B) = local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B ?j2)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B ?j2) B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>j. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m project_vecs (zero_col U) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = sum_mat
     (\<lambda>j. sum_mat (\<lambda>ia. (diag_mat B ! ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
    (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}
[PROOF STEP]
proof (rule sum_mat_cong)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. finite {..<dist_el_card B}
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
 3. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
 4. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
show "finite {..<dist_el_card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {..<dist_el_card B}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {..<dist_el_card B}

goal (3 subgoals):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
 3. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
show "\<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow>
         sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP
      project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult sum_mat_carrier)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B ?i2)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B ?i2) B) \<in> fc_mats

goal (2 subgoals):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
show "\<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow>
         local.sum_mat (\<lambda>ia.  (diag_mat B ! ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP
      project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult sum_mat_carrier)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B ?i2) B) \<in> fc_mats

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
show "\<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow>
         sum_mat (\<lambda>ia. (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B) =
         sum_mat (\<lambda>ia. (diag_mat B ! ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
assume "i\<in> {..< dist_el_card B}"
[PROOF STATE]
proof (state)
this:
i \<in> {..<dist_el_card B}

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
show "sum_mat (\<lambda>ia. (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B) =
         sum_mat (\<lambda>ia. (diag_mat B ! ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia))
          (diag_elem_indices (diag_idx_to_el B i) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
proof (rule sum_mat_cong)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. finite (diag_elem_indices (diag_idx_to_el B i) B)
 2. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
 3. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
 4. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
show "finite (diag_elem_indices (diag_idx_to_el B i) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
using diag_elem_indices_finite[of _ B]
[PROOF STATE]
proof (prove)
using this:
finite (diag_elem_indices ?x B)

goal (1 subgoal):
 1. finite (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (diag_elem_indices (diag_idx_to_el B i) B)

goal (3 subgoals):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
 2. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
 3. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
show "\<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow>
          (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult)
[PROOF STATE]
proof (state)
this:
?ia2 \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ?ia2) \<in> fc_mats

goal (2 subgoals):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
 2. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
show "\<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow>
          (diag_mat B !ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult)
[PROOF STATE]
proof (state)
this:
?ia2 \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> diag_mat B ! ?ia2 \<cdot>\<^sub>m rank_1_proj (zero_col U ?ia2) \<in> fc_mats

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
show "\<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow>
          (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) =
          (diag_mat B ! ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
fix ia
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
assume ia: "ia \<in> diag_elem_indices (diag_idx_to_el B i) B"
[PROOF STATE]
proof (state)
this:
ia \<in> diag_elem_indices (diag_idx_to_el B i) B

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
hence "ia < dim_row B"
[PROOF STATE]
proof (prove)
using this:
ia \<in> diag_elem_indices (diag_idx_to_el B i) B

goal (1 subgoal):
 1. ia < dim_row B
[PROOF STEP]
using diag_elem_indices_elem[of ia _ B]
[PROOF STATE]
proof (prove)
using this:
ia \<in> diag_elem_indices (diag_idx_to_el B i) B
ia \<in> diag_elem_indices ?x B \<Longrightarrow> ia < dim_row B \<and> B $$ (ia, ia) = ?x

goal (1 subgoal):
 1. ia < dim_row B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ia < dim_row B

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
have "Re (diag_idx_to_el B i) = Re (B $$ (ia, ia))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Re (diag_idx_to_el B i) = Re (B $$ (ia, ia))
[PROOF STEP]
using diag_elem_indices_elem[of ia _ B] ia
[PROOF STATE]
proof (prove)
using this:
ia \<in> diag_elem_indices ?x B \<Longrightarrow> ia < dim_row B \<and> B $$ (ia, ia) = ?x
ia \<in> diag_elem_indices (diag_idx_to_el B i) B

goal (1 subgoal):
 1. Re (diag_idx_to_el B i) = Re (B $$ (ia, ia))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Re (diag_idx_to_el B i) = Re (B $$ (ia, ia))

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Re (diag_idx_to_el B i) = Re (B $$ (ia, ia))

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
have "... = B $$ (ia, ia)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real (Re (B $$ (ia, ia))) = B $$ (ia, ia)
[PROOF STEP]
using Bii
[PROOF STATE]
proof (prove)
using this:
?i2 < dimR \<Longrightarrow> B $$ (?i2, ?i2) \<in> \<real>

goal (1 subgoal):
 1. complex_of_real (Re (B $$ (ia, ia))) = B $$ (ia, ia)
[PROOF STEP]
using \<open>ia < dim_row B\<close> dimB of_real_Re
[PROOF STATE]
proof (prove)
using this:
?i2 < dimR \<Longrightarrow> B $$ (?i2, ?i2) \<in> \<real>
ia < dim_row B
B \<in> carrier_mat dimR dimR
?z \<in> \<real> \<Longrightarrow> complex_of_real (Re ?z) = ?z

goal (1 subgoal):
 1. complex_of_real (Re (B $$ (ia, ia))) = B $$ (ia, ia)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (B $$ (ia, ia))) = B $$ (ia, ia)

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (B $$ (ia, ia))) = B $$ (ia, ia)

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
have "... = diag_mat B ! ia"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B $$ (ia, ia) = diag_mat B ! ia
[PROOF STEP]
using \<open>ia < dim_row B\<close>
[PROOF STATE]
proof (prove)
using this:
ia < dim_row B

goal (1 subgoal):
 1. B $$ (ia, ia) = diag_mat B ! ia
[PROOF STEP]
unfolding diag_mat_def
[PROOF STATE]
proof (prove)
using this:
ia < dim_row B

goal (1 subgoal):
 1. B $$ (ia, ia) = map (\<lambda>i. B $$ (i, i)) [0..<dim_row B] ! ia
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
B $$ (ia, ia) = diag_mat B ! ia

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
complex_of_real (Re (diag_idx_to_el B i)) = diag_mat B ! ia
[PROOF STEP]
have "Re (diag_idx_to_el B i) = diag_mat B ! ia"
[PROOF STATE]
proof (prove)
using this:
complex_of_real (Re (diag_idx_to_el B i)) = diag_mat B ! ia

goal (1 subgoal):
 1. complex_of_real (Re (diag_idx_to_el B i)) = diag_mat B ! ia
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (diag_idx_to_el B i)) = diag_mat B ! ia

goal (1 subgoal):
 1. \<And>ia. ia \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
thus "(Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) =
            (diag_mat B ! ia) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)"
[PROOF STATE]
proof (prove)
using this:
complex_of_real (Re (diag_idx_to_el B i)) = diag_mat B ! ia

goal (1 subgoal):
 1. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia) = diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?ia2 \<in> diag_elem_indices (diag_idx_to_el B i) B \<Longrightarrow> complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ?ia2) = diag_mat B ! ?ia2 \<cdot>\<^sub>m rank_1_proj (zero_col U ?ia2)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B i)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B i) B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dist_el_card B} \<Longrightarrow> local.sum_mat (\<lambda>ia. complex_of_real (Re (diag_idx_to_el B ?i2)) \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B ?i2) B) = local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B ?i2) B)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>i. complex_of_real (Re (diag_idx_to_el B j)) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = sum_mat
    (\<lambda>i. (diag_mat B ! i) \<cdot>\<^sub>m rank_1_proj (zero_col U i))
    (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
unfolding project_vecs_def sum_mat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_with (+) (0\<^sub>m dimR dimC) (\<lambda>j. sum_with (+) (0\<^sub>m dimR dimC) (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = sum_with (+) (0\<^sub>m dimR dimC) (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B)
[PROOF STEP]
proof (rule disj_family_sum_with[symmetric])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<forall>j. diag_mat B ! j \<cdot>\<^sub>m rank_1_proj (zero_col U j) \<in> fc_mats
 2. finite {..<dist_el_card B}
 3. disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
 4. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> finite (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
show "finite {..<dist_el_card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {..<dist_el_card B}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {..<dist_el_card B}

goal (3 subgoals):
 1. \<forall>j. diag_mat B ! j \<cdot>\<^sub>m rank_1_proj (zero_col U j) \<in> fc_mats
 2. disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
 3. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> finite (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
show "\<forall>j. (diag_mat B ! j) \<cdot>\<^sub>m rank_1_proj (zero_col U j) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>j. diag_mat B ! j \<cdot>\<^sub>m rank_1_proj (zero_col U j) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP
      project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<forall>j. diag_mat B ! j \<cdot>\<^sub>m rank_1_proj (zero_col U j) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult)
[PROOF STATE]
proof (state)
this:
\<forall>j. diag_mat B ! j \<cdot>\<^sub>m rank_1_proj (zero_col U j) \<in> fc_mats

goal (2 subgoals):
 1. disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
 2. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> finite (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
show "\<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> finite (diag_elem_indices (diag_idx_to_el B i) B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dist_el_card B} \<Longrightarrow> finite (diag_elem_indices (diag_idx_to_el B i) B)
[PROOF STEP]
by (simp add: diag_elem_indices_finite)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dist_el_card B} \<Longrightarrow> finite (diag_elem_indices (diag_idx_to_el B ?i2) B)

goal (1 subgoal):
 1. disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
[PROOF STEP]
show "disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B)
      {..<dist_el_card B}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
[PROOF STEP]
using diag_elem_indices_disjoint[of B] dimB dim_eq
[PROOF STATE]
proof (prove)
using this:
B \<in> carrier_mat dimR dimC \<Longrightarrow> disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
B \<in> carrier_mat dimR dimR
dimR = dimC

goal (1 subgoal):
 1. disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
disjoint_family_on (\<lambda>n. diag_elem_indices (diag_idx_to_el B n) B) {..<dist_el_card B}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B)

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>j. local.sum_mat (\<lambda>ia. diag_mat B ! ia \<cdot>\<^sub>m rank_1_proj (zero_col U ia)) (diag_elem_indices (diag_idx_to_el B j) B)) {..<dist_el_card B} = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B)

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = sum_mat (\<lambda>i. (diag_mat B ! i) \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..< dimR}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..<dimR}
[PROOF STEP]
using diag_elem_indices_union[of B] dimB dim_eq
[PROOF STATE]
proof (prove)
using this:
B \<in> carrier_mat ?dimR ?dimC \<Longrightarrow> (\<Union>i<dist_el_card B. diag_elem_indices (diag_idx_to_el B i) B) = {..<?dimR}
B \<in> carrier_mat dimR dimR
dimR = dimC

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..<dimR}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..<dimR}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) (\<Union>j<dist_el_card B. diag_elem_indices (diag_idx_to_el B j) B) = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..<dimR}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = sum_mat (\<lambda>i. (diag_mat B ! i) \<cdot>\<^sub>mrank_1_proj (Matrix.col U i)) {..< dimR}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..<dimR} = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)) {..<dimR}
[PROOF STEP]
proof (rule sum_mat_cong, simp)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) = diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)
 2. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) \<in> fc_mats
 3. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i) \<in> fc_mats
[PROOF STEP]
show res: "\<And>i. i \<in> {..<dimR} \<Longrightarrow> (diag_mat B ! i) \<cdot>\<^sub>m rank_1_proj (zero_col U i) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP project_vecs_def project_vecs_dim zero_col_dim dim_eq
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR
dimR = dimC

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) \<in> fc_mats
[PROOF STEP]
by (metis (no_types, lifting) rank_1_proj_carrier cpx_sq_mat_smult)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dimR} \<Longrightarrow> diag_mat B ! ?i2 \<cdot>\<^sub>m rank_1_proj (zero_col U ?i2) \<in> fc_mats

goal (2 subgoals):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) = diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)
 2. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i) \<in> fc_mats
[PROOF STEP]
show "\<And>i. i \<in> {..<dimR} \<Longrightarrow> (diag_mat B ! i) \<cdot>\<^sub>m rank_1_proj (Matrix.col U i) \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i) \<in> fc_mats
[PROOF STEP]
using assms fc_mats_carrier dimP project_vecs_def  project_vecs_dim zero_col_dim
[PROOF STATE]
proof (prove)
using this:
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
fc_mats = carrier_mat dimR dimC
U \<in> carrier_mat dimR dimR
project_vecs ?f ?N = local.sum_mat (\<lambda>i. rank_1_proj (?f i)) ?N
\<forall>i\<in>?N. dim_vec (?f i) = dimR \<Longrightarrow> project_vecs ?f ?N \<in> fc_mats
?U \<in> fc_mats \<Longrightarrow> dim_vec (zero_col ?U ?i) = dimR

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i) \<in> fc_mats
[PROOF STEP]
by (metis res lessThan_iff zero_col_col)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dimR} \<Longrightarrow> diag_mat B ! ?i2 \<cdot>\<^sub>m rank_1_proj (Matrix.col U ?i2) \<in> fc_mats

goal (1 subgoal):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) = diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)
[PROOF STEP]
show "\<And>i. i \<in> {..<dimR} \<Longrightarrow> (diag_mat B ! i) \<cdot>\<^sub>m rank_1_proj (zero_col U i) =
      (diag_mat B ! i) \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>i. i \<in> {..<dimR} \<Longrightarrow> diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i) = diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)
[PROOF STEP]
by (simp add: zero_col_col)
[PROOF STATE]
proof (state)
this:
?i2 \<in> {..<dimR} \<Longrightarrow> diag_mat B ! ?i2 \<cdot>\<^sub>m rank_1_proj (zero_col U ?i2) = diag_mat B ! ?i2 \<cdot>\<^sub>m rank_1_proj (Matrix.col U ?i2)

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

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (zero_col U i)) {..<dimR} = local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)) {..<dimR}

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = U * B * Complex_Matrix.adjoint U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)) {..<dimR} = U * B * Complex_Matrix.adjoint U
[PROOF STEP]
proof (rule weighted_sum_rank_1_proj_unitary)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. U \<in> fc_mats
 2. B \<in> fc_mats
 3. diagonal_mat B
 4. Complex_Matrix.unitary U
[PROOF STEP]
show "diagonal_mat B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. diagonal_mat B
[PROOF STEP]
using dB
[PROOF STATE]
proof (prove)
using this:
diagonal_mat B

goal (1 subgoal):
 1. diagonal_mat B
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
diagonal_mat B

goal (3 subgoals):
 1. U \<in> fc_mats
 2. B \<in> fc_mats
 3. Complex_Matrix.unitary U
[PROOF STEP]
show "Complex_Matrix.unitary U"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex_Matrix.unitary U
[PROOF STEP]
using unit
[PROOF STATE]
proof (prove)
using this:
Complex_Matrix.unitary U

goal (1 subgoal):
 1. Complex_Matrix.unitary U
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
Complex_Matrix.unitary U

goal (2 subgoals):
 1. U \<in> fc_mats
 2. B \<in> fc_mats
[PROOF STEP]
show "U \<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U \<in> fc_mats
[PROOF STEP]
using fc_mats_carrier dim_eq dimP
[PROOF STATE]
proof (prove)
using this:
fc_mats = carrier_mat dimR dimC
dimR = dimC
U \<in> carrier_mat dimR dimR

goal (1 subgoal):
 1. U \<in> fc_mats
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
U \<in> fc_mats

goal (1 subgoal):
 1. B \<in> fc_mats
[PROOF STEP]
show "B\<in> fc_mats"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<in> fc_mats
[PROOF STEP]
using fc_mats_carrier dim_eq dimB
[PROOF STATE]
proof (prove)
using this:
fc_mats = carrier_mat dimR dimC
dimR = dimC
B \<in> carrier_mat dimR dimR

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

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

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. diag_mat B ! i \<cdot>\<^sub>m rank_1_proj (Matrix.col U i)) {..<dimR} = U * B * Complex_Matrix.adjoint U

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
have "... = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U * B * Complex_Matrix.adjoint U = A
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
A = U * B * Complex_Matrix.adjoint U

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

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A

goal (1 subgoal):
 1. local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
local.sum_mat (\<lambda>i. complex_of_real (meas_outcome_val (M i)) \<cdot>\<^sub>m meas_outcome_prj (M i)) {..<p} = A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lemma_2_6_21_a:
  "a r\<rightarrow> (b \<sqinter> c) = (a r\<rightarrow> b) \<sqinter> (a r\<rightarrow> c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a r\<rightarrow> b \<sqinter> c = (a r\<rightarrow> b) \<sqinter> (a r\<rightarrow> c)
[PROOF STEP]
by (rule pseudo_hoop_dual.lemma_2_6_20_a)


[STATEMENT]
lemma LIMSEQ_powrat_base:
  "\<lbrakk> X \<longlonglongrightarrow> a; a > 0 \<rbrakk> \<Longrightarrow> (\<lambda>n. (X n) pow\<^sub>\<rat> q) \<longlonglongrightarrow> a pow\<^sub>\<rat> q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>X \<longlonglongrightarrow> a; 0 < a\<rbrakk> \<Longrightarrow> (\<lambda>n. X n pow\<^sub>\<rat> q) \<longlonglongrightarrow> a pow\<^sub>\<rat> q
[PROOF STEP]
by (metis isCont_tendsto_compose [where g="\<lambda>x. x pow\<^sub>\<rat> q"] isCont_powrat)


[STATEMENT]
lemma meet_leftcomm: "x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)" if "x \<in> carrier L" "y \<in> carrier L" "z \<in> carrier L"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<sqinter> (y \<sqinter> z) = y \<sqinter> (x \<sqinter> z)
[PROOF STEP]
by (metis meet_assoc meet_comm that)


[STATEMENT]
lemma mat_col_first_last_append:
  assumes "dim_col A = m + n"
  shows "(mat_col_first A m) @\<^sub>c (mat_col_last A n) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mat_col_first A m @\<^sub>c mat_col_last A n = A
[PROOF STEP]
unfolding append_cols_def mat_col_first_def mat_col_last_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((mat_row_first A\<^sup>T m)\<^sup>T\<^sup>T @\<^sub>r (mat_row_last A\<^sup>T n)\<^sup>T\<^sup>T)\<^sup>T = A
[PROOF STEP]
using mat_row_first_last_append[of "A\<^sup>T"] assms
[PROOF STATE]
proof (prove)
using this:
dim_row A\<^sup>T = ?m + ?n \<Longrightarrow> mat_row_first A\<^sup>T ?m @\<^sub>r mat_row_last A\<^sup>T ?n = A\<^sup>T
dim_col A = m + n

goal (1 subgoal):
 1. ((mat_row_first A\<^sup>T m)\<^sup>T\<^sup>T @\<^sub>r (mat_row_last A\<^sup>T n)\<^sup>T\<^sup>T)\<^sup>T = A
[PROOF STEP]
by simp


[STATEMENT]
lemma fcard_single_1: "fcard {|x|} = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fcard {|x|} = 1
[PROOF STEP]
by (simp add: fcard_finsert)


[STATEMENT]
theorem unit_group_is_group: "group unit_group"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Group.group unit_group
[PROOF STEP]
by (rule groupI, auto simp add:unit_group_def)


[STATEMENT]
lemma alternating_list_split:
  "alternating_list (m+n) s t = alternating_list m s t @
    (if even m then alternating_list n s t else alternating_list n t s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. alternating_list (m + n) s t = alternating_list m s t @ (if even m then alternating_list n s t else alternating_list n t s)
[PROOF STEP]
using alternating_list_SucSuc_ConsCons[of _ s]
[PROOF STATE]
proof (prove)
using this:
alternating_list (Suc (Suc ?k)) s ?t = s # ?t # alternating_list ?k s ?t

goal (1 subgoal):
 1. alternating_list (m + n) s t = alternating_list m s t @ (if even m then alternating_list n s t else alternating_list n t s)
[PROOF STEP]
by    (induct n rule: nat_induct_step2) auto


[STATEMENT]
theorem to_contra_form': "Trueprop (\<not>A) \<equiv> (A \<Longrightarrow> False)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> A \<equiv> (A \<Longrightarrow> False)
[PROOF STEP]
by (rule equal_intr_rule) auto


[STATEMENT]
lemma integrable_on_all_intervals_integrable_bound:
  fixes f :: "'a::euclidean_space \<Rightarrow> 'b::banach"
  assumes intf: "\<And>a b. (\<lambda>x. if x \<in> S then f x else 0) integrable_on cbox a b"
    and normf: "\<And>x. x \<in> S \<Longrightarrow> norm(f x) \<le> g x" and g: "g integrable_on S"
  shows "f integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f integrable_on S
[PROOF STEP]
using integrable_on_all_intervals_UNIV [OF intf, of "(\<lambda>x. if x \<in> S then g x else 0)"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>x. norm (if x \<in> S then f x else (0::'b)) \<le> (if x \<in> S then g x else 0); (\<lambda>x. if x \<in> S then g x else 0) integrable_on UNIV\<rbrakk> \<Longrightarrow> (\<lambda>x. if x \<in> S then f x else (0::'b)) integrable_on UNIV

goal (1 subgoal):
 1. f integrable_on S
[PROOF STEP]
by (simp add: g integrable_restrict_UNIV normf)


[STATEMENT]
lemma bitlen_twopow_add_eq:
  "bitlen (2 ^ w + b) = w + 1" if "0 \<le> b" "b < 2 ^ w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bitlen (2 ^ w + b) = int (w + 1)
[PROOF STEP]
by (auto simp: that nat_add_distrib bitlen_le_iff_power bitlen_ge_iff_power intro!: antisym)


[STATEMENT]
lemma compow_similar_diag_mat_eq:
  assumes "invertible P"
      and "A = P\<^sup>-\<^sup>1 ** (diag_mat f) ** P"
    shows "((**) A ^^ n) (mat 1) = P\<^sup>-\<^sup>1 ** (diag_mat (\<lambda>i. f i^n)) ** P"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((**) A ^^ n) (mat (1::'a)) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P
[PROOF STEP]
proof(induct n, simp_all add: assms)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. ((**) (P\<^sup>-\<^sup>1 ** diag_mat f ** P) ^^ n) (mat (1::'a)) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P \<Longrightarrow> P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
fix n::nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. ((**) (P\<^sup>-\<^sup>1 ** diag_mat f ** P) ^^ n) (mat (1::'a)) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P \<Longrightarrow> P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
have "P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) =
  P\<^sup>-\<^sup>1 ** diag_mat f ** diag_mat (\<lambda>i. f i ^ n) ** P" (is "?lhs = _")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat f ** diag_mat (\<lambda>i. f i ^ n) ** P
[PROOF STEP]
by (metis (no_types, lifting) assms(1) invertibleD(2) matrix_mul_rid matrix_mul_assoc)
[PROOF STATE]
proof (state)
this:
P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat f ** diag_mat (\<lambda>i. f i ^ n) ** P

goal (1 subgoal):
 1. \<And>n. ((**) (P\<^sup>-\<^sup>1 ** diag_mat f ** P) ^^ n) (mat (1::'a)) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P \<Longrightarrow> P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat f ** diag_mat (\<lambda>i. f i ^ n) ** P

goal (1 subgoal):
 1. \<And>n. ((**) (P\<^sup>-\<^sup>1 ** diag_mat f ** P) ^^ n) (mat (1::'a)) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P \<Longrightarrow> P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
have "... = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P" (is "_ = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P\<^sup>-\<^sup>1 ** diag_mat f ** diag_mat (\<lambda>i. f i ^ n) ** P = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
by (metis (full_types) matrix_mul_assoc matrix_mul_diag_diag)
[PROOF STATE]
proof (state)
this:
P\<^sup>-\<^sup>1 ** diag_mat f ** diag_mat (\<lambda>i. f i ^ n) ** P = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P

goal (1 subgoal):
 1. \<And>n. ((**) (P\<^sup>-\<^sup>1 ** diag_mat f ** P) ^^ n) (mat (1::'a)) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P \<Longrightarrow> P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
show "?lhs = ?rhs"
[PROOF STATE]
proof (prove)
using this:
P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P

goal (1 subgoal):
 1. P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
P\<^sup>-\<^sup>1 ** diag_mat f ** P ** (P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i ^ n) ** P) = P\<^sup>-\<^sup>1 ** diag_mat (\<lambda>i. f i * f i ^ n) ** P

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma eventually_nonneg_mult' [eventually_nonzero_simps]:
  assumes "eventually_nonneg F (\<lambda>x. -f x)" "eventually_nonneg F (\<lambda>x. - g x)"
  shows   "eventually_nonneg F (\<lambda>x. f x * g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eventually_nonneg F (\<lambda>x. f x * g x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
eventually_nonneg F (\<lambda>x. - f x)
eventually_nonneg F (\<lambda>x. - g x)

goal (1 subgoal):
 1. eventually_nonneg F (\<lambda>x. f x * g x)
[PROOF STEP]
unfolding eventually_nonneg_def
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. (0::'b) \<le> - f x
\<forall>\<^sub>F x in F. (0::'b) \<le> - g x

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. (0::'b) \<le> f x * g x
[PROOF STEP]
by eventually_elim (auto intro: mult_nonpos_nonpos)


[STATEMENT]
lemma numeral_le_floor [simp]: "numeral v \<le> \<lfloor>x\<rfloor> \<longleftrightarrow> numeral v \<le> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (numeral v \<le> \<lfloor>x\<rfloor>) = (numeral v \<le> x)
[PROOF STEP]
by (simp add: le_floor_iff)


[STATEMENT]
lemma lincomb_in_cone:
  assumes "x = lincomb l W"
    and "finite W"
    and "\<forall>i \<in> W . l i \<ge> 0"
    and "W \<subseteq> carrier_vec n"
  shows "x \<in> cone W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> cone W
[PROOF STEP]
using cone_iff_finite_cone assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<subseteq> carrier_vec n; finite ?A\<rbrakk> \<Longrightarrow> cone ?A = finite_cone ?A
x = lincomb l W
finite W
\<forall>i\<in>W. (0::'a) \<le> l i
W \<subseteq> carrier_vec n

goal (1 subgoal):
 1. x \<in> cone W
[PROOF STEP]
unfolding finite_cone_def nonneg_lincomb_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?A \<subseteq> carrier_vec n; finite ?A\<rbrakk> \<Longrightarrow> cone ?A = {b. \<exists>c. lincomb c (if finite ?A then ?A else {}) = b \<and> c ` (if finite ?A then ?A else {}) \<subseteq> Collect ((\<le>) (0::'a))}
x = lincomb l W
finite W
\<forall>i\<in>W. (0::'a) \<le> l i
W \<subseteq> carrier_vec n

goal (1 subgoal):
 1. x \<in> cone W
[PROOF STEP]
by auto


[STATEMENT]
lemma fls_zero_eqI: "(\<And>n. f$$n = 0) \<Longrightarrow> f = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n. f $$ n = (0::'a)) \<Longrightarrow> f = 0
[PROOF STEP]
by (fastforce intro: fls_eqI)


[STATEMENT]
lemma dist_triangle_half_l: "dist x1 y < e / 2 \<Longrightarrow> dist x2 y < e / 2 \<Longrightarrow> dist x1 x2 < e"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>dist x1 y < e / 2; dist x2 y < e / 2\<rbrakk> \<Longrightarrow> dist x1 x2 < e
[PROOF STEP]
by (rule dist_triangle_lt [where z=y]) simp


[STATEMENT]
lemma sublist_rev_left: "sublist (rev xs) ys = sublist xs (rev ys)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sublist (rev xs) ys = sublist xs (rev ys)
[PROOF STEP]
by (subst sublist_rev [symmetric]) (simp only: rev_rev_ident)


[STATEMENT]
lemma mtx2_eq_iff: "(mtx
  ([a1, b1] #
   [c1, d1] # []) :: 2 sq_mtx) = mtx
  ([a2, b2] #
   [c2, d2] # []) \<longleftrightarrow> a1 = a2 \<and> b1 = b2 \<and> c1 = c2 \<and> d1 = d2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (mtx [[a1, b1], [c1, d1]] = mtx [[a2, b2], [c2, d2]]) = (a1 = a2 \<and> b1 = b2 \<and> c1 = c2 \<and> d1 = d2)
[PROOF STEP]
apply(simp add: sq_mtx_eq_iff, safe)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> a1 = a2
 2. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> b1 = b2
 3. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> c1 = c2
 4. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> d1 = d2
[PROOF STEP]
using exhaust_2
[PROOF STATE]
proof (prove)
using this:
?x = 1 \<or> ?x = 2

goal (4 subgoals):
 1. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> a1 = a2
 2. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> b1 = b2
 3. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> c1 = c2
 4. \<forall>i. (i = 2 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> d1 = d2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> c1 = c2))) \<and> (i \<noteq> 2 \<longrightarrow> i = 1 \<longrightarrow> (\<forall>j. (j = 2 \<longrightarrow> b1 = b2) \<and> (j \<noteq> 2 \<longrightarrow> j = 1 \<longrightarrow> a1 = a2))) \<Longrightarrow> d1 = d2
[PROOF STEP]
by force+


[STATEMENT]
lemma continuous_on_linepath' [continuous_intros]:
  assumes [continuous_intros]: "continuous_on A f" "continuous_on A g" "continuous_on A h"
  shows   "continuous_on A (\<lambda>x. linepath (f x) (g x) (h x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on A (\<lambda>x. linepath (f x) (g x) (h x))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_on A f
continuous_on A g
continuous_on A h

goal (1 subgoal):
 1. continuous_on A (\<lambda>x. linepath (f x) (g x) (h x))
[PROOF STEP]
unfolding linepath_def
[PROOF STATE]
proof (prove)
using this:
continuous_on A f
continuous_on A g
continuous_on A h

goal (1 subgoal):
 1. continuous_on A (\<lambda>x. (1 - h x) *\<^sub>R f x + h x *\<^sub>R g x)
[PROOF STEP]
by (auto intro!: continuous_intros)


[STATEMENT]
lemma [smt_arith_multiplication]:
  fixes A B :: real and p n :: int
  assumes "A \<le> B" "0 < n" "p > 0"
  shows "(A / n) * p \<le> (B / n) * p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A / real_of_int n * real_of_int p \<le> B / real_of_int n * real_of_int p
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A \<le> B
0 < n
0 < p

goal (1 subgoal):
 1. A / real_of_int n * real_of_int p \<le> B / real_of_int n * real_of_int p
[PROOF STEP]
by (auto simp: field_simps)


[STATEMENT]
lemma ennreal_mult_less_top:
  fixes a b :: ennreal
  shows "a * b < top \<longleftrightarrow> (a = 0 \<or> b = 0 \<or> (a < top \<and> b < top))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * b < top) = (a = 0 \<or> b = 0 \<or> a < top \<and> b < top)
[PROOF STEP]
by transfer (auto simp add: top_ereal_def)


[STATEMENT]
lemma row_swaprows:
  "l < n \<Longrightarrow> row (swaprows_mat n l l) l = unit_vec n l"
  "i \<noteq> k \<Longrightarrow> i \<noteq> l \<Longrightarrow> i < n \<Longrightarrow> row (swaprows_mat n k l) i = unit_vec n i"
  "k < n \<Longrightarrow> l < n \<Longrightarrow> row (swaprows_mat n k l) l = unit_vec n k"
  "k < n \<Longrightarrow> l < n \<Longrightarrow> row (swaprows_mat n k l) k = unit_vec n l"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((l < n \<Longrightarrow> row (swaprows_mat n l l) l = unit_vec n l) &&& (\<lbrakk>i \<noteq> k; i \<noteq> l; i < n\<rbrakk> \<Longrightarrow> row (swaprows_mat n k l) i = unit_vec n i)) &&& (\<lbrakk>k < n; l < n\<rbrakk> \<Longrightarrow> row (swaprows_mat n k l) l = unit_vec n k) &&& (\<lbrakk>k < n; l < n\<rbrakk> \<Longrightarrow> row (swaprows_mat n k l) k = unit_vec n l)
[PROOF STEP]
by (rule eq_vecI, auto)


[STATEMENT]
lemma topspace_subtopology [simp]: "topspace (subtopology U V) = topspace U \<inter> V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. topspace (subtopology U V) = topspace U \<inter> V
[PROOF STEP]
by (auto simp: topspace_def openin_subtopology)


[STATEMENT]
lemma rtos_hom7:"\<lbrakk>(0::nat) < r; (0::nat) < s; i \<le> (r * s - Suc 0);
                   i div s = r - Suc 0 \<rbrakk> \<Longrightarrow> Suc (rtos r s i) mod r = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i div s = r - Suc 0\<rbrakk> \<Longrightarrow> Suc (rtos r s i) mod r = 0
[PROOF STEP]
apply (frule rtos_hom0 [of "r" "s" "i"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < r; 0 < s; i \<le> r * s - Suc 0; i div s = r - Suc 0; i div s < r\<rbrakk> \<Longrightarrow> Suc (rtos r s i) mod r = 0
[PROOF STEP]
apply (simp add: rtos_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < s; i \<le> r * s - Suc 0; i div s = r - Suc 0; r - Suc 0 < r\<rbrakk> \<Longrightarrow> \<not> i < r * s \<longrightarrow> Suc (r * s) mod r = 0
[PROOF STEP]
apply (frule mult_less_mono2[of "0" "s" "r"],
        simp only:mult.commute,
        simp only:mult_0_right)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < s; i \<le> r * s - Suc 0; i div s = r - Suc 0; r - Suc 0 < r; 0 < r * s\<rbrakk> \<Longrightarrow> \<not> i < r * s \<longrightarrow> Suc (r * s) mod r = 0
[PROOF STEP]
apply (simp add: rfn_tool11 [of "r * s" "i"])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma take_bit_not_take_bit:
  \<open>take_bit n (NOT (take_bit n a)) = take_bit n (NOT a)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. take_bit n (NOT (take_bit n a)) = take_bit n (NOT a)
[PROOF STEP]
by (auto simp add: bit_eq_iff bit_take_bit_iff bit_not_iff)


[STATEMENT]
theorem ax4: "\<turnstile> \<box>[P \<longrightarrow> Q]_v \<longrightarrow> (\<box>[P]_v \<longrightarrow> \<box>[Q]_v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<turnstile> \<box>[P \<longrightarrow> Q]_v \<longrightarrow> \<box>[P]_v \<longrightarrow> \<box>[Q]_v
[PROOF STEP]
by (force simp: action_def)


[STATEMENT]
lemma COMB_init[simp]: "COMB_init h init =
                do {
                    (b::bool) \<leftarrow> (bernoulli_pmf 0.8);
                    (xs::bool list) \<leftarrow> Prob_Theory.bv (length init);
                    return_pmf (if b then Inl (xs, init) else Inr h)
                  }"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. COMB_init h init = bernoulli_pmf (8 / 10) \<bind> (\<lambda>b. bv (length init) \<bind> (\<lambda>xs. return_pmf (if b then Inl (xs, init) else Inr h)))
[PROOF STEP]
apply(simp add: bind_return_pmf COMB_init_def BIT_init_def rTS_def
              bind_assoc_pmf )
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sum_pmf (4 / 5) (map_pmf (\<lambda>l. (l, init)) (bv (length init))) (return_pmf h) = bernoulli_pmf (4 / 5) \<bind> (\<lambda>b. bv (length init) \<bind> (\<lambda>xs. return_pmf (if b then Inl (xs, init) else Inr h)))
[PROOF STEP]
unfolding map_pmf_def Sum_pmf_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli_pmf (4 / 5) \<bind> (\<lambda>b. if b then bv (length init) \<bind> (\<lambda>x. return_pmf (x, init)) \<bind> (\<lambda>x. return_pmf (Inl x)) else return_pmf h \<bind> (\<lambda>x. return_pmf (Inr x))) = bernoulli_pmf (4 / 5) \<bind> (\<lambda>b. bv (length init) \<bind> (\<lambda>xs. return_pmf (if b then Inl (xs, init) else Inr h)))
[PROOF STEP]
apply(simp add: if_distrib bind_return_pmf bind_assoc_pmf )
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bernoulli_pmf (4 / 5) \<bind> (\<lambda>b. if b then bv (length init) \<bind> (\<lambda>x. return_pmf (x, init)) \<bind> (\<lambda>x. return_pmf (Inl x)) else return_pmf h \<bind> (\<lambda>x. return_pmf (Inr x))) = bernoulli_pmf (4 / 5) \<bind> (\<lambda>b. bv (length init) \<bind> (\<lambda>xs. if b then return_pmf (Inl (xs, init)) else return_pmf (Inr h)))
[PROOF STEP]
apply(rule bind_pmf_cong)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. bernoulli_pmf (4 / 5) = bernoulli_pmf (4 / 5)
 2. \<And>x. x \<in> set_pmf (bernoulli_pmf (4 / 5)) \<Longrightarrow> (if x then bv (length init) \<bind> (\<lambda>x. return_pmf (x, init)) \<bind> (\<lambda>x. return_pmf (Inl x)) else return_pmf h \<bind> (\<lambda>x. return_pmf (Inr x))) = bv (length init) \<bind> (\<lambda>xs. if x then return_pmf (Inl (xs, init)) else return_pmf (Inr h))
[PROOF STEP]
by(auto simp add: bind_return_pmf bind_assoc_pmf)


[STATEMENT]
lemma f_Exec_Stream_Init_nth_Suc_calc: "
  n < length xs \<Longrightarrow>
  f_Exec_Comp_Stream_Init trans_fun xs c ! Suc n =
  trans_fun (xs ! n) (f_Exec_Comp_Stream_Init trans_fun xs c ! n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < length xs \<Longrightarrow> f_Exec_Comp_Stream_Init trans_fun xs c ! Suc n = trans_fun (xs ! n) (f_Exec_Comp_Stream_Init trans_fun xs c ! n)
[PROOF STEP]
by (simp add: f_Exec_Stream_Init_eq_f_Exec_Stream_Cons f_Exec_Stream_nth nth_Cons' length_greater_0_conv[THEN iffD1, OF gr_implies_gr0] take_Suc_conv_app_nth f_Exec_append)


[STATEMENT]
lemma bounded_subset_ballI: "S \<subseteq> ball x r \<Longrightarrow> bounded S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S \<subseteq> ball x r \<Longrightarrow> bounded S
[PROOF STEP]
by (meson bounded_ball bounded_subset)


[STATEMENT]
lemma continuous_on_topological:
  "continuous_on s f \<longleftrightarrow>
    (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on s f = (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))
[PROOF STEP]
unfolding continuous_on_def tendsto_def eventually_at_topological
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>s. \<forall>S. open S \<longrightarrow> f x \<in> S \<longrightarrow> (\<exists>Sa. open Sa \<and> x \<in> Sa \<and> (\<forall>xa\<in>Sa. xa \<noteq> x \<longrightarrow> xa \<in> s \<longrightarrow> f xa \<in> S))) = (\<forall>x\<in>s. \<forall>B. open B \<longrightarrow> f x \<in> B \<longrightarrow> (\<exists>A. open A \<and> x \<in> A \<and> (\<forall>y\<in>s. y \<in> A \<longrightarrow> f y \<in> B)))
[PROOF STEP]
by metis


[STATEMENT]
lemma DIM_prod[simp]: "DIM('a \<times> 'b) = DIM('a) + DIM('b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. DIM('a \<times> 'b) = DIM('a) + DIM('b)
[PROOF STEP]
unfolding Basis_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((\<lambda>u. (u, 0::'b)) ` Basis \<union> Pair (0::'a) ` Basis) = DIM('a) + DIM('b)
[PROOF STEP]
by (subst card_Un_disjoint) (auto intro!: card_image arg_cong2[where f="(+)"] inj_onI)


[STATEMENT]
lemma ivl_integral_unique: "(f has_ivl_integral y) a b \<Longrightarrow> ivl_integral a b f = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_ivl_integral y) a b \<Longrightarrow> ivl_integral a b f = y
[PROOF STEP]
using integral_unique[of f y "{a .. b}"] integral_unique[of f "- y" "{b .. a}"]
[PROOF STATE]
proof (prove)
using this:
(f has_integral y) {a..b} \<Longrightarrow> integral {a..b} f = y
(f has_integral - y) {b..a} \<Longrightarrow> integral {b..a} f = - y

goal (1 subgoal):
 1. (f has_ivl_integral y) a b \<Longrightarrow> ivl_integral a b f = y
[PROOF STEP]
unfolding ivl_integral_def has_ivl_integral_def
[PROOF STATE]
proof (prove)
using this:
(f has_integral y) {a..b} \<Longrightarrow> integral {a..b} f = y
(f has_integral - y) {b..a} \<Longrightarrow> integral {b..a} f = - y

goal (1 subgoal):
 1. if a \<le> b then (f has_integral y) {a..b} else (f has_integral - y) {b..a} \<Longrightarrow> integral {a..b} f - integral {b..a} f = y
[PROOF STEP]
by (auto split: if_split_asm)


[STATEMENT]
lemma ipoly_add_rat: "ipoly (poly_add_rat r p) x = (of_int (snd (quotient_of r)) ^ degree p) * ipoly p (x - of_rat r)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
obtain n d where quot: "quotient_of r = (n,d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>n d. quotient_of r = (n, d) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
quotient_of r = (n, d)

goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
from quotient_of_div[OF quot]
[PROOF STATE]
proof (chain)
picking this:
r = rat_of_int n / rat_of_int d
[PROOF STEP]
have r: "r = of_int n / of_int d"
[PROOF STATE]
proof (prove)
using this:
r = rat_of_int n / rat_of_int d

goal (1 subgoal):
 1. r = rat_of_int n / rat_of_int d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r = rat_of_int n / rat_of_int d

goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
from quotient_of_denom_pos[OF quot]
[PROOF STATE]
proof (chain)
picking this:
0 < d
[PROOF STEP]
have d: "d \<noteq> 0" "d > 0"
[PROOF STATE]
proof (prove)
using this:
0 < d

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

goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
have id: "ipoly [:- n, 1:] (x / of_int d :: 'a) = - of_int n + x / of_int d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ipoly [:- n, 1:] (x / of_int d) = - of_int n + x / of_int d
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
ipoly [:- n, 1:] (x / of_int d) = - of_int n + x / of_int d

goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
unfolding poly_add_rat_def quot split
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ipoly (poly_mult_rat_main d 1 p \<circ>\<^sub>p [:- n, d:]) x = of_int (snd (n, d)) ^ degree p * ipoly p (x - of_rat r)
[PROOF STEP]
by (simp add: ipoly_mult_rat_main ipoly_poly_compose d r degree_poly_mult_rat_main field_simps id of_rat_divide)
[PROOF STATE]
proof (state)
this:
ipoly (poly_add_rat r p) x = of_int (snd (quotient_of r)) ^ degree p * ipoly p (x - of_rat r)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cmod_square:
  shows "(cmod z)\<^sup>2 = Re (z * cnj z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod z)\<^sup>2 = Re (z * cnj z)
[PROOF STEP]
using complex_mult_cnj_cmod[of z]
[PROOF STATE]
proof (prove)
using this:
z * cnj z = cor ((cmod z)\<^sup>2)

goal (1 subgoal):
 1. (cmod z)\<^sup>2 = Re (z * cnj z)
[PROOF STEP]
by (simp add: power2_eq_square)


[STATEMENT]
lemma ennexp_0 [simp]:
  "ennexp 0 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ennexp 0 = 1
[PROOF STEP]
by (auto simp add: zero_ereal_def one_ennreal_def)


[STATEMENT]
lemma Frct_pow: "Frct (a, numeral b) ^ c = Frct (a ^ c, numeral b ^ c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Frct (a, numeral b) ^ c = Frct (a ^ c, numeral b ^ c)
[PROOF STEP]
by (induction c) (simp_all add: rat_number_collapse)


[STATEMENT]
lemma Greatest_ex_le_nat: assumes "\<exists>k. P k \<and> (\<forall>k'. P k' \<longrightarrow> k' \<le> k)" shows "\<not>(\<exists>n'>Greatest P. P n')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (\<exists>n'>Greatest P. P n')
[PROOF STEP]
by (metis Greatest_equality assms less_le_not_le)


[STATEMENT]
lemma isCont_norm [simp]: "isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a"
  for f :: "'a::t2_space \<Rightarrow> 'b::real_normed_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isCont f a \<Longrightarrow> isCont (\<lambda>x. norm (f x)) a
[PROOF STEP]
by (fact continuous_norm)


[STATEMENT]
lemma lemma_2_7_23: "(a r\<rightarrow> b) * (c r\<rightarrow> d) \<le> (a \<sqinter> c) r\<rightarrow> (b \<sqinter> d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a r\<rightarrow> b) * (c r\<rightarrow> d) \<le> a \<sqinter> c r\<rightarrow> b \<sqinter> d
[PROOF STEP]
apply (rule_tac y = "(c \<sqinter> a) r\<rightarrow> (d \<sqinter> b)" in order_trans)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (a r\<rightarrow> b) * (c r\<rightarrow> d) \<le> c \<sqinter> a r\<rightarrow> d \<sqinter> b
 2. c \<sqinter> a r\<rightarrow> d \<sqinter> b \<le> a \<sqinter> c r\<rightarrow> b \<sqinter> d
[PROOF STEP]
apply (rule pseudo_hoop_dual.lemma_2_7_22)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<sqinter> a r\<rightarrow> d \<sqinter> b \<le> a \<sqinter> c r\<rightarrow> b \<sqinter> d
[PROOF STEP]
by (simp add: inf_commute)


[STATEMENT]
lemma compact_rel_frontier_bounded:
  fixes S :: "'n::euclidean_space set"
  shows "bounded S \<Longrightarrow> compact(rel_frontier S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bounded S \<Longrightarrow> compact (rel_frontier S)
[PROOF STEP]
using bounded_rel_frontier closed_rel_frontier compact_eq_bounded_closed
[PROOF STATE]
proof (prove)
using this:
bounded ?S \<Longrightarrow> bounded (rel_frontier ?S)
closed (rel_frontier ?S)
compact ?S = (bounded ?S \<and> closed ?S)

goal (1 subgoal):
 1. bounded S \<Longrightarrow> compact (rel_frontier S)
[PROOF STEP]
by blast


[STATEMENT]
lemma unit_disc_fix_rotation [simp]:
  shows "unit_disc_fix (moebius_rotation \<phi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_disc_fix (moebius_rotation \<phi>)
[PROOF STEP]
unfolding moebius_rotation_def moebius_similarity_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. unit_disc_fix (mk_moebius (cis \<phi>) 0 0 1)
[PROOF STEP]
by (transfer, transfer, simp add: unitary11_gen_def mat_adj_def mat_cnj_def cis_mult)


[STATEMENT]
lemma starlike_imp_Borsukian:
  fixes S :: "'a::real_normed_vector set"
  shows "starlike S \<Longrightarrow> Borsukian S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. starlike S \<Longrightarrow> Borsukian S
[PROOF STEP]
by (simp add: contractible_imp_Borsukian starlike_imp_contractible)


[STATEMENT]
theorem TOTAL_subset_CONS: "TOTAL \<subset> CONS"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. TOTAL \<subset> CONS
[PROOF STEP]
using TOTAL_subseteq_CONS TOTAL_neq_CONS
[PROOF STATE]
proof (prove)
using this:
TOTAL \<subseteq> CONS
TOTAL \<noteq> CONS

goal (1 subgoal):
 1. TOTAL \<subset> CONS
[PROOF STEP]
by simp