[STATEMENT]
lemma wlp_soundness:
  "well_com S \<Longrightarrow>
    (\<And>P. (is_quantum_predicate P \<Longrightarrow>
      (\<forall>\<rho> \<in> density_states. trace (wlp S P * \<rho>) = trace (P * (denote S \<rho>)) + trace \<rho> - trace (denote S \<rho>))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. well_com S \<Longrightarrow> (\<And>P. is_quantum_predicate P \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>))
[PROOF STEP]
proof (induct S)
[PROOF STATE]
proof (state)
goal (5 subgoals):
 1. \<And>P. \<lbrakk>well_com SKIP; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp SKIP P * \<rho>) = trace (P * denote SKIP \<rho>) + trace \<rho> - trace (denote SKIP \<rho>)
 2. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 3. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 4. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 5. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
case SKIP
[PROOF STATE]
proof (state)
this:
well_com SKIP
is_quantum_predicate P

goal (5 subgoals):
 1. \<And>P. \<lbrakk>well_com SKIP; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp SKIP P * \<rho>) = trace (P * denote SKIP \<rho>) + trace \<rho> - trace (denote SKIP \<rho>)
 2. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 3. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 4. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 5. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
well_com SKIP
is_quantum_predicate P
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
well_com SKIP
is_quantum_predicate P

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp SKIP P * \<rho>) = trace (P * denote SKIP \<rho>) + trace \<rho> - trace (denote SKIP \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<rho>\<in>density_states. trace (wlp SKIP P * \<rho>) = trace (P * denote SKIP \<rho>) + trace \<rho> - trace (denote SKIP \<rho>)

goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
case (Utrans U)
[PROOF STATE]
proof (state)
this:
well_com (Utrans U)
is_quantum_predicate P

goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
well_com (Utrans U)
is_quantum_predicate P
[PROOF STEP]
have dU: "U \<in> carrier_mat d d" and u: "unitary U" and wc: "well_com (Utrans U)"
    and qp: "is_quantum_predicate P" and dP: "P \<in> carrier_mat d d"
[PROOF STATE]
proof (prove)
using this:
well_com (Utrans U)
is_quantum_predicate P

goal (1 subgoal):
 1. (U \<in> carrier_mat d d &&& unitary U) &&& well_com (Utrans U) &&& is_quantum_predicate P &&& P \<in> carrier_mat d d
[PROOF STEP]
using is_quantum_predicate_def
[PROOF STATE]
proof (prove)
using this:
well_com (Utrans U)
is_quantum_predicate P
is_quantum_predicate ?P = (?P \<in> carrier_mat d d \<and> positive ?P \<and> ?P \<le>\<^sub>L 1\<^sub>m d)

goal (1 subgoal):
 1. (U \<in> carrier_mat d d &&& unitary U) &&& well_com (Utrans U) &&& is_quantum_predicate P &&& P \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
U \<in> carrier_mat d d
unitary U
well_com (Utrans U)
is_quantum_predicate P
P \<in> carrier_mat d d

goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have qp': "is_quantum_predicate (wlp (Utrans U) P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_quantum_predicate (wlp (Utrans U) P)
[PROOF STEP]
using wlp_close[OF wc qp]
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (wlp (Utrans U) P)

goal (1 subgoal):
 1. is_quantum_predicate (wlp (Utrans U) P)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (wlp (Utrans U) P)

goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have eq1: "trace (adjoint U * P * U * \<rho>) = trace (P * (U * \<rho> * adjoint U))" if dr: "\<rho> \<in> carrier_mat d d" for \<rho>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint U * P * U * \<rho>) = trace (P * (U * \<rho> * adjoint U))
[PROOF STEP]
using dr dP
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> carrier_mat d d
P \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (adjoint U * P * U * \<rho>) = trace (P * (U * \<rho> * adjoint U))
[PROOF STEP]
apply (mat_assoc d)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. U \<in> carrier_mat d d
[PROOF STEP]
using wc
[PROOF STATE]
proof (prove)
using this:
well_com (Utrans U)

goal (1 subgoal):
 1. U \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> carrier_mat d d \<Longrightarrow> trace (adjoint U * P * U * ?\<rho>) = trace (P * (U * ?\<rho> * adjoint U))

goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have eq2: "trace (U * \<rho> * adjoint U) = trace \<rho>" if dr: "\<rho> \<in> carrier_mat d d" for \<rho>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (U * \<rho> * adjoint U) = trace \<rho>
[PROOF STEP]
using unitary_operator_keep_trace[OF adjoint_dim[OF dU] dr unitary_adjoint[OF dU u]] adjoint_adjoint[of U]
[PROOF STATE]
proof (prove)
using this:
trace \<rho> = trace (adjoint (adjoint U) * \<rho> * adjoint U)
adjoint (adjoint U) = U

goal (1 subgoal):
 1. trace (U * \<rho> * adjoint U) = trace \<rho>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> carrier_mat d d \<Longrightarrow> trace (U * ?\<rho> * adjoint U) = trace ?\<rho>

goal (4 subgoals):
 1. \<And>x P. \<lbrakk>well_com (Utrans x); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Utrans x) P * \<rho>) = trace (P * denote (Utrans x) \<rho>) + trace \<rho> - trace (denote (Utrans x) \<rho>)
 2. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 3. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 4. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp (Utrans U) P * \<rho>) = trace (P * denote (Utrans U) \<rho>) + trace \<rho> - trace (denote (Utrans U) \<rho>)
[PROOF STEP]
using qp' eq1 eq2 density_states_def
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (wlp (Utrans U) P)
?\<rho> \<in> carrier_mat d d \<Longrightarrow> trace (adjoint U * P * U * ?\<rho>) = trace (P * (U * ?\<rho> * adjoint U))
?\<rho> \<in> carrier_mat d d \<Longrightarrow> trace (U * ?\<rho> * adjoint U) = trace ?\<rho>
density_states = {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp (Utrans U) P * \<rho>) = trace (P * denote (Utrans U) \<rho>) + trace \<rho> - trace (denote (Utrans U) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<rho>\<in>density_states. trace (wlp (Utrans U) P * \<rho>) = trace (P * denote (Utrans U) \<rho>) + trace \<rho> - trace (denote (Utrans U) \<rho>)

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
case (Seq S1 S2)
[PROOF STATE]
proof (state)
this:
\<lbrakk>well_com S1; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 ?P * \<rho>) = trace (?P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)
\<lbrakk>well_com S2; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 ?P * \<rho>) = trace (?P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)
well_com (S1;; S2)
is_quantum_predicate P

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>well_com S1; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 ?P * \<rho>) = trace (?P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)
\<lbrakk>well_com S2; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 ?P * \<rho>) = trace (?P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)
well_com (S1;; S2)
is_quantum_predicate P
[PROOF STEP]
have qp: "is_quantum_predicate P" and wc1: "well_com S1" and wc2: "well_com S2"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>well_com S1; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 ?P * \<rho>) = trace (?P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)
\<lbrakk>well_com S2; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 ?P * \<rho>) = trace (?P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)
well_com (S1;; S2)
is_quantum_predicate P

goal (1 subgoal):
 1. is_quantum_predicate P &&& well_com S1 &&& well_com S2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate P
well_com S1
well_com S2

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_quantum_predicate P
well_com S1
well_com S2
[PROOF STEP]
have qp2: "is_quantum_predicate (wlp S2 P)"
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate P
well_com S1
well_com S2

goal (1 subgoal):
 1. is_quantum_predicate (wlp S2 P)
[PROOF STEP]
using wlp_close
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate P
well_com S1
well_com S2
\<lbrakk>well_com ?S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> is_quantum_predicate (wlp ?S ?P)

goal (1 subgoal):
 1. is_quantum_predicate (wlp S2 P)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (wlp S2 P)

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_quantum_predicate (wlp S2 P)
[PROOF STEP]
have qp1: "is_quantum_predicate (wlp S1 (wlp S2 P))"
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (wlp S2 P)

goal (1 subgoal):
 1. is_quantum_predicate (wlp S1 (wlp S2 P))
[PROOF STEP]
using wlp_close wc1
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (wlp S2 P)
\<lbrakk>well_com ?S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> is_quantum_predicate (wlp ?S ?P)
well_com S1

goal (1 subgoal):
 1. is_quantum_predicate (wlp S1 (wlp S2 P))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (wlp S1 (wlp S2 P))

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have eq1: "trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)"
    if ds: "\<rho> \<in> density_states" for \<rho>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)
[PROOF STEP]
using Seq(2) wc2 qp ds
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>well_com S2; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 ?P * \<rho>) = trace (?P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)
well_com S2
is_quantum_predicate P
\<rho> \<in> density_states

goal (1 subgoal):
 1. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S2 P * ?\<rho>) = trace (P * denote S2 ?\<rho>) + trace ?\<rho> - trace (denote S2 ?\<rho>)

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have eq2: "trace (wlp S1 (wlp S2 P) * \<rho>) = trace ((wlp S2 P) * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)"
    if ds: "\<rho> \<in> density_states" for \<rho>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (wlp S2 P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)
[PROOF STEP]
using Seq(1) wc1 qp2 ds
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>well_com S1; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 ?P * \<rho>) = trace (?P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)
well_com S1
is_quantum_predicate (wlp S2 P)
\<rho> \<in> density_states

goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (wlp S2 P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S1 (wlp S2 P) * ?\<rho>) = trace (wlp S2 P * denote S1 ?\<rho>) + trace ?\<rho> - trace (denote S1 ?\<rho>)

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have eq3: "trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * (denote S2 (denote S1 \<rho>))) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))"
    if ds: "\<rho> \<in> density_states" for \<rho>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
have "denote S1 \<rho> \<in> density_states"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. denote S1 \<rho> \<in> density_states
[PROOF STEP]
using ds denote_density_states wc1
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states
\<lbrakk>?\<rho> \<in> density_states; well_com ?S\<rbrakk> \<Longrightarrow> denote ?S ?\<rho> \<in> density_states
well_com S1

goal (1 subgoal):
 1. denote S1 \<rho> \<in> density_states
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
denote S1 \<rho> \<in> density_states

goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
denote S1 \<rho> \<in> density_states
[PROOF STEP]
have  "trace ((wlp S2 P) * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))"
[PROOF STATE]
proof (prove)
using this:
denote S1 \<rho> \<in> density_states

