[STATEMENT]
lemma gen_lucas_lehmer_sequence_4_closed_form2:
  "gen_lucas_lehmer_sequence 4 n = round ((2 + sqrt 3) ^ (2 ^ n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gen_lucas_lehmer_sequence 4 n = round ((2 + sqrt 3) ^ 2 ^ n)
[PROOF STEP]
proof (rule sym, rule round_unique')
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
have "5 / 3 < sqrt (3 :: real)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 5 / 3 < sqrt 3
[PROOF STEP]
by (rule real_less_rsqrt) (auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
5 / 3 < sqrt 3

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
hence "(2 - sqrt 3) ^ (2 ^ n) < (1 / 3) ^ (2 ^ n)"
[PROOF STATE]
proof (prove)
using this:
5 / 3 < sqrt 3

goal (1 subgoal):
 1. (2 - sqrt 3) ^ 2 ^ n < (1 / 3) ^ 2 ^ n
[PROOF STEP]
by (intro power_strict_mono) (auto simp: real_le_lsqrt)
[PROOF STATE]
proof (state)
this:
(2 - sqrt 3) ^ 2 ^ n < (1 / 3) ^ 2 ^ n

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(2 - sqrt 3) ^ 2 ^ n < (1 / 3) ^ 2 ^ n

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
have "\<dots> \<le> (1 / 3) ^ 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (1 / 3) ^ 2 ^ n \<le> (1 / 3) ^ 1
[PROOF STEP]
by (intro power_decreasing) auto
[PROOF STATE]
proof (state)
this:
(1 / 3) ^ 2 ^ n \<le> (1 / 3) ^ 1

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(2 - sqrt 3) ^ 2 ^ n < (1 / 3) ^ 1
[PROOF STEP]
have "(2 - sqrt 3) ^ (2 ^ n) < 1 / 2"
[PROOF STATE]
proof (prove)
using this:
(2 - sqrt 3) ^ 2 ^ n < (1 / 3) ^ 1

goal (1 subgoal):
 1. (2 - sqrt 3) ^ 2 ^ n < 1 / 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(2 - sqrt 3) ^ 2 ^ n < 1 / 2

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(2 - sqrt 3) ^ 2 ^ n < 1 / 2

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
have "(2 - sqrt 3) ^ (2 ^ n) \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> (2 - sqrt 3) ^ 2 ^ n
[PROOF STEP]
by (intro zero_le_power) (auto simp: real_le_lsqrt)
[PROOF STATE]
proof (state)
this:
0 \<le> (2 - sqrt 3) ^ 2 ^ n

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(2 - sqrt 3) ^ 2 ^ n < 1 / 2
0 \<le> (2 - sqrt 3) ^ 2 ^ n
[PROOF STEP]
show "\<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2"
[PROOF STATE]
proof (prove)
using this:
(2 - sqrt 3) ^ 2 ^ n < 1 / 2
0 \<le> (2 - sqrt 3) ^ 2 ^ n

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2
[PROOF STEP]
unfolding gen_lucas_lehmer_sequence_4_closed_form1
[PROOF STATE]
proof (prove)
using this:
(2 - sqrt 3) ^ 2 ^ n < 1 / 2
0 \<le> (2 - sqrt 3) ^ 2 ^ n

goal (1 subgoal):
 1. \<bar>(2 + sqrt 3) ^ 2 ^ n - ((2 + sqrt 3) ^ 2 ^ n + (2 - sqrt 3) ^ 2 ^ n)\<bar> < 1 / 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<bar>(2 + sqrt 3) ^ 2 ^ n - real_of_int (gen_lucas_lehmer_sequence 4 n)\<bar> < 1 / 2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma per_lemma_len_le: assumes le: "p + q - gcd p q \<le> (n :: nat)" and "q \<noteq> 0" shows "p \<le> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p \<le> n
[PROOF STEP]
using le
[PROOF STATE]
proof (prove)
using this:
p + q - gcd p q \<le> n

goal (1 subgoal):
 1. p \<le> n
[PROOF STEP]
unfolding add_diff_assoc[OF gcd_le2_nat[OF \<open>q \<noteq> 0\<close>], symmetric]
[PROOF STATE]
proof (prove)
using this:
p + (q - gcd p q) \<le> n

goal (1 subgoal):
 1. p \<le> n
[PROOF STEP]
by (rule add_leD1)


[STATEMENT]
lemma elements_four_block_mat_id:
  assumes c: "A \<in> carrier_mat nr1 nc1" "B \<in> carrier_mat nr1 nc2"
    "C \<in> carrier_mat nr2 nc1" "D \<in> carrier_mat nr2 nc2"
  shows
    "elements_mat (four_block_mat A B C D) =
   elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D"
    (is "elements_mat ?four = ?X")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. elements_mat (four_block_mat A B C D) = elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. elements_mat (four_block_mat A B C D) \<subseteq> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D
 2. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
show "elements_mat ?four \<subseteq> ?X"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. elements_mat (four_block_mat A B C D) \<subseteq> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D
[PROOF STEP]
by (rule elements_four_block_mat[OF c])
[PROOF STATE]
proof (state)
this:
elements_mat (four_block_mat A B C D) \<subseteq> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
have 4: "?four \<in> carrier_mat (nr1 + nr2) (nc1 + nc2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. four_block_mat A B C D \<in> carrier_mat (nr1 + nr2) (nc1 + nc2)
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. four_block_mat A B C D \<in> carrier_mat (nr1 + nr2) (nc1 + nc2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
four_block_mat A B C D \<in> carrier_mat (nr1 + nr2) (nc1 + nc2)

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
four_block_mat A B C D \<in> carrier_mat (nr1 + nr2) (nc1 + nc2)

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
assume "x \<in> ?X"
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D
[PROOF STEP]
consider (A) "x \<in> elements_mat A"
      | (B) "x \<in> elements_mat B"
      | (C) "x \<in> elements_mat C"
      | (D) "x \<in> elements_mat D"
[PROOF STATE]
proof (prove)
using this:
x \<in> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D

goal (1 subgoal):
 1. \<lbrakk>x \<in> elements_mat A \<Longrightarrow> thesis; x \<in> elements_mat B \<Longrightarrow> thesis; x \<in> elements_mat C \<Longrightarrow> thesis; x \<in> elements_mat D \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>x \<in> elements_mat A \<Longrightarrow> ?thesis; x \<in> elements_mat B \<Longrightarrow> ?thesis; x \<in> elements_mat C \<Longrightarrow> ?thesis; x \<in> elements_mat D \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
hence "x \<in> elements_mat ?four"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>x \<in> elements_mat A \<Longrightarrow> ?thesis; x \<in> elements_mat B \<Longrightarrow> ?thesis; x \<in> elements_mat C \<Longrightarrow> ?thesis; x \<in> elements_mat D \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
proof (cases)
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. x \<in> elements_mat A \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 4. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
case A
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat A

goal (4 subgoals):
 1. x \<in> elements_mat A \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 4. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matD[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>i j. i < dim_row A \<and> j < dim_col A \<and> x = A $$ (i, j)
[PROOF STEP]
obtain i j
        where *: "i < nr1" "j < nc1" and x: "x = A $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row A \<and> j < dim_col A \<and> x = A $$ (i, j)

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr1; j < nc1; x = A $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row A \<and> j < dim_col A \<and> x = A $$ (i, j)
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr1; j < nc1; x = A $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < nr1
j < nc1
x = A $$ (i, j)

goal (4 subgoals):
 1. x \<in> elements_mat A \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 4. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matI[OF 4, of i j x] * c
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>i < nr1 + nr2; j < nc1 + nc2; x = four_block_mat A B C D $$ (i, j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr1
j < nc1
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i < nr1 + nr2; j < nc1 + nc2; x = four_block_mat A B C D $$ (i, j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr1
j < nc1
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
unfolding x
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i < nr1 + nr2; j < nc1 + nc2; A $$ (i, j) = four_block_mat A B C D $$ (i, j)\<rbrakk> \<Longrightarrow> A $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
i < nr1
j < nc1
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. A $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat (four_block_mat A B C D)

goal (3 subgoals):
 1. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
case B
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat B

goal (3 subgoals):
 1. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matD[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>i j. i < dim_row B \<and> j < dim_col B \<and> x = B $$ (i, j)
[PROOF STEP]
obtain i j
        where *: "i < nr1" "j < nc2" and x: "x = B $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row B \<and> j < dim_col B \<and> x = B $$ (i, j)

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr1; j < nc2; x = B $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row B \<and> j < dim_col B \<and> x = B $$ (i, j)
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr1; j < nc2; x = B $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < nr1
j < nc2
x = B $$ (i, j)

goal (3 subgoals):
 1. x \<in> elements_mat B \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 3. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matI[OF 4, of i "nc1 + j" x] * c
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>i < nr1 + nr2; nc1 + j < nc1 + nc2; x = four_block_mat A B C D $$ (i, nc1 + j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr1
j < nc2
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i < nr1 + nr2; nc1 + j < nc1 + nc2; x = four_block_mat A B C D $$ (i, nc1 + j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr1
j < nc2
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
unfolding x
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>i < nr1 + nr2; nc1 + j < nc1 + nc2; B $$ (i, j) = four_block_mat A B C D $$ (i, nc1 + j)\<rbrakk> \<Longrightarrow> B $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
i < nr1
j < nc2
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. B $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat (four_block_mat A B C D)

goal (2 subgoals):
 1. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
case C
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat C

goal (2 subgoals):
 1. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matD[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>i j. i < dim_row C \<and> j < dim_col C \<and> x = C $$ (i, j)
[PROOF STEP]
obtain i j
        where *: "i < nr2" "j < nc1" and x: "x = C $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row C \<and> j < dim_col C \<and> x = C $$ (i, j)

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr2; j < nc1; x = C $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row C \<and> j < dim_col C \<and> x = C $$ (i, j)
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr2; j < nc1; x = C $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < nr2
j < nc1
x = C $$ (i, j)

goal (2 subgoals):
 1. x \<in> elements_mat C \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
 2. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matI[OF 4, of "nr1 + i" j x] * c
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>nr1 + i < nr1 + nr2; j < nc1 + nc2; x = four_block_mat A B C D $$ (nr1 + i, j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr2
j < nc1
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>nr1 + i < nr1 + nr2; j < nc1 + nc2; x = four_block_mat A B C D $$ (nr1 + i, j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr2
j < nc1
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
unfolding x
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>nr1 + i < nr1 + nr2; j < nc1 + nc2; C $$ (i, j) = four_block_mat A B C D $$ (nr1 + i, j)\<rbrakk> \<Longrightarrow> C $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
i < nr2
j < nc1
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. C $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat (four_block_mat A B C D)

goal (1 subgoal):
 1. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
case D
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat D

goal (1 subgoal):
 1. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matD[OF this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>i j. i < dim_row D \<and> j < dim_col D \<and> x = D $$ (i, j)
[PROOF STEP]
obtain i j
        where *: "i < nr2" "j < nc2" and x: "x = D $$ (i,j)"
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row D \<and> j < dim_col D \<and> x = D $$ (i, j)

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr2; j < nc2; x = D $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using c
[PROOF STATE]
proof (prove)
using this:
\<exists>i j. i < dim_row D \<and> j < dim_col D \<and> x = D $$ (i, j)
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. (\<And>i j. \<lbrakk>i < nr2; j < nc2; x = D $$ (i, j)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
i < nr2
j < nc2
x = D $$ (i, j)

goal (1 subgoal):
 1. x \<in> elements_mat D \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
from elements_matI[OF 4, of "nr1 + i" "nc1 + j" x] * c
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>nr1 + i < nr1 + nr2; nc1 + j < nc1 + nc2; x = four_block_mat A B C D $$ (nr1 + i, nc1 + j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr2
j < nc2
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>nr1 + i < nr1 + nr2; nc1 + j < nc1 + nc2; x = four_block_mat A B C D $$ (nr1 + i, nc1 + j)\<rbrakk> \<Longrightarrow> x \<in> elements_mat (four_block_mat A B C D)
i < nr2
j < nc2
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. x \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
unfolding x
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>nr1 + i < nr1 + nr2; nc1 + j < nc1 + nc2; D $$ (i, j) = four_block_mat A B C D $$ (nr1 + i, nc1 + j)\<rbrakk> \<Longrightarrow> D $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
i < nr2
j < nc2
A \<in> carrier_mat nr1 nc1
B \<in> carrier_mat nr1 nc2
C \<in> carrier_mat nr2 nc1
D \<in> carrier_mat nr2 nc2

goal (1 subgoal):
 1. D $$ (i, j) \<in> elements_mat (four_block_mat A B C D)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat (four_block_mat A B C D)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
x \<in> elements_mat (four_block_mat A B C D)

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?x2 \<in> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<Longrightarrow> ?x2 \<in> elements_mat (four_block_mat A B C D)

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
thus "elements_mat ?four \<supseteq> ?X"
[PROOF STATE]
proof (prove)
using this:
?x2 \<in> elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<Longrightarrow> ?x2 \<in> elements_mat (four_block_mat A B C D)

goal (1 subgoal):
 1. elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
elements_mat A \<union> elements_mat B \<union> elements_mat C \<union> elements_mat D \<subseteq> elements_mat (four_block_mat A B C D)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma supporters_def:
  assumes "is_pref_profile R"
  shows   "supporters R x y = {i\<in>agents. x \<succeq>[R i] y}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. supporters R x y = {i \<in> agents. R i y x}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. supporters R x y = {i \<in> agents. R i y x}
[PROOF STEP]
interpret pref_profile_wf agents alts R
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_pref_profile R
[PROOF STEP]
by fact
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. supporters R x y = {i \<in> agents. R i y x}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. supporters R x y = {i \<in> agents. R i y x}
[PROOF STEP]
using not_outside
[PROOF STATE]
proof (prove)
using this:
R ?i ?x ?y \<Longrightarrow> ?i \<in> agents
R ?i ?x ?y \<Longrightarrow> ?x \<in> alts
R ?i ?x ?y \<Longrightarrow> ?y \<in> alts

goal (1 subgoal):
 1. supporters R x y = {i \<in> agents. R i y x}
[PROOF STEP]
unfolding supporters_auxdef
[PROOF STATE]
proof (prove)
using this:
R ?i ?x ?y \<Longrightarrow> ?i \<in> agents
R ?i ?x ?y \<Longrightarrow> ?x \<in> alts
R ?i ?x ?y \<Longrightarrow> ?y \<in> alts

goal (1 subgoal):
 1. {i. R i y x} = {i \<in> agents. R i y x}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
supporters R x y = {i \<in> agents. R i y x}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma val_fract:
  assumes "a \<in> carrier Q\<^sub>p"
  assumes "b \<in> nonzero Q\<^sub>p"
  shows "val (a \<div> b) = val a - val b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. val (a \<div> b) = val a - val b
[PROOF STEP]
apply(cases "a = \<zero>")
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. a = \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
 2. a \<noteq> \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
[PROOF STEP]
apply (simp add: Units_eq_nonzero assms(2) val_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<noteq> \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<noteq> \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
[PROOF STEP]
assume "a \<noteq> \<zero>"
[PROOF STATE]
proof (state)
this:
a \<noteq> \<zero>

goal (1 subgoal):
 1. a \<noteq> \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> \<zero>
[PROOF STEP]
have 0: "a \<in> nonzero Q\<^sub>p"
[PROOF STATE]
proof (prove)
using this:
a \<noteq> \<zero>

goal (1 subgoal):
 1. a \<in> nonzero Q\<^sub>p
[PROOF STEP]
by (simp add: Qp.nonzero_memI assms(1))
[PROOF STATE]
proof (state)
this:
a \<in> nonzero Q\<^sub>p

goal (1 subgoal):
 1. a \<noteq> \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
[PROOF STEP]
have 1: "(a \<div> b) \<in> nonzero Q\<^sub>p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a \<div> b) \<in> nonzero Q\<^sub>p
[PROOF STEP]
by (simp add: "0" Localization.submonoid.m_closed Qp.nonzero_is_submonoid assms(2) nonzero_inverse_Qp)
[PROOF STATE]
proof (state)
this:
(a \<div> b) \<in> nonzero Q\<^sub>p

goal (1 subgoal):
 1. a \<noteq> \<zero> \<Longrightarrow> val (a \<div> b) = val a - val b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. val (a \<div> b) = val a - val b
[PROOF STEP]
using 0 1 assms
[PROOF STATE]
proof (prove)
using this:
a \<in> nonzero Q\<^sub>p
(a \<div> b) \<in> nonzero Q\<^sub>p
a \<in> carrier Q\<^sub>p
b \<in> nonzero Q\<^sub>p

goal (1 subgoal):
 1. val (a \<div> b) = val a - val b
[PROOF STEP]
by (simp add: ord_fract)
[PROOF STATE]
proof (state)
this:
val (a \<div> b) = val a - val b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in monoid) pow_nat_eq_1_imp_unit:
  fixes n :: nat
  assumes "x [^] n = \<one>" and "n > 0" and [simp]: "x \<in> carrier G"
  shows   "x \<in> Units G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
from \<open>n > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "x [^] (1 :: nat) \<otimes> x [^] (n - 1) = x [^] n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. x [^] 1 \<otimes> x [^] (n - 1) = x [^] n
[PROOF STEP]
by (subst nat_pow_mult) auto
[PROOF STATE]
proof (state)
this:
x [^] 1 \<otimes> x [^] (n - 1) = x [^] n

goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
x [^] n = \<one>
0 < n
x \<in> carrier G
x [^] 1 \<otimes> x [^] (n - 1) = x [^] n
[PROOF STEP]
have "x \<otimes> x [^] (n - 1) = \<one>"
[PROOF STATE]
proof (prove)
using this:
x [^] n = \<one>
0 < n
x \<in> carrier G
x [^] 1 \<otimes> x [^] (n - 1) = x [^] n

goal (1 subgoal):
 1. x \<otimes> x [^] (n - 1) = \<one>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x \<otimes> x [^] (n - 1) = \<one>

goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x \<otimes> x [^] (n - 1) = \<one>

goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
from \<open>n > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have "x [^] (n - 1) \<otimes> x [^] (1 :: nat) = x [^] n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. x [^] (n - 1) \<otimes> x [^] 1 = x [^] n
[PROOF STEP]
by (subst nat_pow_mult) auto
[PROOF STATE]
proof (state)
this:
x [^] (n - 1) \<otimes> x [^] 1 = x [^] n

goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
x [^] n = \<one>
0 < n
x \<in> carrier G
x [^] (n - 1) \<otimes> x [^] 1 = x [^] n
[PROOF STEP]
have "x [^] (n - 1) \<otimes> x = \<one>"
[PROOF STATE]
proof (prove)
using this:
x [^] n = \<one>
0 < n
x \<in> carrier G
x [^] (n - 1) \<otimes> x [^] 1 = x [^] n

goal (1 subgoal):
 1. x [^] (n - 1) \<otimes> x = \<one>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x [^] (n - 1) \<otimes> x = \<one>

goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x \<otimes> x [^] (n - 1) = \<one>
x [^] (n - 1) \<otimes> x = \<one>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<otimes> x [^] (n - 1) = \<one>
x [^] (n - 1) \<otimes> x = \<one>

goal (1 subgoal):
 1. x \<in> Units G
[PROOF STEP]
by (auto simp: Units_def)
[PROOF STATE]
proof (state)
this:
x \<in> Units G

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma  cross_rotoinversion_matrix: "rotoinversion_matrix A \<Longrightarrow> (A *v x) \<times> (A *v y) = - A *v (x \<times> y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rotoinversion_matrix A \<Longrightarrow> (A *v x) \<times> (A *v y) = - A *v x \<times> y
[PROOF STEP]
by (simp add: rotoinversion_matrix_def cross_orthogonal_matrix scaleR_matrix_vector_assoc)


[STATEMENT]
lemma int_and_ge0 [simp]:
  \<open>x AND y \<ge> 0 \<longleftrightarrow> x \<ge> 0 \<or> y \<ge> 0\<close> for x y :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (0 \<le> x AND y) = (0 \<le> x \<or> 0 \<le> y)
[PROOF STEP]
by (fact and_nonnegative_int_iff)


[STATEMENT]
lemma sum_ssub_zero_distrib: "a * (\<Sum>S0 p d f) = (\<Sum>S0 p d (\<lambda>k. a * f k))" for a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a * \<Sum>S0 p d f  = \<Sum>S0 p d (\<lambda>k. a * f k)
[PROOF STEP]
by (auto simp add: sum_ssub_zero.simps sum_distrib_left; smt mult_is_0 sum.cong)


[STATEMENT]
lemma STAR_subset_closed: "x \<in> *s* A \<Longrightarrow> A \<subseteq> B \<Longrightarrow> x \<in> *s* B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<in> *s* A; A \<subseteq> B\<rbrakk> \<Longrightarrow> x \<in> *s* B
[PROOF STEP]
by (erule rev_subsetD) simp


[STATEMENT]
lemma bin_to_bl_or:
  "bin_to_bl n (a OR b) = map2 (\<or>) (bin_to_bl n a) (bin_to_bl n b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bin_to_bl n (a OR b) = map2 (\<or>) (bin_to_bl n a) (bin_to_bl n b)
[PROOF STEP]
using bl_or_aux_bin[where n=n and v=a and w=b and bs="[]" and cs="[]"]
[PROOF STATE]
proof (prove)
using this:
map2 (\<or>) (bin_to_bl_aux n a []) (bin_to_bl_aux n b []) = bin_to_bl_aux n (a OR b) (map2 (\<or>) [] [])

goal (1 subgoal):
 1. bin_to_bl n (a OR b) = map2 (\<or>) (bin_to_bl n a) (bin_to_bl n b)
[PROOF STEP]
by simp


[STATEMENT]
lemma "dep_set S \<or> indep_set S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dep_set S \<or> indep_set S
[PROOF STEP]
by (simp add: indep_set_def)


[STATEMENT]
lemma of_nat_fact [simp]: "of_nat (fact n) = fact n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. of_nat (fact n) = fact n
[PROOF STEP]
by (simp add: fact_prod)


[STATEMENT]
lemma if_eq_is_pr [prec]: "\<lbrakk> p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda> x. if (p1 x = p2 x) then (q1 x) else (q2 x)) \<in> PrimRec1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
have S1: "(\<lambda> x. if (p1 x = p2 x) then (q1 x) else (q2 x)) = (\<lambda> x. if (abs_of_diff (p1 x) (p2 x) = 0) then (q1 x) else (q2 x))" (is "?L = ?R")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) = (\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x)
[PROOF STEP]
by (simp add: abs_of_diff_eq)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if p1 x = p2 x then q1 x else q2 x) = (\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x)

goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
assume A1: "p1 \<in> PrimRec1" and A2: "p2 \<in> PrimRec1"
[PROOF STATE]
proof (state)
this:
p1 \<in> PrimRec1
p2 \<in> PrimRec1

goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
with abs_of_diff_is_pr
[PROOF STATE]
proof (chain)
picking this:
abs_of_diff \<in> PrimRec2
p1 \<in> PrimRec1
p2 \<in> PrimRec1
[PROOF STEP]
have S2: "(\<lambda> x. abs_of_diff (p1 x) (p2 x)) \<in> PrimRec1"
[PROOF STATE]
proof (prove)
using this:
abs_of_diff \<in> PrimRec2
p1 \<in> PrimRec1
p2 \<in> PrimRec1

goal (1 subgoal):
 1. (\<lambda>x. abs_of_diff (p1 x) (p2 x)) \<in> PrimRec1
[PROOF STEP]
by prec0
[PROOF STATE]
proof (state)
this:
(\<lambda>x. abs_of_diff (p1 x) (p2 x)) \<in> PrimRec1

goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
assume "q1 \<in> PrimRec1" and "q2 \<in> PrimRec1"
[PROOF STATE]
proof (state)
this:
q1 \<in> PrimRec1
q2 \<in> PrimRec1

goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
with S2
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. abs_of_diff (p1 x) (p2 x)) \<in> PrimRec1
q1 \<in> PrimRec1
q2 \<in> PrimRec1
[PROOF STEP]
have "?R \<in> PrimRec1"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. abs_of_diff (p1 x) (p2 x)) \<in> PrimRec1
q1 \<in> PrimRec1
q2 \<in> PrimRec1

goal (1 subgoal):
 1. (\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
by (rule if_is_pr)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x) \<in> PrimRec1

goal (1 subgoal):
 1. \<lbrakk>p1 \<in> PrimRec1; p2 \<in> PrimRec1; q1 \<in> PrimRec1; q2 \<in> PrimRec1\<rbrakk> \<Longrightarrow> (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
with S1
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. if p1 x = p2 x then q1 x else q2 x) = (\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x)
(\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. if p1 x = p2 x then q1 x else q2 x) = (\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x)
(\<lambda>x. if abs_of_diff (p1 x) (p2 x) = 0 then q1 x else q2 x) \<in> PrimRec1

goal (1 subgoal):
 1. (\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<lambda>x. if p1 x = p2 x then q1 x else q2 x) \<in> PrimRec1

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dominated_convergence_absolutely_integrable:
  fixes f :: "nat \<Rightarrow> 'n::euclidean_space \<Rightarrow> 'm::euclidean_space"
  assumes f: "\<And>k. f k absolutely_integrable_on S"
    and h: "h integrable_on S"
    and normg: "\<And>x. x \<in> S \<Longrightarrow> norm(g x) \<le> (h x)"
    and lim: "\<And>x. x \<in> S \<Longrightarrow> (\<lambda>k. f k x) \<longlonglongrightarrow> g x"
  shows "g absolutely_integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g absolutely_integrable_on S
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. g absolutely_integrable_on S
[PROOF STEP]
have "g integrable_on S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g integrable_on S
[PROOF STEP]
by (rule dominated_convergence_integrable [OF assms])
[PROOF STATE]
proof (state)
this:
g integrable_on S

goal (1 subgoal):
 1. g absolutely_integrable_on S
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
f ?k absolutely_integrable_on S
h integrable_on S
?x \<in> S \<Longrightarrow> norm (g ?x) \<le> h ?x
?x \<in> S \<Longrightarrow> (\<lambda>k. f k ?x) \<longlonglongrightarrow> g ?x
g integrable_on S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f ?k absolutely_integrable_on S
h integrable_on S
?x \<in> S \<Longrightarrow> norm (g ?x) \<le> h ?x
?x \<in> S \<Longrightarrow> (\<lambda>k. f k ?x) \<longlonglongrightarrow> g ?x
g integrable_on S

goal (1 subgoal):
 1. g absolutely_integrable_on S
[PROOF STEP]
by (blast intro:  absolutely_integrable_integrable_bound [where g=h])
[PROOF STATE]
proof (state)
this:
g absolutely_integrable_on S

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem gauss_sum_1_mod_square_eq_k:
  assumes "(\<forall>k. k > 0 \<longrightarrow> separable k)"
  shows "norm (gauss_sum 1) ^ 2 = real n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "(norm (gauss_sum 1))^2 = gauss_sum 1 * cnj (gauss_sum 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = gauss_sum 1 * cnj (gauss_sum 1)
[PROOF STEP]
using complex_norm_square
[PROOF STATE]
proof (prove)
using this:
complex_of_real ((cmod ?z)\<^sup>2) = ?z * cnj ?z

goal (1 subgoal):
 1. complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = gauss_sum 1 * cnj (gauss_sum 1)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = gauss_sum 1 * cnj (gauss_sum 1)

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = gauss_sum 1 * cnj (gauss_sum 1)

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi>(m)) * unity_root n (-m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
have "cnj (gauss_sum 1) = (\<Sum>m = 1..n. cnj (\<chi>(m)) * unity_root n (-m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cnj (gauss_sum 1) = (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
unfolding gauss_sum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cnj (\<Sum>m = 1..n. \<chi> m * unity_root n (int (m * 1))) = (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
by (simp add: unity_root_uminus)
[PROOF STATE]
proof (state)
this:
cnj (gauss_sum 1) = (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))

goal (1 subgoal):
 1. gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
cnj (gauss_sum 1) = (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
cnj (gauss_sum 1) = (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))

goal (1 subgoal):
 1. gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gauss_sum 1 * cnj (gauss_sum 1) = gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi>(m)) * unity_root n (-m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m)) = (\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi> m) * unity_root n (- int m))
[PROOF STEP]
by (subst sum_distrib_left)(simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m)) = (\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi> m) * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
gauss_sum 1 * (\<Sum>m = 1..n. cnj (\<chi> m) * unity_root n (- int m)) = (\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi> m) * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>m = 1..n. gauss_sum m * unity_root n (-m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi> m) * unity_root n (- int m)) = (\<Sum>m = 1..n. gauss_sum m * unity_root n (- int m))
[PROOF STEP]
proof (rule sum.cong,simp)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)
[PROOF STEP]
assume as: "x \<in> {1..n}"
[PROOF STATE]
proof (state)
this:
x \<in> {1..n}

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)
[PROOF STEP]
show "gauss_sum 1 * cnj (\<chi> x) * unity_root n (-x) =
          gauss_sum x * unity_root n (-x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
\<forall>k>0. separable k

goal (1 subgoal):
 1. gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)
[PROOF STEP]
unfolding separable_def
[PROOF STATE]
proof (prove)
using this:
\<forall>k>0. gauss_sum k = cnj (\<chi> k) * gauss_sum 1

goal (1 subgoal):
 1. gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)
[PROOF STEP]
by (rule allE[of _ x]) (use as in auto)
[PROOF STATE]
proof (state)
this:
gauss_sum 1 * cnj (\<chi> x) * unity_root n (- int x) = gauss_sum x * unity_root n (- int x)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi> m) * unity_root n (- int m)) = (\<Sum>m = 1..n. gauss_sum m * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. gauss_sum 1 * cnj (\<chi> m) * unity_root n (- int m)) = (\<Sum>m = 1..n. gauss_sum m * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>m = 1..n. (\<Sum>r = 1..n. \<chi> r * unity_root n (r*m) * unity_root n (-m)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..n. gauss_sum m * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m))
[PROOF STEP]
unfolding gauss_sum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..n. (\<Sum>ma = 1..n. \<chi> ma * unity_root n (int (ma * m))) * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m))
[PROOF STEP]
by (rule sum.cong,simp,rule sum_distrib_right)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. gauss_sum m * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. gauss_sum m * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>m = 1..n. (\<Sum>r = 1..n. \<chi> r * unity_root n (m*(r-1)) ))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (m * (r - 1))))
[PROOF STEP]
by (intro sum.cong refl) (auto simp: unity_root_diff of_nat_diff unity_root_uminus field_simps)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (m * (r - 1))))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (r * m)) * unity_root n (- int m)) = (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (m * (r - 1))))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>r=1..n. (\<Sum>m=1..n.  \<chi>(r) *unity_root n (m*(r-1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (m * (r - 1)))) = (\<Sum>r = 1..n. \<Sum>m = 1..n. \<chi> r * unity_root n (int (m * (r - 1))))
[PROOF STEP]
by (rule sum.swap)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (m * (r - 1)))) = (\<Sum>r = 1..n. \<Sum>m = 1..n. \<chi> r * unity_root n (int (m * (r - 1))))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. \<Sum>r = 1..n. \<chi> r * unity_root n (int (m * (r - 1)))) = (\<Sum>r = 1..n. \<Sum>m = 1..n. \<chi> r * unity_root n (int (m * (r - 1))))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>r=1..n. \<chi>(r) *(\<Sum>m=1..n. unity_root n (m*(r-1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = 1..n. \<Sum>m = 1..n. \<chi> r * unity_root n (int (m * (r - 1)))) = (\<Sum>r = 1..n. \<chi> r * (\<Sum>m = 1..n. unity_root n (int (m * (r - 1)))))
[PROOF STEP]
by (rule sum.cong, simp, simp add: sum_distrib_left)
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..n. \<Sum>m = 1..n. \<chi> r * unity_root n (int (m * (r - 1)))) = (\<Sum>r = 1..n. \<chi> r * (\<Sum>m = 1..n. unity_root n (int (m * (r - 1)))))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..n. \<Sum>m = 1..n. \<chi> r * unity_root n (int (m * (r - 1)))) = (\<Sum>r = 1..n. \<chi> r * (\<Sum>m = 1..n. unity_root n (int (m * (r - 1)))))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>r=1..n. \<chi>(r) * unity_root_sum n (r-1))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = 1..n. \<chi> r * (\<Sum>m = 1..n. unity_root n (int (m * (r - 1))))) = (\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1)))
[PROOF STEP]
proof (intro sum.cong refl)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
assume "x \<in> {1..n}"
[PROOF STATE]
proof (state)
this:
x \<in> {1..n}

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {1..n}
[PROOF STEP]
have 1: "periodic_arithmetic (\<lambda>m. unity_root n (int (m * (x - 1)))) n"
[PROOF STATE]
proof (prove)
using this:
x \<in> {1..n}

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. unity_root n (int (m * (x - 1)))) n
[PROOF STEP]
using unity_periodic_arithmetic_mult[of n "x-1"]
[PROOF STATE]
proof (prove)
using this:
x \<in> {1..n}
periodic_arithmetic (\<lambda>n. unity_root n (int (x - 1) * int n)) n

