[STATEMENT]
lemma lower_higher_commute: "higher (lower p s) t = lower (higher p t) s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. higher (lower p s) t = lower (higher p t) s
[PROOF STEP]
by (rule poly_mapping_eqI, simp add: lookup_higher lookup_lower)


[STATEMENT]
lemma span_breakdown_eq: "x \<in> span (insert a S) \<longleftrightarrow> (\<exists>k. x - k *s a \<in> span S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> span (insert a S)) = (\<exists>k. x - k *s a \<in> span S)
[PROOF STEP]
by (simp add: span_insert)


[STATEMENT]
lemma complex_cnj_scaleR [simp]: "cnj (scaleR r x) = scaleR r (cnj x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cnj (r *\<^sub>R x) = r *\<^sub>R cnj x
[PROOF STEP]
by (simp add: complex_eq_iff)


[STATEMENT]
lemma well_founded_ordered_subset: "B \<subseteq> A \<Longrightarrow> well_founded_ordered_set B (\<sqsubset>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B \<subseteq> A \<Longrightarrow> well_founded_ordered_set B (\<sqsubset>)
[PROOF STEP]
apply intro_locales
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. B \<subseteq> A \<Longrightarrow> well_founded B (\<sqsubset>)
 2. B \<subseteq> A \<Longrightarrow> transitive B (\<sqsubset>)
[PROOF STEP]
using well_founded_subset transitive_subset
[PROOF STATE]
proof (prove)
using this:
?B \<subseteq> A \<Longrightarrow> well_founded ?B (\<sqsubset>)
?B \<subseteq> A \<Longrightarrow> transitive ?B (\<sqsubset>)

goal (2 subgoals):
 1. B \<subseteq> A \<Longrightarrow> well_founded B (\<sqsubset>)
 2. B \<subseteq> A \<Longrightarrow> transitive B (\<sqsubset>)
[PROOF STEP]
by auto


[STATEMENT]
lemma
  assumes distA: "distinct A" and
          asm: "q \<in> set A"
  shows
      mtf2_mono:  "q< x in A \<Longrightarrow> q < x in (mtf2 n q A)" and
      mtf2_q_after: "index (mtf2 n q A) q =  index A q - n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<Longrightarrow> q < x in mtf2 n q A) &&& index (mtf2 n q A) q = index A q - n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. q < x in A \<Longrightarrow> q < x in mtf2 n q A
 2. index (mtf2 n q A) q = index A q - n
[PROOF STEP]
have lele: "(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> (index (swaps [index A q - n..<index A q] A) q =  index A q - n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n
[PROOF STEP]
apply(induct n)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (q < x in A \<longrightarrow> q < x in swaps [index A q - 0..<index A q] A) \<and> index (swaps [index A q - 0..<index A q] A) q = index A q - 0
 2. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
fix n
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
assume ind: "(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A)
            \<and> index (swaps [index A q - n..<index A q] A) q =  index A q - n"
[PROOF STATE]
proof (state)
this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n
[PROOF STEP]
have iH: " q < x in A \<Longrightarrow> q < x in swaps [index A q - n..<index A q] A"
[PROOF STATE]
proof (prove)
using this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - n..<index A q] A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q < x in A \<Longrightarrow> q < x in swaps [index A q - n..<index A q] A

goal (1 subgoal):
 1. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
from ind
[PROOF STATE]
proof (chain)
picking this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n
[PROOF STEP]
have indH2: "index (swaps [index A q - n..<index A q] A) q =  index A q - n"
[PROOF STATE]
proof (prove)
using this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. index (swaps [index A q - n..<index A q] A) q = index A q - n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. \<And>n. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
show "(q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and>
          index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n" (is "?part1 \<and> ?part2")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
proof (cases "index A q \<ge> Suc n")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
Suc n \<le> index A q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
Suc n \<le> index A q
[PROOF STEP]
have onemore: "[index A q - Suc n..<index A q] = (index A q - Suc n) # [index A q - n..<index A q]"
[PROOF STATE]
proof (prove)
using this:
Suc n \<le> index A q

goal (1 subgoal):
 1. [index A q - Suc n..<index A q] = (index A q - Suc n) # [index A q - n..<index A q]