goal (1 subgoal):
 1. trace (wlp S2 P * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
using eq1
[PROOF STATE]
proof (prove)
using this:
denote S1 \<rho> \<in> density_states
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S2 P * ?\<rho>) = trace (P * denote S2 ?\<rho>) + trace ?\<rho> - trace (denote S2 ?\<rho>)

goal (1 subgoal):
 1. trace (wlp S2 P * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (wlp S2 P * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))

goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
trace (wlp S2 P * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
show "trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * (denote S2 (denote S1 \<rho>))) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))"
[PROOF STATE]
proof (prove)
using this:
trace (wlp S2 P * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))

goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
using eq2 ds
[PROOF STATE]
proof (prove)
using this:
trace (wlp S2 P * denote S1 \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace (denote S1 \<rho>) - trace (denote S2 (denote S1 \<rho>))
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S1 (wlp S2 P) * ?\<rho>) = trace (wlp S2 P * denote S1 ?\<rho>) + trace ?\<rho> - trace (denote S1 ?\<rho>)
\<rho> \<in> density_states

goal (1 subgoal):
 1. trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (wlp S1 (wlp S2 P) * \<rho>) = trace (P * denote S2 (denote S1 \<rho>)) + trace \<rho> - trace (denote S2 (denote S1 \<rho>))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S1 (wlp S2 P) * ?\<rho>) = trace (P * denote S2 (denote S1 ?\<rho>)) + trace ?\<rho> - trace (denote S2 (denote S1 ?\<rho>))

goal (3 subgoals):
 1. \<And>S1 S2 P. \<lbrakk>\<And>P. \<lbrakk>well_com S1; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S1 P * \<rho>) = trace (P * denote S1 \<rho>) + trace \<rho> - trace (denote S1 \<rho>); \<And>P. \<lbrakk>well_com S2; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S2 P * \<rho>) = trace (P * denote S2 \<rho>) + trace \<rho> - trace (denote S2 \<rho>); well_com (S1;; S2); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
 2. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 3. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S1 (wlp S2 P) * ?\<rho>) = trace (P * denote S2 (denote S1 ?\<rho>)) + trace ?\<rho> - trace (denote S2 (denote S1 ?\<rho>))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S1 (wlp S2 P) * ?\<rho>) = trace (P * denote S2 (denote S1 ?\<rho>)) + trace ?\<rho> - trace (denote S2 (denote S1 ?\<rho>))

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
[PROOF STEP]
using qp1
[PROOF STATE]
proof (prove)
using this:
?\<rho> \<in> density_states \<Longrightarrow> trace (wlp S1 (wlp S2 P) * ?\<rho>) = trace (P * denote S2 (denote S1 ?\<rho>)) + trace ?\<rho> - trace (denote S2 (denote S1 ?\<rho>))
is_quantum_predicate (wlp S1 (wlp S2 P))

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<rho>\<in>density_states. trace (wlp (S1;; S2) P * \<rho>) = trace (P * denote (S1;; S2) \<rho>) + trace \<rho> - trace (denote (S1;; S2) \<rho>)

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
case (Measure n M S)
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x3a \<in> set S; well_com ?x3a; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp ?x3a ?P * \<rho>) = trace (?P * denote ?x3a \<rho>) + trace \<rho> - trace (denote ?x3a \<rho>)
well_com (Measure n M S)
is_quantum_predicate P

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>?x3a \<in> set S; well_com ?x3a; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp ?x3a ?P * \<rho>) = trace (?P * denote ?x3a \<rho>) + trace \<rho> - trace (denote ?x3a \<rho>)
well_com (Measure n M S)
is_quantum_predicate P
[PROOF STEP]
have wc: "well_com (Measure n M S)"
    and wck: "k < n \<Longrightarrow> well_com (S!k)"
    and qpP: "is_quantum_predicate P"
    and dP: "P \<in> carrier_mat d d"
    and qpWk: "k < n \<Longrightarrow> is_quantum_predicate (wlp (S!k) P)"
    and dWk: "k < n \<Longrightarrow> (wlp (S!k) P) \<in> carrier_mat d d"
    and c: "k < n \<Longrightarrow> \<rho> \<in> density_states \<Longrightarrow> trace (wlp (S!k) P * \<rho>) = trace (P * denote (S!k) \<rho>) + trace \<rho> - trace (denote (S!k) \<rho>)"
    and m: "measurement d n M"
    and aMMkleq: "k < n \<Longrightarrow> adjoint (M k) * M k \<le>\<^sub>L 1\<^sub>m d"
    and dMk: "k < n \<Longrightarrow> M k \<in> carrier_mat d d"
    for k \<rho>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x3a \<in> set S; well_com ?x3a; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp ?x3a ?P * \<rho>) = trace (?P * denote ?x3a \<rho>) + trace \<rho> - trace (denote ?x3a \<rho>)
well_com (Measure n M S)
is_quantum_predicate P

goal (1 subgoal):
 1. ((well_com (Measure n M S) &&& (k < n \<Longrightarrow> well_com (S ! k))) &&& is_quantum_predicate P &&& P \<in> carrier_mat d d &&& (k < n \<Longrightarrow> is_quantum_predicate (wlp (S ! k) P))) &&& ((k < n \<Longrightarrow> wlp (S ! k) P \<in> carrier_mat d d) &&& (\<lbrakk>k < n; \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (wlp (S ! k) P * \<rho>) = trace (P * denote (S ! k) \<rho>) + trace \<rho> - trace (denote (S ! k) \<rho>))) &&& measurement d n M &&& (k < n \<Longrightarrow> adjoint (M k) * M k \<le>\<^sub>L 1\<^sub>m d) &&& (k < n \<Longrightarrow> M k \<in> carrier_mat d d)
[PROOF STEP]
using is_quantum_predicate_def measurement_def measure_well_com measurement_le_one_mat wlp_close
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x3a \<in> set S; well_com ?x3a; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp ?x3a ?P * \<rho>) = trace (?P * denote ?x3a \<rho>) + trace \<rho> - trace (denote ?x3a \<rho>)
well_com (Measure n M S)
is_quantum_predicate P
is_quantum_predicate ?P = (?P \<in> carrier_mat d d \<and> positive ?P \<and> ?P \<le>\<^sub>L 1\<^sub>m d)
measurement ?d ?n ?M = ((\<forall>j<?n. ?M j \<in> carrier_mat ?d ?d) \<and> matrix_sum ?d (\<lambda>j. adjoint (?M j) * ?M j) ?n = 1\<^sub>m ?d)
\<lbrakk>well_com (Measure ?n ?M ?S); ?k < ?n\<rbrakk> \<Longrightarrow> well_com (?S ! ?k)
\<lbrakk>measurement ?d ?n ?f; ?j < ?n\<rbrakk> \<Longrightarrow> adjoint (?f ?j) * ?f ?j \<le>\<^sub>L 1\<^sub>m ?d
\<lbrakk>well_com ?S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> is_quantum_predicate (wlp ?S ?P)

goal (1 subgoal):
 1. ((well_com (Measure n M S) &&& (k < n \<Longrightarrow> well_com (S ! k))) &&& is_quantum_predicate P &&& P \<in> carrier_mat d d &&& (k < n \<Longrightarrow> is_quantum_predicate (wlp (S ! k) P))) &&& ((k < n \<Longrightarrow> wlp (S ! k) P \<in> carrier_mat d d) &&& (\<lbrakk>k < n; \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (wlp (S ! k) P * \<rho>) = trace (P * denote (S ! k) \<rho>) + trace \<rho> - trace (denote (S ! k) \<rho>))) &&& measurement d n M &&& (k < n \<Longrightarrow> adjoint (M k) * M k \<le>\<^sub>L 1\<^sub>m d) &&& (k < n \<Longrightarrow> M k \<in> carrier_mat d d)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
well_com (Measure n M S)
?k < n \<Longrightarrow> well_com (S ! ?k)
is_quantum_predicate P
P \<in> carrier_mat d d
?k < n \<Longrightarrow> is_quantum_predicate (wlp (S ! ?k) P)
?k < n \<Longrightarrow> wlp (S ! ?k) P \<in> carrier_mat d d
\<lbrakk>?k < n; ?\<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (wlp (S ! ?k) P * ?\<rho>) = trace (P * denote (S ! ?k) ?\<rho>) + trace ?\<rho> - trace (denote (S ! ?k) ?\<rho>)
measurement d n M
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k \<le>\<^sub>L 1\<^sub>m d
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
well_com (Measure n M S)
?k < n \<Longrightarrow> well_com (S ! ?k)
is_quantum_predicate P
P \<in> carrier_mat d d
?k < n \<Longrightarrow> is_quantum_predicate (wlp (S ! ?k) P)
?k < n \<Longrightarrow> wlp (S ! ?k) P \<in> carrier_mat d d
\<lbrakk>?k < n; ?\<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (wlp (S ! ?k) P * ?\<rho>) = trace (P * denote (S ! ?k) ?\<rho>) + trace ?\<rho> - trace (denote (S ! ?k) ?\<rho>)
measurement d n M
?k < n \<Longrightarrow> adjoint (M ?k) * M ?k \<le>\<^sub>L 1\<^sub>m d
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
fix \<rho>
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
assume \<rho>: "\<rho> \<in> density_states"
[PROOF STATE]
proof (state)
this:
\<rho> \<in> density_states

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<rho> \<in> density_states
[PROOF STEP]
have dr: "\<rho> \<in> carrier_mat d d" and pdor: "partial_density_operator \<rho>"
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states

goal (1 subgoal):
 1. \<rho> \<in> carrier_mat d d &&& partial_density_operator \<rho>