goal (1 subgoal):
 1. periodic_arithmetic (\<lambda>m. unity_root n (int (m * (x - 1)))) n
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
periodic_arithmetic (\<lambda>m. unity_root n (int (m * (x - 1)))) n

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
have "(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) =
          (\<Sum>m = 0..n-1. unity_root n (int (m * (x - 1))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1))))
[PROOF STEP]
using periodic_arithmetic_sum_periodic_arithmetic_shift[OF 1 _, of 1] n
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < n; 0 < 1\<rbrakk> \<Longrightarrow> (\<Sum>l = 0..n - 1. unity_root n (int (l * (x - 1)))) = (\<Sum>l = 1..1 + n - 1. unity_root n (int (l * (x - 1))))
1 < n

goal (1 subgoal):
 1. (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1))))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1))))

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1))))

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
have "\<dots> = unity_root_sum n (x-1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))
[PROOF STEP]
unfolding unity_root_sum_def
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. (\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1)))) = (\<Sum>m<n. unity_root n (int (x - 1) * int m))
[PROOF STEP]
by (intro sum.cong) (auto simp: mult_ac)
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 0..n - 1. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))
[PROOF STEP]
have "(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) =
                  unity_root_sum n (int (x - 1))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))

goal (1 subgoal):
 1. (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))

