[STATEMENT]
lemma "rec_InfTree leaf node (Node g) = node ((\<lambda>InfTree. (InfTree, rec_InfTree leaf node InfTree)) \<circ> g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rec_InfTree leaf node (InfTree.Node g) = node ((\<lambda>InfTree. (InfTree, rec_InfTree leaf node InfTree)) \<circ> g)
[PROOF STEP]
nitpick [card = 1-3, expect = none]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rec_InfTree leaf node (InfTree.Node g) = node ((\<lambda>InfTree. (InfTree, rec_InfTree leaf node InfTree)) \<circ> g)
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma ceiling_divide_upper:
  fixes q :: "'a::floor_ceiling"
  shows "q > 0 \<Longrightarrow> p \<le> of_int (ceiling (p / q)) * q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < q \<Longrightarrow> p \<le> of_int \<lceil>p / q\<rceil> * q
[PROOF STEP]
by (meson divide_le_eq le_of_int_ceiling)


[STATEMENT]
lemma i_Exec_Stream_Acc_LocalState__State_Idle_nth[rule_format]: "
  \<lbrakk> 0 < l; l \<le> k; Exec_Equal_State localState trans_fun;
    \<forall>n\<le>i. State_Idle localState output_fun trans_fun (
      i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n) \<rbrakk> \<Longrightarrow>
  i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c i =
  i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> i_Exec_Comp_Stream_Acc_LocalState k localState trans_fun input c i = i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c i
[PROOF STEP]
apply (simp only: f_Exec_Stream_Acc_LocalState_nth_eq_i_nth[of _ _ "Suc i", symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> f_Exec_Comp_Stream_Acc_LocalState k localState trans_fun (input \<Down> Suc i) c ! i = f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun (input \<Down> Suc i) c ! i
[PROOF STEP]
apply (rule f_Exec_Stream_Acc_LocalState__State_Idle_nth)
[PROOF STATE]
proof (prove)
goal (5 subgoals):
 1. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> 0 < l
 2. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> l \<le> k
 3. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> Exec_Equal_State localState trans_fun
 4. \<And>n. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n); n \<le> i\<rbrakk> \<Longrightarrow> State_Idle localState ?output_fun16 trans_fun (f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun (input \<Down> Suc i) c ! n)
 5. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> i < length (input \<Down> Suc i)
[PROOF STEP]
apply simp_all
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; \<forall>n\<le>i. State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n); n \<le> i\<rbrakk> \<Longrightarrow> State_Idle localState ?output_fun16 trans_fun (f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun (input \<Down> Suc i) c ! n)
[PROOF STEP]
apply (drule_tac x=n in spec)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>0 < l; l \<le> k; Exec_Equal_State localState trans_fun; n \<le> i; n \<le> i \<longrightarrow> State_Idle localState output_fun trans_fun (i_Exec_Comp_Stream_Acc_LocalState l localState trans_fun input c n)\<rbrakk> \<Longrightarrow> State_Idle localState ?output_fun16 trans_fun (f_Exec_Comp_Stream_Acc_LocalState l localState trans_fun (input \<Down> Suc i) c ! n)
[PROOF STEP]
apply (simp add: f_Exec_Stream_Acc_LocalState_nth_eq_i_nth)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma not_aand: "not (\<phi> aand \<psi>) = (not \<phi>) or (not \<psi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>xs. \<not> (\<phi> xs \<and> \<psi> xs)) = (\<lambda>xs. \<not> \<phi> xs \<or> \<not> \<psi> xs)
[PROOF STEP]
by blast


[STATEMENT]
lemma norm_\<nu>_le: "norm \<nu>\<^sub>b \<le> r\<^sub>M / (1-l)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm \<nu>\<^sub>b \<le> r\<^sub>M / (1 - l)
[PROOF STEP]
using abs_\<nu>_le sum_disc_lim
[PROOF STATE]
proof (prove)
using this:
\<bar>\<nu> ?s\<bar> \<le> (\<Sum>i. l ^ i * r\<^sub>M)
\<bar>?c\<bar> < 1 \<Longrightarrow> (\<Sum>x. ?c ^ x * ?B) = ?B / (1 - ?c)

goal (1 subgoal):
 1. norm \<nu>\<^sub>b \<le> r\<^sub>M / (1 - l)
[PROOF STEP]
by (auto simp: \<nu>\<^sub>b.rep_eq norm_bfun_def' intro: cSUP_least)


[STATEMENT]
lemma index_tensor_gate_unitary2 [simp]:
  assumes "gate m G1" and "gate n G2" and "i < dim_row (1\<^sub>m (dim_col G1 * dim_col G2))" and
"j < dim_col (1\<^sub>m (dim_col G1 * dim_col G2))"
  shows "((G1 \<Otimes> G2) * ((G1 \<Otimes> G2)\<^sup>\<dagger>)) $$ (i, j) = 1\<^sub>m(dim_col G1 * dim_col G2) $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "\<And>k. k<2^(m+n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i,k) =
G1 $$ (i div 2^n, k div 2^n) * G2 $$ (i mod 2^n, k mod 2^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. k < 2 ^ (m + n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, k) = G1 $$ (i div 2 ^ n, k div 2 ^ n) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n)
[PROOF STEP]
using assms(1-3)
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
i < dim_row (1\<^sub>m (dim_col G1 * dim_col G2))

goal (1 subgoal):
 1. \<And>k. k < 2 ^ (m + n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, k) = G1 $$ (i div 2 ^ n, k div 2 ^ n) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n)
[PROOF STEP]
by (simp add: gate_def power_add)
[PROOF STATE]
proof (state)
this:
?k < 2 ^ (m + n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
?k < 2 ^ (m + n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "\<And>k. k<2^(m+n) \<Longrightarrow> cnj((G1 \<Otimes> G2) $$ (j,k)) =
cnj(G1 $$ (j div 2^n, k div 2^n)) * cnj(G2 $$ (j mod 2^n, k mod 2^n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. k < 2 ^ (m + n) \<Longrightarrow> cnj ((G1 \<Otimes> G2) $$ (j, k)) = cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))
[PROOF STEP]
using assms(1,2,4)
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
j < dim_col (1\<^sub>m (dim_col G1 * dim_col G2))

goal (1 subgoal):
 1. \<And>k. k < 2 ^ (m + n) \<Longrightarrow> cnj ((G1 \<Otimes> G2) $$ (j, k)) = cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))
[PROOF STEP]
by (simp add: gate_def power_add)
[PROOF STATE]
proof (state)
this:
?k < 2 ^ (m + n) \<Longrightarrow> cnj ((G1 \<Otimes> G2) $$ (j, ?k)) = cnj (G1 $$ (j div 2 ^ n, ?k div 2 ^ n)) * cnj (G2 $$ (j mod 2 ^ n, ?k mod 2 ^ n))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
?k < 2 ^ (m + n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n)
?k < 2 ^ (m + n) \<Longrightarrow> cnj ((G1 \<Otimes> G2) $$ (j, ?k)) = cnj (G1 $$ (j div 2 ^ n, ?k div 2 ^ n)) * cnj (G2 $$ (j mod 2 ^ n, ?k mod 2 ^ n))
[PROOF STEP]
have "\<And>k. k\<in>{..<2^(m+n)} \<Longrightarrow> (G1 \<Otimes> G2) $$ (i,k) * cnj((G1 \<Otimes> G2) $$ (j,k)) =
                         G1 $$ (i div 2^n, k div 2^n) * cnj(G1 $$ (j div 2^n, k div 2^n)) *
                         G2 $$ (i mod 2^n, k mod 2^n) * cnj(G2 $$ (j mod 2^n, k mod 2^n))"
[PROOF STATE]
proof (prove)
using this:
?k < 2 ^ (m + n) \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n)
?k < 2 ^ (m + n) \<Longrightarrow> cnj ((G1 \<Otimes> G2) $$ (j, ?k)) = cnj (G1 $$ (j div 2 ^ n, ?k div 2 ^ n)) * cnj (G2 $$ (j mod 2 ^ n, ?k mod 2 ^ n))

goal (1 subgoal):
 1. \<And>k. k \<in> {..<2 ^ (m + n)} \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k)) = G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
?k \<in> {..<2 ^ (m + n)} \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) * cnj ((G1 \<Otimes> G2) $$ (j, ?k)) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, ?k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, ?k mod 2 ^ n))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
?k \<in> {..<2 ^ (m + n)} \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) * cnj ((G1 \<Otimes> G2) $$ (j, ?k)) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, ?k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, ?k mod 2 ^ n))
[PROOF STEP]
have "(\<Sum>k<2^(m+n). (G1 \<Otimes> G2) $$ (i,k) * cnj((G1 \<Otimes> G2) $$ (j,k))) =
      (\<Sum>k<2^(m+n). G1 $$ (i div 2^n, k div 2^n) * cnj(G1 $$ (j div 2^n, k div 2^n)) *
      G2 $$ (i mod 2^n, k mod 2^n) * cnj(G2 $$ (j mod 2^n, k mod 2^n)))"
[PROOF STATE]
proof (prove)
using this:
?k \<in> {..<2 ^ (m + n)} \<Longrightarrow> (G1 \<Otimes> G2) $$ (i, ?k) * cnj ((G1 \<Otimes> G2) $$ (j, ?k)) = G1 $$ (i div 2 ^ n, ?k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, ?k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, ?k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, ?k mod 2 ^ n))