[PROOF STEP]
using Suc_diff_Suc upt_rec
[PROOF STATE]
proof (prove)
using this:
Suc n \<le> index A q
?n < ?m \<Longrightarrow> Suc (?m - Suc ?n) = ?m - ?n
[?i..<?j] = (if ?i < ?j then ?i # [Suc ?i..<?j] else [])

goal (1 subgoal):
 1. [index A q - Suc n..<index A q] = (index A q - Suc n) # [index A q - n..<index A q]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[index A q - Suc n..<index A q] = (index A q - Suc n) # [index A q - n..<index A q]

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
from onemore
[PROOF STATE]
proof (chain)
picking this:
[index A q - Suc n..<index A q] = (index A q - Suc n) # [index A q - n..<index A q]
[PROOF STEP]
have yeah: "swaps [index A q - Suc n..<index A q] A
              = swap (index A q - Suc n) (swaps  [index A q - n..<index A q] A)"
[PROOF STATE]
proof (prove)
using this:
[index A q - Suc n..<index A q] = (index A q - Suc n) # [index A q - n..<index A q]

goal (1 subgoal):
 1. swaps [index A q - Suc n..<index A q] A = swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
swaps [index A q - Suc n..<index A q] A = swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
from indH2
[PROOF STATE]
proof (chain)
picking this:
index (swaps [index A q - n..<index A q] A) q = index A q - n
[PROOF STEP]
have gr: "index (swaps [index A q - n..<index A q] A) q =  Suc(index A q - Suc n)"
[PROOF STATE]
proof (prove)
using this:
index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. index (swaps [index A q - n..<index A q] A) q = Suc (index A q - Suc n)
[PROOF STEP]
using Suc_diff_Suc True
[PROOF STATE]
proof (prove)
using this:
index (swaps [index A q - n..<index A q] A) q = index A q - n
?n < ?m \<Longrightarrow> Suc (?m - Suc ?n) = ?m - ?n
Suc n \<le> index A q

goal (1 subgoal):
 1. index (swaps [index A q - n..<index A q] A) q = Suc (index A q - Suc n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
index (swaps [index A q - n..<index A q] A) q = Suc (index A q - Suc n)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have whereisq: "swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q
[PROOF STEP]
unfolding gr[symmetric]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q = q
[PROOF STEP]
apply(rule nth_index)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<in> set (swaps [index A q - n..<index A q] A)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
q \<in> set A

goal (1 subgoal):
 1. q \<in> set (swaps [index A q - n..<index A q] A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have indSi: "index A q < length A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index A q < length A
[PROOF STEP]
using asm index_less
[PROOF STATE]
proof (prove)
using this:
q \<in> set A
\<lbrakk>?x \<in> set ?xs; length ?xs \<le> ?n\<rbrakk> \<Longrightarrow> index ?xs ?x < ?n

goal (1 subgoal):
 1. index A q < length A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
index A q < length A

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have 3: "Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
[PROOF STEP]
using True
[PROOF STATE]
proof (prove)
using this:
Suc n \<le> index A q

goal (1 subgoal):
 1. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
[PROOF STEP]
apply(auto simp: Suc_diff_Suc asm)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc n \<le> index A q \<Longrightarrow> index A q - n < length A
[PROOF STEP]
using indSi
[PROOF STATE]
proof (prove)
using this:
index A q < length A

goal (1 subgoal):
 1. Suc n \<le> index A q \<Longrightarrow> index A q - n < length A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have 1: "q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
assume as: "q = swaps [index A q - n..<index A q] A ! (index A q - Suc n)"
[PROOF STATE]
proof (state)
this:
q = swaps [index A q - n..<index A q] A ! (index A q - Suc n)

goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
q = swaps [index A q - n..<index A q] A ! (index A q - Suc n)

goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
fix xs x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
have "Suc x < length xs \<Longrightarrow> xs ! x = q \<Longrightarrow> xs ! Suc x = q \<Longrightarrow> \<not> distinct xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Suc x < length xs; xs ! x = q; xs ! Suc x = q\<rbrakk> \<Longrightarrow> \<not> distinct xs
[PROOF STEP]
by (metis Suc_lessD index_nth_id n_not_Suc_n)
[PROOF STATE]
proof (state)
this:
\<lbrakk>Suc x < length xs; xs ! x = q; xs ! Suc x = q\<rbrakk> \<Longrightarrow> \<not> distinct xs

goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>Suc ?xa2 < length ?xs2; ?xs2 ! ?xa2 = q; ?xs2 ! Suc ?xa2 = q\<rbrakk> \<Longrightarrow> \<not> distinct ?xs2

goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
note cool=this
[PROOF STATE]
proof (state)
this:
\<lbrakk>Suc ?xa2 < length ?xs2; ?xs2 ! ?xa2 = q; ?xs2 ! Suc ?xa2 = q\<rbrakk> \<Longrightarrow> \<not> distinct ?xs2

goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
have "\<not> distinct (swaps [index A q - n..<index A q] A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> distinct (swaps [index A q - n..<index A q] A)
[PROOF STEP]
apply(rule cool[of "(index A q - Suc n)"])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
 2. swaps [index A q - n..<index A q] A ! (index A q - Suc n) = q
 3. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q
[PROOF STEP]
apply(simp only: 3)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. swaps [index A q - n..<index A q] A ! (index A q - Suc n) = q
 2. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q
[PROOF STEP]
apply(simp only: as[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q
[PROOF STEP]
by(simp only: whereisq)
[PROOF STATE]
proof (state)
this:
\<not> distinct (swaps [index A q - n..<index A q] A)

goal (1 subgoal):
 1. q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> distinct (swaps [index A q - n..<index A q] A)
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
\<not> distinct (swaps [index A q - n..<index A q] A)

goal (1 subgoal):
 1. False
[PROOF STEP]
using distA
[PROOF STATE]
proof (prove)
using this:
\<not> distinct (swaps [index A q - n..<index A q] A)
distinct A

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have part1: ?part1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
assume qx: "q < x in A"
[PROOF STATE]
proof (state)
this:
q < x in A

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
q < x in A

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
fix q x B i
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
assume a1: "q < x in B"
[PROOF STATE]
proof (state)
this:
q < x in B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
assume a2: "~ q = B ! i"
[PROOF STATE]
proof (state)
this:
q \<noteq> B ! i

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
assume a3: "distinct B"
[PROOF STATE]
proof (state)
this:
distinct B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
assume a4: "Suc i < length B"
[PROOF STATE]
proof (state)
this:
Suc i < length B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
have "dist_perm B B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist_perm B B
[PROOF STEP]
by(simp add: a3)
[PROOF STATE]
proof (state)
this:
dist_perm B B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
dist_perm B B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
have "Suc i < length B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc i < length B
[PROOF STEP]
using a4
[PROOF STATE]
proof (prove)
using this:
Suc i < length B

goal (1 subgoal):
 1. Suc i < length B
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Suc i < length B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
Suc i < length B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
have "q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)
[PROOF STEP]
using a1 a2
[PROOF STATE]
proof (prove)
using this:
q < x in B
q \<noteq> B ! i

goal (1 subgoal):
 1. q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
dist_perm B B
Suc i < length B
q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)
[PROOF STEP]
have "q < x in swap i B"
[PROOF STATE]
proof (prove)
using this:
dist_perm B B
Suc i < length B
q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)

goal (1 subgoal):
 1. q < x in swap i B
[PROOF STEP]
using before_in_swap[of B B]
[PROOF STATE]
proof (prove)
using this:
dist_perm B B
Suc i < length B
q < x in B \<and> \<not> (q = B ! i \<and> x = B ! Suc i)
\<lbrakk>dist_perm B B; Suc ?n < length B\<rbrakk> \<Longrightarrow> ?x < ?y in swap ?n B = (?x < ?y in B \<and> \<not> (?x = B ! ?n \<and> ?y = B ! Suc ?n) \<or> ?x = B ! Suc ?n \<and> ?y = B ! ?n)

goal (1 subgoal):
 1. q < x in swap i B
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
q < x in swap i B

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
\<lbrakk>?qa2 < ?xa2 in ?B2; ?qa2 \<noteq> ?B2 ! ?i2; distinct ?B2; Suc ?i2 < length ?B2\<rbrakk> \<Longrightarrow> ?qa2 < ?xa2 in swap ?i2 ?B2

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
note grr=this
[PROOF STATE]
proof (state)
this:
\<lbrakk>?qa2 < ?xa2 in ?B2; ?qa2 \<noteq> ?B2 ! ?i2; distinct ?B2; Suc ?i2 < length ?B2\<rbrakk> \<Longrightarrow> ?qa2 < ?xa2 in swap ?i2 ?B2

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
have 2: "distinct (swaps [index A q - n..<index A q] A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct (swaps [index A q - n..<index A q] A)
[PROOF STEP]
using distA
[PROOF STATE]
proof (prove)
using this:
distinct A

goal (1 subgoal):
 1. distinct (swaps [index A q - n..<index A q] A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
distinct (swaps [index A q - n..<index A q] A)

goal (1 subgoal):
 1. q < x in A \<Longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
show "q < x in swaps [index A q - Suc n..<index A q] A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q < x in swaps [index A q - Suc n..<index A q] A
[PROOF STEP]
apply(simp only: yeah)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q < x in swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)
[PROOF STEP]
apply(rule grr[OF iH[OF qx]])
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)
 2. distinct (swaps [index A q - n..<index A q] A)
 3. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
[PROOF STEP]
using 1 2 3
[PROOF STATE]
proof (prove)
using this:
q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)
distinct (swaps [index A q - n..<index A q] A)
Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)

goal (3 subgoals):
 1. q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)
 2. distinct (swaps [index A q - n..<index A q] A)
 3. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q < x in swaps [index A q - Suc n..<index A q] A

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
let ?xs = "(swaps [index A q - n..<index A q] A)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
let ?n = "(index A q - Suc n)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have "?xs ! Suc ?n = swaps [index A q - n..<index A q] A ! (index (swaps [index A q - n..<index A q] A) q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q
[PROOF STEP]
using indH2 Suc_diff_Suc True
[PROOF STATE]
proof (prove)
using this:
index (swaps [index A q - n..<index A q] A) q = index A q - n
?n < ?m \<Longrightarrow> Suc (?m - Suc ?n) = ?m - ?n
Suc n \<le> index A q

goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have "\<dots> = q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q = q
[PROOF STEP]
apply(rule nth_index)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<in> set (swaps [index A q - n..<index A q] A)
[PROOF STEP]
using asm
[PROOF STATE]
proof (prove)
using this:
q \<in> set A

goal (1 subgoal):
 1. q \<in> set (swaps [index A q - n..<index A q] A)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
swaps [index A q - n..<index A q] A ! index (swaps [index A q - n..<index A q] A) q = q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q
[PROOF STEP]
have sndTrue: "?xs ! Suc ?n = q"
[PROOF STATE]
proof (prove)
using this:
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q

goal (1 subgoal):
 1. swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have fstFalse: "~ q = ?xs ! ?n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)
[PROOF STEP]
by (fact 1)
[PROOF STATE]
proof (state)
this:
q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have "index (swaps [index A q - Suc n..<index A q] A) q
              = index (swap (index A q - Suc n) ?xs) q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index (swaps [index A q - Suc n..<index A q] A) q = index (swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)) q
[PROOF STEP]
by (simp only: yeah)
[PROOF STATE]
proof (state)
this:
index (swaps [index A q - Suc n..<index A q] A) q = index (swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)) q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
index (swaps [index A q - Suc n..<index A q] A) q = index (swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)) q

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have "\<dots> = (if q = ?xs ! ?n then Suc ?n else if q = ?xs ! Suc ?n then ?n else index ?xs q)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index (swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)) q = (if q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) then Suc (index A q - Suc n) else if q = swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) then index A q - Suc n else index (swaps [index A q - n..<index A q] A) q)
[PROOF STEP]
apply(rule index_swap_distinct)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct (swaps [index A q - n..<index A q] A)
 2. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