goal (1 subgoal):
 1. \<And>x. x \<in> {1..n} \<Longrightarrow> \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))
[PROOF STEP]
show "\<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) =
               \<chi> x * unity_root_sum n (int (x - 1))"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = unity_root_sum n (int (x - 1))

goal (1 subgoal):
 1. \<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))
[PROOF STEP]
by argo
[PROOF STATE]
proof (state)
this:
\<chi> x * (\<Sum>m = 1..n. unity_root n (int (m * (x - 1)))) = \<chi> x * unity_root_sum n (int (x - 1))

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..n. \<chi> r * (\<Sum>m = 1..n. unity_root n (int (m * (r - 1))))) = (\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1)))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..n. \<chi> r * (\<Sum>m = 1..n. unity_root n (int (m * (r - 1))))) = (\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1)))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = (\<Sum>r \<in> {1}. \<chi> r * unity_root_sum n (int (r - 1)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1))) = (\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1)))
[PROOF STEP]
using n unity_root_sum_nonzero_iff int_ops(6)
[PROOF STATE]
proof (prove)
using this:
1 < n
\<lbrakk>1 \<le> ?k; ?r \<in> {- int ?k<..<int ?k}\<rbrakk> \<Longrightarrow> (unity_root_sum ?k ?r \<noteq> 0) = (?r = 0)
int (?a - ?b) = (if int ?a < int ?b then 0 else int ?a - int ?b)