[PROOF STEP]
using density_states_def
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states
density_states = {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. \<rho> \<in> carrier_mat d d &&& partial_density_operator \<rho>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have dsr: "k < n \<Longrightarrow> (M k) * \<rho> * adjoint (M k) \<in> density_states" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * \<rho> * adjoint (M k) \<in> density_states
[PROOF STEP]
unfolding density_states_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * \<rho> * adjoint (M k) \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
[PROOF STEP]
using dMk pdo_close_under_measurement[OF dMk dr pdor aMMkleq] dr
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
\<lbrakk>?k1 < n; ?k1 < n\<rbrakk> \<Longrightarrow> partial_density_operator (M ?k1 * \<rho> * adjoint (M ?k1))
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * \<rho> * adjoint (M k) \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> density_states

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> density_states
[PROOF STEP]
have leqk: "k < n \<Longrightarrow> trace (wlp (S!k) P * ((M k) * \<rho> * adjoint (M k))) =
      trace (P * (denote (S!k) ((M k) * \<rho> * adjoint (M k)))) +
      (trace ((M k) * \<rho> * adjoint (M k)) - trace (denote (S ! k) ((M k) * \<rho> * adjoint (M k))))" for k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> density_states

goal (1 subgoal):
 1. k < n \<Longrightarrow> trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k))) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> density_states
\<lbrakk>?k < n; ?\<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (wlp (S ! ?k) P * ?\<rho>) = trace (P * denote (S ! ?k) ?\<rho>) + trace ?\<rho> - trace (denote (S ! ?k) ?\<rho>)

goal (1 subgoal):
 1. k < n \<Longrightarrow> trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k))) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> trace (wlp (S ! ?k) P * (M ?k * \<rho> * adjoint (M ?k))) = trace (P * denote (S ! ?k) (M ?k * \<rho> * adjoint (M ?k))) + (trace (M ?k * \<rho> * adjoint (M ?k)) - trace (denote (S ! ?k) (M ?k * \<rho> * adjoint (M ?k))))

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "k < n \<Longrightarrow> M k * \<rho> * adjoint (M k) \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * \<rho> * adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
using dMk dr
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> M k * \<rho> * adjoint (M k) \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> carrier_mat d d
[PROOF STEP]
have dsMrk: "k < n \<Longrightarrow> matrix_sum d (\<lambda>k. (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k \<in> carrier_mat d d
[PROOF STEP]
using matrix_sum_dim[of k "\<lambda>k. (M k * \<rho> * adjoint (M k))" d]
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> carrier_mat d d
(\<And>ka. ka < k \<Longrightarrow> M ka * \<rho> * adjoint (M ka) \<in> carrier_mat d d) \<Longrightarrow> matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) ?k \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "k < n \<Longrightarrow> adjoint (M k) * (wlp (S!k) P) * M k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) * wlp (S ! k) P * M k \<in> carrier_mat d d
[PROOF STEP]
using dMk
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> M ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> adjoint (M k) * wlp (S ! k) P * M k \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> adjoint (M ?k) * wlp (S ! ?k) P * M ?k \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k < n \<Longrightarrow> adjoint (M ?k) * wlp (S ! ?k) P * M ?k \<in> carrier_mat d d
[PROOF STEP]
have dsMW: "k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k) k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> adjoint (M ?k) * wlp (S ! ?k) P * M ?k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k \<in> carrier_mat d d
[PROOF STEP]
using matrix_sum_dim[of k "\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k" d]
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> adjoint (M ?k) * wlp (S ! ?k) P * M ?k \<in> carrier_mat d d
(\<And>ka. ka < k \<Longrightarrow> adjoint (M ka) * wlp (S ! ka) P * M ka \<in> carrier_mat d d) \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) ?k \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have dSMrk: "k < n \<Longrightarrow> denote (S ! k) (M k * \<rho> * adjoint (M k)) \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> denote (S ! k) (M k * \<rho> * adjoint (M k)) \<in> carrier_mat d d
[PROOF STEP]
using denote_dim[OF wck, of k "M k * \<rho> * adjoint (M k)"] dsr density_states_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>k < n; M k * \<rho> * adjoint (M k) \<in> carrier_mat d d; partial_density_operator (M k * \<rho> * adjoint (M k))\<rbrakk> \<Longrightarrow> denote (S ! k) (M k * \<rho> * adjoint (M k)) \<in> carrier_mat d d
?k < n \<Longrightarrow> M ?k * \<rho> * adjoint (M ?k) \<in> density_states
density_states = {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. k < n \<Longrightarrow> denote (S ! k) (M k * \<rho> * adjoint (M k)) \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> denote (S ! ?k) (M ?k * \<rho> * adjoint (M ?k)) \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have dsSMrk: "k < n \<Longrightarrow> matrix_sum d (\<lambda>k. denote (S!k) (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d
[PROOF STEP]
using matrix_sum_dim[of k "\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))" d, OF dSMrk]
[PROOF STATE]
proof (prove)
using this:
(\<And>ka. ka < k \<Longrightarrow> ka < n) \<Longrightarrow> matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d

goal (1 subgoal):
 1. k < n \<Longrightarrow> matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
?k < n \<Longrightarrow> matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) ?k \<in> carrier_mat d d

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "k \<le> n \<Longrightarrow>
        trace (matrix_sum d (\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k) k * \<rho>)
       = trace (P * (denote (Measure k M S) \<rho>)) + (trace (matrix_sum d (\<lambda>k. (M k) * \<rho> * adjoint (M k)) k) - trace (denote (Measure k M S) \<rho>))" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (Measure k M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (denote (Measure k M S) \<rho>))
[PROOF STEP]
unfolding denote_measure_expand[OF _ wc]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
[PROOF STEP]
proof (induct k)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) 0 * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) 0) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0))
 2. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
0 \<le> n

goal (2 subgoals):
 1. 0 \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) 0 * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) 0) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0))
 2. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 \<le> n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 \<le> n

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) 0 * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) 0) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0))
[PROOF STEP]
unfolding matrix_sum.simps
[PROOF STATE]
proof (prove)
using this:
0 \<le> n

goal (1 subgoal):
 1. trace (0\<^sub>m d d * \<rho>) = trace (P * 0\<^sub>m d d) + (trace (0\<^sub>m d d) - trace (0\<^sub>m d d))
[PROOF STEP]
using dP dr
[PROOF STATE]
proof (prove)
using this:
0 \<le> n
P \<in> carrier_mat d d
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (0\<^sub>m d d * \<rho>) = trace (P * 0\<^sub>m d d) + (trace (0\<^sub>m d d) - trace (0\<^sub>m d d))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) 0 * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) 0) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) 0))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
Suc k \<le> n

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
Suc k \<le> n
[PROOF STEP]
have k: "k < n"
[PROOF STATE]
proof (prove)
using this:
k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
Suc k \<le> n

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

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
have eq1: "trace (matrix_sum d (\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k) (Suc k) * \<rho>)
        = trace (adjoint (M k) * (wlp (S!k) P) * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k) k * \<rho>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>)
[PROOF STEP]
unfolding matrix_sum.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace ((adjoint (M k) * wlp (S ! k) P * M k + matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k) * \<rho>) = trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>)
[PROOF STEP]
using dMk[OF k] dWk[OF k] dr dsMW[OF k]
[PROOF STATE]
proof (prove)
using this:
M k \<in> carrier_mat d d
wlp (S ! k) P \<in> carrier_mat d d
\<rho> \<in> carrier_mat d d
matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace ((adjoint (M k) * wlp (S ! k) P * M k + matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k) * \<rho>) = trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>)
[PROOF STEP]
by (mat_assoc d)
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
have "trace (adjoint (M k) * (wlp (S!k) P) * M k * \<rho>) = trace ((wlp (S!k) P) * (M k * \<rho> * adjoint (M k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k)))
[PROOF STEP]
using dMk[OF k] dWk[OF k] dr
[PROOF STATE]
proof (prove)
using this:
M k \<in> carrier_mat d d
wlp (S ! k) P \<in> carrier_mat d d
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k)))
[PROOF STEP]
by (mat_assoc d)
[PROOF STATE]
proof (state)
this:
trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k)))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k)))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
have "\<dots> = trace (P * (denote (S!k) ((M k) * \<rho> * adjoint (M k)))) +
        (trace ((M k) * \<rho> * adjoint (M k)) - trace (denote (S ! k) ((M k) * \<rho> * adjoint (M k))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k))) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))
[PROOF STEP]
using leqk k
[PROOF STATE]
proof (prove)
using this:
?k < n \<Longrightarrow> trace (wlp (S ! ?k) P * (M ?k * \<rho> * adjoint (M ?k))) = trace (P * denote (S ! ?k) (M ?k * \<rho> * adjoint (M ?k))) + (trace (M ?k * \<rho> * adjoint (M ?k)) - trace (denote (S ! ?k) (M ?k * \<rho> * adjoint (M ?k))))
k < n

goal (1 subgoal):
 1. trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k))) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (wlp (S ! k) P * (M k * \<rho> * adjoint (M k))) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))
[PROOF STEP]
have eq2: "trace (adjoint (M k) * (wlp (S!k) P) * M k * \<rho>) = trace (P * (denote (S!k) ((M k) * \<rho> * adjoint (M k)))) +
        (trace ((M k) * \<rho> * adjoint (M k)) - trace (denote (S ! k) ((M k) * \<rho> * adjoint (M k))))"
[PROOF STATE]
proof (prove)
using this:
trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))

goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + (trace (M k * \<rho> * adjoint (M k)) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k))))

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
have eq3: "trace (P * matrix_sum d (\<lambda>k. denote (S!k) (M k * \<rho> * adjoint (M k))) (Suc k))
        = trace (P * (denote (S!k) (M k * \<rho> * adjoint (M k)))) + trace (P * matrix_sum d (\<lambda>k. denote (S!k) (M k * \<rho> * adjoint (M k))) k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)
[PROOF STEP]
unfolding matrix_sum.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)
[PROOF STEP]
using dP dSMrk[OF k] dsSMrk[OF k]
[PROOF STATE]
proof (prove)
using this:
P \<in> carrier_mat d d
denote (S ! k) (M k * \<rho> * adjoint (M k)) \<in> carrier_mat d d
matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (P * (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)
[PROOF STEP]
by (mat_assoc d)
[PROOF STATE]
proof (state)
this:
trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
have eq4: "trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S!k) (M k * \<rho> * adjoint (M k))) k)
        = trace (denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (matrix_sum d (\<lambda>k. denote (S!k) (M k * \<rho> * adjoint (M k))) k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) = trace (denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)
[PROOF STEP]
using dSMrk[OF k] dsSMrk[OF k]
[PROOF STATE]
proof (prove)
using this:
denote (S ! k) (M k * \<rho> * adjoint (M k)) \<in> carrier_mat d d
matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) = trace (denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)
[PROOF STEP]
by (mat_assoc d)
[PROOF STATE]
proof (state)
this:
trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) = trace (denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)