[PROOF STEP]
apply(simp add: distA)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Suc (index A q - Suc n) < length (swaps [index A q - n..<index A q] A)
[PROOF STEP]
by (fact 3)
[PROOF STATE]
proof (state)
this:
index (swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)) q = (if q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) then Suc (index A q - Suc n) else if q = swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) then index A q - Suc n else index (swaps [index A q - n..<index A q] A) q)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
index (swap (index A q - Suc n) (swaps [index A q - n..<index A q] A)) q = (if q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) then Suc (index A q - Suc n) else if q = swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) then index A q - Suc n else index (swaps [index A q - n..<index A q] A) q)

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have "\<dots> = ?n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (if q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) then Suc (index A q - Suc n) else if q = swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) then index A q - Suc n else index (swaps [index A q - n..<index A q] A) q) = index A q - Suc n
[PROOF STEP]
using fstFalse sndTrue
[PROOF STATE]
proof (prove)
using this:
q \<noteq> swaps [index A q - n..<index A q] A ! (index A q - Suc n)
swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) = q

goal (1 subgoal):
 1. (if q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) then Suc (index A q - Suc n) else if q = swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) then index A q - Suc n else index (swaps [index A q - n..<index A q] A) q) = index A q - Suc n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(if q = swaps [index A q - n..<index A q] A ! (index A q - Suc n) then Suc (index A q - Suc n) else if q = swaps [index A q - n..<index A q] A ! Suc (index A q - Suc n) then index A q - Suc n else index (swaps [index A q - n..<index A q] A) q) = index A q - Suc n

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
have part2: ?part2
[PROOF STATE]
proof (prove)
using this:
index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n

goal (1 subgoal):
 1. index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n

goal (2 subgoals):
 1. Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
 2. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
from part1 part2
[PROOF STATE]
proof (chain)
picking this:
q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
show "?part1 \<and> ?part2"
[PROOF STATE]
proof (prove)
using this:
q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A
index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n

goal (1 subgoal):
 1. (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n

goal (1 subgoal):
 1. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> Suc n \<le> index A q

goal (1 subgoal):
 1. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> Suc n \<le> index A q
[PROOF STEP]
have a: "index A q - Suc n = index A q - n"
[PROOF STATE]
proof (prove)
using this:
\<not> Suc n \<le> index A q

goal (1 subgoal):
 1. index A q - Suc n = index A q - n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
index A q - Suc n = index A q - n

goal (1 subgoal):
 1. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
index A q - Suc n = index A q - n
[PROOF STEP]
have b: "[index A q - Suc n..<index A q] = [index A q - n..<index A q]"
[PROOF STATE]
proof (prove)
using this:
index A q - Suc n = index A q - n

goal (1 subgoal):
 1. [index A q - Suc n..<index A q] = [index A q - n..<index A q]
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[index A q - Suc n..<index A q] = [index A q - n..<index A q]

goal (1 subgoal):
 1. \<not> Suc n \<le> index A q \<Longrightarrow> (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n
[PROOF STEP]
apply(simp only: b a)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n
[PROOF STEP]
by (fact ind)
[PROOF STATE]
proof (state)
this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - Suc n..<index A q] A) \<and> index (swaps [index A q - Suc n..<index A q] A) q = index A q - Suc n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (2 subgoals):
 1. q < x in A \<Longrightarrow> q < x in mtf2 n q A
 2. index (mtf2 n q A) q = index A q - n
[PROOF STEP]
show "q < x in A \<Longrightarrow> q < x in (mtf2 n q A)"
        "(index (mtf2 n q A) q) =  index A q - n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<Longrightarrow> q < x in mtf2 n q A) &&& index (mtf2 n q A) q = index A q - n
[PROOF STEP]
unfolding mtf2_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (q < x in A \<Longrightarrow> q < x in (if q \<in> set A then swaps [index A q - n..<index A q] A else A)) &&& index (if q \<in> set A then swaps [index A q - n..<index A q] A else A) q = index A q - n
[PROOF STEP]
using asm lele
[PROOF STATE]
proof (prove)
using this:
q \<in> set A
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. (q < x in A \<Longrightarrow> q < x in (if q \<in> set A then swaps [index A q - n..<index A q] A else A)) &&& index (if q \<in> set A then swaps [index A q - n..<index A q] A else A) q = index A q - n
[PROOF STEP]
apply(simp)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. index (if q \<in> set A then swaps [index A q - n..<index A q] A else A) q = index A q - n
[PROOF STEP]
using asm lele
[PROOF STATE]
proof (prove)
using this:
q \<in> set A
(q < x in A \<longrightarrow> q < x in swaps [index A q - n..<index A q] A) \<and> index (swaps [index A q - n..<index A q] A) q = index A q - n

goal (1 subgoal):
 1. index (if q \<in> set A then swaps [index A q - n..<index A q] A else A) q = index A q - n
[PROOF STEP]
by(simp)
[PROOF STATE]
proof (state)
this:
q < x in A \<Longrightarrow> q < x in mtf2 n q A
index (mtf2 n q A) q = index A q - n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sgn_real_alg_sound: "sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)"
  (is "_ = ?r")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
have "real_of (sgn x) = sgn (real_of x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of (sgn x) = sgn (real_of x)
[PROOF STEP]
by (simp add: sgn_real_alg)
[PROOF STATE]
proof (state)
this:
real_of (sgn x) = sgn (real_of x)

goal (1 subgoal):
 1. sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of (sgn x) = sgn (real_of x)

goal (1 subgoal):
 1. sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
have "\<dots> = real_of ?r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sgn (real_of x) = real_of (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
unfolding sgn_real_def if_distrib
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if x = 0 then (if real_of x = 0 then (=) ((if real_of x = 0 then If (0 < real_of x) 0 else If (0 < real_of x) 1) 0) else (=) ((if real_of x = 0 then If (0 < real_of x) 0 else If (0 < real_of x) 1) (- 1))) (real_of ((if x = 0 then If (0 < real_of x) 0 else If (0 < real_of x) 1) 0)) else (if real_of x = 0 then (=) ((if real_of x = 0 then If (0 < real_of x) 0 else If (0 < real_of x) 1) 0) else (=) ((if real_of x = 0 then If (0 < real_of x) 0 else If (0 < real_of x) 1) (- 1))) (real_of ((if x = 0 then If (0 < real_of x) 0 else If (0 < real_of x) 1) (- 1)))
[PROOF STEP]
by (auto simp: less_real_alg_def
    zero_real_alg_def one_real_alg_def of_rat_real_alg[symmetric] equal_real_alg[symmetric]
    equal_real_def uminus_real_alg[symmetric])
[PROOF STATE]
proof (state)
this:
sgn (real_of x) = real_of (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)

goal (1 subgoal):
 1. sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
real_of (sgn x) = real_of (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
show "sgn x = ?r"
[PROOF STATE]
proof (prove)
using this:
real_of (sgn x) = real_of (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)

goal (1 subgoal):
 1. sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)
[PROOF STEP]
unfolding equal_real_alg[symmetric] equal_real_def
[PROOF STATE]
proof (prove)
using this:
real_of (sgn x) = real_of (if real_of x - real_of 0 = 0 then 0 else if 0 < real_of x then 1 else - 1)