goal (1 subgoal):
 1. (\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1))) = (\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1)))
[PROOF STEP]
by (intro sum.mono_neutral_right) auto
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1))) = (\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1)))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r = 1..n. \<chi> r * unity_root_sum n (int (r - 1))) = (\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1)))

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = \<chi> 1 * n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1))) = \<chi> 1 * of_nat n
[PROOF STEP]
using n
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. (\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1))) = \<chi> 1 * of_nat n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1))) = \<chi> 1 * of_nat n

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(\<Sum>r\<in>{1}. \<chi> r * unity_root_sum n (int (r - 1))) = \<chi> 1 * of_nat n

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
have "\<dots> = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<chi> 1 * of_nat n = of_nat n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<chi> 1 * of_nat n = of_nat n

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = of_nat n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = of_nat n

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
using of_real_eq_iff
[PROOF STATE]
proof (prove)
using this:
complex_of_real ((cmod (gauss_sum 1))\<^sup>2) = of_nat n
(of_real ?x = of_real ?y) = (?x = ?y)

goal (1 subgoal):
 1. (cmod (gauss_sum 1))\<^sup>2 = real n
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
(cmod (gauss_sum 1))\<^sup>2 = real n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lmap_eq_LCons_conv:
  "lmap f xs = LCons y ys \<longleftrightarrow>
  (\<exists>x xs'. xs = LCons x xs' \<and> y = f x \<and> ys = lmap f xs')"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (lmap f xs = LCons y ys) = (\<exists>x xs'. xs = LCons x xs' \<and> y = f x \<and> ys = lmap f xs')