goal (1 subgoal):
 1. \<And>k. \<lbrakk>k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)); Suc k \<le> n\<rbrakk> \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
apply (subst eq1)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
apply (subst eq3)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))
[PROOF STEP]
apply (simp del: less_eq_complex_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (M k * \<rho> * adjoint (M k) + matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
[PROOF STEP]
apply (subst trace_add_linear[of "M k * \<rho> * adjoint (M k)" d "matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. M k * \<rho> * adjoint (M k) \<in> carrier_mat d d
 2. matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k \<in> carrier_mat d d
 3. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (M k * \<rho> * adjoint (M k)) + trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
[PROOF STEP]
apply (simp add: dMk adjoint_dim[OF dMk] dr mult_carrier_mat[of _ d d _ d] k)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k \<in> carrier_mat d d
 2. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (M k * \<rho> * adjoint (M k)) + trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
[PROOF STEP]
apply (simp add: dsMrk k)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (M k * \<rho> * adjoint (M k)) + trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - trace (denote (S ! k) (M k * \<rho> * adjoint (M k)) + matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k))
[PROOF STEP]
apply (subst eq4)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (adjoint (M k) * wlp (S ! k) P * M k * \<rho>) + trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) k * \<rho>) = trace (P * denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k) + (trace (M k * \<rho> * adjoint (M k)) + trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) k) - (trace (denote (S ! k) (M k * \<rho> * adjoint (M k))) + trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) k)))
[PROOF STEP]
apply (insert eq2 Suc(1) k, fastforce)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) (Suc k) * \<rho>) = trace (P * matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) (Suc k)) - trace (matrix_sum d (\<lambda>k. denote (S ! k) (M k * \<rho> * adjoint (M k))) (Suc k)))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) ?k * \<rho>) = trace (P * denote (Measure ?k M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) ?k) - trace (denote (Measure ?k M S) \<rho>))

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) ?k * \<rho>) = trace (P * denote (Measure ?k M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) ?k) - trace (denote (Measure ?k M S) \<rho>))
[PROOF STEP]
have leq: "trace (matrix_sum d (\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k) n * \<rho>)
       = trace (P * denote (Measure n M S) \<rho>) +
          (trace (matrix_sum d (\<lambda>k. (M k) * \<rho> * adjoint (M k)) n) - trace (denote (Measure n M S) \<rho>))"
[PROOF STATE]
proof (prove)
using this:
?k \<le> n \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) ?k * \<rho>) = trace (P * denote (Measure ?k M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) ?k) - trace (denote (Measure ?k M S) \<rho>))

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) - trace (denote (Measure n M S) \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) - trace (denote (Measure n M S) \<rho>))

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "trace (matrix_sum d (\<lambda>k. (M k) * \<rho> * adjoint (M k)) n) = trace \<rho>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) = trace \<rho>
[PROOF STEP]
using trace_measurement m dr
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>measurement ?d ?n ?M; ?A \<in> carrier_mat ?d ?d\<rbrakk> \<Longrightarrow> trace (matrix_sum ?d (\<lambda>k. ?M k * ?A * adjoint (?M k)) ?n) = trace ?A
measurement d n M
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) = trace \<rho>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) = trace \<rho>

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
with leq
[PROOF STATE]
proof (chain)
picking this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) - trace (denote (Measure n M S) \<rho>))
trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) = trace \<rho>
[PROOF STEP]
have "trace (matrix_sum d (\<lambda>k. adjoint (M k) * (wlp (S!k) P) * M k) n * \<rho>)
       = trace (P * denote (Measure n M S) \<rho>) + (trace \<rho> - trace (denote (Measure n M S) \<rho>))"
[PROOF STATE]
proof (prove)
using this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) - trace (denote (Measure n M S) \<rho>))
trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) = trace \<rho>

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace \<rho> - trace (denote (Measure n M S) \<rho>))
[PROOF STEP]
unfolding denote_measure_def
[PROOF STATE]
proof (prove)
using this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) - trace (denote (Measure n M S) \<rho>))
trace (matrix_sum d (\<lambda>k. M k * \<rho> * adjoint (M k)) n) = trace \<rho>

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace \<rho> - trace (denote (Measure n M S) \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + (trace \<rho> - trace (denote (Measure n M S) \<rho>))

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * ?\<rho>2) = trace (P * denote (Measure n M S) ?\<rho>2) + (trace ?\<rho>2 - trace (denote (Measure n M S) ?\<rho>2))

goal (2 subgoals):
 1. \<And>x1 x2a x3 P. \<lbrakk>\<And>x3a P. \<lbrakk>x3a \<in> set x3; well_com x3a; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp x3a P * \<rho>) = trace (P * denote x3a \<rho>) + trace \<rho> - trace (denote x3a \<rho>); well_com (Measure x1 x2a x3); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (Measure x1 x2a x3) P * \<rho>) = trace (P * denote (Measure x1 x2a x3) \<rho>) + trace \<rho> - trace (denote (Measure x1 x2a x3) \<rho>)
 2. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * ?\<rho>2) = trace (P * denote (Measure n M S) ?\<rho>2) + (trace ?\<rho>2 - trace (denote (Measure n M S) ?\<rho>2))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * ?\<rho>2) = trace (P * denote (Measure n M S) ?\<rho>2) + (trace ?\<rho>2 - trace (denote (Measure n M S) ?\<rho>2))

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp (Measure n M S) P * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + trace \<rho> - trace (denote (Measure n M S) \<rho>)
[PROOF STEP]
unfolding wlp_measure_expand[OF wc]
[PROOF STATE]
proof (prove)
using this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * ?\<rho>2) = trace (P * denote (Measure n M S) ?\<rho>2) + (trace ?\<rho>2 - trace (denote (Measure n M S) ?\<rho>2))

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (matrix_sum d (\<lambda>k. adjoint (M k) * wlp (S ! k) P * M k) n * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + trace \<rho> - trace (denote (Measure n M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<rho>\<in>density_states. trace (wlp (Measure n M S) P * \<rho>) = trace (P * denote (Measure n M S) \<rho>) + trace \<rho> - trace (denote (Measure n M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
case (While M S)
[PROOF STATE]
proof (state)
this:
\<lbrakk>well_com S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S ?P * \<rho>) = trace (?P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>)
well_com (While M S)
is_quantum_predicate P

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>well_com S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S ?P * \<rho>) = trace (?P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>)
well_com (While M S)
is_quantum_predicate P
[PROOF STEP]
have qpP: "is_quantum_predicate P" and dP: "P \<in> carrier_mat d d"
    and wcS: "well_com S" and m: "measurement d 2 M" and wc: "well_com (While M S)"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>well_com S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S ?P * \<rho>) = trace (?P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>)
well_com (While M S)
is_quantum_predicate P

goal (1 subgoal):
 1. (is_quantum_predicate P &&& P \<in> carrier_mat d d) &&& well_com S &&& measurement d 2 M &&& well_com (While M S)
[PROOF STEP]
using is_quantum_predicate_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>well_com S; is_quantum_predicate ?P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S ?P * \<rho>) = trace (?P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>)
well_com (While M S)
is_quantum_predicate P
is_quantum_predicate ?P = (?P \<in> carrier_mat d d \<and> positive ?P \<and> ?P \<le>\<^sub>L 1\<^sub>m d)

goal (1 subgoal):
 1. (is_quantum_predicate P &&& P \<in> carrier_mat d d) &&& well_com S &&& measurement d 2 M &&& well_com (While M S)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate P
P \<in> carrier_mat d d
well_com S
measurement d 2 M
well_com (While M S)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define M0 where "M0 = M 0"
[PROOF STATE]
proof (state)
this:
M0 = M 0

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define M1 where "M1 = M 1"
[PROOF STATE]
proof (state)
this:
M1 = M 1

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have dM0: "M0 \<in> carrier_mat d d" and dM1: "M1 \<in> carrier_mat d d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. M0 \<in> carrier_mat d d &&& M1 \<in> carrier_mat d d
[PROOF STEP]
using m measurement_def M0_def M1_def
[PROOF STATE]
proof (prove)
using this:
measurement d 2 M
measurement ?d ?n ?M = ((\<forall>j<?n. ?M j \<in> carrier_mat ?d ?d) \<and> matrix_sum ?d (\<lambda>j. adjoint (?M j) * ?M j) ?n = 1\<^sub>m ?d)
M0 = M 0
M1 = M 1

goal (1 subgoal):
 1. M0 \<in> carrier_mat d d &&& M1 \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M0 \<in> carrier_mat d d
M1 \<in> carrier_mat d d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have leM1: "adjoint M1 * M1 \<le>\<^sub>L 1\<^sub>m d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. adjoint M1 * M1 \<le>\<^sub>L 1\<^sub>m d
[PROOF STEP]
using measurement_le_one_mat m M1_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>measurement ?d ?n ?f; ?j < ?n\<rbrakk> \<Longrightarrow> adjoint (?f ?j) * ?f ?j \<le>\<^sub>L 1\<^sub>m ?d
measurement d 2 M
M1 = M 1

goal (1 subgoal):
 1. adjoint M1 * M1 \<le>\<^sub>L 1\<^sub>m d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
adjoint M1 * M1 \<le>\<^sub>L 1\<^sub>m d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define W where "W k = wlp_while_n M0 M1 (wlp S) k P" for k
[PROOF STATE]
proof (state)
this:
W ?k = wlp_while_n M0 M1 (wlp S) ?k P

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define DS where "DS = denote S"
[PROOF STATE]
proof (state)
this:
DS = denote S

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define D0 where "D0 = denote_while_n M0 M1 DS"
[PROOF STATE]
proof (state)
this:
D0 = denote_while_n M0 M1 DS

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define D1 where "D1 = denote_while_n_comp M0 M1 DS"
[PROOF STATE]
proof (state)
this:
D1 = denote_while_n_comp M0 M1 DS

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
define D where "D = denote_while_n_iter M0 M1 DS"
[PROOF STATE]
proof (state)
this:
D = denote_while_n_iter M0 M1 DS

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have eqk: "\<rho> \<in> density_states \<Longrightarrow> trace ((W k) * \<rho>) = (\<Sum>k=0..<k. trace (P * (D0 k \<rho>))) + trace \<rho> - (\<Sum>k=0..<k. trace (D0 k \<rho>))" for k \<rho>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))
[PROOF STEP]
proof (induct k arbitrary: \<rho>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W 0 * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))
 2. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