goal (1 subgoal):
 1. real_of (sgn x) - real_of (if real_of x - real_of 0 = 0 then 0 else if 0 < real_of x then 1 else - 1) = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sgn x = (if x = 0 then 0 else if 0 < real_of x then 1 else - 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma span_neg: "x \<in> span S \<Longrightarrow> - x \<in> span S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> span S \<Longrightarrow> - x \<in> span S
[PROOF STEP]
by (metis subspace_neg subspace_span)


[STATEMENT]
lemma (in gcd_condition_monoid) gcd_divides:
  assumes "z divides x" "z divides y"
    and L: "x \<in> carrier G"  "y \<in> carrier G"  "z \<in> carrier G"
  shows "z divides (somegcd G x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z divides somegcd G x y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z divides somegcd G x y
[PROOF STEP]
interpret weak_lower_semilattice "division_rel G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. weak_lower_semilattice (division_rel G)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z divides somegcd G x y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z divides somegcd G x y
[PROOF STEP]
by (metis gcd_isgcd isgcd_def assms)
[PROOF STATE]
proof (state)
this:
z divides somegcd G x y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma square_rtrancl_reflcl_commute:
    "square R S (S\<^sup>*\<^sup>*) (R\<^sup>=\<^sup>=) ==> commute (R\<^sup>*\<^sup>*) (S\<^sup>*\<^sup>*)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. square R S S\<^sup>*\<^sup>* R\<^sup>=\<^sup>= \<Longrightarrow> commute R\<^sup>*\<^sup>* S\<^sup>*\<^sup>*
[PROOF STEP]
apply (unfold commute_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. square R S S\<^sup>*\<^sup>* R\<^sup>=\<^sup>= \<Longrightarrow> square R\<^sup>*\<^sup>* S\<^sup>*\<^sup>* S\<^sup>*\<^sup>* R\<^sup>*\<^sup>*
[PROOF STEP]
apply (fastforce dest: square_reflcl square_sym [THEN square_rtrancl])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma minWait_least: "\<lbrakk>enabled (shd (sdrop n rs)) s\<rbrakk> \<Longrightarrow> minWait rs s \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enabled (shd (sdrop n rs)) s \<Longrightarrow> minWait rs s \<le> n
[PROOF STEP]
unfolding minWait_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. enabled (shd (sdrop n rs)) s \<Longrightarrow> (LEAST n. enabled (shd (sdrop n rs)) s) \<le> n
[PROOF STEP]
by (intro Least_le conjI)


[STATEMENT]
lemma image_stretch_interval_cart:
  fixes m :: "'n::finite \<Rightarrow> real"
  shows "(\<lambda>x. \<chi> k. m k * x$k) ` cbox a b =
            (if cbox a b = {} then {}
            else cbox (\<chi> k. min (m k * a$k) (m k * b$k)) (\<chi> k. max (m k * a$k) (m k * b$k)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<chi>k. m k * x $ k) ` cbox a b = (if cbox a b = {} then {} else cbox (\<chi>k. min (m k * a $ k) (m k * b $ k)) (\<chi>k. max (m k * a $ k) (m k * b $ k)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. \<chi>k. m k * x $ k) ` cbox a b = (if cbox a b = {} then {} else cbox (\<chi>k. min (m k * a $ k) (m k * b $ k)) (\<chi>k. max (m k * a $ k) (m k * b $ k)))
[PROOF STEP]
have *: "(\<Sum>k\<in>Basis. min (m (axis_index k) * (a \<bullet> k)) (m (axis_index k) * (b \<bullet> k)) *\<^sub>R k)
           = (\<chi> k. min (m k * a $ k) (m k * b $ k))"
          "(\<Sum>k\<in>Basis. max (m (axis_index k) * (a \<bullet> k)) (m (axis_index k) * (b \<bullet> k)) *\<^sub>R k)
           = (\<chi> k. max (m k * a $ k) (m k * b $ k))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<in>Basis. min (m (axis_index k) * (a \<bullet> k)) (m (axis_index k) * (b \<bullet> k)) *\<^sub>R k) = (\<chi>k. min (m k * a $ k) (m k * b $ k)) &&& (\<Sum>k\<in>Basis. max (m (axis_index k) * (a \<bullet> k)) (m (axis_index k) * (b \<bullet> k)) *\<^sub>R k) = (\<chi>k. max (m k * a $ k) (m k * b $ k))
[PROOF STEP]
apply (simp_all add: Basis_vec_def cart_eq_inner_axis UNION_singleton_eq_range sum.reindex axis_eq_axis inj_on_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (\<Sum>x\<in>UNIV. min (m x * (a \<bullet> axis x 1)) (m x * (b \<bullet> axis x 1)) *\<^sub>R axis x 1) = (\<chi>k. min (m k * (a \<bullet> axis k 1)) (m k * (b \<bullet> axis k 1)))
 2. (\<Sum>x\<in>UNIV. max (m x * (a \<bullet> axis x 1)) (m x * (b \<bullet> axis x 1)) *\<^sub>R axis x 1) = (\<chi>k. max (m k * (a \<bullet> axis k 1)) (m k * (b \<bullet> axis k 1)))
[PROOF STEP]
apply (simp_all add: vec_eq_iff axis_def if_distrib cong: if_cong)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
(\<Sum>k\<in>Basis. min (m (axis_index k) * (a \<bullet> k)) (m (axis_index k) * (b \<bullet> k)) *\<^sub>R k) = (\<chi>k. min (m k * a $ k) (m k * b $ k))
(\<Sum>k\<in>Basis. max (m (axis_index k) * (a \<bullet> k)) (m (axis_index k) * (b \<bullet> k)) *\<^sub>R k) = (\<chi>k. max (m k * a $ k) (m k * b $ k))

goal (1 subgoal):
 1. (\<lambda>x. \<chi>k. m k * x $ k) ` cbox a b = (if cbox a b = {} then {} else cbox (\<chi>k. min (m k * a $ k) (m k * b $ k)) (\<chi>k. max (m k * a $ k) (m k * b $ k)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. \<chi>k. m k * x $ k) ` cbox a b = (if cbox a b = {} then {} else cbox (\<chi>k. min (m k * a $ k) (m k * b $ k)) (\<chi>k. max (m k * a $ k) (m k * b $ k)))
[PROOF STEP]
by (simp add: vec_lambda_eq_sum [where f="\<lambda>i x. m i * x"] image_stretch_interval eq_cbox *)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. \<chi>k. m k * x $ k) ` cbox a b = (if cbox a b = {} then {} else cbox (\<chi>k. min (m k * a $ k) (m k * b $ k)) (\<chi>k. max (m k * a $ k) (m k * b $ k)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma AD_aux:
  "AllowPortFromTo a b po \<in> set p \<Longrightarrow> DenyAllFromTo c d \<in> set p \<Longrightarrow>
   allNetsDistinct  p \<Longrightarrow> singleCombinators p \<Longrightarrow> a \<noteq> c \<or> b \<noteq> d \<Longrightarrow>
   dom (Cp (AllowPortFromTo a b po)) \<inter> dom (Cp (DenyAllFromTo c d)) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>AllowPortFromTo a b po \<in> set p; DenyAllFromTo c d \<in> set p; allNetsDistinct p; singleCombinators p; a \<noteq> c \<or> b \<noteq> d\<rbrakk> \<Longrightarrow> dom (Cp (AllowPortFromTo a b po)) \<inter> dom (Cp (DenyAllFromTo c d)) = {}
[PROOF STEP]
by (rule aux26,rule_tac x ="AllowPortFromTo a b po" and y = "DenyAllFromTo c d" in tND) auto


[STATEMENT]
lemma (in topological_space) eventually_at_topological:
  "eventually P (at a within s) \<longleftrightarrow> (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> x \<in> s \<longrightarrow> P x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. eventually P (at a within s) = (\<exists>S. open S \<and> a \<in> S \<and> (\<forall>x\<in>S. x \<noteq> a \<longrightarrow> x \<in> s \<longrightarrow> P x))
[PROOF STEP]
by (simp add: eventually_nhds eventually_at_filter)


[STATEMENT]
lemma im_diff: "g \<in> G \<Longrightarrow> g' \<in> G \<Longrightarrow> T (g - g') = T g - T g'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>g \<in> G; g' \<in> G\<rbrakk> \<Longrightarrow> T (g - g') = T g - T g'
[PROOF STEP]
using hom uminus_closed hom[of g "-g'"] im_uminus
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?g \<in> G; ?g' \<in> G\<rbrakk> \<Longrightarrow> T (?g + ?g') = T ?g + T ?g'
?g \<in> G \<Longrightarrow> - ?g \<in> G
\<lbrakk>g \<in> G; - g' \<in> G\<rbrakk> \<Longrightarrow> T (g + - g') = T g + T (- g')
T (- ?g) = - T ?g

goal (1 subgoal):
 1. \<lbrakk>g \<in> G; g' \<in> G\<rbrakk> \<Longrightarrow> T (g - g') = T g - T g'
[PROOF STEP]
by simp


[STATEMENT]
lemma uint_2p: "(0::'a::len word) < 2 ^ n \<Longrightarrow> uint (2 ^ n::'a::len word) = 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 2 ^ n \<Longrightarrow> uint (2 ^ n) = 2 ^ n
[PROOF STEP]
by (cases \<open>n < LENGTH('a)\<close>; transfer; force)


[STATEMENT]
lemma ccINF_sup_distrib2:
  "countable A \<Longrightarrow> countable B \<Longrightarrow> sup (INF a\<in>A. f a) (INF b\<in>B. g b) = (INF a\<in>A. INF b\<in>B. sup (f a) (g b))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable A; countable B\<rbrakk> \<Longrightarrow> sup (Inf (f ` A)) (Inf (g ` B)) = (INF a\<in>A. INF b\<in>B. sup (f a) (g b))
[PROOF STEP]
by (subst ccINF_commute) (simp_all add: sup_ccINF ccINF_sup)


[STATEMENT]
lemma to_nat_suc:
  assumes "to_nat (x)+1 < CARD ('a)"
  shows "to_nat (x + 1::'a) = (to_nat x) + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
have "(x::'a) + 1 = from_nat (to_nat x + to_nat (1::'a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x + (1::'a) = mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))
[PROOF STEP]
unfolding add_to_nat_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a)) = mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
x + (1::'a) = mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
hence "to_nat ((x::'a) + 1) = to_nat (from_nat (to_nat x + to_nat (1::'a))::'a)"
[PROOF STATE]
proof (prove)
using this:
x + (1::'a) = mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a)))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a)))

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a)))

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
have "... = to_nat (from_nat (to_nat x + 1)::'a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1))
[PROOF STEP]
unfolding to_nat_1
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1)) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1))
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1))

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + mod_type_class.to_nat (1::'a))) = mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1))

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
have "... = (to_nat x + 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1)) = mod_type_class.to_nat x + 1
[PROOF STEP]
by (metis assms to_nat_from_nat_id)
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (mod_type_class.from_nat (mod_type_class.to_nat x + 1)) = mod_type_class.to_nat x + 1

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1

goal (1 subgoal):
 1. mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
mod_type_class.to_nat (x + (1::'a)) = mod_type_class.to_nat x + 1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma mat_to_polys_to_mat:
  assumes "distinct ts" and "length ts = dim_col A"
  shows "(polys_to_mat ts (mat_to_polys ts A)) = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polys_to_mat ts (mat_to_polys ts A) = A
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)
 2. dim_row (polys_to_mat ts (mat_to_polys ts A)) = dim_row A
 3. dim_col (polys_to_mat ts (mat_to_polys ts A)) = dim_col A
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)
 2. dim_row (polys_to_mat ts (mat_to_polys ts A)) = dim_row A
 3. dim_col (polys_to_mat ts (mat_to_polys ts A)) = dim_col A
[PROOF STEP]
assume i: "i < dim_row A" and j: "j < dim_col A"
[PROOF STATE]
proof (state)
this:
i < dim_row A
j < dim_col A

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)
 2. dim_row (polys_to_mat ts (mat_to_polys ts A)) = dim_row A
 3. dim_col (polys_to_mat ts (mat_to_polys ts A)) = dim_col A
[PROOF STEP]
hence i': "i < length (mat_to_polys ts A)" and j': "j < length ts"
[PROOF STATE]
proof (prove)
using this:
i < dim_row A
j < dim_col A

goal (1 subgoal):
 1. i < length (mat_to_polys ts A) &&& j < length ts
[PROOF STEP]
by (simp, simp only: assms(2))
[PROOF STATE]
proof (state)
this:
i < length (mat_to_polys ts A)
j < length ts

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)
 2. dim_row (polys_to_mat ts (mat_to_polys ts A)) = dim_row A
 3. dim_col (polys_to_mat ts (mat_to_polys ts A)) = dim_col A
[PROOF STEP]
have r: "dim_vec (row A i) = length ts"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (row A i) = length ts
[PROOF STEP]
by (simp add: assms(2))
[PROOF STATE]
proof (state)
this:
dim_vec (row A i) = length ts

goal (3 subgoals):
 1. \<And>i j. \<lbrakk>i < dim_row A; j < dim_col A\<rbrakk> \<Longrightarrow> polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)
 2. dim_row (polys_to_mat ts (mat_to_polys ts A)) = dim_row A
 3. dim_col (polys_to_mat ts (mat_to_polys ts A)) = dim_col A
[PROOF STEP]
show "polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)
[PROOF STEP]
by (simp only: polys_to_mat_index[OF i' j'] mat_to_polys_nth[OF \<open>i < dim_row A\<close>]
        lookup_row_to_poly[OF assms(1) r j'] index_row(1)[OF i j])
[PROOF STATE]
proof (state)
this:
polys_to_mat ts (mat_to_polys ts A) $$ (i, j) = A $$ (i, j)

goal (2 subgoals):
 1. dim_row (polys_to_mat ts (mat_to_polys ts A)) = dim_row A
 2. dim_col (polys_to_mat ts (mat_to_polys ts A)) = dim_col A
[PROOF STEP]
qed (simp_all add: assms)


[STATEMENT]
lemma poly_eval_monom_insert:
  assumes "closed_fun R g"
  assumes "\<one> \<noteq>\<zero>"
  assumes "i \<in> S"
  shows "poly_eval R  S g (mset_to_IP R (add_mset i m))
           = poly_scalar_mult R (g i)
                    (poly_eval R  S g (mset_to_IP R m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
have 0: "poly_eval R  S g (mset_to_IP R (add_mset i m)) =
                poly_scalar_mult R (monom_eval R (restrict_to_indices (add_mset i m) S) g)
                              (mset_to_IP R (remove_indices (add_mset i m) S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (monom_eval R (restrict_to_indices (add_mset i m) S) g) (mset_to_IP R (remove_indices (add_mset i m) S))
[PROOF STEP]
using assms(1) assms(2) poly_eval_monomial
[PROOF STATE]
proof (prove)
using this:
g \<in> UNIV \<rightarrow> carrier R
\<one> \<noteq> \<zero>
\<lbrakk>?g \<in> UNIV \<rightarrow> carrier R; \<one> \<noteq> \<zero>\<rbrakk> \<Longrightarrow> poly_eval R ?S ?g (mset_to_IP R ?m) = poly_scalar_mult R (monom_eval R (restrict_to_indices ?m ?S) ?g) (mset_to_IP R (remove_indices ?m ?S))

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (monom_eval R (restrict_to_indices (add_mset i m) S) g) (mset_to_IP R (remove_indices (add_mset i m) S))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (monom_eval R (restrict_to_indices (add_mset i m) S) g) (mset_to_IP R (remove_indices (add_mset i m) S))

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
have 1: "(mset_to_IP R (remove_indices (add_mset i m) S)) =
                           (mset_to_IP R (remove_indices m S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mset_to_IP R (remove_indices (add_mset i m) S) = mset_to_IP R (remove_indices m S)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
g \<in> UNIV \<rightarrow> carrier R
\<one> \<noteq> \<zero>
i \<in> S

goal (1 subgoal):
 1. mset_to_IP R (remove_indices (add_mset i m) S) = mset_to_IP R (remove_indices m S)
[PROOF STEP]
by (metis (full_types) Diff_iff insert_Diff1 remove_indices_def restrict_to_indices_add_element set_mset_add_mset_insert)
[PROOF STATE]
proof (state)
this:
mset_to_IP R (remove_indices (add_mset i m) S) = mset_to_IP R (remove_indices m S)

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
have 2: "(monom_eval R (restrict_to_indices (add_mset i m) S) g) =
            (g i) \<otimes> ((monom_eval R (restrict_to_indices m S) g))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. monom_eval R (restrict_to_indices (add_mset i m) S) g = g i \<otimes> monom_eval R (restrict_to_indices m S) g
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
g \<in> UNIV \<rightarrow> carrier R
\<one> \<noteq> \<zero>
i \<in> S

goal (1 subgoal):
 1. monom_eval R (restrict_to_indices (add_mset i m) S) g = g i \<otimes> monom_eval R (restrict_to_indices m S) g
[PROOF STEP]
by (metis monom_eval_add restrict_to_indices_add_element)
[PROOF STATE]
proof (state)
this:
monom_eval R (restrict_to_indices (add_mset i m) S) g = g i \<otimes> monom_eval R (restrict_to_indices m S) g

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
have 3: "poly_eval R  S g (mset_to_IP R (add_mset i m)) =
                poly_scalar_mult R ((g i) \<otimes> ((monom_eval R (restrict_to_indices m S) g)))
                              (mset_to_IP R (remove_indices m S))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i \<otimes> monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))
[PROOF STEP]
using 0 1 2 assms
[PROOF STATE]
proof (prove)
using this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (monom_eval R (restrict_to_indices (add_mset i m) S) g) (mset_to_IP R (remove_indices (add_mset i m) S))
mset_to_IP R (remove_indices (add_mset i m) S) = mset_to_IP R (remove_indices m S)
monom_eval R (restrict_to_indices (add_mset i m) S) g = g i \<otimes> monom_eval R (restrict_to_indices m S) g
g \<in> UNIV \<rightarrow> carrier R
\<one> \<noteq> \<zero>
i \<in> S

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i \<otimes> monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i \<otimes> monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
hence "poly_eval R  S g (mset_to_IP R (add_mset i m)) =
                poly_scalar_mult R (g i)
                  (poly_scalar_mult R ((monom_eval R (restrict_to_indices m S) g))
                              (mset_to_IP R (remove_indices m S)))"
[PROOF STATE]
proof (prove)
using this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i \<otimes> monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_scalar_mult R (monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S)))
[PROOF STEP]
using assms poly_scalar_mult_iter[of "(mset_to_IP R (remove_indices m S))"
                                          UNIV "g i" "monom_eval R (restrict_to_indices m S) g"]
          mset_to_IP_closed[of "remove_indices m S" UNIV]
[PROOF STATE]
proof (prove)
using this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i \<otimes> monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))
g \<in> UNIV \<rightarrow> carrier R
\<one> \<noteq> \<zero>
i \<in> S
\<lbrakk>\<one> \<noteq> \<zero>; mset_to_IP R (remove_indices m S) \<in> carrier R [\<X>\<^bsub>UNIV\<^esub>]; g i \<in> carrier R; monom_eval R (restrict_to_indices m S) g \<in> carrier R\<rbrakk> \<Longrightarrow> poly_scalar_mult R (g i) (poly_scalar_mult R (monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))) = poly_scalar_mult R (g i \<otimes> monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S))
set_mset (remove_indices m S) \<subseteq> UNIV \<Longrightarrow> mset_to_IP R (remove_indices m S) \<in> carrier R [\<X>\<^bsub>UNIV\<^esub>]

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_scalar_mult R (monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S)))
[PROOF STEP]
by (metis PiE UNIV_I monom_eval_car subsetI)
[PROOF STATE]
proof (state)
this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_scalar_mult R (monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S)))

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_scalar_mult R (monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S)))

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_scalar_mult R (monom_eval R (restrict_to_indices m S) g) (mset_to_IP R (remove_indices m S)))
g \<in> UNIV \<rightarrow> carrier R
\<one> \<noteq> \<zero>
i \<in> S

goal (1 subgoal):
 1. poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))
[PROOF STEP]
by (metis poly_eval_monomial)
[PROOF STATE]
proof (state)
this:
poly_eval R S g (mset_to_IP R (add_mset i m)) = poly_scalar_mult R (g i) (poly_eval R S g (mset_to_IP R m))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma harry_sum_correct: "harry_sum n = sum harry_meas (seqs n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. harry_sum n = sum harry_meas (seqs n)
[PROOF STEP]
proof (induction n rule: Suc_Suc_induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
case (3 n)
[PROOF STATE]
proof (state)
this:
harry_sum n = sum harry_meas (seqs n)
harry_sum (Suc n) = sum harry_meas (seqs (Suc n))

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
have "seqs (Suc (Suc n)) =
          (\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union>
          (\<lambda>xs. True # xs @ [True]) ` seqs n \<union>
          (\<lambda>xs. False # xs @ [True]) ` seqs n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. seqs (Suc (Suc n)) = (\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union> (\<lambda>xs. True # xs @ [True]) ` seqs n \<union> (\<lambda>xs. False # xs @ [True]) ` seqs n
[PROOF STEP]
by (subst (1) seqs_Suc, subst (1 2) seqs_Suc') (simp add: image_Un image_image Un_ac seqs_Suc)
[PROOF STATE]
proof (state)
this:
seqs (Suc (Suc n)) = (\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union> (\<lambda>xs. True # xs @ [True]) ` seqs n \<union> (\<lambda>xs. False # xs @ [True]) ` seqs n

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
seqs (Suc (Suc n)) = (\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union> (\<lambda>xs. True # xs @ [True]) ` seqs n \<union> (\<lambda>xs. False # xs @ [True]) ` seqs n

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
have "int (sum harry_meas \<dots>) =
               int (harry_sum (Suc n)) +
               int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) +
               int (\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (sum harry_meas ((\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union> (\<lambda>xs. True # xs @ [True]) ` seqs n \<union> (\<lambda>xs. False # xs @ [True]) ` seqs n)) = int (harry_sum (Suc n)) + int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) + int (\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True]))
[PROOF STEP]
by (subst sum.union_disjoint sum.reindex, auto simp: inj_on_def 3)+
[PROOF STATE]
proof (state)
this:
int (sum harry_meas ((\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union> (\<lambda>xs. True # xs @ [True]) ` seqs n \<union> (\<lambda>xs. False # xs @ [True]) ` seqs n)) = int (harry_sum (Suc n)) + int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) + int (\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True]))

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (sum harry_meas ((\<lambda>xs. xs @ [False]) ` seqs (Suc n) \<union> (\<lambda>xs. True # xs @ [True]) ` seqs n \<union> (\<lambda>xs. False # xs @ [True]) ` seqs n)) = int (harry_sum (Suc n)) + int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) + int (\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True]))

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
have "int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) =
                2 ^ n + int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True]))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) = 2 ^ n + int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True]))
[PROOF STEP]
by (subst sum.distrib) auto
[PROOF STATE]
proof (state)
this:
int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) = 2 ^ n + int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True]))

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
int (\<Sum>xs\<in>seqs n. 1 + harry_meas (xs @ [True])) = 2 ^ n + int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True]))

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
have "(\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True])) = harry_sum n + (2 * n + 3) * 2 ^ n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True])) = harry_sum n + (2 * n + 3) * 2 ^ n
[PROOF STEP]
by (auto simp: 3 harry_meas_False_True sum.distrib algebra_simps length_seqs)
[PROOF STATE]
proof (state)
this:
(\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True])) = harry_sum n + (2 * n + 3) * 2 ^ n

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>xs\<in>seqs n. harry_meas (False # xs @ [True])) = harry_sum n + (2 * n + 3) * 2 ^ n

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
have "harry_sum (Suc n) = (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) + harry_sum n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. harry_sum (Suc n) = (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) + harry_sum n
[PROOF STEP]
unfolding seqs_Suc' 3
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum harry_meas ((\<lambda>xs. xs @ [True]) ` seqs n \<union> (\<lambda>xs. xs @ [False]) ` seqs n) = (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) + sum harry_meas (seqs n)
[PROOF STEP]
by (subst sum.union_disjoint sum.reindex, auto simp: inj_on_def)+
[PROOF STATE]
proof (state)
this:
harry_sum (Suc n) = (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) + harry_sum n

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
hence "int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) = int (harry_sum (Suc n)) - int (harry_sum n)"
[PROOF STATE]
proof (prove)
using this:
harry_sum (Suc n) = (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) + harry_sum n

goal (1 subgoal):
 1. int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) = int (harry_sum (Suc n)) - int (harry_sum n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int (\<Sum>xs\<in>seqs n. harry_meas (xs @ [True])) = int (harry_sum (Suc n)) - int (harry_sum n)

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
int (sum harry_meas (seqs (Suc (Suc n)))) = int (harry_sum (Suc n)) + (2 ^ n + (int (harry_sum (Suc n)) - int (harry_sum n))) + int (harry_sum n + (2 * n + 3) * 2 ^ n)
[PROOF STEP]
have "int (\<Sum>x\<in>seqs (Suc (Suc n)). harry_meas x) =
                  int (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)"
[PROOF STATE]
proof (prove)
using this:
int (sum harry_meas (seqs (Suc (Suc n)))) = int (harry_sum (Suc n)) + (2 ^ n + (int (harry_sum (Suc n)) - int (harry_sum n))) + int (harry_sum n + (2 * n + 3) * 2 ^ n)

goal (1 subgoal):
 1. int (sum harry_meas (seqs (Suc (Suc n)))) = int (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)
[PROOF STEP]
unfolding of_nat_add
[PROOF STATE]
proof (prove)
using this:
int (sum harry_meas (seqs (Suc (Suc n)))) = int (harry_sum (Suc n)) + (2 ^ n + (int (harry_sum (Suc n)) - int (harry_sum n))) + (int (harry_sum n) + int ((2 * n + 3) * 2 ^ n))

goal (1 subgoal):
 1. int (sum harry_meas (seqs (Suc (Suc n)))) = int (2 * harry_sum (Suc n)) + int ((2 * n + 4) * 2 ^ n)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
int (sum harry_meas (seqs (Suc (Suc n)))) = int (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
hence "(\<Sum>x\<in>seqs (Suc (Suc n)). (harry_meas x)) =
            (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)"
[PROOF STATE]
proof (prove)
using this:
int (sum harry_meas (seqs (Suc (Suc n)))) = int (2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n)

goal (1 subgoal):
 1. sum harry_meas (seqs (Suc (Suc n))) = 2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
sum harry_meas (seqs (Suc (Suc n))) = 2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n

goal (3 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
 3. \<And>n. \<lbrakk>harry_sum n = sum harry_meas (seqs n); harry_sum (Suc n) = sum harry_meas (seqs (Suc n))\<rbrakk> \<Longrightarrow> harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
sum harry_meas (seqs (Suc (Suc n))) = 2 * harry_sum (Suc n) + (2 * n + 4) * 2 ^ n

goal (1 subgoal):
 1. harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
harry_sum (Suc (Suc n)) = sum harry_meas (seqs (Suc (Suc n)))

goal (2 subgoals):
 1. harry_sum 0 = sum harry_meas (seqs 0)
 2. harry_sum (Suc 0) = sum harry_meas (seqs (Suc 0))
[PROOF STEP]
qed (auto simp: seqs_Suc)


[STATEMENT]
lemma inj_comp_eq: assumes "inj (f :: 'a list \<Rightarrow> 'b list)" shows "(g = h \<longleftrightarrow> f \<circ> g = f \<circ> h)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (g = h) = (f \<circ> g = f \<circ> h)
[PROOF STEP]
by (rule, fast)  (use fun.inj_map[OF assms, unfolded inj_on_def] in fast)


[STATEMENT]
lemma subd_power_sum: "subd p (sum f I) = sum (subd p \<circ> f) I"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subd p (sum f I) = sum (subd p \<circ> f) I
[PROOF STEP]
apply (induction I rule: infinite_finite_induct)
[PROOF STATE]
proof (prove)
goal (3 subgoals):
 1. \<And>A. infinite A \<Longrightarrow> subd p (sum f A) = sum (subd p \<circ> f) A
 2. subd p (sum f {}) = sum (subd p \<circ> f) {}
 3. \<And>x F. \<lbrakk>finite F; x \<notin> F; subd p (sum f F) = sum (subd p \<circ> f) F\<rbrakk> \<Longrightarrow> subd p (sum f (insert x F)) = sum (subd p \<circ> f) (insert x F)
[PROOF STEP]
by auto (metis add_diff_cancel_left' diff_add_cancel subd_diff)


[STATEMENT]
lemma partition_on_mset_distinct_inter:
  assumes "partition_on_mset A P"
  assumes "distinct_mset A"
  assumes "p1 \<in># P" and "p2 \<in># P" and "p1 \<noteq> p2"
  shows "p1 \<inter># p2 = {#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p1 \<inter># p2 = {#}
[PROOF STEP]
by (metis assms in_remove1_mset_neq partition_on_mset_distinct_disjoint)


[STATEMENT]
lemma real_less_lsqrt: "0 \<le> x \<Longrightarrow> 0 \<le> y \<Longrightarrow> x < y\<^sup>2 \<Longrightarrow> sqrt x < y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> x; 0 \<le> y; x < y\<^sup>2\<rbrakk> \<Longrightarrow> sqrt x < y
[PROOF STEP]
using real_sqrt_less_iff[of x "y\<^sup>2"]
[PROOF STATE]
proof (prove)
using this:
(sqrt x < sqrt (y\<^sup>2)) = (x < y\<^sup>2)

goal (1 subgoal):
 1. \<lbrakk>0 \<le> x; 0 \<le> y; x < y\<^sup>2\<rbrakk> \<Longrightarrow> sqrt x < y
[PROOF STEP]
by simp


[STATEMENT]
lemma span_breakdown_eq: "x \<in> span (insert a S) \<longleftrightarrow> (\<exists>k. x - k *s a \<in> span S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<in> span (insert a S)) = (\<exists>k. x - k *s a \<in> span S)
[PROOF STEP]
by (simp add: span_insert)


[STATEMENT]
lemma evaln_Suc: "<c,s> -n-> s' ==> <c,s> -Suc n-> s'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. <c,s> -n-> s' \<Longrightarrow> <c,s> -Suc n-> s'
[PROOF STEP]
apply (erule evaln_nonstrict)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<le> Suc n
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma var_eq_mvar:
  assumes "t0 \<in> existence_ivl0 x0"
  assumes "t \<in> existence_ivl0 x0"
  shows "var.flow x0 t0 i t = mvar.flow x0 t0 id_blinfun t i"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. var.flow x0 t0 i t = blinfun_apply (mvar.flow x0 t0 1\<^sub>L t) i
[PROOF STEP]
by (rule var.flow_unique)
     (auto intro!: assms derivative_eq_intros mvar.flow_has_derivative
       simp: varexivl_eq_exivl assms has_vector_derivative_def blinfun.bilinear_simps)


[STATEMENT]
lemma NOT_VS_IN_DOM_PROJ_PRE_EFF:
  fixes ROB vs v a
  assumes "\<not>(v \<in> vs)" "(a \<in> PROB)"
  shows "(
    ((v \<in> fmdom' (fst a)) \<longrightarrow> (v \<in> fmdom' (fst (action_proj a (prob_dom PROB - vs)))))
    \<and> ((v \<in> fmdom' (snd a)) \<longrightarrow> (v \<in> fmdom' (snd (action_proj a (prob_dom PROB - vs)))))
  )"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v \<in> fmdom' (fst a) \<longrightarrow> v \<in> fmdom' (fst (action_proj a (prob_dom PROB - vs)))) \<and> (v \<in> fmdom' (snd a) \<longrightarrow> v \<in> fmdom' (snd (action_proj a (prob_dom PROB - vs))))
[PROOF STEP]
unfolding action_proj_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (v \<in> fmdom' (fst a) \<longrightarrow> v \<in> fmdom' (fst (fmrestrict_set (prob_dom PROB - vs) (fst a), fmrestrict_set (prob_dom PROB - vs) (snd a)))) \<and> (v \<in> fmdom' (snd a) \<longrightarrow> v \<in> fmdom' (snd (fmrestrict_set (prob_dom PROB - vs) (fst a), fmrestrict_set (prob_dom PROB - vs) (snd a))))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
v \<notin> vs
a \<in> PROB

goal (1 subgoal):
 1. (v \<in> fmdom' (fst a) \<longrightarrow> v \<in> fmdom' (fst (fmrestrict_set (prob_dom PROB - vs) (fst a), fmrestrict_set (prob_dom PROB - vs) (snd a)))) \<and> (v \<in> fmdom' (snd a) \<longrightarrow> v \<in> fmdom' (snd (fmrestrict_set (prob_dom PROB - vs) (fst a), fmrestrict_set (prob_dom PROB - vs) (snd a))))
[PROOF STEP]
by (simp add: IN_FDOM_DRESTRICT_DIFF FDOM_pre_subset_prob_dom_pair
      FDOM_eff_subset_prob_dom_pair)


[STATEMENT]
lemma Ln_conv_Arctan:
  assumes "z \<noteq> -1"
  shows   "Ln z = -2*\<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
have "Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z) =
             \<i>/2 * Ln (moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z) = \<i> / 2 * Ln (moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z))
[PROOF STEP]
by (simp add: Arctan_def_moebius)
[PROOF STATE]
proof (state)
this:
Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z) = \<i> / 2 * Ln (moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z))

goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z) = \<i> / 2 * Ln (moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z))

goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
z \<noteq> - 1
[PROOF STEP]
have "\<i> * z \<noteq> \<i> * (-1)"
[PROOF STATE]
proof (prove)
using this:
z \<noteq> - 1

goal (1 subgoal):
 1. \<i> * z \<noteq> \<i> * - 1
[PROOF STEP]
by (subst mult_left_cancel) simp
[PROOF STATE]
proof (state)
this:
\<i> * z \<noteq> \<i> * - 1

goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
hence "\<i> * z - -\<i> \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
\<i> * z \<noteq> \<i> * - 1

goal (1 subgoal):
 1. \<i> * z - - \<i> \<noteq> 0
[PROOF STEP]
by (simp add: eq_neg_iff_add_eq_0)
[PROOF STATE]
proof (state)
this:
\<i> * z - - \<i> \<noteq> 0

goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
from moebius_inverse'[OF _ this, of 1 1]
[PROOF STATE]
proof (chain)
picking this:
- \<i> * 1 \<noteq> 1 * \<i> \<Longrightarrow> moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z) = z
[PROOF STEP]
have "moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z) = z"
[PROOF STATE]
proof (prove)
using this:
- \<i> * 1 \<noteq> 1 * \<i> \<Longrightarrow> moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z) = z