[PROOF STEP]
by(cases xs)(auto)


[STATEMENT]
lemma disjE3: "A \<or> B \<or> C \<Longrightarrow> (A \<Longrightarrow> G) \<Longrightarrow> (B \<Longrightarrow> G) \<Longrightarrow> (C \<Longrightarrow> G) \<Longrightarrow> G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>A \<or> B \<or> C; A \<Longrightarrow> G; B \<Longrightarrow> G; C \<Longrightarrow> G\<rbrakk> \<Longrightarrow> G
[PROOF STEP]
by auto


[STATEMENT]
lemma d_mult_greatest_lower_bound:
  "d(x) \<le> d(y) * d(z) \<longleftrightarrow> d(x) \<le> d(y) \<and> d(x) \<le> d(z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (d x \<le> d y * d z) = (d x \<le> d y \<and> d x \<le> d z)
[PROOF STEP]
by (metis d_commutative d_idempotent d_mult_left_lower_bound mult_isotone order_trans)


[STATEMENT]
lemma radius_Min_alt: "radius = Min ((\<lambda> v. eccentricity v) ` V)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. radius = Min (eccentricity ` V)
[PROOF STEP]
unfolding radius_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Inf (eccentricity ` V) = Min (eccentricity ` V)
[PROOF STEP]
using Min_Inf finV not_empty
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>finite ?A; ?A \<noteq> {}\<rbrakk> \<Longrightarrow> Min ?A = Inf ?A
finite V
V \<noteq> {}