\<rho> \<in> density_states

goal (2 subgoals):
 1. \<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W 0 * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))
 2. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<rho> \<in> density_states
[PROOF STEP]
have dsr: "\<rho> \<in> density_states"
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states

goal (1 subgoal):
 1. \<rho> \<in> density_states
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<rho> \<in> density_states

goal (2 subgoals):
 1. \<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W 0 * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))
 2. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (W 0 * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))
[PROOF STEP]
unfolding W_def wlp_while_n.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (1\<^sub>m d * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))
[PROOF STEP]
using dsr density_states_def
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states
density_states = {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. trace (1\<^sub>m d * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (W 0 * \<rho>) = (\<Sum>k = 0..<0. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<0. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
case (Suc k)
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> density_states \<Longrightarrow> trace (W k * ?\<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k ?\<rho>)) + trace ?\<rho> - (\<Sum>k = 0..<k. trace (D0 k ?\<rho>))
\<rho> \<in> density_states

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?\<rho> \<in> density_states \<Longrightarrow> trace (W k * ?\<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k ?\<rho>)) + trace ?\<rho> - (\<Sum>k = 0..<k. trace (D0 k ?\<rho>))
\<rho> \<in> density_states
[PROOF STEP]
have dsr: "\<rho> \<in> density_states" and dr: "\<rho> \<in> carrier_mat d d" and pdor: "partial_density_operator \<rho>"
[PROOF STATE]
proof (prove)
using this:
?\<rho> \<in> density_states \<Longrightarrow> trace (W k * ?\<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k ?\<rho>)) + trace ?\<rho> - (\<Sum>k = 0..<k. trace (D0 k ?\<rho>))
\<rho> \<in> density_states

goal (1 subgoal):
 1. \<rho> \<in> density_states &&& \<rho> \<in> carrier_mat d d &&& partial_density_operator \<rho>
[PROOF STEP]
using density_states_def
[PROOF STATE]
proof (prove)
using this:
?\<rho> \<in> density_states \<Longrightarrow> trace (W k * ?\<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k ?\<rho>)) + trace ?\<rho> - (\<Sum>k = 0..<k. trace (D0 k ?\<rho>))
\<rho> \<in> density_states
density_states = {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. \<rho> \<in> density_states &&& \<rho> \<in> carrier_mat d d &&& partial_density_operator \<rho>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<rho> \<in> density_states
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<rho> \<in> density_states
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>
[PROOF STEP]
have dsM1r: "M1 * \<rho> * adjoint M1 \<in> density_states"
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>

goal (1 subgoal):
 1. M1 * \<rho> * adjoint M1 \<in> density_states
[PROOF STEP]
unfolding density_states_def
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>

goal (1 subgoal):
 1. M1 * \<rho> * adjoint M1 \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
[PROOF STEP]
using pdo_close_under_measurement[OF dM1 dr pdor leM1] dr dM1
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>
partial_density_operator (M1 * \<rho> * adjoint M1)
\<rho> \<in> carrier_mat d d
M1 \<in> carrier_mat d d

goal (1 subgoal):
 1. M1 * \<rho> * adjoint M1 \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
M1 * \<rho> * adjoint M1 \<in> density_states

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
M1 * \<rho> * adjoint M1 \<in> density_states
[PROOF STEP]
have dsDSM1r: "(DS (M1 * \<rho> * adjoint M1)) \<in> density_states"
[PROOF STATE]
proof (prove)
using this:
M1 * \<rho> * adjoint M1 \<in> density_states

goal (1 subgoal):
 1. DS (M1 * \<rho> * adjoint M1) \<in> density_states
[PROOF STEP]
unfolding density_states_def DS_def
[PROOF STATE]
proof (prove)
using this:
M1 * \<rho> * adjoint M1 \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. denote S (M1 * \<rho> * adjoint M1) \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
[PROOF STEP]
using denote_dim[OF wcS] denote_partial_density_operator[OF wcS] dsM1r
[PROOF STATE]
proof (prove)
using this:
M1 * \<rho> * adjoint M1 \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
\<lbrakk>?\<rho> \<in> carrier_mat d d; partial_density_operator ?\<rho>\<rbrakk> \<Longrightarrow> denote S ?\<rho> \<in> carrier_mat d d
\<lbrakk>partial_density_operator ?\<rho>; ?\<rho> \<in> carrier_mat d d\<rbrakk> \<Longrightarrow> partial_density_operator (denote S ?\<rho>)
M1 * \<rho> * adjoint M1 \<in> density_states

goal (1 subgoal):
 1. denote S (M1 * \<rho> * adjoint M1) \<in> {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
DS (M1 * \<rho> * adjoint M1) \<in> density_states

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have qpWk: "is_quantum_predicate (W k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_quantum_predicate (W k)
[PROOF STEP]
using wlp_while_n_close[OF _ m qpP, folded M0_def M1_def, of "wlp S", folded W_def] wlp_close[OF wcS]
[PROOF STATE]
proof (prove)
using this:
(\<And>P. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P)) \<Longrightarrow> is_quantum_predicate (W ?k)
is_quantum_predicate ?P \<Longrightarrow> is_quantum_predicate (wlp S ?P)

goal (1 subgoal):
 1. is_quantum_predicate (W k)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (W k)

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_quantum_predicate (W k)
[PROOF STEP]
have "is_quantum_predicate (wlp S (W k))"
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (W k)

goal (1 subgoal):
 1. is_quantum_predicate (wlp S (W k))
[PROOF STEP]
using wlp_close[OF wcS]
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (W k)
is_quantum_predicate ?P \<Longrightarrow> is_quantum_predicate (wlp S ?P)

goal (1 subgoal):
 1. is_quantum_predicate (wlp S (W k))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (wlp S (W k))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_quantum_predicate (wlp S (W k))
[PROOF STEP]
have dWWk: "wlp S (W k) \<in> carrier_mat d d"
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (wlp S (W k))

goal (1 subgoal):
 1. wlp S (W k) \<in> carrier_mat d d
[PROOF STEP]
using is_quantum_predicate_def
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (wlp S (W k))
is_quantum_predicate ?P = (?P \<in> carrier_mat d d \<and> positive ?P \<and> ?P \<le>\<^sub>L 1\<^sub>m d)

goal (1 subgoal):
 1. wlp S (W k) \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
wlp S (W k) \<in> carrier_mat d d

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k=0..<k. trace (P * (D0 k (DS (M1 * \<rho> * adjoint M1)))))
      = trace (P * (D0 0 \<rho>)) + (\<Sum>k=0..<k. trace (P * (D0 (Suc k) \<rho>)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>))
[PROOF STEP]
unfolding D0_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * denote_while_n M0 M1 DS k (DS (M1 * \<rho> * adjoint M1)))) = trace (P * denote_while_n M0 M1 DS 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * denote_while_n M0 M1 DS (Suc k) \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = trace (P * (D0 0 \<rho>)) + (\<Sum>k=1..<(Suc k). trace (P * (D0 k \<rho>)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>)) = trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>))
[PROOF STEP]
using sum.shift_bounds_Suc_ivl[symmetric, of "\<lambda>k. trace (P * (D0 k \<rho>))"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = ?m..<?n. trace (P * D0 (Suc i) \<rho>)) = (\<Sum>k = Suc ?m..<Suc ?n. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>)) = trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>)) = trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (P * D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (P * D0 (Suc k) \<rho>)) = trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = (\<Sum>k=0..<(Suc k). trace (P * (D0 k \<rho>)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>)) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))
[PROOF STEP]
using sum.atLeast_Suc_lessThan[of 0 "Suc k" "\<lambda>k. trace (P * (D0 k \<rho>))"]
[PROOF STATE]
proof (prove)
using this:
0 < Suc k \<Longrightarrow> (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) = trace (P * D0 0 \<rho>) + (\<Sum>k = Suc 0..<Suc k. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>)) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (P * D0 k \<rho>)) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))
[PROOF STEP]
have eq1: "trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k=0..<k. trace (P * (D0 k (DS (M1 * \<rho> * adjoint M1)))))
      = (\<Sum>k=0..<(Suc k). trace (P * (D0 k \<rho>)))"
[PROOF STATE]
proof (prove)
using this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have eq2: "trace (M1 * \<rho> * adjoint M1) = trace \<rho> - trace (M0 * \<rho> * adjoint M0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (M1 * \<rho> * adjoint M1) = trace \<rho> - trace (M0 * \<rho> * adjoint M0)
[PROOF STEP]
unfolding M0_def M1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (M 1 * \<rho> * adjoint (M 1)) = trace \<rho> - trace (M 0 * \<rho> * adjoint (M 0))
[PROOF STEP]
using m trace_measurement2[OF m dr] dr
[PROOF STATE]
proof (prove)
using this:
measurement d 2 M
trace (M 0 * \<rho> * adjoint (M 0)) + trace (M 1 * \<rho> * adjoint (M 1)) = trace \<rho>
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (M 1 * \<rho> * adjoint (M 1)) = trace \<rho> - trace (M 0 * \<rho> * adjoint (M 0))
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
trace (M1 * \<rho> * adjoint M1) = trace \<rho> - trace (M0 * \<rho> * adjoint M0)

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "trace (M0 * \<rho> * adjoint M0) + (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))
       = trace (D0 0 \<rho>) + (\<Sum>k=0..<k. trace (D0 (Suc k) \<rho>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>))