goal (1 subgoal):
 1. moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z) = z
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
moebius (- \<i>) 1 \<i> 1 (moebius 1 (- 1) (- \<i>) (- \<i>) z) = z

goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z) = \<i> / 2 * Ln z
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z) = \<i> / 2 * Ln z

goal (1 subgoal):
 1. Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
Ln z = - 2 * \<i> * Arctan (moebius 1 (- 1) (- \<i>) (- \<i>) z)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in cpx_sq_mat) sum_over_spectrum:
  assumes "A\<in> fc_mats"
and "hermitian A"
and "make_pm A = (p, M)"
shows "(\<Sum> y \<in> spectrum A. f y) =  (\<Sum> i < p. f (meas_outcome_val (M i)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum f (spectrum A) = (\<Sum>i<p. f (complex_of_real (meas_outcome_val (M i))))
[PROOF STEP]
proof (rule sum.reindex_cong)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. inj_on ?l {..<p}
 2. spectrum A = ?l ` {..<p}
 3. \<And>x. x \<in> {..<p} \<Longrightarrow> f (?l x) = f (complex_of_real (meas_outcome_val (M x)))
[PROOF STEP]
show "spectrum A =(\<lambda>x. (meas_outcome_val (M x)))` {..< p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. spectrum A = (\<lambda>x. complex_of_real (meas_outcome_val (M x))) ` {..<p}
[PROOF STEP]
using spectrum_meas_outcome_val_eq assms
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>hermitian ?A; ?A \<in> fc_mats; make_pm ?A = (?p, ?M)\<rbrakk> \<Longrightarrow> spectrum ?A = (\<lambda>x. complex_of_real (meas_outcome_val (?M x))) ` {..<?p}
A \<in> fc_mats
hermitian A
make_pm A = (p, M)

goal (1 subgoal):
 1. spectrum A = (\<lambda>x. complex_of_real (meas_outcome_val (M x))) ` {..<p}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
spectrum A = (\<lambda>x. complex_of_real (meas_outcome_val (M x))) ` {..<p}

goal (2 subgoals):
 1. inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}
 2. \<And>x. x \<in> {..<p} \<Longrightarrow> f (complex_of_real (meas_outcome_val (M x))) = f (complex_of_real (meas_outcome_val (M x)))