goal (1 subgoal):
 1. Inf (eccentricity ` V) = Min (eccentricity ` V)
[PROOF STEP]
by (metis (no_types, opaque_lifting) empty_is_image finite_imageI)


[STATEMENT]
lemma aux_Cauchy:
shows "0 \<le> real_of (inner x x + (cnj a) * (inner x y) + a * ((cnj (inner x y)) + (cnj a) * (inner y y)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))
[PROOF STEP]
have "(inner (x+scale a y) (x+scale a y)) = (inner (x+scale a y) x) + (inner (x+scale a y) (scale a y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner (x + scale a y) (x + scale a y) = inner (x + scale a y) x + inner (x + scale a y) (scale a y)
[PROOF STEP]
unfolding inner_add_right
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner (x + scale a y) x + inner (x + scale a y) (scale a y) = inner (x + scale a y) x + inner (x + scale a y) (scale a y)
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
inner (x + scale a y) (x + scale a y) = inner (x + scale a y) x + inner (x + scale a y) (scale a y)

goal (1 subgoal):
 1. 0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
inner (x + scale a y) (x + scale a y) = inner (x + scale a y) x + inner (x + scale a y) (scale a y)

goal (1 subgoal):
 1. 0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))
[PROOF STEP]
have "... = inner x x + (cnj a) * (inner x y) + a * ((cnj (inner x y)) + (cnj a) * (inner y y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner (x + scale a y) x + inner (x + scale a y) (scale a y) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)
[PROOF STEP]
unfolding inner_add_left
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner x x + inner (scale a y) x + (inner x (scale a y) + inner (scale a y) (scale a y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)
[PROOF STEP]
unfolding inner_scaleR_left
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner x x + a * inner y x + (inner x (scale a y) + a * inner y (scale a y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)
[PROOF STEP]
unfolding inner_scaleR_right
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner x x + a * inner y x + (cnj_class.cnj a * inner x y + a * (cnj_class.cnj a * inner y y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)
[PROOF STEP]
unfolding inner_commute[of y x]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner x x + a * cnj_class.cnj (inner x y) + (cnj_class.cnj a * inner x y + a * (cnj_class.cnj a * inner y y)) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)
[PROOF STEP]
unfolding distrib_left
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner x x + a * cnj_class.cnj (inner x y) + (cnj_class.cnj a * inner x y + a * (cnj_class.cnj a * inner y y)) = inner x x + cnj_class.cnj a * inner x y + (a * cnj_class.cnj (inner x y) + a * (cnj_class.cnj a * inner y y))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
inner (x + scale a y) x + inner (x + scale a y) (scale a y) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)

goal (1 subgoal):
 1. 0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
inner (x + scale a y) (x + scale a y) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
inner (x + scale a y) (x + scale a y) = inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y)