[PROOF STEP]
unfolding D0_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (denote_while_n M0 M1 DS k (DS (M1 * \<rho> * adjoint M1)))) = trace (denote_while_n M0 M1 DS 0 \<rho>) + (\<Sum>k = 0..<k. trace (denote_while_n M0 M1 DS (Suc k) \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = trace (D0 0 \<rho>) + (\<Sum>k=1..<(Suc k). trace (D0 k \<rho>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>)) = trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
using sum.shift_bounds_Suc_ivl[symmetric, of "\<lambda>k. trace (D0 k \<rho>)"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>i = ?m..<?n. trace (D0 (Suc i) \<rho>)) = (\<Sum>k = Suc ?m..<Suc ?n. trace (D0 k \<rho>))

goal (1 subgoal):
 1. trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>)) = trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>)) = trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (D0 0 \<rho>) + (\<Sum>k = 0..<k. trace (D0 (Suc k) \<rho>)) = trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = (\<Sum>k=0..<(Suc k). trace (D0 k \<rho>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>)) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
using sum.atLeast_Suc_lessThan[of 0 "Suc k" "\<lambda>k. trace (D0 k \<rho>)"]
[PROOF STATE]
proof (prove)
using this:
0 < Suc k \<Longrightarrow> (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>)) = trace (D0 0 \<rho>) + (\<Sum>k = Suc 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>)) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (D0 0 \<rho>) + (\<Sum>k = 1..<Suc k. trace (D0 k \<rho>)) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have eq3: "trace (M0 * \<rho> * adjoint M0) + (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k=0..<(Suc k). trace (D0 k \<rho>))"
[PROOF STATE]
proof (prove)
using this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "trace (M1 * \<rho> * adjoint M1) - (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))
      = trace \<rho> - (trace (M0 * \<rho> * adjoint M0) + (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))))"
[PROOF STATE]
proof (prove)
using this:
trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))))
[PROOF STEP]
by (simp add: algebra_simps eq2)
[PROOF STATE]
proof (state)
this:
trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))))
[PROOF STEP]
have eq4: "trace (M1 * \<rho> * adjoint M1) - (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (\<Sum>k=0..<(Suc k). trace (D0 k \<rho>))"
[PROOF STATE]
proof (prove)
using this:
trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (trace (M0 * \<rho> * adjoint M0) + (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))))

goal (1 subgoal):
 1. trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
by (simp add: eq3)
[PROOF STATE]
proof (state)
this:
trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "trace ((W (Suc k)) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace ((wlp S (W k)) * (M1 * \<rho> * adjoint M1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (W (Suc k) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1))
[PROOF STEP]
unfolding W_def wlp_while_n.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace ((adjoint M0 * P * M0 + adjoint M1 * wlp S (wlp_while_n M0 M1 (wlp S) k P) * M1) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (wlp_while_n M0 M1 (wlp S) k P) * (M1 * \<rho> * adjoint M1))
[PROOF STEP]
apply (fold W_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace ((adjoint M0 * P * M0 + adjoint M1 * wlp S (W k) * M1) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1))
[PROOF STEP]
using dM0 dP dM1 dWWk dr
[PROOF STATE]
proof (prove)
using this:
M0 \<in> carrier_mat d d
P \<in> carrier_mat d d
M1 \<in> carrier_mat d d
wlp S (W k) \<in> carrier_mat d d
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. trace ((adjoint M0 * P * M0 + adjoint M1 * wlp S (W k) * M1) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1))
[PROOF STEP]
by (mat_assoc d)
[PROOF STATE]
proof (state)
this:
trace (W (Suc k) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (W (Suc k) * \<rho>) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = trace (P * (M0 * \<rho> * adjoint M0)) + trace ((W k) * (DS (M1 * \<rho> * adjoint M1))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))
[PROOF STEP]
using While(1)[OF wcS, of "W k"] qpWk dsM1r DS_def
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate (W k) \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S (W k) * \<rho>) = trace (W k * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>)
is_quantum_predicate (W k)
M1 * \<rho> * adjoint M1 \<in> density_states
DS = denote S

goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + trace (wlp S (W k) * (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = trace (P * (M0 * \<rho> * adjoint M0))
      + (\<Sum>k=0..<k. trace (P * (D0 k (DS (M1 * \<rho> * adjoint M1))))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))
      + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))
[PROOF STEP]
using Suc(1)[OF dsDSM1r]
[PROOF STATE]
proof (prove)
using this:
trace (W k * DS (M1 * \<rho> * adjoint M1)) = (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))

goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + trace (W k * DS (M1 * \<rho> * adjoint M1)) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k=0..<k. trace (P * (D0 k (DS (M1 * \<rho> * adjoint M1)))))
      + trace (M1 * \<rho> * adjoint M1) - (\<Sum>k=0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (DS (M1 * \<rho> * adjoint M1)) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - trace (DS (M1 * \<rho> * adjoint M1)) = trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1))))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
have "\<dots> = (\<Sum>k=0..<(Suc k). trace (P * (D0 k \<rho>))) + trace \<rho> - (\<Sum>k=0..<(Suc k). trace (D0 k \<rho>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
by (simp add: eq1 eq4)
[PROOF STATE]
proof (state)
this:
trace (P * (M0 * \<rho> * adjoint M0)) + (\<Sum>k = 0..<k. trace (P * D0 k (DS (M1 * \<rho> * adjoint M1)))) + trace (M1 * \<rho> * adjoint M1) - (\<Sum>k = 0..<k. trace (D0 k (DS (M1 * \<rho> * adjoint M1)))) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>k \<rho>. \<lbrakk>\<And>\<rho>. \<rho> \<in> density_states \<Longrightarrow> trace (W k * \<rho>) = (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>)); \<rho> \<in> density_states\<rbrakk> \<Longrightarrow> trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
trace (W (Suc k) * \<rho>) = (\<Sum>k = 0..<Suc k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<Suc k. trace (D0 k \<rho>))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> density_states \<Longrightarrow> trace (W ?k * ?\<rho>) = (\<Sum>k = 0..<?k. trace (P * D0 k ?\<rho>)) + trace ?\<rho> - (\<Sum>k = 0..<?k. trace (D0 k ?\<rho>))

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
?\<rho> \<in> density_states \<Longrightarrow> trace (W ?k * ?\<rho>) = (\<Sum>k = 0..<?k. trace (P * D0 k ?\<rho>)) + trace ?\<rho> - (\<Sum>k = 0..<?k. trace (D0 k ?\<rho>))

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
fix \<rho>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
assume dsr: "\<rho> \<in> density_states"
[PROOF STATE]
proof (state)
this:
\<rho> \<in> density_states

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<rho> \<in> density_states
[PROOF STEP]
have dr: "\<rho> \<in> carrier_mat d d" and pdor: "partial_density_operator \<rho>"
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states

goal (1 subgoal):
 1. \<rho> \<in> carrier_mat d d &&& partial_density_operator \<rho>
[PROOF STEP]
using density_states_def
[PROOF STATE]
proof (prove)
using this:
\<rho> \<in> density_states
density_states = {\<rho> \<in> carrier_mat d d. partial_density_operator \<rho>}

goal (1 subgoal):
 1. \<rho> \<in> carrier_mat d d &&& partial_density_operator \<rho>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<rho> \<in> carrier_mat d d
partial_density_operator \<rho>

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have limDW: "limit_mat (\<lambda>n. matrix_sum d (\<lambda>k. D0 k \<rho>) (n)) (denote (While M S) \<rho>) d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
[PROOF STEP]
using limit_mat_denote_while_n[OF wc dr pdor]
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. denote_while_n (M 0) (M 1) (denote S) k \<rho>)) (denote (While M S) \<rho>) d

goal (1 subgoal):
 1. limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
[PROOF STEP]
unfolding D0_def M0_def M1_def DS_def
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. denote_while_n (M 0) (M 1) (denote S) k \<rho>)) (denote (While M S) \<rho>) d

goal (1 subgoal):
 1. limit_mat (matrix_sum d (\<lambda>k. denote_while_n (M 0) (M 1) (denote S) k \<rho>)) (denote (While M S) \<rho>) d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
[PROOF STEP]
have "limit_mat (\<lambda>n. (P * (matrix_sum d (\<lambda>k. D0 k \<rho>) (n)))) (P * (denote (While M S) \<rho>)) d"
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d

goal (1 subgoal):
 1. limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d
[PROOF STEP]
using mat_mult_limit[OF dP]
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
limit_mat ?X ?A d \<Longrightarrow> limit_mat (mat_mult_seq P ?X) (P * ?A) d

goal (1 subgoal):
 1. limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d
[PROOF STEP]
unfolding mat_mult_seq_def
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
limit_mat ?X ?A d \<Longrightarrow> limit_mat (\<lambda>n. P * ?X n) (P * ?A) d

goal (1 subgoal):
 1. limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d
[PROOF STEP]
have limtrPm: "(\<lambda>n. trace (P * (matrix_sum d (\<lambda>k. D0 k \<rho>) (n)))) \<longlonglongrightarrow> trace (P * (denote (While M S) \<rho>))"
[PROOF STATE]
proof (prove)
using this:
limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d