[PROOF STEP]
show "inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}
[PROOF STEP]
have "inj_on (\<lambda>x. (meas_outcome_val (M x))) {..<p}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. meas_outcome_val (M x)) {..<p}
[PROOF STEP]
using make_pm_proj_measurement[of A p M] assms proj_measurement_inj
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>A \<in> fc_mats; hermitian A; make_pm A = (p, M)\<rbrakk> \<Longrightarrow> proj_measurement p M
A \<in> fc_mats
hermitian A
make_pm A = (p, M)
proj_measurement ?p ?M \<Longrightarrow> inj_on (\<lambda>i. meas_outcome_val (?M i)) {..<?p}

goal (1 subgoal):
 1. inj_on (\<lambda>x. meas_outcome_val (M x)) {..<p}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>x. meas_outcome_val (M x)) {..<p}

goal (1 subgoal):
 1. inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
inj_on (\<lambda>x. meas_outcome_val (M x)) {..<p}

goal (1 subgoal):
 1. inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}
[PROOF STEP]
by (simp add: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>x. complex_of_real (meas_outcome_val (M x))) {..<p}

goal (1 subgoal):
 1. \<And>x. x \<in> {..<p} \<Longrightarrow> f (complex_of_real (meas_outcome_val (M x))) = f (complex_of_real (meas_outcome_val (M x)))