goal (1 subgoal):
 1. (\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k))) = (\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k))) = (\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k))) = (\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "\<dots> =
             (\<Sum>k<2^m. G1 $$ (i div 2^n, k) * cnj(G1 $$ (j div 2^n, k))) *
             (\<Sum>k<2^n. G2 $$ (i mod 2^n, k) * cnj(G2 $$ (j mod 2^n, k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
[PROOF STEP]
using sum_prod[of "\<lambda>k. G1 $$ (i div 2^n, k) * cnj(G1 $$ (j div 2^n, k))" "2^n"
                        "\<lambda>k. G2 $$ (i mod 2^n, k) * cnj(G2 $$ (j mod 2^n, k))" "2^m"]
[PROOF STATE]
proof (prove)
using this:
(\<Sum>ia<2 ^ m * 2 ^ n. G1 $$ (i div 2 ^ n, ia div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, ia div 2 ^ n)) * (G2 $$ (i mod 2 ^ n, ia mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, ia mod 2 ^ n)))) = (\<Sum>ia<2 ^ m. G1 $$ (i div 2 ^ n, ia) * cnj (G1 $$ (j div 2 ^ n, ia))) * (\<Sum>ja<2 ^ n. G2 $$ (i mod 2 ^ n, ja) * cnj (G2 $$ (j mod 2 ^ n, ja)))

goal (1 subgoal):
 1. (\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
[PROOF STEP]
by (metis (no_types, lifting) power_add semigroup_mult_class.mult.assoc sum.cong)
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ (m + n). G1 $$ (i div 2 ^ n, k div 2 ^ n) * cnj (G1 $$ (j div 2 ^ n, k div 2 ^ n)) * G2 $$ (i mod 2 ^ n, k mod 2 ^ n) * cnj (G2 $$ (j mod 2 ^ n, k mod 2 ^ n))) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "((G1 \<Otimes> G2) * ((G1 \<Otimes> G2)\<^sup>\<dagger>)) $$ (i, j) = (\<Sum>k<2^(m+n). (G1 \<Otimes> G2) $$ (i,k) * cnj((G1 \<Otimes> G2) $$ (j,k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k)))
[PROOF STEP]
using assms index_matrix_prod[of "i" "(G1 \<Otimes> G2)" "j" "(G1 \<Otimes> G2)\<^sup>\<dagger>"] dagger_def
dim_row_of_tensor_gate tensor_gate_sqr_mat
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
i < dim_row (1\<^sub>m (dim_col G1 * dim_col G2))
j < dim_col (1\<^sub>m (dim_col G1 * dim_col G2))
\<lbrakk>i < dim_row (G1 \<Otimes> G2); j < dim_col G1 \<Otimes> G2\<^sup>\<dagger>; dim_col (G1 \<Otimes> G2) = dim_row G1 \<Otimes> G2\<^sup>\<dagger>\<rbrakk> \<Longrightarrow> ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<dim_row G1 \<Otimes> G2\<^sup>\<dagger>. (G1 \<Otimes> G2) $$ (i, k) * G1 \<Otimes> G2\<^sup>\<dagger> $$ (k, j))
?M\<^sup>\<dagger> \<equiv> Matrix.mat (dim_col ?M) (dim_row ?M) (\<lambda>(i, j). cnj (?M $$ (j, i)))
\<lbrakk>gate ?m ?G1.0; gate ?n ?G2.0\<rbrakk> \<Longrightarrow> dim_row (?G1.0 \<Otimes> ?G2.0) = 2 ^ (?m + ?n)
\<lbrakk>gate ?m ?G1.0; gate ?n ?G2.0\<rbrakk> \<Longrightarrow> square_mat (?G1.0 \<Otimes> ?G2.0)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k))) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k)))
[PROOF STEP]
have "((G1 \<Otimes> G2) * ((G1 \<Otimes> G2)\<^sup>\<dagger>)) $$ (i,j) =
             (\<Sum>k<2^m. G1 $$ (i div 2^n, k) * cnj(G1 $$ (j div 2^n, k))) *
             (\<Sum>k<2^n. G2 $$ (i mod 2^n, k) * cnj(G2 $$ (j mod 2^n, k)))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k))) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ (m + n). (G1 \<Otimes> G2) $$ (i, k) * cnj ((G1 \<Otimes> G2) $$ (j, k)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "(\<Sum>k<2^m. G1 $$ (i div 2^n, k) * cnj(G1 $$ (j div 2^n, k))) = (G1 * (G1\<^sup>\<dagger>)) $$ (i div 2^n, j div 2^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) = (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n)
[PROOF STEP]
using assms gate_def dagger_def index_matrix_prod[of "i div 2^n" "G1" "j div 2^n" "G1\<^sup>\<dagger>"]
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
i < dim_row (1\<^sub>m (dim_col G1 * dim_col G2))
j < dim_col (1\<^sub>m (dim_col G1 * dim_col G2))
gate ?n ?A \<equiv> dim_row ?A = 2 ^ ?n \<and> square_mat ?A \<and> unitary ?A
?M\<^sup>\<dagger> \<equiv> Matrix.mat (dim_col ?M) (dim_row ?M) (\<lambda>(i, j). cnj (?M $$ (j, i)))
\<lbrakk>i div 2 ^ n < dim_row G1; j div 2 ^ n < dim_col G1\<^sup>\<dagger>; dim_col G1 = dim_row G1\<^sup>\<dagger>\<rbrakk> \<Longrightarrow> (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = (\<Sum>k<dim_row G1\<^sup>\<dagger>. G1 $$ (i div 2 ^ n, k) * G1\<^sup>\<dagger> $$ (k, j div 2 ^ n))

goal (1 subgoal):
 1. (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) = (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n)
[PROOF STEP]
by (simp add: less_mult_imp_div_less power_add)
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) = (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) = (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "\<dots> = 1\<^sub>m(2^m) $$ (i div 2^n, j div 2^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n)
[PROOF STEP]
using assms(1,2) gate_def unitary_def
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
gate ?n ?A \<equiv> dim_row ?A = 2 ^ ?n \<and> square_mat ?A \<and> unitary ?A
unitary ?M \<equiv> ?M\<^sup>\<dagger> * ?M = 1\<^sub>m (dim_col ?M) \<and> ?M * ?M\<^sup>\<dagger> = 1\<^sub>m (dim_row ?M)

goal (1 subgoal):
 1. (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "(\<Sum>k<2^n. G2 $$ (i mod 2^n, k) * cnj(G2 $$ (j mod 2^n, k))) = (G2 * (G2\<^sup>\<dagger>)) $$ (i mod 2^n, j mod 2^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k))) = (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n)
[PROOF STEP]
using assms(1,2) gate_def dagger_def index_matrix_prod[of "i mod 2^n" "G2" "j mod 2^n" "G2\<^sup>\<dagger>"]
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
gate ?n ?A \<equiv> dim_row ?A = 2 ^ ?n \<and> square_mat ?A \<and> unitary ?A
?M\<^sup>\<dagger> \<equiv> Matrix.mat (dim_col ?M) (dim_row ?M) (\<lambda>(i, j). cnj (?M $$ (j, i)))
\<lbrakk>i mod 2 ^ n < dim_row G2; j mod 2 ^ n < dim_col G2\<^sup>\<dagger>; dim_col G2 = dim_row G2\<^sup>\<dagger>\<rbrakk> \<Longrightarrow> (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n) = (\<Sum>k<dim_row G2\<^sup>\<dagger>. G2 $$ (i mod 2 ^ n, k) * G2\<^sup>\<dagger> $$ (k, j mod 2 ^ n))

goal (1 subgoal):
 1. (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k))) = (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k))) = (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k))) = (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
have "\<dots> = 1\<^sub>m(2^n) $$ (i mod 2^n, j mod 2^n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n) = 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)
[PROOF STEP]
using assms(1,2) gate_def unitary_def
[PROOF STATE]
proof (prove)
using this:
gate m G1
gate n G2
gate ?n ?A \<equiv> dim_row ?A = 2 ^ ?n \<and> square_mat ?A \<and> unitary ?A
unitary ?M \<equiv> ?M\<^sup>\<dagger> * ?M = 1\<^sub>m (dim_col ?M) \<and> ?M * ?M\<^sup>\<dagger> = 1\<^sub>m (dim_row ?M)

goal (1 subgoal):
 1. (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n) = 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n) = 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
(\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) = (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n)
(G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n)
(\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k))) = (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n)
(G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n) = 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)
[PROOF STEP]
have "((G1 \<Otimes> G2) * ((G1 \<Otimes> G2)\<^sup>\<dagger>)) $$ (i,j) = 1\<^sub>m(2^m) $$ (i div 2^n, j div 2^n) * 1\<^sub>m(2^n) $$ (i mod 2^n, j mod 2^n)"
[PROOF STATE]
proof (prove)
using this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = (\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) * (\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k)))
(\<Sum>k<2 ^ m. G1 $$ (i div 2 ^ n, k) * cnj (G1 $$ (j div 2 ^ n, k))) = (G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n)
(G1 * G1\<^sup>\<dagger>) $$ (i div 2 ^ n, j div 2 ^ n) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n)
(\<Sum>k<2 ^ n. G2 $$ (i mod 2 ^ n, k) * cnj (G2 $$ (j mod 2 ^ n, k))) = (G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n)
(G2 * G2\<^sup>\<dagger>) $$ (i mod 2 ^ n, j mod 2 ^ n) = 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n) * 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n) * 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n) * 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
using assms gate_def index_one_mat_div_mod[of "i" "m" "n" "j"]
[PROOF STATE]
proof (prove)
using this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n) * 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n)
gate m G1
gate n G2
i < dim_row (1\<^sub>m (dim_col G1 * dim_col G2))
j < dim_col (1\<^sub>m (dim_col G1 * dim_col G2))
gate ?n ?A \<equiv> dim_row ?A = 2 ^ ?n \<and> square_mat ?A \<and> unitary ?A
\<lbrakk>i < 2 ^ (m + n); j < 2 ^ (m + n)\<rbrakk> \<Longrightarrow> 1\<^sub>m (2 ^ m) $$ (i div 2 ^ n, j div 2 ^ n) * 1\<^sub>m (2 ^ n) $$ (i mod 2 ^ n, j mod 2 ^ n) = 1\<^sub>m (2 ^ (m + n)) $$ (i, j)