goal (1 subgoal):
 1. (\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
[PROOF STEP]
using mat_trace_limit
[PROOF STATE]
proof (prove)
using this:
limit_mat (\<lambda>n. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) (P * denote (While M S) \<rho>) d
limit_mat ?g ?A ?d \<Longrightarrow> (\<lambda>n. trace (?g n)) \<longlonglongrightarrow> trace ?A

goal (1 subgoal):
 1. (\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
with limDW
[PROOF STATE]
proof (chain)
picking this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
(\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
[PROOF STEP]
have limtrDW:"(\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) (n))) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)"
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
(\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)

goal (1 subgoal):
 1. (\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
[PROOF STEP]
using mat_trace_limit
[PROOF STATE]
proof (prove)
using this:
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d
(\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
limit_mat ?g ?A ?d \<Longrightarrow> (\<lambda>n. trace (?g n)) \<longlonglongrightarrow> trace ?A

goal (1 subgoal):
 1. (\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have limm: "(\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) (n))) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
[PROOF STEP]
using mat_trace_limit limDW
[PROOF STATE]
proof (prove)
using this:
limit_mat ?g ?A ?d \<Longrightarrow> (\<lambda>n. trace (?g n)) \<longlonglongrightarrow> trace ?A
limit_mat (matrix_sum d (\<lambda>k. D0 k \<rho>)) (denote (While M S) \<rho>) d

goal (1 subgoal):
 1. (\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have closeWS: "is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P)" for P
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P)
[PROOF STEP]
assume asm: "is_quantum_predicate P"
[PROOF STATE]
proof (state)
this:
is_quantum_predicate P

goal (1 subgoal):
 1. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_quantum_predicate P
[PROOF STEP]
have dP: "P \<in> carrier_mat d d"
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate P

goal (1 subgoal):
 1. P \<in> carrier_mat d d
[PROOF STEP]
using is_quantum_predicate_def
[PROOF STATE]
proof (prove)
using this:
is_quantum_predicate P
is_quantum_predicate ?P = (?P \<in> carrier_mat d d \<and> positive ?P \<and> ?P \<le>\<^sub>L 1\<^sub>m d)

goal (1 subgoal):
 1. P \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
P \<in> carrier_mat d d

goal (1 subgoal):
 1. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
P \<in> carrier_mat d d
[PROOF STEP]
show "is_quantum_predicate (wlp S P)"
[PROOF STATE]
proof (prove)
using this:
P \<in> carrier_mat d d

goal (1 subgoal):
 1. is_quantum_predicate (wlp S P)
[PROOF STEP]
using wlp_mono_and_close[OF wcS asm asm] lowner_le_refl
[PROOF STATE]
proof (prove)
using this:
P \<in> carrier_mat d d
P \<le>\<^sub>L P \<Longrightarrow> is_quantum_predicate (wlp S P) \<and> wlp S P \<le>\<^sub>L wlp S P
?A \<in> carrier_mat ?n ?n \<Longrightarrow> ?A \<le>\<^sub>L ?A

goal (1 subgoal):
 1. is_quantum_predicate (wlp S P)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (wlp S P)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
is_quantum_predicate ?P \<Longrightarrow> is_quantum_predicate (wlp S ?P)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have monoWS: "is_quantum_predicate P \<Longrightarrow> is_quantum_predicate Q \<Longrightarrow> P \<le>\<^sub>L Q \<Longrightarrow> wlp S P \<le>\<^sub>L wlp S Q" for P Q
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_quantum_predicate P; is_quantum_predicate Q; P \<le>\<^sub>L Q\<rbrakk> \<Longrightarrow> wlp S P \<le>\<^sub>L wlp S Q
[PROOF STEP]
using wlp_mono_and_close[OF wcS]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>is_quantum_predicate ?P; is_quantum_predicate ?Q; ?P \<le>\<^sub>L ?Q\<rbrakk> \<Longrightarrow> is_quantum_predicate (wlp S ?P) \<and> wlp S ?P \<le>\<^sub>L wlp S ?Q

goal (1 subgoal):
 1. \<lbrakk>is_quantum_predicate P; is_quantum_predicate Q; P \<le>\<^sub>L Q\<rbrakk> \<Longrightarrow> wlp S P \<le>\<^sub>L wlp S Q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>is_quantum_predicate ?P; is_quantum_predicate ?Q; ?P \<le>\<^sub>L ?Q\<rbrakk> \<Longrightarrow> wlp S ?P \<le>\<^sub>L wlp S ?Q

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "is_quantum_predicate (wlp (While M S) P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_quantum_predicate (wlp (While M S) P)
[PROOF STEP]
using wlp_while_exists[of "wlp S" M P] closeWS monoWS m qpP
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>P. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P); \<And>P Q. \<lbrakk>is_quantum_predicate P; is_quantum_predicate Q; P \<le>\<^sub>L Q\<rbrakk> \<Longrightarrow> wlp S P \<le>\<^sub>L wlp S Q; measurement d 2 M; is_quantum_predicate P\<rbrakk> \<Longrightarrow> is_quantum_predicate (wlp_while (M 0) (M 1) (wlp S) P) \<and> (\<forall>n. wlp_while (M 0) (M 1) (wlp S) P \<le>\<^sub>L wlp_while_n (M 0) (M 1) (wlp S) n P) \<and> (\<forall>W'. (\<forall>n. W' \<le>\<^sub>L wlp_while_n (M 0) (M 1) (wlp S) n P) \<longrightarrow> W' \<le>\<^sub>L wlp_while (M 0) (M 1) (wlp S) P) \<and> limit_mat (\<lambda>n. wlp_while_n (M 0) (M 1) (wlp S) n P) (wlp_while (M 0) (M 1) (wlp S) P) d
is_quantum_predicate ?P \<Longrightarrow> is_quantum_predicate (wlp S ?P)
\<lbrakk>is_quantum_predicate ?P; is_quantum_predicate ?Q; ?P \<le>\<^sub>L ?Q\<rbrakk> \<Longrightarrow> wlp S ?P \<le>\<^sub>L wlp S ?Q
measurement d 2 M
is_quantum_predicate P

goal (1 subgoal):
 1. is_quantum_predicate (wlp (While M S) P)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
is_quantum_predicate (wlp (While M S) P)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "limit_mat W (wlp_while M0 M1 (wlp S) P) d"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limit_mat W (wlp_while M0 M1 (wlp S) P) d
[PROOF STEP]
unfolding W_def M0_def M1_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. limit_mat (\<lambda>k. wlp_while_n (M 0) (M 1) (wlp S) k P) (wlp_while (M 0) (M 1) (wlp S) P) d
[PROOF STEP]
using wlp_while_exists[of "wlp S" M P] closeWS monoWS m qpP
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>\<And>P. is_quantum_predicate P \<Longrightarrow> is_quantum_predicate (wlp S P); \<And>P Q. \<lbrakk>is_quantum_predicate P; is_quantum_predicate Q; P \<le>\<^sub>L Q\<rbrakk> \<Longrightarrow> wlp S P \<le>\<^sub>L wlp S Q; measurement d 2 M; is_quantum_predicate P\<rbrakk> \<Longrightarrow> is_quantum_predicate (wlp_while (M 0) (M 1) (wlp S) P) \<and> (\<forall>n. wlp_while (M 0) (M 1) (wlp S) P \<le>\<^sub>L wlp_while_n (M 0) (M 1) (wlp S) n P) \<and> (\<forall>W'. (\<forall>n. W' \<le>\<^sub>L wlp_while_n (M 0) (M 1) (wlp S) n P) \<longrightarrow> W' \<le>\<^sub>L wlp_while (M 0) (M 1) (wlp S) P) \<and> limit_mat (\<lambda>n. wlp_while_n (M 0) (M 1) (wlp S) n P) (wlp_while (M 0) (M 1) (wlp S) P) d
is_quantum_predicate ?P \<Longrightarrow> is_quantum_predicate (wlp S ?P)
\<lbrakk>is_quantum_predicate ?P; is_quantum_predicate ?Q; ?P \<le>\<^sub>L ?Q\<rbrakk> \<Longrightarrow> wlp S ?P \<le>\<^sub>L wlp S ?Q
measurement d 2 M
is_quantum_predicate P

goal (1 subgoal):
 1. limit_mat (\<lambda>k. wlp_while_n (M 0) (M 1) (wlp S) k P) (wlp_while (M 0) (M 1) (wlp S) P) d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
limit_mat W (wlp_while M0 M1 (wlp S) P) d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
limit_mat W (wlp_while M0 M1 (wlp S) P) d
[PROOF STEP]
have "limit_mat (\<lambda>k. (W k) * \<rho>) ((wlp_while M0 M1 (wlp S) P) * \<rho>) d"
[PROOF STATE]
proof (prove)
using this:
limit_mat W (wlp_while M0 M1 (wlp S) P) d

goal (1 subgoal):
 1. limit_mat (\<lambda>k. W k * \<rho>) (wlp_while M0 M1 (wlp S) P * \<rho>) d
[PROOF STEP]
using mult_mat_limit dr
[PROOF STATE]
proof (prove)
using this:
limit_mat W (wlp_while M0 M1 (wlp S) P) d
\<lbrakk>?B \<in> carrier_mat ?m ?m; limit_mat ?X ?A ?m\<rbrakk> \<Longrightarrow> limit_mat (\<lambda>k. ?X k * ?B) (?A * ?B) ?m
\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. limit_mat (\<lambda>k. W k * \<rho>) (wlp_while M0 M1 (wlp S) P * \<rho>) d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
limit_mat (\<lambda>k. W k * \<rho>) (wlp_while M0 M1 (wlp S) P * \<rho>) d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
limit_mat (\<lambda>k. W k * \<rho>) (wlp_while M0 M1 (wlp S) P * \<rho>) d
[PROOF STEP]
have lim1: "(\<lambda>k. trace ((W k) * \<rho>)) \<longlonglongrightarrow> trace ((wlp_while M0 M1 (wlp S) P) * \<rho>)"
[PROOF STATE]
proof (prove)
using this:
limit_mat (\<lambda>k. W k * \<rho>) (wlp_while M0 M1 (wlp S) P * \<rho>) d

goal (1 subgoal):
 1. (\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (wlp_while M0 M1 (wlp S) P * \<rho>)
[PROOF STEP]
using mat_trace_limit
[PROOF STATE]
proof (prove)
using this:
limit_mat (\<lambda>k. W k * \<rho>) (wlp_while M0 M1 (wlp S) P * \<rho>) d
limit_mat ?g ?A ?d \<Longrightarrow> (\<lambda>n. trace (?g n)) \<longlonglongrightarrow> trace ?A

goal (1 subgoal):
 1. (\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (wlp_while M0 M1 (wlp S) P * \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (wlp_while M0 M1 (wlp S) P * \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have dD0kr: "D0 k \<rho> \<in> carrier_mat d d" for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. D0 k \<rho> \<in> carrier_mat d d
[PROOF STEP]
unfolding D0_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. denote_while_n M0 M1 DS k \<rho> \<in> carrier_mat d d
[PROOF STEP]
using denote_while_n_dim[OF dr dM0 dM1 pdor] denote_positive_trace_dim[OF wcS, folded DS_def]
[PROOF STATE]
proof (prove)
using this:
(\<And>\<rho>'. \<lbrakk>\<rho>' \<in> carrier_mat d d; partial_density_operator \<rho>'\<rbrakk> \<Longrightarrow> positive (?DS \<rho>') \<and> trace (?DS \<rho>') \<le> trace \<rho>' \<and> ?DS \<rho>' \<in> carrier_mat d d) \<Longrightarrow> denote_while_n M0 M1 ?DS ?n \<rho> \<in> carrier_mat d d
\<lbrakk>?\<rho> \<in> carrier_mat d d; partial_density_operator ?\<rho>\<rbrakk> \<Longrightarrow> positive (DS ?\<rho>) \<and> trace (DS ?\<rho>) \<le> trace ?\<rho> \<and> DS ?\<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. denote_while_n M0 M1 DS k \<rho> \<in> carrier_mat d d
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
D0 ?k \<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
D0 ?k \<rho> \<in> carrier_mat d d
[PROOF STEP]
have "(P * (matrix_sum d (\<lambda>k. D0 k \<rho>) (n))) = matrix_sum d (\<lambda>k. P * (D0 k \<rho>)) n" for n
[PROOF STATE]
proof (prove)
using this:
D0 ?k \<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n = matrix_sum d (\<lambda>k. P * D0 k \<rho>) n
[PROOF STEP]
using matrix_sum_distrib_left[OF dP]
[PROOF STATE]
proof (prove)
using this:
D0 ?k \<rho> \<in> carrier_mat d d
(\<And>k. k < ?n \<Longrightarrow> ?f k \<in> carrier_mat d d) \<Longrightarrow> matrix_sum d (\<lambda>k. P * ?f k) ?n = P * matrix_sum d ?f ?n

goal (1 subgoal):
 1. P * matrix_sum d (\<lambda>k. D0 k \<rho>) n = matrix_sum d (\<lambda>k. P * D0 k \<rho>) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n = matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n = matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "trace (matrix_sum d (\<lambda>k. P * (D0 k \<rho>)) n) = (\<Sum>k=0..<n. trace (P * (D0 k \<rho>)))" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. P * D0 k \<rho>) n) = (\<Sum>k = 0..<n. trace (P * D0 k \<rho>))
[PROOF STEP]
using trace_matrix_sum_linear dD0kr dP
[PROOF STATE]
proof (prove)
using this:
(\<And>k. k < ?n \<Longrightarrow> ?f k \<in> carrier_mat ?d ?d) \<Longrightarrow> trace (matrix_sum ?d ?f ?n) = (\<Sum>k = 0..<?n. trace (?f k))
D0 ?k \<rho> \<in> carrier_mat d d
P \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. P * D0 k \<rho>) n) = (\<Sum>k = 0..<n. trace (P * D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n = matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n
trace (matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (P * D0 k \<rho>))
[PROOF STEP]
have eqPsD0kr: "trace (P * (matrix_sum d (\<lambda>k. D0 k \<rho>) (n))) = (\<Sum>k=0..<n. trace (P * (D0 k \<rho>)))" for n
[PROOF STATE]
proof (prove)
using this:
P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n = matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n
trace (matrix_sum d (\<lambda>k. P * D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n) = (\<Sum>k = 0..<n. trace (P * D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
with limtrPm
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (P * D0 k \<rho>))
[PROOF STEP]
have lim2: "(\<lambda>k. (\<Sum>k=0..<k. trace (P * (D0 k \<rho>)))) \<longlonglongrightarrow> trace (P * (denote (While M S) \<rho>))"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
trace (P * matrix_sum d (\<lambda>k. D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (P * D0 k \<rho>))

goal (1 subgoal):
 1. (\<lambda>k. \<Sum>k = 0..<k. trace (P * D0 k \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. \<Sum>k = 0..<k. trace (P * D0 k \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "trace (matrix_sum d (\<lambda>k. D0 k \<rho>) (n)) = (\<Sum>k=0..<n. trace (D0 k \<rho>))" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n) = (\<Sum>k = 0..<n. trace (D0 k \<rho>))
[PROOF STEP]
using trace_matrix_sum_linear dD0kr
[PROOF STATE]
proof (prove)
using this:
(\<And>k. k < ?n \<Longrightarrow> ?f k \<in> carrier_mat ?d ?d) \<Longrightarrow> trace (matrix_sum ?d ?f ?n) = (\<Sum>k = 0..<?n. trace (?f k))
D0 ?k \<rho> \<in> carrier_mat d d

goal (1 subgoal):
 1. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n) = (\<Sum>k = 0..<n. trace (D0 k \<rho>))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (matrix_sum d (\<lambda>k. D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (D0 k \<rho>))

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
with limtrDW
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
trace (matrix_sum d (\<lambda>k. D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (D0 k \<rho>))
[PROOF STEP]
have lim3: "(\<lambda>k. (\<Sum>k=0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. trace (matrix_sum d (\<lambda>k. D0 k \<rho>) n)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
trace (matrix_sum d (\<lambda>k. D0 k \<rho>) ?n) = (\<Sum>k = 0..<?n. trace (D0 k \<rho>))

goal (1 subgoal):
 1. (\<lambda>k. \<Sum>k = 0..<k. trace (D0 k \<rho>)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. \<Sum>k = 0..<k. trace (D0 k \<rho>)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
have "(\<lambda>k. (\<Sum>k=0..<k. trace (P * (D0 k \<rho>))) + trace \<rho>) \<longlonglongrightarrow> trace (P * (denote (While M S) \<rho>)) + trace \<rho>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho>) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho>
[PROOF STEP]
using tendsto_add[of "\<lambda>k. (\<Sum>k=0..<k. trace (P * (D0 k \<rho>)))"] lim2
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>((\<lambda>k. \<Sum>k = 0..<k. trace (P * D0 k \<rho>)) \<longlongrightarrow> ?a) ?F; (?g \<longlongrightarrow> ?b) ?F\<rbrakk> \<Longrightarrow> ((\<lambda>x. (\<Sum>k = 0..<x. trace (P * D0 k \<rho>)) + ?g x) \<longlongrightarrow> ?a + ?b) ?F
(\<lambda>k. \<Sum>k = 0..<k. trace (P * D0 k \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>)

goal (1 subgoal):
 1. (\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho>) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho>
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho>) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho>

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho>) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho>
[PROOF STEP]
have "(\<lambda>k. (\<Sum>k=0..<k. trace (P * (D0 k \<rho>))) + trace \<rho> - (\<Sum>k=0..<k. trace (D0 k \<rho>)))
       \<longlonglongrightarrow> trace (P * (denote (While M S) \<rho>)) + trace \<rho> -  trace (denote (While M S) \<rho>)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho>) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho>

goal (1 subgoal):
 1. (\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
using tendsto_diff[of _ _ _ "\<lambda>k. (\<Sum>k=0..<k. trace (D0 k \<rho>))"] lim3
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho>) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho>
\<lbrakk>(?f \<longlongrightarrow> ?a) ?F; ((\<lambda>k. \<Sum>k = 0..<k. trace (D0 k \<rho>)) \<longlongrightarrow> ?b) ?F\<rbrakk> \<Longrightarrow> ((\<lambda>x. ?f x - (\<Sum>k = 0..<x. trace (D0 k \<rho>))) \<longlongrightarrow> ?a - ?b) ?F
(\<lambda>k. \<Sum>k = 0..<k. trace (D0 k \<rho>)) \<longlonglongrightarrow> trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. (\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
have lim4: "(\<lambda>k. trace ((W k) * \<rho>)) \<longlonglongrightarrow> trace (P * (denote (While M S) \<rho>)) + trace \<rho> -  trace (denote (While M S) \<rho>)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. (\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
using eqk[OF dsr]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. (\<Sum>k = 0..<k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<k. trace (D0 k \<rho>))) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
trace (W ?k * \<rho>) = (\<Sum>k = 0..<?k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<?k. trace (D0 k \<rho>))

goal (1 subgoal):
 1. (\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
have "trace ((wlp_while M0 M1 (wlp S) P) * \<rho>) = trace (P * (denote (While M S) \<rho>)) + trace \<rho> -  trace (denote (While M S) \<rho>)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. trace (wlp_while M0 M1 (wlp S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
using eqk[OF dsr] tendsto_unique[OF _ lim1 lim4]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>k. trace (W k * \<rho>)) \<longlonglongrightarrow> trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
trace (W ?k * \<rho>) = (\<Sum>k = 0..<?k. trace (P * D0 k \<rho>)) + trace \<rho> - (\<Sum>k = 0..<?k. trace (D0 k \<rho>))
sequentially \<noteq> bot \<Longrightarrow> trace (wlp_while M0 M1 (wlp S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. trace (wlp_while M0 M1 (wlp S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
trace (wlp_while M0 M1 (wlp S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (wlp_while M0 M1 (wlp S) P * ?\<rho>2) = trace (P * denote (While M S) ?\<rho>2) + trace ?\<rho>2 - trace (denote (While M S) ?\<rho>2)

goal (1 subgoal):
 1. \<And>x1 S P. \<lbrakk>\<And>P. \<lbrakk>well_com S; is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp S P * \<rho>) = trace (P * denote S \<rho>) + trace \<rho> - trace (denote S \<rho>); well_com (While x1 S); is_quantum_predicate P\<rbrakk> \<Longrightarrow> \<forall>\<rho>\<in>density_states. trace (wlp (While x1 S) P * \<rho>) = trace (P * denote (While x1 S) \<rho>) + trace \<rho> - trace (denote (While x1 S) \<rho>)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (wlp_while M0 M1 (wlp S) P * ?\<rho>2) = trace (P * denote (While M S) ?\<rho>2) + trace ?\<rho>2 - trace (denote (While M S) ?\<rho>2)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (wlp_while M0 M1 (wlp S) P * ?\<rho>2) = trace (P * denote (While M S) ?\<rho>2) + trace ?\<rho>2 - trace (denote (While M S) ?\<rho>2)

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp (While M S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
unfolding M0_def M1_def DS_def wlp.simps
[PROOF STATE]
proof (prove)
using this:
?\<rho>2 \<in> density_states \<Longrightarrow> trace (wlp_while (M 0) (M 1) (wlp S) P * ?\<rho>2) = trace (P * denote (While M S) ?\<rho>2) + trace ?\<rho>2 - trace (denote (While M S) ?\<rho>2)

goal (1 subgoal):
 1. \<forall>\<rho>\<in>density_states. trace (wlp_while (M 0) (M 1) (wlp S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>\<rho>\<in>density_states. trace (wlp (While M S) P * \<rho>) = trace (P * denote (While M S) \<rho>) + trace \<rho> - trace (denote (While M S) \<rho>)

goal:
No subgoals!
[PROOF STEP]
qed