[PROOF STEP]
qed simp


[STATEMENT]
lemma set_less_eq_aux_rec:
  assumes "finite A" "finite B" "A \<noteq> {}" "B \<noteq> {}"
  shows "A \<sqsubseteq>' B \<longleftrightarrow> Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
proof(cases "A = B")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. A = B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
 2. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
A = B

goal (2 subgoals):
 1. A = B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
 2. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
A = B

goal (1 subgoal):
 1. (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
A = B
finite A
finite B
A \<noteq> {}
B \<noteq> {}

goal (1 subgoal):
 1. (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
by(simp add: finite_complement_partition)
[PROOF STATE]
proof (state)
this:
(A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})

goal (1 subgoal):
 1. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
A \<noteq> B

goal (1 subgoal):
 1. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
A \<noteq> B

goal (1 subgoal):
 1. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
hence "Min A = Min B \<Longrightarrow> A - {Min A} \<noteq> B - {Min B}"
[PROOF STATE]
proof (prove)
using this:
A \<noteq> B

goal (1 subgoal):
 1. Min A = Min B \<Longrightarrow> A - {Min A} \<noteq> B - {Min B}
[PROOF STEP]
by (metis (lifting) assms Min_in insert_Diff)
[PROOF STATE]
proof (state)
this:
Min A = Min B \<Longrightarrow> A - {Min A} \<noteq> B - {Min B}

goal (1 subgoal):
 1. A \<noteq> B \<Longrightarrow> (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
A \<noteq> B
Min A = Min B \<Longrightarrow> A - {Min A} \<noteq> B - {Min B}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
A \<noteq> B
Min A = Min B \<Longrightarrow> A - {Min A} \<noteq> B - {Min B}

goal (1 subgoal):
 1. (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
using set_less_aux_rec[OF assms]
[PROOF STATE]
proof (prove)
using this:
A \<noteq> B
Min A = Min B \<Longrightarrow> A - {Min A} \<noteq> B - {Min B}
(A \<sqsubset>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubset>' B - {Min A})

goal (1 subgoal):
 1. (A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})
[PROOF STEP]
by(simp add: set_less_eq_aux_def cong: conj_cong)
[PROOF STATE]
proof (state)
this:
(A \<sqsubseteq>' B) = (Min B < Min A \<or> Min A = Min B \<and> A - {Min A} \<sqsubseteq>' B - {Min A})

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma span_neg: "x \<in> span S \<Longrightarrow> - x \<in> span S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> span S \<Longrightarrow> - x \<in> span S
[PROOF STEP]
by (metis subspace_neg subspace_span)