goal (1 subgoal):
 1. ((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)
[PROOF STEP]
by(simp add: power_add)
[PROOF STATE]
proof (state)
this:
((G1 \<Otimes> G2) * G1 \<Otimes> G2\<^sup>\<dagger>) $$ (i, j) = 1\<^sub>m (dim_col G1 * dim_col G2) $$ (i, j)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma cf_comp_ObjMap_app[cat_cs_simps]:
  assumes "\<GG> : \<BB> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>" and "\<FF> : \<AA> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<BB>" and [simp]: "a \<in>\<^sub>\<circ> \<AA>\<lparr>Obj\<rparr>"
  shows "(\<GG> \<circ>\<^sub>C\<^sub>F \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<GG> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<GG> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>
[PROOF STEP]
interpret L: is_functor \<alpha> \<BB> \<CC> \<GG>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<GG> : \<BB> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<CC>
[PROOF STEP]
by (rule assms(1))
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<GG> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>
[PROOF STEP]
interpret R: is_functor \<alpha> \<AA> \<BB> \<FF>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<FF> : \<AA> \<mapsto>\<mapsto>\<^sub>C\<^bsub>\<alpha>\<^esub> \<BB>
[PROOF STEP]
by (rule assms(2))
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<GG> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<GG> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>
[PROOF STEP]
by
      (
        rule smcf_comp_ObjMap_app
          [
            OF L.cf_is_semifunctor R.cf_is_semifunctor,
            unfolded slicing_simps slicing_commute,
            OF assms(3)
          ]
      )
[PROOF STATE]
proof (state)
this:
(\<GG> \<circ>\<^sub>D\<^sub>G\<^sub>H\<^sub>M \<FF>)\<lparr>ObjMap\<rparr>\<lparr>a\<rparr> = \<GG>\<lparr>ObjMap\<rparr>\<lparr>\<FF>\<lparr>ObjMap\<rparr>\<lparr>a\<rparr>\<rparr>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma csqrt_principal: "0 < Re (csqrt z) \<or> Re (csqrt z) = 0 \<and> 0 \<le> Im (csqrt z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < Re (csqrt z) \<or> Re (csqrt z) = 0 \<and> 0 \<le> Im (csqrt z)
[PROOF STEP]
by (auto simp add: not_less cmod_plus_Re_le_0_iff Im_eq_0)


[STATEMENT]
lemma gen_paths_ss: "gen_paths \<subseteq> cycles \<union> paths \<union> {[v] | v. v \<in> V}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gen_paths \<subseteq> cycles \<union> paths \<union> {[v] |v. v \<in> V}
[PROOF STEP]
unfolding gen_paths_def cycles_def paths_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Collect is_gen_path \<subseteq> Collect is_cycle \<union> Collect is_path \<union> {[v] |v. v \<in> V}
[PROOF STEP]
using is_gen_path_options
[PROOF STATE]
proof (prove)
using this:
is_gen_path ?p = (is_cycle ?p \<or> is_path ?p \<or> (\<exists>v\<in>V. ?p = [v]))

goal (1 subgoal):
 1. Collect is_gen_path \<subseteq> Collect is_cycle \<union> Collect is_path \<union> {[v] |v. v \<in> V}
[PROOF STEP]
by auto


[STATEMENT]
lemma seq_comp_refusals_finite [rule_format]:
  assumes A: "xs \<in> Domain (seq_comp_failures P Q)"
  shows "finite A \<Longrightarrow> (\<forall>x \<in> A. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow>
    (xs, \<Union>x \<in> A. F x) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite A \<Longrightarrow> (\<forall>x\<in>A. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q
[PROOF STEP]
proof (erule finite_induct, simp, rule_tac [2] impI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (xs, {}) \<in> seq_comp_failures P Q
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
have "\<exists>X. (xs, X) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>X. (xs, X) \<in> seq_comp_failures P Q
[PROOF STEP]
using A
[PROOF STATE]
proof (prove)
using this:
xs \<in> Domain (seq_comp_failures P Q)

goal (1 subgoal):
 1. \<exists>X. (xs, X) \<in> seq_comp_failures P Q
[PROOF STEP]
by (simp add: Domain_iff)
[PROOF STATE]
proof (state)
this:
\<exists>X. (xs, X) \<in> seq_comp_failures P Q

goal (2 subgoals):
 1. (xs, {}) \<in> seq_comp_failures P Q
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>X. (xs, X) \<in> seq_comp_failures P Q
[PROOF STEP]
obtain X where "(xs, X) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
using this:
\<exists>X. (xs, X) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. (\<And>X. (xs, X) \<in> seq_comp_failures P Q \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(xs, X) \<in> seq_comp_failures P Q

goal (2 subgoals):
 1. (xs, {}) \<in> seq_comp_failures P Q
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(xs, X) \<in> seq_comp_failures P Q

goal (2 subgoals):
 1. (xs, {}) \<in> seq_comp_failures P Q
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
have "{} \<subseteq> X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {} \<subseteq> X
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
{} \<subseteq> X

goal (2 subgoals):
 1. (xs, {}) \<in> seq_comp_failures P Q
 2. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(xs, X) \<in> seq_comp_failures P Q
{} \<subseteq> X
[PROOF STEP]
show "(xs, {}) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
using this:
(xs, X) \<in> seq_comp_failures P Q
{} \<subseteq> X

goal (1 subgoal):
 1. (xs, {}) \<in> seq_comp_failures P Q
[PROOF STEP]
by (rule seq_comp_prop_3)
[PROOF STATE]
proof (state)
this:
(xs, {}) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
fix x' A
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
assume B: "\<forall>x \<in> insert x' A. (xs, F x) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>insert x' A. (xs, F x) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
hence "(xs, F x') \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>insert x' A. (xs, F x) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. (xs, F x') \<in> seq_comp_failures P Q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(xs, F x') \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(xs, F x') \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
assume "(\<forall>x \<in> A. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow>
    (xs, \<Union>x \<in> A. F x) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (state)
this:
(\<forall>x\<in>A. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
hence "(xs, \<Union>x \<in> A. F x) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>A. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. (xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q
[PROOF STEP]
using B
[PROOF STATE]
proof (prove)
using this:
(\<forall>x\<in>A. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q
\<forall>x\<in>insert x' A. (xs, F x) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. (xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(xs, F x') \<in> seq_comp_failures P Q
(xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q
[PROOF STEP]
have "(xs, F x' \<union> (\<Union>x \<in> A. F x)) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
using this:
(xs, F x') \<in> seq_comp_failures P Q
(xs, \<Union> (F ` A)) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. (xs, F x' \<union> \<Union> (F ` A)) \<in> seq_comp_failures P Q
[PROOF STEP]
by (rule SCF_R4)
[PROOF STATE]
proof (state)
this:
(xs, F x' \<union> \<Union> (F ` A)) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. \<And>x Fa. \<lbrakk>finite Fa; x \<notin> Fa; (\<forall>x\<in>Fa. (xs, F x) \<in> seq_comp_failures P Q) \<longrightarrow> (xs, \<Union> (F ` Fa)) \<in> seq_comp_failures P Q; \<forall>x\<in>insert x Fa. (xs, F x) \<in> seq_comp_failures P Q\<rbrakk> \<Longrightarrow> (xs, \<Union> (F ` insert x Fa)) \<in> seq_comp_failures P Q
[PROOF STEP]
thus "(xs, \<Union>x \<in> insert x' A. F x) \<in> seq_comp_failures P Q"
[PROOF STATE]
proof (prove)
using this:
(xs, F x' \<union> \<Union> (F ` A)) \<in> seq_comp_failures P Q

goal (1 subgoal):
 1. (xs, \<Union> (F ` insert x' A)) \<in> seq_comp_failures P Q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(xs, \<Union> (F ` insert x' A)) \<in> seq_comp_failures P Q

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma partition_on_disjoint:
  assumes "partition_on A P"
  assumes "partition_on B Q"
  assumes "A \<inter> B = {}"
  shows "P \<inter> Q = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P \<inter> Q = {}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
partition_on A P
partition_on B Q
A \<inter> B = {}

goal (1 subgoal):
 1. P \<inter> Q = {}
[PROOF STEP]
by (fastforce elim: partition_onE)


[STATEMENT]
lemma insertion_neg : "insertion f (-p) = -insertion f p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. insertion f (- p) = - insertion f p
[PROOF STEP]
by (metis add.inverse_inverse insertionNegative)


[STATEMENT]
lemma Gr_Image_image[simp]:
  shows "BNF_Def.Gr A f `` B = f ` (A \<inter> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. BNF_Def.Gr A f `` B = f ` (A \<inter> B)
[PROOF STEP]
unfolding BNF_Def.Gr_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(a, f a) |a. a \<in> A} `` B = f ` (A \<inter> B)
[PROOF STEP]
by auto


[STATEMENT]
lemma routing_ipassmt_distinct: "distinct (map fst (routing_ipassmt rtbl))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (map fst (routing_ipassmt rtbl))
[PROOF STEP]
using routing_ipassmt_wi_distinct[of rtbl]
[PROOF STATE]
proof (prove)
using this:
distinct (map fst (routing_ipassmt_wi rtbl))

goal (1 subgoal):
 1. distinct (map fst (routing_ipassmt rtbl))
[PROOF STEP]
unfolding routing_ipassmt_def
[PROOF STATE]
proof (prove)
using this:
distinct (map fst (routing_ipassmt_wi rtbl))

goal (1 subgoal):
 1. distinct (map fst (map ((apfst Iface \<circ>\<circ> apsnd) cidr_split) (routing_ipassmt_wi rtbl)))
[PROOF STEP]
apply(simp add: comp_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (map fst (routing_ipassmt_wi rtbl)) \<Longrightarrow> distinct (map (\<lambda>x. Iface (fst x)) (routing_ipassmt_wi rtbl))
[PROOF STEP]
apply(subst distinct_map[where f = Iface and xs = "map fst (routing_ipassmt_wi rtbl)", simplified, unfolded comp_def])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (map fst (routing_ipassmt_wi rtbl)) \<Longrightarrow> distinct (map fst (routing_ipassmt_wi rtbl)) \<and> inj_on Iface (fst ` set (routing_ipassmt_wi rtbl))
[PROOF STEP]
apply(auto intro: inj_onI)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma nonpos_upto_add: "nonpos_upto a t \<Longrightarrow> nonpos_upto b t \<Longrightarrow> nonpos_upto (a+b) t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>nonpos_upto a t; nonpos_upto b t\<rbrakk> \<Longrightarrow> nonpos_upto (a + b) t
[PROOF STEP]
by (auto intro: add_nonpos_nonpos simp: nonpos_upto_def)


[STATEMENT]
lemma iff_simps:
  "iff p p = T"
  "iff p (Not p) = F"
  "iff (Not p) p = F"
  "iff p F = not p"
  "iff F p = not p"
  "p \<noteq> Not T \<Longrightarrow> iff T p = p"
  "p\<noteq> Not T \<Longrightarrow> iff p T = p"
  "p\<noteq>q \<Longrightarrow> p\<noteq> Not q \<Longrightarrow> q\<noteq> Not p \<Longrightarrow> p\<noteq> F \<Longrightarrow> q\<noteq> F \<Longrightarrow> p \<noteq> T \<Longrightarrow> q \<noteq> T \<Longrightarrow> iff p q = Iff p q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((Ferrack.iff p p = T &&& Ferrack.iff p (fm.Not p) = F) &&& Ferrack.iff (fm.Not p) p = F &&& Ferrack.iff p F = Ferrack.not p) &&& (Ferrack.iff F p = Ferrack.not p &&& (p \<noteq> fm.Not T \<Longrightarrow> Ferrack.iff T p = p)) &&& (p \<noteq> fm.Not T \<Longrightarrow> Ferrack.iff p T = p) &&& (\<lbrakk>p \<noteq> q; p \<noteq> fm.Not q; q \<noteq> fm.Not p; p \<noteq> F; q \<noteq> F; p \<noteq> T; q \<noteq> T\<rbrakk> \<Longrightarrow> Ferrack.iff p q = Iff p q)
[PROOF STEP]
using trivNot
[PROOF STATE]
proof (prove)
using this:
?p \<noteq> fm.Not ?p
fm.Not ?p \<noteq> ?p

goal (1 subgoal):
 1. ((Ferrack.iff p p = T &&& Ferrack.iff p (fm.Not p) = F) &&& Ferrack.iff (fm.Not p) p = F &&& Ferrack.iff p F = Ferrack.not p) &&& (Ferrack.iff F p = Ferrack.not p &&& (p \<noteq> fm.Not T \<Longrightarrow> Ferrack.iff T p = p)) &&& (p \<noteq> fm.Not T \<Longrightarrow> Ferrack.iff p T = p) &&& (\<lbrakk>p \<noteq> q; p \<noteq> fm.Not q; q \<noteq> fm.Not p; p \<noteq> F; q \<noteq> F; p \<noteq> T; q \<noteq> T\<rbrakk> \<Longrightarrow> Ferrack.iff p q = Iff p q)
[PROOF STEP]
by (simp_all add: iff_def, cases p, auto)


[STATEMENT]
lemma lossless_iff_set_pmf_None:
  "lossless_spmf p \<longleftrightarrow> None \<notin> set_pmf p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lossless_spmf p = (None \<notin> set_pmf p)
[PROOF STEP]
by (simp add: lossless_iff_pmf_None pmf_eq_0_set_pmf)


[STATEMENT]
lemma nth_eq_iff_index_eq:
  "\<lbrakk> distinct xs; i < length xs; j < length xs \<rbrakk> \<Longrightarrow> (xs!i = xs!j) = (i = j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>distinct xs; i < length xs; j < length xs\<rbrakk> \<Longrightarrow> (xs ! i = xs ! j) = (i = j)
[PROOF STEP]
by(auto simp: distinct_conv_nth)


[STATEMENT]
lemma open_Inter [continuous_intros, intro]: "finite S \<Longrightarrow> \<forall>T\<in>S. open T \<Longrightarrow> open (\<Inter>S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; Ball S open\<rbrakk> \<Longrightarrow> open (\<Inter> S)
[PROOF STEP]
by (induction set: finite) auto


[STATEMENT]
lemma union_subseteqIr: "\<lbrakk>A \<union> B \<subseteq> C; B' \<subseteq> B\<rbrakk>  \<Longrightarrow>   A \<union> B' \<subseteq> C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<union> B \<subseteq> C; B' \<subseteq> B\<rbrakk> \<Longrightarrow> A \<union> B' \<subseteq> C
[PROOF STEP]
by blast


[STATEMENT]
lemma sums_finite:
  assumes [simp]: "finite N"
    and f: "\<And>n. n \<notin> N \<Longrightarrow> f n = 0"
  shows "f sums (\<Sum>n\<in>N. f n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f sums sum f N
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f sums sum f N
[PROOF STEP]
have eq: "sum f {..<n + Suc (Max N)} = sum f N" for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f {..<n + Suc (Max N)} = sum f N
[PROOF STEP]
by (rule sum.mono_neutral_right) (auto simp: add_increasing less_Suc_eq_le f)
[PROOF STATE]
proof (state)
this:
sum f {..<?n + Suc (Max N)} = sum f N

goal (1 subgoal):
 1. f sums sum f N
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f sums sum f N
[PROOF STEP]
unfolding sums_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>n. sum f {..<n}) \<longlonglongrightarrow> sum f N
[PROOF STEP]
by (rule LIMSEQ_offset[of _ "Suc (Max N)"])
      (simp add: eq atLeast0LessThan del: add_Suc_right)
[PROOF STATE]
proof (state)
this:
f sums sum f N

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma deleteMin_correct:
  assumes INV: "invar q"
  assumes NE: "q \<noteq> Nil"
  shows
  "invar (deleteMin q)"
  "queue_to_multiset (deleteMin q) = queue_to_multiset q - {# (findMin q) #}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. invar (deleteMin q) &&& queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
using deleteMin_invar deleteMin_mset INV NE
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>invar ?bq; ?bq \<noteq> []\<rbrakk> \<Longrightarrow> invar (deleteMin ?bq)
\<lbrakk>queue_invar ?q; ?q \<noteq> []\<rbrakk> \<Longrightarrow> queue_to_multiset (deleteMin ?q) = queue_to_multiset ?q - {#findMin ?q#}
invar q
q \<noteq> []

goal (1 subgoal):
 1. invar (deleteMin q) &&& queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
unfolding invar_def
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>queue_invar ?bq \<and> rank_invar ?bq; ?bq \<noteq> []\<rbrakk> \<Longrightarrow> queue_invar (deleteMin ?bq) \<and> rank_invar (deleteMin ?bq)
\<lbrakk>queue_invar ?q; ?q \<noteq> []\<rbrakk> \<Longrightarrow> queue_to_multiset (deleteMin ?q) = queue_to_multiset ?q - {#findMin ?q#}
queue_invar q \<and> rank_invar q
q \<noteq> []

goal (1 subgoal):
 1. queue_invar (deleteMin q) \<and> rank_invar (deleteMin q) &&& queue_to_multiset (deleteMin q) = queue_to_multiset q - {#findMin q#}
[PROOF STEP]
by auto


[STATEMENT]
lemma nn_integral_set_ennreal:
  "(\<integral>\<^sup>+x. ennreal (f x) * indicator A x \<partial>M) = (\<integral>\<^sup>+x. ennreal (f x * indicator A x) \<partial>M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<integral>\<^sup>+ x. ennreal (f x) * indicator A x \<partial>M = \<integral>\<^sup>+ x. ennreal (f x * indicat_real A x) \<partial>M
[PROOF STEP]
by (rule nn_integral_cong) (simp split: split_indicator)


[STATEMENT]
lemma H_cond_iff2[simp]: "PRE p (IF r THEN x ELSE y FI) POST q \<longleftrightarrow> (PRE (p \<sqinter> r) x POST q) \<and> (PRE (p \<sqinter> - r) y POST q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. PRE p (IF r THEN x ELSE y FI) POST q = (PRE p \<sqinter> r x POST q \<and> PRE p \<sqinter> - r y POST q)
[PROOF STEP]
by (simp add: rel_kat.H_cond_iff)


[STATEMENT]
lemma problem_plan_bound_s_works:
  fixes PROB :: "'a problem" and as s
  assumes "finite PROB" "(as \<in> valid_plans PROB)" "(s \<in> valid_states PROB)"
  shows "(\<exists>as'.
    (exec_plan s as = exec_plan s as')
    \<and> (subseq as' as)
    \<and> (length as' \<le> problem_plan_bound_s PROB s)
  )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
have "problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1
[PROOF STEP]
using assms(1, 3) bound_main_lemma_s
[PROOF STATE]
proof (prove)
using this:
finite PROB
s \<in> valid_states PROB
\<lbrakk>finite ?PROB; ?s \<in> valid_states ?PROB\<rbrakk> \<Longrightarrow> problem_plan_bound_s ?PROB ?s \<le> 2 ^ card (prob_dom ?PROB) - 1

goal (1 subgoal):
 1. problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1
[PROOF STEP]
have 1: "Inf (PLS s as) \<le> problem_plan_bound_s PROB s"
[PROOF STATE]
proof (prove)
using this:
problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1

goal (1 subgoal):
 1. Inf (PLS s as) \<le> problem_plan_bound_s PROB s
[PROOF STEP]
using assms problem_plan_bound_s_ge_min_pls[of PROB s as " 2 ^ card (prob_dom PROB) - 1"]
[PROOF STATE]
proof (prove)
using this:
problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1
finite PROB
as \<in> valid_plans PROB
s \<in> valid_states PROB
\<lbrakk>finite PROB; s \<in> valid_states PROB; as \<in> valid_plans PROB; problem_plan_bound_s PROB s \<le> 2 ^ card (prob_dom PROB) - 1\<rbrakk> \<Longrightarrow> Inf (PLS s as) \<le> problem_plan_bound_s PROB s

goal (1 subgoal):
 1. Inf (PLS s as) \<le> problem_plan_bound_s PROB s
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Inf (PLS s as) \<le> problem_plan_bound_s PROB s

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Inf (PLS s as) \<le> problem_plan_bound_s PROB s
[PROOF STEP]
obtain x where obtain_x: "x \<in> PLS s as \<and> x = Inf (PLS s as)"
[PROOF STATE]
proof (prove)
using this:
Inf (PLS s as) \<le> problem_plan_bound_s PROB s

goal (1 subgoal):
 1. (\<And>x. x \<in> PLS s as \<and> x = Inf (PLS s as) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using PLS_nempty_and_has_min
[PROOF STATE]
proof (prove)
using this:
Inf (PLS s as) \<le> problem_plan_bound_s PROB s
\<exists>x. x \<in> PLS ?s ?as \<and> x = Inf (PLS ?s ?as)

goal (1 subgoal):
 1. (\<And>x. x \<in> PLS s as \<and> x = Inf (PLS s as) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> PLS s as \<and> x = Inf (PLS s as)

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> PLS s as \<and> x = Inf (PLS s as)
[PROOF STEP]
have "\<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as"
[PROOF STATE]
proof (prove)
using this:
x \<in> PLS s as \<and> x = Inf (PLS s as)

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as
[PROOF STEP]
using PLS_works[where s = s and as = as and x = "Inf (PLS s as)"]
      obtain_x
[PROOF STATE]
proof (prove)
using this:
x \<in> PLS s as \<and> x = Inf (PLS s as)
Inf (PLS s as) \<in> PLS s as \<Longrightarrow> \<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as
x \<in> PLS s as \<and> x = Inf (PLS s as)

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as
[PROOF STEP]
show "(\<exists>as'.
    (exec_plan s as = exec_plan s as') \<and> (subseq as' as)
    \<and> (length as' \<le> problem_plan_bound_s PROB s)
  )"
[PROOF STATE]
proof (prove)
using this:
\<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
using 1
[PROOF STATE]
proof (prove)
using this:
\<exists>as'. exec_plan s as = exec_plan s as' \<and> length as' = Inf (PLS s as) \<and> subseq as' as
Inf (PLS s as) \<le> problem_plan_bound_s PROB s

goal (1 subgoal):
 1. \<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>as'. exec_plan s as = exec_plan s as' \<and> subseq as' as \<and> length as' \<le> problem_plan_bound_s PROB s

goal:
No subgoals!
[PROOF STEP]
qed

\<comment> \<open>NOTE skipped second declaration (declared twice in source).\<close>


[STATEMENT]
lemma analz_list_set (*[simp]*):
  "\<not>(\<exists> K . Key K \<in> analz (L`ls))
    \<Longrightarrow> analz (L`ls) =  (L`ls) \<union> (\<Union>l \<in> ls. analz (set l)) "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<nexists>K. Key K \<in> analz (L ` ls) \<Longrightarrow> analz (L ` ls) = L ` ls \<union> (\<Union>l\<in>ls. analz (set l))
[PROOF STEP]
apply (rule equalityI, rule subsetI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>x. \<lbrakk>\<nexists>K. Key K \<in> analz (L ` ls); x \<in> analz (L ` ls)\<rbrakk> \<Longrightarrow> x \<in> L ` ls \<union> (\<Union>l\<in>ls. analz (set l))
 2. \<nexists>K. Key K \<in> analz (L ` ls) \<Longrightarrow> L ` ls \<union> (\<Union>l\<in>ls. analz (set l)) \<subseteq> analz (L ` ls)
[PROOF STEP]
apply (erule analz.induct, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x l. \<lbrakk>\<forall>K. Key K \<notin> analz (L ` ls); l \<in> ls; x \<in> analz (set l)\<rbrakk> \<Longrightarrow> x \<in> analz (L ` ls)
[PROOF STEP]
using L_analz image_subset_iff analz_increasing analz_trans
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>L ?l \<in> analz ?H; set ?l \<subseteq> analz ?H \<Longrightarrow> ?P\<rbrakk> \<Longrightarrow> ?P
(?f ` ?A \<subseteq> ?B) = (\<forall>x\<in>?A. ?f x \<in> ?B)
?H \<subseteq> analz ?H
\<lbrakk>?X \<in> analz ?G; ?G \<subseteq> analz ?H\<rbrakk> \<Longrightarrow> ?X \<in> analz ?H

goal (1 subgoal):
 1. \<And>x l. \<lbrakk>\<forall>K. Key K \<notin> analz (L ` ls); l \<in> ls; x \<in> analz (set l)\<rbrakk> \<Longrightarrow> x \<in> analz (L ` ls)
[PROOF STEP]
by metis


[STATEMENT]
lemma one_is_id:
  assumes "m \<in> M"
  shows "(\<phi> \<one>) m = m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
from grouphom
[PROOF STATE]
proof (chain)
picking this:
group_hom G (BijGroup M) \<phi>
[PROOF STEP]
have "(\<phi> \<one>) m = \<one>\<^bsub>(BijGroup M)\<^esub> m"
[PROOF STATE]
proof (prove)
using this:
group_hom G (BijGroup M) \<phi>

goal (1 subgoal):
 1. \<phi> \<one> m = \<one>\<^bsub>BijGroup M\<^esub> m
[PROOF STEP]
by (metis group_hom.hom_one)
[PROOF STATE]
proof (state)
this:
\<phi> \<one> m = \<one>\<^bsub>BijGroup M\<^esub> m

goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<phi> \<one> m = \<one>\<^bsub>BijGroup M\<^esub> m

goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
have "... = (\<lambda>x\<in>M. x) m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one>\<^bsub>BijGroup M\<^esub> m = (\<lambda>x\<in>M. x) m
[PROOF STEP]
unfolding BijGroup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<one>\<^bsub>\<lparr>carrier = Bij M, monoid.mult = \<lambda>g\<in>Bij M. restrict (compose M g) (Bij M), one = \<lambda>x\<in>M. x\<rparr>\<^esub> m = (\<lambda>x\<in>M. x) m
[PROOF STEP]
by (metis monoid.select_convs(2))
[PROOF STATE]
proof (state)
this:
\<one>\<^bsub>BijGroup M\<^esub> m = (\<lambda>x\<in>M. x) m

goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<one>\<^bsub>BijGroup M\<^esub> m = (\<lambda>x\<in>M. x) m

goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
m \<in> M
[PROOF STEP]
have "... = m"
[PROOF STATE]
proof (prove)
using this:
m \<in> M

goal (1 subgoal):
 1. (\<lambda>x\<in>M. x) m = m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>x\<in>M. x) m = m

goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<phi> \<one> m = m
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<phi> \<one> m = m

goal (1 subgoal):
 1. \<phi> \<one> m = m
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
\<phi> \<one> m = m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_list_replicate_length' [simp]:
  "sum_list (replicate n (Suc 0)) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum_list (replicate n (Suc 0)) = n
[PROOF STEP]
by (induct n) simp_all


[STATEMENT]
lemma in_Fvars_psubstD:
  assumes "y \<in> Fvars (psubst \<phi> txs)"
    and "\<phi> \<in> fmla" and "snd ` (set txs) \<subseteq> var" and "fst ` (set txs) \<subseteq> trm"
    and "distinct (map snd txs)"
  shows "y \<in> (Fvars \<phi> - snd ` (set txs)) \<union>
           (\<Union> {if x \<in> Fvars \<phi> then FvarsT t else {} | t x . (t,x) \<in> set txs})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<in> Fvars \<phi> - snd ` set txs \<union> \<Union> {if x \<in> Fvars \<phi> then FvarsT t else {} |t x. (t, x) \<in> set txs}
[PROOF STEP]
using assms Fvars_psubst
[PROOF STATE]
proof (prove)
using this:
y \<in> Fvars (psubst \<phi> txs)
\<phi> \<in> fmla
snd ` set txs \<subseteq> var
fst ` set txs \<subseteq> trm
distinct (map snd txs)
\<lbrakk>?\<phi> \<in> fmla; snd ` set ?txs \<subseteq> var; fst ` set ?txs \<subseteq> trm; distinct (map snd ?txs)\<rbrakk> \<Longrightarrow> Fvars (psubst ?\<phi> ?txs) = Fvars ?\<phi> - snd ` set ?txs \<union> \<Union> {if x \<in> Fvars ?\<phi> then FvarsT t else {} |t x. (t, x) \<in> set ?txs}

goal (1 subgoal):
 1. y \<in> Fvars \<phi> - snd ` set txs \<union> \<Union> {if x \<in> Fvars \<phi> then FvarsT t else {} |t x. (t, x) \<in> set txs}
[PROOF STEP]
by auto


[STATEMENT]
lemma mss_rec_naive_max_mid_sum: "mss_rec_naive xs = Max (mid_sums xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mss_rec_naive xs = Max (mid_sums xs)
[PROOF STEP]
by (induction xs) (simp add: mid_sums_def mids_def, auto simp: max_mid_sums_cons mss_rec_naive_aux front_sums)


[STATEMENT]
lemma \<phi>_in_terms_of_\<eta>o:
    assumes "D.ide y" and "\<guillemotleft>f : F y \<rightarrow>\<^sub>C x\<guillemotright>"
    shows "\<phi> y f = G f \<cdot>\<^sub>D \<eta>o y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<phi> y f = G f \<cdot>\<^sub>D \<eta>o y
[PROOF STEP]
proof (unfold \<eta>o_def)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)
[PROOF STEP]
have 1: "\<guillemotleft>F y : F y \<rightarrow>\<^sub>C F y\<guillemotright>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<guillemotleft>F y : F y \<rightarrow>\<^sub>C F y\<guillemotright>
[PROOF STEP]
using assms(1) D.ide_in_hom
[PROOF STATE]
proof (prove)
using this:
D.ide y
D.ide ?a = \<guillemotleft>?a : ?a \<rightarrow>\<^sub>D ?a\<guillemotright>

goal (1 subgoal):
 1. \<guillemotleft>F y : F y \<rightarrow>\<^sub>C F y\<guillemotright>
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<guillemotleft>F y : F y \<rightarrow>\<^sub>C F y\<guillemotright>

goal (1 subgoal):
 1. \<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)
[PROOF STEP]
hence "\<phi> y (F y) = \<phi> y (F y) \<cdot>\<^sub>D y"
[PROOF STATE]
proof (prove)
using this:
\<guillemotleft>F y : F y \<rightarrow>\<^sub>C F y\<guillemotright>

goal (1 subgoal):
 1. \<phi> y (F y) = \<phi> y (F y) \<cdot>\<^sub>D y
[PROOF STEP]
by (metis assms(1) D.in_homE \<phi>_in_hom D.comp_arr_dom)
[PROOF STATE]
proof (state)
this:
\<phi> y (F y) = \<phi> y (F y) \<cdot>\<^sub>D y

goal (1 subgoal):
 1. \<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)
[PROOF STEP]
thus "\<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)"
[PROOF STATE]
proof (prove)
using this:
\<phi> y (F y) = \<phi> y (F y) \<cdot>\<^sub>D y

goal (1 subgoal):
 1. \<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)
[PROOF STEP]
using assms 1 D.ide_in_hom
[PROOF STATE]
proof (prove)
using this:
\<phi> y (F y) = \<phi> y (F y) \<cdot>\<^sub>D y
D.ide y
\<guillemotleft>f : F y \<rightarrow>\<^sub>C x\<guillemotright>
\<guillemotleft>F y : F y \<rightarrow>\<^sub>C F y\<guillemotright>
D.ide ?a = \<guillemotleft>?a : ?a \<rightarrow>\<^sub>D ?a\<guillemotright>

goal (1 subgoal):
 1. \<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)
[PROOF STEP]
by (metis C.comp_arr_dom C.in_homE \<phi>_naturality)
[PROOF STATE]
proof (state)
this:
\<phi> y f = G f \<cdot>\<^sub>D \<phi> y (F y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma word_power_mod_div:
  fixes x :: "'a::len word"
  shows "\<lbrakk> n < LENGTH('a); m < LENGTH('a)\<rbrakk>
  \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < LENGTH('a); m < LENGTH('a)\<rbrakk> \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
[PROOF STEP]
apply (simp add: word_arith_nat_div unat_mod power_mod_div)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < LENGTH('a); m < LENGTH('a)\<rbrakk> \<Longrightarrow> word_of_nat (unat x div 2 ^ m mod 2 ^ (n - m)) = word_of_nat (unat x div 2 ^ m) mod 2 ^ (n - m)
[PROOF STEP]
apply (subst unat_arith_simps(3))
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < LENGTH('a); m < LENGTH('a)\<rbrakk> \<Longrightarrow> unat (word_of_nat (unat x div 2 ^ m mod 2 ^ (n - m))) = unat (word_of_nat (unat x div 2 ^ m) mod 2 ^ (n - m))
[PROOF STEP]
apply (subst unat_mod)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < LENGTH('a); m < LENGTH('a)\<rbrakk> \<Longrightarrow> unat (word_of_nat (unat x div 2 ^ m mod 2 ^ (n - m))) = unat (word_of_nat (unat x div 2 ^ m)) mod unat (2 ^ (n - m))
[PROOF STEP]
apply (subst unat_of_nat)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n < LENGTH('a); m < LENGTH('a)\<rbrakk> \<Longrightarrow> unat x div 2 ^ m mod 2 ^ (n - m) mod 2 ^ LENGTH('a) = unat x div 2 ^ m mod 2 ^ LENGTH('a) mod unat (2 ^ (n - m))
[PROOF STEP]
apply (simp add: mod_mod_power min.commute)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma left_inverse_linear:
  assumes lf: "linear scale scale f"
    and gf: "g \<circ> f = id"
  shows "linear scale scale g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
from gf
[PROOF STATE]
proof (chain)
picking this:
g \<circ> f = id
[PROOF STEP]
have fi: "inj f"
[PROOF STATE]
proof (prove)
using this:
g \<circ> f = id

goal (1 subgoal):
 1. inj f
[PROOF STEP]
by (auto simp add: inj_on_def o_def id_def fun_eq_iff) metis
[PROOF STATE]
proof (state)
this:
inj f

goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
interpret finite_dimensional_vector_space_pair scale Basis scale Basis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite_dimensional_vector_space_pair (*s) Basis (*s) Basis
[PROOF STEP]
by unfold_locales
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
from linear_injective_isomorphism[OF lf fi]
[PROOF STATE]
proof (chain)
picking this:
dim UNIV = dim UNIV \<Longrightarrow> \<exists>f'. linear (*s) (*s) f' \<and> (\<forall>x. f' (f x) = x) \<and> (\<forall>x. f (f' x) = x)
[PROOF STEP]
obtain h :: "'b \<Rightarrow> 'b" where "linear scale scale h" and h: "\<forall>x. h (f x) = x" "\<forall>x. f (h x) = x"
[PROOF STATE]
proof (prove)
using this:
dim UNIV = dim UNIV \<Longrightarrow> \<exists>f'. linear (*s) (*s) f' \<and> (\<forall>x. f' (f x) = x) \<and> (\<forall>x. f (f' x) = x)

goal (1 subgoal):
 1. (\<And>h. \<lbrakk>linear (*s) (*s) h; \<forall>x. h (f x) = x; \<forall>x. f (h x) = x\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
linear (*s) (*s) h
\<forall>x. h (f x) = x
\<forall>x. f (h x) = x

goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
have "h = g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. h = g
[PROOF STEP]
by (metis gf h isomorphism_expand left_right_inverse_eq)
[PROOF STATE]
proof (state)
this:
h = g

goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
with \<open>linear scale scale h\<close>
[PROOF STATE]
proof (chain)
picking this:
linear (*s) (*s) h
h = g
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
linear (*s) (*s) h
h = g

goal (1 subgoal):
 1. linear (*s) (*s) g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
linear (*s) (*s) g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma vle_trans [trans]: "\<lbrakk>x \<unlhd> y; y \<unlhd> z\<rbrakk> \<Longrightarrow> x \<unlhd> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<unlhd> y; y \<unlhd> z\<rbrakk> \<Longrightarrow> x \<unlhd> z
[PROOF STEP]
by (metis add.assoc vle_def)


[STATEMENT]
theorem lang\<^sub>W\<^sub>S\<^sub>1\<^sub>S_rexp_of': "wf_formula n \<phi> \<Longrightarrow> lang\<^sub>W\<^sub>S\<^sub>1\<^sub>S n \<phi> = lang n (rexp_of' n \<phi>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_formula n \<phi> \<Longrightarrow> lang\<^sub>W\<^sub>S\<^sub>1\<^sub>S n \<phi> = lang n (rexp_of' n \<phi>)
[PROOF STEP]
unfolding lang\<^sub>W\<^sub>S\<^sub>1\<^sub>S_rexp_of_rexp_of'[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. wf_formula n \<phi> \<Longrightarrow> lang\<^sub>W\<^sub>S\<^sub>1\<^sub>S n \<phi> = lang n (rexp_of n \<phi>)
[PROOF STEP]
by (rule lang\<^sub>W\<^sub>S\<^sub>1\<^sub>S_rexp_of)


[STATEMENT]
lemma RG_proj_mult_right :
  "x \<in> (group_ring :: ('r::ring_1, 'g) aezfun set)
        \<Longrightarrow> RG_proj (y * x) = RG_proj y * x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> group_ring \<Longrightarrow> RG_proj (y * x) = RG_proj y * x
[PROOF STEP]
using RG_el_decomp_aezdeltafun sum_list_const_mult_prod[of y "\<lambda>r g. r \<delta>\<delta> g"]
        RG_proj_sum_list_prod[of "\<lambda>r g. y * (r \<delta>\<delta> g)"] RG_proj_mult_rightdelta[of _ y]
        sum_list_prod_cong[
          of _ "\<lambda>r g. RG_proj (y * (r \<delta>\<delta> g))" "\<lambda>r g. RG_proj y * (r \<delta>\<delta> g)"
        ]
        sum_list_const_mult_prod[of "RG_proj y" "\<lambda>r g. r \<delta>\<delta> g"]
[PROOF STATE]
proof (prove)
using this:
?c \<in> group_ring \<Longrightarrow> \<exists>ras. set (map snd ras) \<subseteq> G \<and> ?c = (\<Sum>(r, a)\<leftarrow>ras. r \<delta>\<delta> a)
y * (\<Sum>(x, y)\<leftarrow>?xys. x \<delta>\<delta> y) = (\<Sum>(x, ya)\<leftarrow>?xys. y * (x \<delta>\<delta> ya))
RG_proj (\<Sum>(x, ya)\<leftarrow>?xys. y * (x \<delta>\<delta> ya)) = (\<Sum>(x, ya)\<leftarrow>?xys. RG_proj (y * (x \<delta>\<delta> ya)))
?g \<in> G \<Longrightarrow> RG_proj (y * (?r \<delta>\<delta> ?g)) = RG_proj y * (?r \<delta>\<delta> ?g)
\<forall>(x, ya)\<in>set ?xys. RG_proj (y * (x \<delta>\<delta> ya)) = RG_proj y * (x \<delta>\<delta> ya) \<Longrightarrow> (\<Sum>(x, ya)\<leftarrow>?xys. RG_proj (y * (x \<delta>\<delta> ya))) = (\<Sum>(x, ya)\<leftarrow>?xys. RG_proj y * (x \<delta>\<delta> ya))
RG_proj y * (\<Sum>(x, y)\<leftarrow>?xys. x \<delta>\<delta> y) = (\<Sum>(x, ya)\<leftarrow>?xys. RG_proj y * (x \<delta>\<delta> ya))

goal (1 subgoal):
 1. x \<in> group_ring \<Longrightarrow> RG_proj (y * x) = RG_proj y * x
[PROOF STEP]
by    fastforce


[STATEMENT]
lemma open_Inter [continuous_intros, intro]: "finite S \<Longrightarrow> \<forall>T\<in>S. open T \<Longrightarrow> open (\<Inter>S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>finite S; Ball S open\<rbrakk> \<Longrightarrow> open (\<Inter> S)
[PROOF STEP]
by (induction set: finite) auto


[STATEMENT]
lemma pderiv_mult: "pderiv (p * q) = p * pderiv q + q * pderiv p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pderiv (p * q) = p * pderiv q + q * pderiv p
[PROOF STEP]
by (induct p) (auto simp: pderiv_add pderiv_smult pderiv_pCons algebra_simps)


[STATEMENT]
lemma Exists_in_sub_DISJ: "Exists x Q' \<in> sub (DISJ \<Q>) \<Longrightarrow> finite \<Q> \<Longrightarrow> (\<exists>Q \<in> \<Q>. Exists x Q' \<in> sub Q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Exists x Q' \<in> sub (DISJ \<Q>); finite \<Q>\<rbrakk> \<Longrightarrow> \<exists>Q\<in>\<Q>. Exists x Q' \<in> sub Q
[PROOF STEP]
unfolding DISJ_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Exists x Q' \<in> sub (foldr1 Disj (sorted_list_of_set \<Q>) (Bool False)); finite \<Q>\<rbrakk> \<Longrightarrow> \<exists>Q\<in>\<Q>. Exists x Q' \<in> sub Q
[PROOF STEP]
by (drule Exists_in_sub_foldr1_Disj) auto


[STATEMENT]
lemma ordered_resolvent_upon_is_resolvent :
  assumes "strictly_maximal_literal P1 (Pos A)"
  assumes "strictly_maximal_literal P2 (Neg A)"
  shows "ordered_resolvent P1 P2 (resolvent_upon P1 P2 A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ordered_resolvent P1 P2 (resolvent_upon P1 P2 A)
[PROOF STEP]
using assms ordered_resolvent_def
[PROOF STATE]
proof (prove)
using this:
strictly_maximal_literal P1 (Pos A)
strictly_maximal_literal P2 (Neg A)
ordered_resolvent ?P1.0 ?P2.0 ?C \<equiv> \<exists>A. ?C = ?P1.0 - {Pos A} \<union> (?P2.0 - {Neg A}) \<and> strictly_maximal_literal ?P1.0 (Pos A) \<and> strictly_maximal_literal ?P2.0 (Neg A)

goal (1 subgoal):
 1. ordered_resolvent P1 P2 (resolvent_upon P1 P2 A)
[PROOF STEP]
by auto


[STATEMENT]
lemma dist_cancel_add1: "dist (t0 + et) t0 = norm et"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (t0 + et) t0 = norm et
[PROOF STEP]
by (simp add: dist_norm)


[STATEMENT]
lemma algebraic_int_cnj [intro]:
  assumes "algebraic_int x"
  shows   "algebraic_int (cnj x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int (cnj x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. algebraic_int (cnj x)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
algebraic_int x
[PROOF STEP]
obtain p where p: "lead_coeff p = 1" "\<forall>i. coeff p i \<in> \<int>" "poly p x = 0"
[PROOF STATE]
proof (prove)
using this:
algebraic_int x

goal (1 subgoal):
 1. (\<And>p. \<lbrakk>lead_coeff p = 1; \<forall>i. coeff p i \<in> \<int>; poly p x = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: algebraic_int.simps)
[PROOF STATE]
proof (state)
this:
lead_coeff p = 1
\<forall>i. coeff p i \<in> \<int>
poly p x = 0

goal (1 subgoal):
 1. algebraic_int (cnj x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic_int (cnj x)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. lead_coeff ?p = 1
 2. \<forall>i. coeff ?p i \<in> \<int>
 3. poly ?p (cnj x) = 0
[PROOF STEP]
show "poly (map_poly cnj p) (cnj x) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (map_poly cnj p) (cnj x) = 0
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
lead_coeff p = 1
\<forall>i. coeff p i \<in> \<int>
poly p x = 0

goal (1 subgoal):
 1. poly (map_poly cnj p) (cnj x) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
poly (map_poly cnj p) (cnj x) = 0

goal (2 subgoals):
 1. lead_coeff (map_poly cnj p) = 1
 2. \<forall>i. coeff (map_poly cnj p) i \<in> \<int>
[PROOF STEP]
show "lead_coeff (map_poly cnj p) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lead_coeff (map_poly cnj p) = 1
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
lead_coeff p = 1
\<forall>i. coeff p i \<in> \<int>
poly p x = 0

goal (1 subgoal):
 1. lead_coeff (map_poly cnj p) = 1
[PROOF STEP]
by (simp add: coeff_map_poly degree_map_poly)
[PROOF STATE]
proof (state)
this:
lead_coeff (map_poly cnj p) = 1

goal (1 subgoal):
 1. \<forall>i. coeff (map_poly cnj p) i \<in> \<int>
[PROOF STEP]
show "\<forall>i. coeff (map_poly cnj p) i \<in> \<int>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. coeff (map_poly cnj p) i \<in> \<int>
[PROOF STEP]
using p
[PROOF STATE]
proof (prove)
using this:
lead_coeff p = 1
\<forall>i. coeff p i \<in> \<int>
poly p x = 0

goal (1 subgoal):
 1. \<forall>i. coeff (map_poly cnj p) i \<in> \<int>
[PROOF STEP]
by (auto simp: coeff_map_poly)
[PROOF STATE]
proof (state)
this:
\<forall>i. coeff (map_poly cnj p) i \<in> \<int>

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
algebraic_int (cnj x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma suminf_divide: "summable f \<Longrightarrow> suminf (\<lambda>n. f n / c) = suminf f / c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable f \<Longrightarrow> (\<Sum>n. f n / c) = suminf f / c
[PROOF STEP]
by (rule bounded_linear.suminf [OF bounded_linear_divide, symmetric])


[STATEMENT]
lemma strict_sorted_append_iff:
  "strict_sorted (xs @ ys) \<longleftrightarrow> xs < ys \<and> strict_sorted xs \<and> strict_sorted ys" (is "?lhs = ?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. strict_sorted (xs @ ys) = (xs < ys \<and> strict_sorted xs \<and> strict_sorted ys)
[PROOF STEP]
by (metis less_list_iff_less_sets less_setsD sorted_wrt_append strict_sorted_imp_less_sets strict_sorted_imp_sorted)


[STATEMENT]
lemma subst_inj_on_is_bij_betw:
  "inj_on \<theta> (subst_domain \<theta>) = bij_betw \<theta> (subst_domain \<theta>) (subst_range \<theta>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on \<theta> (subst_domain \<theta>) = bij_betw \<theta> (subst_domain \<theta>) (subst_range \<theta>)
[PROOF STEP]
unfolding inj_on_def bij_betw_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>subst_domain \<theta>. \<forall>y\<in>subst_domain \<theta>. \<theta> x = \<theta> y \<longrightarrow> x = y) = ((\<forall>x\<in>subst_domain \<theta>. \<forall>y\<in>subst_domain \<theta>. \<theta> x = \<theta> y \<longrightarrow> x = y) \<and> \<theta> ` subst_domain \<theta> = subst_range \<theta>)
[PROOF STEP]
by auto


[STATEMENT]
lemma butlast_map: "xs \<noteq> [] \<Longrightarrow> butlast (map f xs) = map f (butlast xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xs \<noteq> [] \<Longrightarrow> butlast (map f xs) = map f (butlast xs)
[PROOF STEP]
by (induct xs) auto


[STATEMENT]
lemma sum_list_prod_map_aezfun :
  "aezfun (\<Sum>(x,y)\<leftarrow>xys. f x y) = (\<Sum>(x,y)\<leftarrow>xys. aezfun (f x y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. aezfun (\<Sum>(x, y)\<leftarrow>xys. f x y) = (\<Sum>(x, y)\<leftarrow>xys. aezfun (f x y))
[PROOF STEP]
using sum_list_prod_map_aezfun_apply[of f]
        sum_list_prod_fun_apply[of "\<lambda>y z. aezfun (f y z)"]
[PROOF STATE]
proof (prove)
using this:
aezfun (\<Sum>(x, y)\<leftarrow>?xys. f x y) ?a = (\<Sum>(x, y)\<leftarrow>?xys. aezfun (f x y) ?a)
(\<Sum>(x, y)\<leftarrow>?xys. aezfun (f x y)) ?z = (\<Sum>(x, y)\<leftarrow>?xys. aezfun (f x y) ?z)

goal (1 subgoal):
 1. aezfun (\<Sum>(x, y)\<leftarrow>xys. f x y) = (\<Sum>(x, y)\<leftarrow>xys. aezfun (f x y))
[PROOF STEP]
by    auto


[STATEMENT]
lemma ereal_abs_diff:
  fixes a b::ereal
  shows "abs(a-b) \<le> abs a + abs b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>a - b\<bar> \<le> \<bar>a\<bar> + \<bar>b\<bar>
[PROOF STEP]
by (cases rule: ereal2_cases[of a b]) (auto)


[STATEMENT]
lemma iIN_Suc: "\<lbrakk> x \<in> [n\<dots>,d]; x < n + d \<rbrakk> \<Longrightarrow> Suc x \<in> [n\<dots>,d]"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> [n\<dots>,d]; x < n + d\<rbrakk> \<Longrightarrow> Suc x \<in> [n\<dots>,d]
[PROOF STEP]
by (simp add: iIN_iff)


[STATEMENT]
lemma ucast_le_ucast_8_32:
  "(ucast x \<le> (ucast y :: word32)) = (x \<le> (y :: 8 word))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (UCAST(8 \<rightarrow> 32) x \<le> UCAST(8 \<rightarrow> 32) y) = (x \<le> y)
[PROOF STEP]
by (simp add: ucast_le_ucast)


[STATEMENT]
lemma Span_consistent:
  assumes "subring K R" shows "ring.Span (R \<lparr> carrier := K \<rparr>) = Span"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ring.Span (R\<lparr>carrier := K\<rparr>) = Span
[PROOF STEP]
unfolding ring.Span.simps[OF subring_is_ring[OF assms]] Span.simps
            line_extension_consistent[OF assms]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>Ka Us. foldr (line_extension Ka) Us {\<zero>\<^bsub>R\<lparr>carrier := K\<rparr>\<^esub>}) = (\<lambda>K Us. foldr (line_extension K) Us {\<zero>})
[PROOF STEP]
by simp


[STATEMENT]
lemma inverse_positive_imp_positive:
  assumes inv_gt_0: "0 < inverse a" and nz: "a \<noteq> 0"
  shows "0 < a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < a
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (0::'a) < a
[PROOF STEP]
have "0 < inverse (inverse a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0::'a) < inverse (inverse a)
[PROOF STEP]
using inv_gt_0
[PROOF STATE]
proof (prove)
using this:
(0::'a) < inverse a

goal (1 subgoal):
 1. (0::'a) < inverse (inverse a)
[PROOF STEP]
by (rule positive_imp_inverse_positive)
[PROOF STATE]
proof (state)
this:
(0::'a) < inverse (inverse a)

goal (1 subgoal):
 1. (0::'a) < a
[PROOF STEP]
thus "0 < a"
[PROOF STATE]
proof (prove)
using this:
(0::'a) < inverse (inverse a)

goal (1 subgoal):
 1. (0::'a) < a
[PROOF STEP]
using nz
[PROOF STATE]
proof (prove)
using this:
(0::'a) < inverse (inverse a)
a \<noteq> (0::'a)

goal (1 subgoal):
 1. (0::'a) < a
[PROOF STEP]
by (simp add: nonzero_inverse_inverse_eq)
[PROOF STATE]
proof (state)
this:
(0::'a) < a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_wrt_quicksort_by_rel:
  fixes R:: "'x \<Rightarrow> 'x \<Rightarrow> bool"
  assumes lin : "\<And>x y. (R x y) \<or> (R y x)"
      and trans_R: "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
  shows "sorted_wrt R (quicksort_by_rel R [] xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
proof (induct xs rule: measure_induct_rule[of "length"])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. (\<And>y. length y < length x \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] y)) \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] x)
[PROOF STEP]
case (less xs)
[PROOF STATE]
proof (state)
this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] ?y)

goal (1 subgoal):
 1. \<And>x. (\<And>y. length y < length x \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] y)) \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] x)
[PROOF STEP]
note ind_hyp = this
[PROOF STATE]
proof (state)
this:
length ?y < length xs \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] ?y)

goal (1 subgoal):
 1. \<And>x. (\<And>y. length y < length x \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] y)) \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] x)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
proof (cases xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. xs = [] \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
 2. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:
xs = []

goal (2 subgoals):
 1. xs = [] \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
 2. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
xs = []

goal (1 subgoal):
 1. sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted_wrt R (quicksort_by_rel R [] xs)

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
case (Cons x xs')
[PROOF STATE]
proof (state)
this:
xs = x # xs'

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
note xs_eq[simp] = this
[PROOF STATE]
proof (state)
this:
xs = x # xs'

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
obtain xs1 xs2 where part_rev_eq[simp]: "partition_rev (\<lambda>y. R y x) ([], []) xs' = (xs1, xs2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>xs1 xs2. partition_rev (\<lambda>y. R y x) ([], []) xs' = (xs1, xs2) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (rule prod.exhaust)
[PROOF STATE]
proof (state)
this:
partition_rev (\<lambda>y. R y x) ([], []) xs' = (xs1, xs2)

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
from part_rev_eq[symmetric]
[PROOF STATE]
proof (chain)
picking this:
(xs1, xs2) = partition_rev (\<lambda>y. R y x) ([], []) xs'
[PROOF STEP]
have xs1_props: "\<And>y. y \<in> set xs1 \<Longrightarrow> (R y x)" and
                                     xs2_props: "\<And>y. y \<in> set xs2 \<Longrightarrow> \<not>(R y x)"
[PROOF STATE]
proof (prove)
using this:
(xs1, xs2) = partition_rev (\<lambda>y. R y x) ([], []) xs'

goal (1 subgoal):
 1. (\<And>y. y \<in> set xs1 \<Longrightarrow> R y x) &&& (\<And>y. y \<in> set xs2 \<Longrightarrow> \<not> R y x)
[PROOF STEP]
unfolding partition_rev_filter_conv
[PROOF STATE]
proof (prove)
using this:
(xs1, xs2) = (rev (filter (\<lambda>y. R y x) xs') @ [], rev (filter (Not \<circ> (\<lambda>y. R y x)) xs') @ [])

goal (1 subgoal):
 1. (\<And>y. y \<in> set xs1 \<Longrightarrow> R y x) &&& (\<And>y. y \<in> set xs2 \<Longrightarrow> \<not> R y x)
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
?y \<in> set xs1 \<Longrightarrow> R ?y x
?y \<in> set xs2 \<Longrightarrow> \<not> R ?y x

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
from xs2_props lin
[PROOF STATE]
proof (chain)
picking this:
?y \<in> set xs2 \<Longrightarrow> \<not> R ?y x
R ?x ?y \<or> R ?y ?x
[PROOF STEP]
have xs2_props': "\<And>y. y \<in> set xs2 \<Longrightarrow> (R x y)"
[PROOF STATE]
proof (prove)
using this:
?y \<in> set xs2 \<Longrightarrow> \<not> R ?y x
R ?x ?y \<or> R ?y ?x

goal (1 subgoal):
 1. \<And>y. y \<in> set xs2 \<Longrightarrow> R x y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?y \<in> set xs2 \<Longrightarrow> R x ?y

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
from xs2_props' xs1_props trans_R
[PROOF STATE]
proof (chain)
picking this:
?y \<in> set xs2 \<Longrightarrow> R x ?y
?y \<in> set xs1 \<Longrightarrow> R ?y x
\<lbrakk>R ?x ?y; R ?y ?z\<rbrakk> \<Longrightarrow> R ?x ?z
[PROOF STEP]
have xs1_props':
      "\<And>y1 y2. y1 \<in> set xs1 \<Longrightarrow> y2 \<in> set xs2 \<Longrightarrow> (R y1 y2)"
[PROOF STATE]
proof (prove)
using this:
?y \<in> set xs2 \<Longrightarrow> R x ?y
?y \<in> set xs1 \<Longrightarrow> R ?y x
\<lbrakk>R ?x ?y; R ?y ?z\<rbrakk> \<Longrightarrow> R ?x ?z

goal (1 subgoal):
 1. \<And>y1 y2. \<lbrakk>y1 \<in> set xs1; y2 \<in> set xs2\<rbrakk> \<Longrightarrow> R y1 y2
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<lbrakk>?y1.0 \<in> set xs1; ?y2.0 \<in> set xs2\<rbrakk> \<Longrightarrow> R ?y1.0 ?y2.0

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
from part_rev_eq[symmetric]
[PROOF STATE]
proof (chain)
picking this:
(xs1, xs2) = partition_rev (\<lambda>y. R y x) ([], []) xs'
[PROOF STEP]
have length_le: "length xs1 < length xs" "length xs2 < length xs"
[PROOF STATE]
proof (prove)
using this:
(xs1, xs2) = partition_rev (\<lambda>y. R y x) ([], []) xs'

goal (1 subgoal):
 1. length xs1 < length xs &&& length xs2 < length xs
[PROOF STEP]
unfolding partition_rev_filter_conv
[PROOF STATE]
proof (prove)
using this:
(xs1, xs2) = (rev (filter (\<lambda>y. R y x) xs') @ [], rev (filter (Not \<circ> (\<lambda>y. R y x)) xs') @ [])

goal (1 subgoal):
 1. length xs1 < length xs &&& length xs2 < length xs
[PROOF STEP]
by (simp_all add: less_Suc_eq_le)
[PROOF STATE]
proof (state)
this:
length xs1 < length xs
length xs2 < length xs

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
note ind_hyps = ind_hyp[OF length_le(1)] ind_hyp[OF length_le(2)]
[PROOF STATE]
proof (state)
this:
sorted_wrt R (quicksort_by_rel R [] xs1)
sorted_wrt R (quicksort_by_rel R [] xs2)

goal (1 subgoal):
 1. \<And>a list. xs = a # list \<Longrightarrow> sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
sorted_wrt R (quicksort_by_rel R [] xs1)
sorted_wrt R (quicksort_by_rel R [] xs2)

goal (1 subgoal):
 1. sorted_wrt R (quicksort_by_rel R [] xs)
[PROOF STEP]
by (simp add: quicksort_by_rel_remove_acc_guared sorted_wrt_append Ball_def
                    xs1_props xs2_props' xs1_props')
[PROOF STATE]
proof (state)
this:
sorted_wrt R (quicksort_by_rel R [] xs)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
sorted_wrt R (quicksort_by_rel R [] xs)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ex_iter': "(\<exists>n. R (iter g a n)) = (R a | (\<exists>n. R (iter g (g a) n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>n. R (iter g a n)) = (R a \<or> (\<exists>n. R (iter g (g a) n)))
[PROOF STEP]
apply(rule)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<exists>n. R (iter g a n) \<Longrightarrow> R a \<or> (\<exists>n. R (iter g (g a) n))
 2. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(erule exE)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n. R (iter g a n) \<Longrightarrow> R a \<or> (\<exists>n. R (iter g (g a) n))
 2. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(case_tac n)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>n. \<lbrakk>R (iter g a n); n = 0\<rbrakk> \<Longrightarrow> R a \<or> (\<exists>n. R (iter g (g a) n))
 2. \<And>n nat. \<lbrakk>R (iter g a n); n = Suc nat\<rbrakk> \<Longrightarrow> R a \<or> (\<exists>n. R (iter g (g a) n))
 3. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n nat. \<lbrakk>R (iter g a n); n = Suc nat\<rbrakk> \<Longrightarrow> R a \<or> (\<exists>n. R (iter g (g a) n))
 2. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(rule disjI2)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n nat. \<lbrakk>R (iter g a n); n = Suc nat\<rbrakk> \<Longrightarrow> \<exists>n. R (iter g (g a) n)
 2. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(rule_tac x=nat in exI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>n nat. \<lbrakk>R (iter g a n); n = Suc nat\<rbrakk> \<Longrightarrow> R (iter g (g a) nat)
 2. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(simp add: iter)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. R a \<or> (\<exists>n. R (iter g (g a) n)) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(erule disjE)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. R a \<Longrightarrow> \<exists>n. R (iter g a n)
 2. \<exists>n. R (iter g (g a) n) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(rule_tac x=0 in exI, simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n. R (iter g (g a) n) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(erule exE)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. R (iter g (g a) n) \<Longrightarrow> \<exists>n. R (iter g a n)
[PROOF STEP]
apply(rule_tac x="Suc n" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. R (iter g (g a) n) \<Longrightarrow> R (iter g a (Suc n))
[PROOF STEP]
apply(simp add: iter)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done

    \<comment> \<open>version suitable for computation\<close>