goal (1 subgoal):
 1. 0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))
[PROOF STEP]
by (metis inner_ge_zero)
[PROOF STATE]
proof (state)
this:
0 \<le> real_of (inner x x + cnj_class.cnj a * inner x y + a * (cnj_class.cnj (inner x y) + cnj_class.cnj a * inner y y))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma PartNum_DataSpace [simp]:
  "PartNum (DSpace) = 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. PartNum DSpace = 2
[PROOF STEP]
apply (unfold PartNum_def DSpace_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (length \<circ> Rep_dataspace) (Abs_dataspace [range V0, range V1]) = 2
[PROOF STEP]
apply (simp add: Abs_dataspace_inverse)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma module_criteria:
  fixes R and M
  assumes cring: "cring R"
      and zero: "\<zero>\<^bsub>M\<^esub>\<in> carrier M"
      and add: "\<forall>v w. v\<in>carrier M \<and> w\<in>carrier M\<longrightarrow> v\<oplus>\<^bsub>M\<^esub> w\<in> carrier M"
      and neg: "\<forall>v\<in>carrier M. (\<exists>neg_v\<in>carrier M. v\<oplus>\<^bsub>M\<^esub>neg_v=\<zero>\<^bsub>M\<^esub>)"
      and smult: "\<forall>c v. c\<in> carrier R \<and> v\<in>carrier M\<longrightarrow> c\<odot>\<^bsub>M\<^esub> v \<in> carrier M"
      and comm: "\<forall>v w. v\<in>carrier M \<and> w\<in>carrier M\<longrightarrow> v\<oplus>\<^bsub>M\<^esub> w=w\<oplus>\<^bsub>M\<^esub> v"
      and assoc: "\<forall>v w x. v\<in>carrier M \<and> w\<in>carrier M \<and> x\<in>carrier M\<longrightarrow> (v\<oplus>\<^bsub>M\<^esub> w)\<oplus>\<^bsub>M\<^esub> x= v\<oplus>\<^bsub>M\<^esub> (w\<oplus>\<^bsub>M\<^esub> x)"
      and add_id: "\<forall>v\<in>carrier M. (v\<oplus>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> =v)"
      and compat: "\<forall>a b v. a\<in> carrier R \<and> b\<in> carrier R \<and> v\<in>carrier M\<longrightarrow> (a\<otimes>\<^bsub>R\<^esub> b)\<odot>\<^bsub>M\<^esub> v =a\<odot>\<^bsub>M\<^esub> (b\<odot>\<^bsub>M\<^esub> v)"
      and smult_id: "\<forall>v\<in>carrier M. (\<one>\<^bsub>R\<^esub> \<odot>\<^bsub>M\<^esub> v =v)"
      and dist_f: "\<forall>a b v. a\<in> carrier R \<and> b\<in> carrier R \<and> v\<in>carrier M\<longrightarrow> (a\<oplus>\<^bsub>R\<^esub> b)\<odot>\<^bsub>M\<^esub> v =(a\<odot>\<^bsub>M\<^esub> v) \<oplus>\<^bsub>M\<^esub> (b\<odot>\<^bsub>M\<^esub> v)"
      and dist_add: "\<forall>a v w. a\<in> carrier R \<and> v\<in>carrier M \<and> w\<in>carrier M\<longrightarrow> a\<odot>\<^bsub>M\<^esub> (v\<oplus>\<^bsub>M\<^esub> w) =(a\<odot>\<^bsub>M\<^esub> v) \<oplus>\<^bsub>M\<^esub> (a\<odot>\<^bsub>M\<^esub> w)"
  shows "module R M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. module R M
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. module R M
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
cring R
\<zero>\<^bsub>M\<^esub> \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<in> carrier M
\<forall>v\<in>carrier M. \<exists>neg_v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> neg_v = \<zero>\<^bsub>M\<^esub>
\<forall>c v. c \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> c \<odot>\<^bsub>M\<^esub> v \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w = w \<oplus>\<^bsub>M\<^esub> v
\<forall>v w x. v \<in> carrier M \<and> w \<in> carrier M \<and> x \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<oplus>\<^bsub>M\<^esub> x = v \<oplus>\<^bsub>M\<^esub> (w \<oplus>\<^bsub>M\<^esub> x)
\<forall>v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> a \<otimes>\<^bsub>R\<^esub> b \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> v)
\<forall>v\<in>carrier M. \<one>\<^bsub>R\<^esub> \<odot>\<^bsub>M\<^esub> v = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> (a \<oplus>\<^bsub>R\<^esub> b) \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> b \<odot>\<^bsub>M\<^esub> v
\<forall>a v w. a \<in> carrier R \<and> v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> a \<odot>\<^bsub>M\<^esub> (v \<oplus>\<^bsub>M\<^esub> w) = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> w
[PROOF STEP]
have 2: "abelian_group M"
[PROOF STATE]
proof (prove)
using this:
cring R
\<zero>\<^bsub>M\<^esub> \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<in> carrier M
\<forall>v\<in>carrier M. \<exists>neg_v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> neg_v = \<zero>\<^bsub>M\<^esub>
\<forall>c v. c \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> c \<odot>\<^bsub>M\<^esub> v \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w = w \<oplus>\<^bsub>M\<^esub> v
\<forall>v w x. v \<in> carrier M \<and> w \<in> carrier M \<and> x \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<oplus>\<^bsub>M\<^esub> x = v \<oplus>\<^bsub>M\<^esub> (w \<oplus>\<^bsub>M\<^esub> x)
\<forall>v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> a \<otimes>\<^bsub>R\<^esub> b \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> v)
\<forall>v\<in>carrier M. \<one>\<^bsub>R\<^esub> \<odot>\<^bsub>M\<^esub> v = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> (a \<oplus>\<^bsub>R\<^esub> b) \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> b \<odot>\<^bsub>M\<^esub> v
\<forall>a v w. a \<in> carrier R \<and> v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> a \<odot>\<^bsub>M\<^esub> (v \<oplus>\<^bsub>M\<^esub> w) = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> w

goal (1 subgoal):
 1. abelian_group M
[PROOF STEP]
by (intro abelian_groupI, auto)
[PROOF STATE]
proof (state)
this:
abelian_group M

goal (1 subgoal):
 1. module R M
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
cring R
\<zero>\<^bsub>M\<^esub> \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<in> carrier M
\<forall>v\<in>carrier M. \<exists>neg_v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> neg_v = \<zero>\<^bsub>M\<^esub>
\<forall>c v. c \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> c \<odot>\<^bsub>M\<^esub> v \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w = w \<oplus>\<^bsub>M\<^esub> v
\<forall>v w x. v \<in> carrier M \<and> w \<in> carrier M \<and> x \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<oplus>\<^bsub>M\<^esub> x = v \<oplus>\<^bsub>M\<^esub> (w \<oplus>\<^bsub>M\<^esub> x)
\<forall>v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> a \<otimes>\<^bsub>R\<^esub> b \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> v)
\<forall>v\<in>carrier M. \<one>\<^bsub>R\<^esub> \<odot>\<^bsub>M\<^esub> v = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> (a \<oplus>\<^bsub>R\<^esub> b) \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> b \<odot>\<^bsub>M\<^esub> v
\<forall>a v w. a \<in> carrier R \<and> v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> a \<odot>\<^bsub>M\<^esub> (v \<oplus>\<^bsub>M\<^esub> w) = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> w
[PROOF STEP]
have 3: "module_axioms R M"
[PROOF STATE]
proof (prove)
using this:
cring R
\<zero>\<^bsub>M\<^esub> \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<in> carrier M
\<forall>v\<in>carrier M. \<exists>neg_v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> neg_v = \<zero>\<^bsub>M\<^esub>
\<forall>c v. c \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> c \<odot>\<^bsub>M\<^esub> v \<in> carrier M
\<forall>v w. v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w = w \<oplus>\<^bsub>M\<^esub> v
\<forall>v w x. v \<in> carrier M \<and> w \<in> carrier M \<and> x \<in> carrier M \<longrightarrow> v \<oplus>\<^bsub>M\<^esub> w \<oplus>\<^bsub>M\<^esub> x = v \<oplus>\<^bsub>M\<^esub> (w \<oplus>\<^bsub>M\<^esub> x)
\<forall>v\<in>carrier M. v \<oplus>\<^bsub>M\<^esub> \<zero>\<^bsub>M\<^esub> = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> a \<otimes>\<^bsub>R\<^esub> b \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> (b \<odot>\<^bsub>M\<^esub> v)
\<forall>v\<in>carrier M. \<one>\<^bsub>R\<^esub> \<odot>\<^bsub>M\<^esub> v = v
\<forall>a b v. a \<in> carrier R \<and> b \<in> carrier R \<and> v \<in> carrier M \<longrightarrow> (a \<oplus>\<^bsub>R\<^esub> b) \<odot>\<^bsub>M\<^esub> v = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> b \<odot>\<^bsub>M\<^esub> v
\<forall>a v w. a \<in> carrier R \<and> v \<in> carrier M \<and> w \<in> carrier M \<longrightarrow> a \<odot>\<^bsub>M\<^esub> (v \<oplus>\<^bsub>M\<^esub> w) = a \<odot>\<^bsub>M\<^esub> v \<oplus>\<^bsub>M\<^esub> a \<odot>\<^bsub>M\<^esub> w

goal (1 subgoal):
 1. module_axioms R M
[PROOF STEP]
by (unfold module_axioms_def, auto)
[PROOF STATE]
proof (state)
this:
module_axioms R M

goal (1 subgoal):
 1. module R M
[PROOF STEP]
from 2 3 cring
[PROOF STATE]
proof (chain)
picking this:
abelian_group M
module_axioms R M
cring R
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
abelian_group M
module_axioms R M
cring R

goal (1 subgoal):
 1. module R M
[PROOF STEP]
by (unfold module_def module_def, auto)
[PROOF STATE]
proof (state)
this:
module R M

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma tagged_division_split_left_inj_content:
  assumes \<D>: "\<D> tagged_division_of S"
    and "(x1, K1) \<in> \<D>" "(x2, K2) \<in> \<D>" "K1 \<noteq> K2" "K1 \<inter> {x. x\<bullet>k \<le> c} = K2 \<inter> {x. x\<bullet>k \<le> c}" "k \<in> Basis"
  shows "content (K1 \<inter> {x. x\<bullet>k \<le> c}) = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. content (K1 \<inter> {x. x \<bullet> k \<le> c}) = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. content (K1 \<inter> {x. x \<bullet> k \<le> c}) = 0
[PROOF STEP]
from tagged_division_ofD(4)[OF \<D> \<open>(x1, K1) \<in> \<D>\<close>]
[PROOF STATE]
proof (chain)
picking this:
\<exists>a b. K1 = cbox a b
[PROOF STEP]
obtain a b where K1: "K1 = cbox a b"
[PROOF STATE]
proof (prove)
using this:
\<exists>a b. K1 = cbox a b

goal (1 subgoal):
 1. (\<And>a b. K1 = cbox a b \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
K1 = cbox a b

goal (1 subgoal):
 1. content (K1 \<inter> {x. x \<bullet> k \<le> c}) = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
K1 = cbox a b
[PROOF STEP]
have "interior (K1 \<inter> {x. x \<bullet> k \<le> c}) = {}"
[PROOF STATE]
proof (prove)
using this:
K1 = cbox a b

goal (1 subgoal):
 1. interior (K1 \<inter> {x. x \<bullet> k \<le> c}) = {}
[PROOF STEP]
by (metis tagged_division_split_left_inj assms)
[PROOF STATE]
proof (state)
this:
interior (K1 \<inter> {x. x \<bullet> k \<le> c}) = {}

goal (1 subgoal):
 1. content (K1 \<inter> {x. x \<bullet> k \<le> c}) = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
interior (K1 \<inter> {x. x \<bullet> k \<le> c}) = {}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
interior (K1 \<inter> {x. x \<bullet> k \<le> c}) = {}

goal (1 subgoal):
 1. content (K1 \<inter> {x. x \<bullet> k \<le> c}) = 0
[PROOF STEP]
unfolding K1 interval_split[OF \<open>k \<in> Basis\<close>]
[PROOF STATE]
proof (prove)
using this:
interior (cbox a (\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i)) = {}

goal (1 subgoal):
 1. content (cbox a (\<Sum>i\<in>Basis. (if i = k then min (b \<bullet> k) c else b \<bullet> i) *\<^sub>R i)) = 0
[PROOF STEP]
by (auto simp: content_eq_0_interior)
[PROOF STATE]
proof (state)
this:
content (K1 \<inter> {x. x \<bullet> k \<le> c}) = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma f_Exec_Stream_Acc_Output_nth_eq_i_nth: "
  \<lbrakk> 0 < k; n < n' \<rbrakk> \<Longrightarrow>
  f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Down> n') c ! n =
  i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; n < n'\<rbrakk> \<Longrightarrow> f_Exec_Comp_Stream_Acc_Output k output_fun trans_fun (input \<Down> n') c ! n = i_Exec_Comp_Stream_Acc_Output k output_fun trans_fun input c n
[PROOF STEP]
by (unfold f_Exec_Comp_Stream_Acc_Output_def i_Exec_Comp_Stream_Acc_Output_def f_shrink_def i_shrink_def, rule f_Exec_Stream_expand_aggregate_map_nth_eq_i_nth)