[STATEMENT]
lemma mult_oddprime_is_sum4sq: "\<lbrakk> prime (nat p); odd p \<rbrakk> \<Longrightarrow>
  \<exists> t. 0<t \<and> t<p \<and> is_sum4sq_int (p*t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
assume p1: "prime (nat p)"
[PROOF STATE]
proof (state)
this:
prime (nat p)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime (nat p)
[PROOF STEP]
have p0: "p > 1" and "prime p"
[PROOF STATE]
proof (prove)
using this:
prime (nat p)

goal (1 subgoal):
 1. 1 < p &&& prime p
[PROOF STEP]
by (simp_all add: prime_int_nat_transfer prime_nat_iff)
[PROOF STATE]
proof (state)
this:
1 < p
prime p

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
assume p2: "odd p"
[PROOF STATE]
proof (state)
this:
odd p

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
odd p
[PROOF STEP]
obtain n where n: "p = 2*n+1"
[PROOF STATE]
proof (prove)
using this:
odd p

goal (1 subgoal):
 1. (\<And>n. p = 2 * n + 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using oddE
[PROOF STATE]
proof (prove)
using this:
odd p
\<lbrakk>odd ?a; \<And>b. ?a = (2::?'a) * b + (1::?'a) \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>n. p = 2 * n + 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p = 2 * n + 1

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
with p1
[PROOF STATE]
proof (chain)
picking this:
prime (nat p)
p = 2 * n + 1
[PROOF STEP]
have n0: "n > 0"
[PROOF STATE]
proof (prove)
using this:
prime (nat p)
p = 2 * n + 1

goal (1 subgoal):
 1. 0 < n
[PROOF STEP]
by (auto simp add: prime_nat_iff)
[PROOF STATE]
proof (state)
this:
0 < n

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
let ?C = "{0 ..< p}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
let ?D = "{0 .. n}"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
let ?f = "%x. x^2 mod p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
let ?g = "%x. (-1-x^2) mod p"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
let ?A = "?f ` ?D"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
let ?B = "?g ` ?D"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have finC: "finite ?C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {0..<p}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {0..<p}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have finD: "finite ?D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {0..n}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite {0..n}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
from p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
[PROOF STEP]
have AsubC: "?A \<subseteq> ?C" and BsubC: "?B \<subseteq> ?C"
[PROOF STATE]
proof (prove)
using this:
1 < p

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<subseteq> {0..<p} &&& (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<subseteq> {0..<p}
(\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
with finC
[PROOF STATE]
proof (chain)
picking this:
finite {0..<p}
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<subseteq> {0..<p}
(\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}
[PROOF STEP]
have finA: "finite ?A" and finB: "finite ?B"
[PROOF STATE]
proof (prove)
using this:
finite {0..<p}
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<subseteq> {0..<p}
(\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}

goal (1 subgoal):
 1. finite ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) &&& finite ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
[PROOF STEP]
by (auto simp add: finite_subset)
[PROOF STATE]
proof (state)
this:
finite ((\<lambda>x. x\<^sup>2 mod p) ` {0..n})
finite ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
from AsubC BsubC
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<subseteq> {0..<p}
(\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}
[PROOF STEP]
have AunBsubC: "?A \<union> ?B \<subseteq> ?C"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<subseteq> {0..<p}
(\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}
[PROOF STEP]
by (rule Un_least)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
from p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
[PROOF STEP]
have cardC: "card ?C = nat p"
[PROOF STATE]
proof (prove)
using this:
1 < p

goal (1 subgoal):
 1. card {0..<p} = nat p
[PROOF STEP]
using card_atLeastZeroLessThan_int
[PROOF STATE]
proof (prove)
using this:
1 < p
card {0..<?u} = nat ?u

goal (1 subgoal):
 1. card {0..<p} = nat p
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card {0..<p} = nat p

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
from n0
[PROOF STATE]
proof (chain)
picking this:
0 < n
[PROOF STEP]
have cardD: "card ?D = 1+ nat n"
[PROOF STATE]
proof (prove)
using this:
0 < n

goal (1 subgoal):
 1. card {0..n} = 1 + nat n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {0..n} = 1 + nat n

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have cardA: "card ?A = card ?D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
have "inj_on ?f ?D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. x\<^sup>2 mod p) {0..n}
[PROOF STEP]
proof (unfold inj_on_def, auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume x0: "0 \<le> x" and xn: "x \<le> n" and y0: "0 \<le> y" and yn: " y \<le> n"
        and xyp: "x^2 mod p = y^2 mod p"
[PROOF STATE]
proof (state)
this:
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
x\<^sup>2 mod p = y\<^sup>2 mod p

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
with p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
x\<^sup>2 mod p = y\<^sup>2 mod p
[PROOF STEP]
have "[x^2 = y^2] (mod p)"
[PROOF STATE]
proof (prove)
using this:
1 < p
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
x\<^sup>2 mod p = y\<^sup>2 mod p

goal (1 subgoal):
 1. [x\<^sup>2 = y\<^sup>2] (mod p)
[PROOF STEP]
using cong_def
[PROOF STATE]
proof (prove)
using this:
1 < p
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
x\<^sup>2 mod p = y\<^sup>2 mod p
[?b = ?c] (mod ?a) = (?b mod ?a = ?c mod ?a)

goal (1 subgoal):
 1. [x\<^sup>2 = y\<^sup>2] (mod p)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 = y\<^sup>2] (mod p)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "p dvd x^2-y^2"
[PROOF STATE]
proof (prove)
using this:
[x\<^sup>2 = y\<^sup>2] (mod p)

goal (1 subgoal):
 1. p dvd x\<^sup>2 - y\<^sup>2
[PROOF STEP]
using cong_iff_dvd_diff
[PROOF STATE]
proof (prove)
using this:
[x\<^sup>2 = y\<^sup>2] (mod p)
[?a = ?b] (mod ?m) = (?m dvd ?a - ?b)

goal (1 subgoal):
 1. p dvd x\<^sup>2 - y\<^sup>2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
p dvd x\<^sup>2 - y\<^sup>2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "p dvd (x+y)*(x-y)"
[PROOF STATE]
proof (prove)
using this:
p dvd x\<^sup>2 - y\<^sup>2

goal (1 subgoal):
 1. p dvd (x + y) * (x - y)
[PROOF STEP]
by (simp add: power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
p dvd (x + y) * (x - y)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "p dvd x+y \<or> p dvd x-y"
[PROOF STATE]
proof (prove)
using this:
p dvd (x + y) * (x - y)

goal (1 subgoal):
 1. p dvd x + y \<or> p dvd x - y
[PROOF STEP]
using \<open>prime p\<close> p0
[PROOF STATE]
proof (prove)
using this:
p dvd (x + y) * (x - y)
prime p
1 < p

goal (1 subgoal):
 1. p dvd x + y \<or> p dvd x - y
[PROOF STEP]
by (auto dest: prime_dvd_multD)
[PROOF STATE]
proof (state)
this:
p dvd x + y \<or> p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x + y \<or> p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
p dvd x + y \<or> p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume "p dvd x+y"
[PROOF STATE]
proof (state)
this:
p dvd x + y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x + y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
from xn yn n
[PROOF STATE]
proof (chain)
picking this:
x \<le> n
y \<le> n
p = 2 * n + 1
[PROOF STEP]
have "x+y < p"
[PROOF STATE]
proof (prove)
using this:
x \<le> n
y \<le> n
p = 2 * n + 1

goal (1 subgoal):
 1. x + y < p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x + y < p

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd x + y
x + y < p
[PROOF STEP]
have "\<not> x+y > 0"
[PROOF STATE]
proof (prove)
using this:
p dvd x + y
x + y < p

goal (1 subgoal):
 1. \<not> 0 < x + y
[PROOF STEP]
by (auto simp add: zdvd_not_zless)
[PROOF STATE]
proof (state)
this:
\<not> 0 < x + y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
with x0 y0
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
0 \<le> y
\<not> 0 < x + y
[PROOF STEP]
have "x = y"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
0 \<le> y
\<not> 0 < x + y

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

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
} \<comment> \<open>both are zero\<close>
[PROOF STATE]
proof (state)
this:
p dvd x + y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x + y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
p dvd x + y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume ass: "p dvd x-y"
[PROOF STATE]
proof (state)
this:
p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
proof (rule ccontr, case_tac "x-y \<ge> 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "x-y \<ge> 0" and "x \<noteq> y"
[PROOF STATE]
proof (state)
this:
0 \<le> x - y
x \<noteq> y

goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "x-y > 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x - y
x \<noteq> y

goal (1 subgoal):
 1. 0 < x - y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < x - y

goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
with ass
[PROOF STATE]
proof (chain)
picking this:
p dvd x - y
0 < x - y
[PROOF STEP]
have "\<not> x-y < p"
[PROOF STATE]
proof (prove)
using this:
p dvd x - y
0 < x - y

goal (1 subgoal):
 1. \<not> x - y < p
[PROOF STEP]
by (auto simp add: zdvd_not_zless)
[PROOF STATE]
proof (state)
this:
\<not> x - y < p

goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
with xn y0 n p0
[PROOF STATE]
proof (chain)
picking this:
x \<le> n
0 \<le> y
p = 2 * n + 1
1 < p
\<not> x - y < p
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
x \<le> n
0 \<le> y
p = 2 * n + 1
1 < p
\<not> x - y < p

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

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "\<not> 0 \<le> x-y"
[PROOF STATE]
proof (state)
this:
\<not> 0 \<le> x - y

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "y-x > 0"
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> x - y

goal (1 subgoal):
 1. 0 < y - x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 < y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
from x0 yn n p0
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
y \<le> n
p = 2 * n + 1
1 < p
[PROOF STEP]
have "y-x < p"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
y \<le> n
p = 2 * n + 1
1 < p

goal (1 subgoal):
 1. y - x < p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y - x < p

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 < y - x
y - x < p
[PROOF STEP]
have "\<not> p dvd y-x"
[PROOF STATE]
proof (prove)
using this:
0 < y - x
y - x < p

goal (1 subgoal):
 1. \<not> p dvd y - x
[PROOF STEP]
by (auto simp add: zdvd_not_zless)
[PROOF STATE]
proof (state)
this:
\<not> p dvd y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<not> p dvd y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
from ass
[PROOF STATE]
proof (chain)
picking this:
p dvd x - y
[PROOF STEP]
have "p dvd -(x-y)"
[PROOF STATE]
proof (prove)
using this:
p dvd x - y

goal (1 subgoal):
 1. p dvd - (x - y)
[PROOF STEP]
by (simp only: dvd_minus_iff)
[PROOF STATE]
proof (state)
this:
p dvd - (x - y)

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<not> p dvd y - x
p dvd - (x - y)
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
\<not> p dvd y - x
p dvd - (x - y)

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:
x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
p dvd x - y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>x\<^sup>2 mod p = y\<^sup>2 mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd x + y \<or> p dvd x - y
p dvd x + y \<Longrightarrow> x = y
p dvd x - y \<Longrightarrow> x = y
[PROOF STEP]
show "x=y"
[PROOF STATE]
proof (prove)
using this:
p dvd x + y \<or> p dvd x - y
p dvd x + y \<Longrightarrow> x = y
p dvd x - y \<Longrightarrow> x = y

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>x. x\<^sup>2 mod p) {0..n}

goal (1 subgoal):
 1. card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
with finD
[PROOF STATE]
proof (chain)
picking this:
finite {0..n}
inj_on (\<lambda>x. x\<^sup>2 mod p) {0..n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite {0..n}
inj_on (\<lambda>x. x\<^sup>2 mod p) {0..n}

goal (1 subgoal):
 1. card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
by (simp only: inj_on_iff_eq_card)
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have cardB: "card ?B = card ?D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
have "inj_on ?g ?D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. (- 1 - x\<^sup>2) mod p) {0..n}
[PROOF STEP]
proof (unfold inj_on_def, auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
fix y
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume x0: "0 \<le> x" and xn: "x \<le> n" and y0: "0 \<le> y" and yn: " y \<le> n"
        and xyp: "(-1-x^2) mod p = (-1-y^2) mod p"
[PROOF STATE]
proof (state)
this:
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
with p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p
[PROOF STEP]
have "[-1-y^2 = -1-x^2] (mod p)"
[PROOF STATE]
proof (prove)
using this:
1 < p
0 \<le> x
x \<le> n
0 \<le> y
y \<le> n
(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p

goal (1 subgoal):
 1. [- 1 - y\<^sup>2 = - 1 - x\<^sup>2] (mod p)
[PROOF STEP]
by (simp only: cong_def)
[PROOF STATE]
proof (state)
this:
[- 1 - y\<^sup>2 = - 1 - x\<^sup>2] (mod p)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "p dvd (-1-y^2) - (-1-x^2)"
[PROOF STATE]
proof (prove)
using this:
[- 1 - y\<^sup>2 = - 1 - x\<^sup>2] (mod p)

goal (1 subgoal):
 1. p dvd - 1 - y\<^sup>2 - (- 1 - x\<^sup>2)
[PROOF STEP]
by (simp only: cong_iff_dvd_diff)
[PROOF STATE]
proof (state)
this:
p dvd - 1 - y\<^sup>2 - (- 1 - x\<^sup>2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd - 1 - y\<^sup>2 - (- 1 - x\<^sup>2)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "-1-y^2 - (-1-x^2) = x^2 - y^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 1 - y\<^sup>2 - (- 1 - x\<^sup>2) = x\<^sup>2 - y\<^sup>2
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
- 1 - y\<^sup>2 - (- 1 - x\<^sup>2) = x\<^sup>2 - y\<^sup>2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd - 1 - y\<^sup>2 - (- 1 - x\<^sup>2)
- 1 - y\<^sup>2 - (- 1 - x\<^sup>2) = x\<^sup>2 - y\<^sup>2
[PROOF STEP]
have "p dvd x^2-y^2"
[PROOF STATE]
proof (prove)
using this:
p dvd - 1 - y\<^sup>2 - (- 1 - x\<^sup>2)
- 1 - y\<^sup>2 - (- 1 - x\<^sup>2) = x\<^sup>2 - y\<^sup>2

goal (1 subgoal):
 1. p dvd x\<^sup>2 - y\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p dvd x\<^sup>2 - y\<^sup>2

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
hence "p dvd (x+y)*(x-y)"
[PROOF STATE]
proof (prove)
using this:
p dvd x\<^sup>2 - y\<^sup>2

goal (1 subgoal):
 1. p dvd (x + y) * (x - y)
[PROOF STEP]
by (simp add: power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
p dvd (x + y) * (x - y)

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
with p1
[PROOF STATE]
proof (chain)
picking this:
prime (nat p)
p dvd (x + y) * (x - y)
[PROOF STEP]
have "p dvd x+y \<or> p dvd x-y"
[PROOF STATE]
proof (prove)
using this:
prime (nat p)
p dvd (x + y) * (x - y)

goal (1 subgoal):
 1. p dvd x + y \<or> p dvd x - y
[PROOF STEP]
using \<open>prime p\<close> p0
[PROOF STATE]
proof (prove)
using this:
prime (nat p)
p dvd (x + y) * (x - y)
prime p
1 < p

goal (1 subgoal):
 1. p dvd x + y \<or> p dvd x - y
[PROOF STEP]
by (auto dest: prime_dvd_multD)
[PROOF STATE]
proof (state)
this:
p dvd x + y \<or> p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x + y \<or> p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
p dvd x + y \<or> p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume "p dvd x+y"
[PROOF STATE]
proof (state)
this:
p dvd x + y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x + y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
from xn yn n
[PROOF STATE]
proof (chain)
picking this:
x \<le> n
y \<le> n
p = 2 * n + 1
[PROOF STEP]
have "x+y < p"
[PROOF STATE]
proof (prove)
using this:
x \<le> n
y \<le> n
p = 2 * n + 1

goal (1 subgoal):
 1. x + y < p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x + y < p

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd x + y
x + y < p
[PROOF STEP]
have "\<not> x+y > 0"
[PROOF STATE]
proof (prove)
using this:
p dvd x + y
x + y < p

goal (1 subgoal):
 1. \<not> 0 < x + y
[PROOF STEP]
by (auto simp add: zdvd_not_zless)
[PROOF STATE]
proof (state)
this:
\<not> 0 < x + y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
with x0 y0
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
0 \<le> y
\<not> 0 < x + y
[PROOF STEP]
have "x = y"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
0 \<le> y
\<not> 0 < x + y

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

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
} \<comment> \<open>both are zero\<close>
[PROOF STATE]
proof (state)
this:
p dvd x + y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x + y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
p dvd x + y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
assume ass: "p dvd x-y"
[PROOF STATE]
proof (state)
this:
p dvd x - y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
have "x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x = y
[PROOF STEP]
proof (rule ccontr, case_tac "x-y \<ge> 0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "x-y \<ge> 0" and "x \<noteq> y"
[PROOF STATE]
proof (state)
this:
0 \<le> x - y
x \<noteq> y

goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "x-y > 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x - y
x \<noteq> y

goal (1 subgoal):
 1. 0 < x - y
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < x - y

goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
with ass
[PROOF STATE]
proof (chain)
picking this:
p dvd x - y
0 < x - y
[PROOF STEP]
have "\<not> x-y < p"
[PROOF STATE]
proof (prove)
using this:
p dvd x - y
0 < x - y

goal (1 subgoal):
 1. \<not> x - y < p
[PROOF STEP]
by (auto simp add: zdvd_not_zless)
[PROOF STATE]
proof (state)
this:
\<not> x - y < p

goal (2 subgoals):
 1. \<lbrakk>x \<noteq> y; 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
 2. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
with xn y0 n p0
[PROOF STATE]
proof (chain)
picking this:
x \<le> n
0 \<le> y
p = 2 * n + 1
1 < p
\<not> x - y < p
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
x \<le> n
0 \<le> y
p = 2 * n + 1
1 < p
\<not> x - y < p

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

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "\<not> 0 \<le> x-y"
[PROOF STATE]
proof (state)
this:
\<not> 0 \<le> x - y

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "y-x > 0"
[PROOF STATE]
proof (prove)
using this:
\<not> 0 \<le> x - y

goal (1 subgoal):
 1. 0 < y - x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 < y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
from x0 yn n p0
[PROOF STATE]
proof (chain)
picking this:
0 \<le> x
y \<le> n
p = 2 * n + 1
1 < p
[PROOF STEP]
have "y-x < p"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x
y \<le> n
p = 2 * n + 1
1 < p

goal (1 subgoal):
 1. y - x < p
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
y - x < p

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 < y - x
y - x < p
[PROOF STEP]
have "\<not> p dvd y-x"
[PROOF STATE]
proof (prove)
using this:
0 < y - x
y - x < p

goal (1 subgoal):
 1. \<not> p dvd y - x
[PROOF STEP]
by (auto simp add: zdvd_not_zless)
[PROOF STATE]
proof (state)
this:
\<not> p dvd y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<not> p dvd y - x

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
from ass
[PROOF STATE]
proof (chain)
picking this:
p dvd x - y
[PROOF STEP]
have "p dvd -(x-y)"
[PROOF STATE]
proof (prove)
using this:
p dvd x - y

goal (1 subgoal):
 1. p dvd - (x - y)
[PROOF STEP]
by (simp only: dvd_minus_iff)
[PROOF STATE]
proof (state)
this:
p dvd - (x - y)

goal (1 subgoal):
 1. \<lbrakk>x \<noteq> y; \<not> 0 \<le> x - y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<not> p dvd y - x
p dvd - (x - y)
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
\<not> p dvd y - x
p dvd - (x - y)

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:
x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
p dvd x - y \<Longrightarrow> x = y

goal (1 subgoal):
 1. \<And>x y. \<lbrakk>(- 1 - x\<^sup>2) mod p = (- 1 - y\<^sup>2) mod p; 0 \<le> x; x \<le> n; 0 \<le> y; y \<le> n\<rbrakk> \<Longrightarrow> x = y
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd x + y \<or> p dvd x - y
p dvd x + y \<Longrightarrow> x = y
p dvd x - y \<Longrightarrow> x = y
[PROOF STEP]
show "x=y"
[PROOF STATE]
proof (prove)
using this:
p dvd x + y \<or> p dvd x - y
p dvd x + y \<Longrightarrow> x = y
p dvd x - y \<Longrightarrow> x = y

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
inj_on (\<lambda>x. (- 1 - x\<^sup>2) mod p) {0..n}

goal (1 subgoal):
 1. card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
with finD
[PROOF STATE]
proof (chain)
picking this:
finite {0..n}
inj_on (\<lambda>x. (- 1 - x\<^sup>2) mod p) {0..n}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
finite {0..n}
inj_on (\<lambda>x. (- 1 - x\<^sup>2) mod p) {0..n}

goal (1 subgoal):
 1. card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}
[PROOF STEP]
by (simp only: inj_on_iff_eq_card)
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have "?A \<inter> ?B \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<noteq> {}
[PROOF STEP]
proof (rule ccontr, auto)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
assume ABdisj: "?A \<inter> ?B = {}"
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {}

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
from cardA cardB cardD
[PROOF STATE]
proof (chain)
picking this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}
card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}
card {0..n} = 1 + nat n
[PROOF STEP]
have "2 + 2*(nat n) = card ?A + card ?B"
[PROOF STATE]
proof (prove)
using this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) = card {0..n}
card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card {0..n}
card {0..n} = 1 + nat n

goal (1 subgoal):
 1. 2 + 2 * nat n = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 + 2 * nat n = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 + 2 * nat n = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
with finA finB ABdisj
[PROOF STATE]
proof (chain)
picking this:
finite ((\<lambda>x. x\<^sup>2 mod p) ` {0..n})
finite ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {}
2 + 2 * nat n = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
[PROOF STEP]
have "\<dots> = card (?A \<union> ?B)"
[PROOF STATE]
proof (prove)
using this:
finite ((\<lambda>x. x\<^sup>2 mod p) ` {0..n})
finite ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {}
2 + 2 * nat n = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
[PROOF STEP]
by (simp only: card_Un_disjoint)
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
with finC AunBsubC
[PROOF STATE]
proof (chain)
picking this:
finite {0..<p}
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})
[PROOF STEP]
have "\<dots> \<le> card ?C"
[PROOF STATE]
proof (prove)
using this:
finite {0..<p}
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<subseteq> {0..<p}
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n}) + card ((\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) = card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n})

goal (1 subgoal):
 1. card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) \<le> card {0..<p}
[PROOF STEP]
by (simp only: card_mono)
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) \<le> card {0..<p}

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) \<le> card {0..<p}

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
with cardC
[PROOF STATE]
proof (chain)
picking this:
card {0..<p} = nat p
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) \<le> card {0..<p}
[PROOF STEP]
have "\<dots> = nat p"
[PROOF STATE]
proof (prove)
using this:
card {0..<p} = nat p
card ((\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<union> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}) \<le> card {0..<p}

goal (1 subgoal):
 1. card {0..<p} = nat p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card {0..<p} = nat p

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 + 2 * nat n \<le> nat p
[PROOF STEP]
have "2 + 2*(nat n) \<le> nat p"
[PROOF STATE]
proof (prove)
using this:
2 + 2 * nat n \<le> nat p

goal (1 subgoal):
 1. 2 + 2 * nat n \<le> nat p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 + 2 * nat n \<le> nat p

goal (1 subgoal):
 1. (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} = {} \<Longrightarrow> False
[PROOF STEP]
with n
[PROOF STATE]
proof (chain)
picking this:
p = 2 * n + 1
2 + 2 * nat n \<le> nat p
[PROOF STEP]
show "False"
[PROOF STATE]
proof (prove)
using this:
p = 2 * n + 1
2 + 2 * nat n \<le> nat p

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<noteq> {}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<noteq> {}
[PROOF STEP]
obtain z where "z \<in> ?A \<and> z \<in> ?B"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<inter> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<noteq> {}

goal (1 subgoal):
 1. (\<And>z. z \<in> (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<and> z \<in> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n} \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z \<in> (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<and> z \<in> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
z \<in> (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<and> z \<in> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}
[PROOF STEP]
obtain x y where xy: "x \<in> ?D \<and> y \<in> ?D \<and> z = x^2 mod p \<and> z = (-1-y^2) mod p"
[PROOF STATE]
proof (prove)
using this:
z \<in> (\<lambda>x. x\<^sup>2 mod p) ` {0..n} \<and> z \<in> (\<lambda>x. (- 1 - x\<^sup>2) mod p) ` {0..n}

goal (1 subgoal):
 1. (\<And>x y. x \<in> {0..n} \<and> y \<in> {0..n} \<and> z = x\<^sup>2 mod p \<and> z = (- 1 - y\<^sup>2) mod p \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {0..n} \<and> y \<in> {0..n} \<and> z = x\<^sup>2 mod p \<and> z = (- 1 - y\<^sup>2) mod p

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
with p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
x \<in> {0..n} \<and> y \<in> {0..n} \<and> z = x\<^sup>2 mod p \<and> z = (- 1 - y\<^sup>2) mod p
[PROOF STEP]
have "[x^2=-1-y^2](mod p)"
[PROOF STATE]
proof (prove)
using this:
1 < p
x \<in> {0..n} \<and> y \<in> {0..n} \<and> z = x\<^sup>2 mod p \<and> z = (- 1 - y\<^sup>2) mod p

goal (1 subgoal):
 1. [x\<^sup>2 = - 1 - y\<^sup>2] (mod p)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 = - 1 - y\<^sup>2] (mod p)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
hence "p dvd x^2-(-1-y^2)"
[PROOF STATE]
proof (prove)
using this:
[x\<^sup>2 = - 1 - y\<^sup>2] (mod p)

goal (1 subgoal):
 1. p dvd x\<^sup>2 - (- 1 - y\<^sup>2)
[PROOF STEP]
by (simp only: cong_iff_dvd_diff)
[PROOF STATE]
proof (state)
this:
p dvd x\<^sup>2 - (- 1 - y\<^sup>2)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p dvd x\<^sup>2 - (- 1 - y\<^sup>2)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have "x^2-(-1-y^2)=x^2+y^2+1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sup>2 - (- 1 - y\<^sup>2) = x\<^sup>2 + y\<^sup>2 + 1
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
x\<^sup>2 - (- 1 - y\<^sup>2) = x\<^sup>2 + y\<^sup>2 + 1

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p dvd x\<^sup>2 - (- 1 - y\<^sup>2)
x\<^sup>2 - (- 1 - y\<^sup>2) = x\<^sup>2 + y\<^sup>2 + 1
[PROOF STEP]
have "p dvd sum4sq_int(x,y,1,0)"
[PROOF STATE]
proof (prove)
using this:
p dvd x\<^sup>2 - (- 1 - y\<^sup>2)
x\<^sup>2 - (- 1 - y\<^sup>2) = x\<^sup>2 + y\<^sup>2 + 1

goal (1 subgoal):
 1. p dvd sum4sq_int (x, y, 1, 0)
[PROOF STEP]
by (auto simp add: sum4sq_int_def)
[PROOF STATE]
proof (state)
this:
p dvd sum4sq_int (x, y, 1, 0)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
p dvd sum4sq_int (x, y, 1, 0)
[PROOF STEP]
obtain t where t: "p * t = sum4sq_int(x,y,1,0)"
[PROOF STATE]
proof (prove)
using this:
p dvd sum4sq_int (x, y, 1, 0)

goal (1 subgoal):
 1. (\<And>t. p * t = sum4sq_int (x, y, 1, 0) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp only: dvd_def eq_refl)
[PROOF STATE]
proof (state)
this:
p * t = sum4sq_int (x, y, 1, 0)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
hence "is_sum4sq_int (p*t)"
[PROOF STATE]
proof (prove)
using this:
p * t = sum4sq_int (x, y, 1, 0)

goal (1 subgoal):
 1. is_sum4sq_int (p * t)
[PROOF STEP]
by (unfold is_sum4sq_int_def, auto)
[PROOF STATE]
proof (state)
this:
is_sum4sq_int (p * t)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
is_sum4sq_int (p * t)

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
have "t > 0 \<and> t < p"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < t \<and> t < p
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
have "x^2 \<ge> 0 \<and> y^2 \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> x\<^sup>2 \<and> 0 \<le> y\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 \<le> x\<^sup>2 \<and> 0 \<le> y\<^sup>2

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
hence "x^2+y^2+1 > 0"
[PROOF STATE]
proof (prove)
using this:
0 \<le> x\<^sup>2 \<and> 0 \<le> y\<^sup>2

goal (1 subgoal):
 1. 0 < x\<^sup>2 + y\<^sup>2 + 1
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
0 < x\<^sup>2 + y\<^sup>2 + 1

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
with t
[PROOF STATE]
proof (chain)
picking this:
p * t = sum4sq_int (x, y, 1, 0)
0 < x\<^sup>2 + y\<^sup>2 + 1
[PROOF STEP]
have "p*t > 0"
[PROOF STATE]
proof (prove)
using this:
p * t = sum4sq_int (x, y, 1, 0)
0 < x\<^sup>2 + y\<^sup>2 + 1

goal (1 subgoal):
 1. 0 < p * t
[PROOF STEP]
by (unfold sum4sq_int_def, auto)
[PROOF STATE]
proof (state)
this:
0 < p * t

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
0 < p * t

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
0 < p * t

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
assume "t < 0"
[PROOF STATE]
proof (state)
this:
t < 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
with p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
t < 0
[PROOF STEP]
have "p*t < p*0"
[PROOF STATE]
proof (prove)
using this:
1 < p
t < 0

goal (1 subgoal):
 1. p * t < p * 0
[PROOF STEP]
by (simp only: zmult_zless_mono2)
[PROOF STATE]
proof (state)
this:
p * t < p * 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
hence "p*t < 0"
[PROOF STATE]
proof (prove)
using this:
p * t < p * 0

goal (1 subgoal):
 1. p * t < 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p * t < 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
t < 0 \<Longrightarrow> p * t < 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
t < 0 \<Longrightarrow> p * t < 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
t < 0 \<Longrightarrow> p * t < 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
assume "t = 0"
[PROOF STATE]
proof (state)
this:
t = 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
hence "p*t = 0"
[PROOF STATE]
proof (prove)
using this:
t = 0

goal (1 subgoal):
 1. p * t = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p * t = 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
t = 0 \<Longrightarrow> p * t = 0

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
0 < p * t
t < 0 \<Longrightarrow> p * t < 0
t = 0 \<Longrightarrow> p * t = 0
[PROOF STEP]
have "\<not> t < 0 \<and> t \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
0 < p * t
t < 0 \<Longrightarrow> p * t < 0
t = 0 \<Longrightarrow> p * t = 0

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

goal (2 subgoals):
 1. 0 < t
 2. t < p
[PROOF STEP]
thus "t > 0"
[PROOF STATE]
proof (prove)
using this:
\<not> t < 0 \<and> t \<noteq> 0

goal (1 subgoal):
 1. 0 < t
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
from xy
[PROOF STATE]
proof (chain)
picking this:
x \<in> {0..n} \<and> y \<in> {0..n} \<and> z = x\<^sup>2 mod p \<and> z = (- 1 - y\<^sup>2) mod p
[PROOF STEP]
have "x^2 \<le> n^2 \<and> y^2 \<le> n^2"
[PROOF STATE]
proof (prove)
using this:
x \<in> {0..n} \<and> y \<in> {0..n} \<and> z = x\<^sup>2 mod p \<and> z = (- 1 - y\<^sup>2) mod p

goal (1 subgoal):
 1. x\<^sup>2 \<le> n\<^sup>2 \<and> y\<^sup>2 \<le> n\<^sup>2
[PROOF STEP]
by (auto simp add: power_mono)
[PROOF STATE]
proof (state)
this:
x\<^sup>2 \<le> n\<^sup>2 \<and> y\<^sup>2 \<le> n\<^sup>2

goal (1 subgoal):
 1. t < p
[PROOF STEP]
hence "x^2+y^2+1 \<le> 2*n^2 + 1"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>2 \<le> n\<^sup>2 \<and> y\<^sup>2 \<le> n\<^sup>2

goal (1 subgoal):
 1. x\<^sup>2 + y\<^sup>2 + 1 \<le> 2 * n\<^sup>2 + 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x\<^sup>2 + y\<^sup>2 + 1 \<le> 2 * n\<^sup>2 + 1

goal (1 subgoal):
 1. t < p
[PROOF STEP]
with t
[PROOF STATE]
proof (chain)
picking this:
p * t = sum4sq_int (x, y, 1, 0)
x\<^sup>2 + y\<^sup>2 + 1 \<le> 2 * n\<^sup>2 + 1
[PROOF STEP]
have contr: "p*t \<le> 2*n^2+1"
[PROOF STATE]
proof (prove)
using this:
p * t = sum4sq_int (x, y, 1, 0)
x\<^sup>2 + y\<^sup>2 + 1 \<le> 2 * n\<^sup>2 + 1

goal (1 subgoal):
 1. p * t \<le> 2 * n\<^sup>2 + 1
[PROOF STEP]
by (simp add: sum4sq_int_def)
[PROOF STATE]
proof (state)
this:
p * t \<le> 2 * n\<^sup>2 + 1

goal (1 subgoal):
 1. t < p
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p * t \<le> 2 * n\<^sup>2 + 1

goal (1 subgoal):
 1. t < p
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
p * t \<le> 2 * n\<^sup>2 + 1

goal (1 subgoal):
 1. t < p
[PROOF STEP]
assume "t > n+1"
[PROOF STATE]
proof (state)
this:
n + 1 < t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
with p0
[PROOF STATE]
proof (chain)
picking this:
1 < p
n + 1 < t
[PROOF STEP]
have "p*(n+1) < p*t"
[PROOF STATE]
proof (prove)
using this:
1 < p
n + 1 < t

goal (1 subgoal):
 1. p * (n + 1) < p * t
[PROOF STEP]
by (simp only: zmult_zless_mono2)
[PROOF STATE]
proof (state)
this:
p * (n + 1) < p * t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
with n
[PROOF STATE]
proof (chain)
picking this:
p = 2 * n + 1
p * (n + 1) < p * t
[PROOF STEP]
have "p*t > (2*n+1)*n + (2*n+1)*1"
[PROOF STATE]
proof (prove)
using this:
p = 2 * n + 1
p * (n + 1) < p * t

goal (1 subgoal):
 1. (2 * n + 1) * n + (2 * n + 1) * 1 < p * t
[PROOF STEP]
by (simp only: distrib_left)
[PROOF STATE]
proof (state)
this:
(2 * n + 1) * n + (2 * n + 1) * 1 < p * t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
hence "p*t > 2*n*n + n + 2*n + 1"
[PROOF STATE]
proof (prove)
using this:
(2 * n + 1) * n + (2 * n + 1) * 1 < p * t

goal (1 subgoal):
 1. 2 * n * n + n + 2 * n + 1 < p * t
[PROOF STEP]
by (simp only: distrib_right mult_1_left)
[PROOF STATE]
proof (state)
this:
2 * n * n + n + 2 * n + 1 < p * t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
with n0
[PROOF STATE]
proof (chain)
picking this:
0 < n
2 * n * n + n + 2 * n + 1 < p * t
[PROOF STEP]
have "p*t > 2*n^2 + 1"
[PROOF STATE]
proof (prove)
using this:
0 < n
2 * n * n + n + 2 * n + 1 < p * t

goal (1 subgoal):
 1. 2 * n\<^sup>2 + 1 < p * t
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
2 * n\<^sup>2 + 1 < p * t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
n + 1 < t \<Longrightarrow> 2 * n\<^sup>2 + 1 < p * t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p * t \<le> 2 * n\<^sup>2 + 1
n + 1 < t \<Longrightarrow> 2 * n\<^sup>2 + 1 < p * t
[PROOF STEP]
have "\<not> t > n+1"
[PROOF STATE]
proof (prove)
using this:
p * t \<le> 2 * n\<^sup>2 + 1
n + 1 < t \<Longrightarrow> 2 * n\<^sup>2 + 1 < p * t

goal (1 subgoal):
 1. \<not> n + 1 < t
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> n + 1 < t

goal (1 subgoal):
 1. t < p
[PROOF STEP]
with n0 n
[PROOF STATE]
proof (chain)
picking this:
0 < n
p = 2 * n + 1
\<not> n + 1 < t
[PROOF STEP]
show "t < p"
[PROOF STATE]
proof (prove)
using this:
0 < n
p = 2 * n + 1
\<not> n + 1 < t

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < t \<and> t < p

goal (1 subgoal):
 1. \<lbrakk>prime (nat p); odd p\<rbrakk> \<Longrightarrow> \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
is_sum4sq_int (p * t)
0 < t \<and> t < p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
is_sum4sq_int (p * t)
0 < t \<and> t < p

goal (1 subgoal):
 1. \<exists>t>0. t < p \<and> is_sum4sq_int (p * t)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>t>0. t < p \<and> is_sum4sq_int (p * t)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in ring_char_0) UNIV_ring_char_0_infinte: "\<not> finite (UNIV :: 'a set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite UNIV
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite UNIV \<Longrightarrow> False
[PROOF STEP]
assume F: "finite (UNIV :: 'a set)"
[PROOF STATE]
proof (state)
this:
finite UNIV

goal (1 subgoal):
 1. finite UNIV \<Longrightarrow> False
[PROOF STEP]
have "finite (UNIV :: nat set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite UNIV
[PROOF STEP]
proof (rule finite_imageD)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. finite (range ?f)
 2. inj ?f
[PROOF STEP]
have "of_nat ` UNIV \<subseteq> UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range of_nat \<subseteq> UNIV
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
range of_nat \<subseteq> UNIV

goal (2 subgoals):
 1. finite (range ?f)
 2. inj ?f
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
range of_nat \<subseteq> UNIV
[PROOF STEP]
show "finite (of_nat ` UNIV :: 'a set)"
[PROOF STATE]
proof (prove)
using this:
range of_nat \<subseteq> UNIV

goal (1 subgoal):
 1. finite (range of_nat)
[PROOF STEP]
using F
[PROOF STATE]
proof (prove)
using this:
range of_nat \<subseteq> UNIV
finite UNIV

goal (1 subgoal):
 1. finite (range of_nat)
[PROOF STEP]
by (rule finite_subset)
[PROOF STATE]
proof (state)
this:
finite (range of_nat)

goal (1 subgoal):
 1. inj of_nat
[PROOF STEP]
show "inj (of_nat :: nat \<Rightarrow> 'a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj of_nat
[PROOF STEP]
by (simp add: inj_on_def)
[PROOF STATE]
proof (state)
this:
inj of_nat

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
finite UNIV

goal (1 subgoal):
 1. finite UNIV \<Longrightarrow> False
[PROOF STEP]
with infinite_UNIV_nat
[PROOF STATE]
proof (chain)
picking this:
infinite UNIV
finite UNIV
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
infinite UNIV
finite UNIV

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma length_rows[simp]: "length (rows A) = dim_row A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (rows A) = dim_row A
[PROOF STEP]
unfolding rows_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (map (row A) [0..<dim_row A]) = dim_row A
[PROOF STEP]
by auto


[STATEMENT]
lemma R_mult_right_mono: "R a b \<Longrightarrow> c \<ge> 0 \<Longrightarrow> R (a*c) (b*c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>R a b; 0 \<le> c\<rbrakk> \<Longrightarrow> R (a * c) (b * c)
[PROOF STEP]
using R
[PROOF STATE]
proof (prove)
using this:
R = (\<le>) \<or> R = (\<lambda>x y. y \<le> x)

goal (1 subgoal):
 1. \<lbrakk>R a b; 0 \<le> c\<rbrakk> \<Longrightarrow> R (a * c) (b * c)
[PROOF STEP]
by (auto simp: mult_right_mono)


[STATEMENT]
lemma "(x AND 0xff00) OR (x AND 0x00ff) = (x::16 word)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
have "(x AND 0xff00) OR (x AND 0x00ff) = x AND (0xff00 OR 0x00ff)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x AND (65280 OR 255)
[PROOF STEP]
by (simp only: word_ao_dist2)
[PROOF STATE]
proof (state)
this:
x AND 65280 OR x AND 255 = x AND (65280 OR 255)

goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x AND 65280 OR x AND 255 = x AND (65280 OR 255)

goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
have "0xff00 OR 0x00ff = (-1::16 word)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 65280 OR 255 = - 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
65280 OR 255 = - 1

goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
65280 OR 255 = - 1

goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
have "x AND -1 = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x AND - 1 = x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x AND - 1 = x

goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x AND 65280 OR x AND 255 = x
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x AND 65280 OR x AND 255 = x

goal (1 subgoal):
 1. x AND 65280 OR x AND 255 = x
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
x AND 65280 OR x AND 255 = x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sum_bitset:
  "(\<Sum>i\<in>bitset n. 2 ^ i) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) 2) (bitset n) = n
[PROOF STEP]
proof (induct rule: nat_bit_induct)
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. sum ((^) 2) (bitset 0) = 0
 2. \<And>n. \<lbrakk>sum ((^) 2) (bitset n) = n; 0 < n\<rbrakk> \<Longrightarrow> sum ((^) 2) (bitset (2 * n)) = 2 * n
 3. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
case zero
[PROOF STATE]
proof (state)
this:

goal (3 subgoals):
 1. sum ((^) 2) (bitset 0) = 0
 2. \<And>n. \<lbrakk>sum ((^) 2) (bitset n) = n; 0 < n\<rbrakk> \<Longrightarrow> sum ((^) 2) (bitset (2 * n)) = 2 * n
 3. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) 2) (bitset 0) = 0
[PROOF STEP]
by (auto simp add: bitset_0)
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (bitset 0) = 0

goal (2 subgoals):
 1. \<And>n. \<lbrakk>sum ((^) 2) (bitset n) = n; 0 < n\<rbrakk> \<Longrightarrow> sum ((^) 2) (bitset (2 * n)) = 2 * n
 2. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>n. \<lbrakk>sum ((^) 2) (bitset n) = n; 0 < n\<rbrakk> \<Longrightarrow> sum ((^) 2) (bitset (2 * n)) = 2 * n
 2. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
case (even n)
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (bitset n) = n
0 < n

goal (2 subgoals):
 1. \<And>n. \<lbrakk>sum ((^) 2) (bitset n) = n; 0 < n\<rbrakk> \<Longrightarrow> sum ((^) 2) (bitset (2 * n)) = 2 * n
 2. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
from this
[PROOF STATE]
proof (chain)
picking this:
sum ((^) 2) (bitset n) = n
0 < n
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
sum ((^) 2) (bitset n) = n
0 < n

goal (1 subgoal):
 1. sum ((^) 2) (bitset (2 * n)) = 2 * n
[PROOF STEP]
by (simp add: bitset_2n sum.reindex sum_distrib_left[symmetric])
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (bitset (2 * n)) = 2 * n

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
case (odd n)
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (bitset n) = n

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
have "(\<Sum>i\<in>bitset (2 * n + 1). 2 ^ i) = (\<Sum>i\<in>insert 0 (Suc ` bitset n). 2 ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) (2::'a)) (bitset (2 * n + 1)) = sum ((^) (2::'a)) (insert 0 (Suc ` bitset n))
[PROOF STEP]
by (simp only: bitset_2n1)
[PROOF STATE]
proof (state)
this:
sum ((^) (2::?'a1)) (bitset (2 * n + 1)) = sum ((^) (2::?'a1)) (insert 0 (Suc ` bitset n))

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((^) (2::?'a1)) (bitset (2 * n + 1)) = sum ((^) (2::?'a1)) (insert 0 (Suc ` bitset n))

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
have "... = 2 ^ 0 + (\<Sum>i\<in>Suc ` bitset n. 2 ^ i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum ((^) (2::'a)) (insert 0 (Suc ` bitset n)) = (2::'a) ^ 0 + sum ((^) (2::'a)) (Suc ` bitset n)
[PROOF STEP]
by (subst sum.insert) (auto simp add: finite_bitset)
[PROOF STATE]
proof (state)
this:
sum ((^) (2::?'a2)) (insert 0 (Suc ` bitset n)) = (2::?'a2) ^ 0 + sum ((^) (2::?'a2)) (Suc ` bitset n)

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum ((^) (2::?'a2)) (insert 0 (Suc ` bitset n)) = (2::?'a2) ^ 0 + sum ((^) (2::?'a2)) (Suc ` bitset n)

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
have "... = 2 * n + 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ 0 + sum ((^) 2) (Suc ` bitset n) = 2 * n + 1
[PROOF STEP]
using odd
[PROOF STATE]
proof (prove)
using this:
sum ((^) 2) (bitset n) = n

goal (1 subgoal):
 1. 2 ^ 0 + sum ((^) 2) (Suc ` bitset n) = 2 * n + 1
[PROOF STEP]
by (simp add: sum.reindex sum_distrib_left[symmetric])
[PROOF STATE]
proof (state)
this:
2 ^ 0 + sum ((^) 2) (Suc ` bitset n) = 2 * n + 1

goal (1 subgoal):
 1. \<And>n. sum ((^) 2) (bitset n) = n \<Longrightarrow> sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum ((^) 2) (bitset (2 * n + 1)) = 2 * n + 1
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
sum ((^) 2) (bitset (2 * n + 1)) = 2 * n + 1

goal (1 subgoal):
 1. sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sum ((^) 2) (bitset (Suc (2 * n))) = Suc (2 * n)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in group) exp_of_derived_is_subgroup:
  assumes "subgroup H G" shows "subgroup ((derived G ^^ n) H) G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subgroup ((derived G ^^ n) H) G
[PROOF STEP]
using assms derived_is_subgroup subgroup.subset
[PROOF STATE]
proof (prove)
using this:
subgroup H G
?H \<subseteq> carrier G \<Longrightarrow> subgroup (derived G ?H) G
subgroup ?H ?G \<Longrightarrow> ?H \<subseteq> carrier ?G

goal (1 subgoal):
 1. subgroup ((derived G ^^ n) H) G
[PROOF STEP]
by (induct n) (auto)


[STATEMENT]
lemma generate_maskedDB_elim: "\<lbrakk>roundup emBits 8 * 8 - emBits \<le> length x; ( roundup emBits 8) * 8 - (length (sha1 M)) - 8 = length (maskedDB_zero x emBits)\<rbrakk> \<Longrightarrow> generate_maskedDB (maskedDB_zero x emBits @ y @ z) emBits (length(sha1 M)) = maskedDB_zero x emBits"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>roundup emBits 8 * 8 - emBits \<le> length x; roundup emBits 8 * 8 - length (sha1 M) - 8 = length (maskedDB_zero x emBits)\<rbrakk> \<Longrightarrow> generate_maskedDB (maskedDB_zero x emBits @ y @ z) emBits (length (sha1 M)) = maskedDB_zero x emBits
[PROOF STEP]
apply (simp add: maskedDB_zero_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>roundup emBits 8 * 8 - emBits \<le> length x; roundup emBits 8 * 8 - (length (sha1 M) + 8) = length (bv_prepend (roundup emBits 8 * 8 - emBits) \<zero> (drop (roundup emBits 8 * 8 - emBits) x))\<rbrakk> \<Longrightarrow> generate_maskedDB (bv_prepend (roundup emBits 8 * 8 - emBits) \<zero> (drop (roundup emBits 8 * 8 - emBits) x) @ y @ z) emBits (length (sha1 M)) = bv_prepend (roundup emBits 8 * 8 - emBits) \<zero> (drop (roundup emBits 8 * 8 - emBits) x)
[PROOF STEP]
apply (insert length_bv_prepend_drop [of "(roundup emBits 8 * 8 - emBits)" "x"])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>roundup emBits 8 * 8 - emBits \<le> length x; roundup emBits 8 * 8 - (length (sha1 M) + 8) = length (bv_prepend (roundup emBits 8 * 8 - emBits) \<zero> (drop (roundup emBits 8 * 8 - emBits) x)); \<And>b. roundup emBits 8 * 8 - emBits \<le> length x \<longrightarrow> length (bv_prepend (roundup emBits 8 * 8 - emBits) b (drop (roundup emBits 8 * 8 - emBits) x)) = length x\<rbrakk> \<Longrightarrow> generate_maskedDB (bv_prepend (roundup emBits 8 * 8 - emBits) \<zero> (drop (roundup emBits 8 * 8 - emBits) x) @ y @ z) emBits (length (sha1 M)) = bv_prepend (roundup emBits 8 * 8 - emBits) \<zero> (drop (roundup emBits 8 * 8 - emBits) x)
[PROOF STEP]
apply (simp add: generate_maskedDB_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma lm016:
  "P || X \<subseteq> (P||(X \<union> Y))       &    P outside X \<subseteq> P outside (X \<inter> Y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. P || X \<subseteq> P || (X \<union> Y) \<and> P outside X \<subseteq> P outside (X \<inter> Y)
[PROOF STEP]
using lm015 distrib_sup_le sup_idem le_inf_iff subset_antisym sup_commute
[PROOF STATE]
proof (prove)
using this:
?P || (?X \<inter> ?Y) \<subseteq> ?P || ?X \<and> ?P outside (?X \<union> ?Y) \<subseteq> ?P outside ?X
sup ?x (inf ?y ?z) \<le> inf (sup ?x ?y) (sup ?x ?z)
sup ?x ?x = ?x
(?x \<le> inf ?y ?z) = (?x \<le> ?y \<and> ?x \<le> ?z)
\<lbrakk>?A \<subseteq> ?B; ?B \<subseteq> ?A\<rbrakk> \<Longrightarrow> ?A = ?B
sup ?x ?y = sup ?y ?x

goal (1 subgoal):
 1. P || X \<subseteq> P || (X \<union> Y) \<and> P outside X \<subseteq> P outside (X \<inter> Y)
[PROOF STEP]
by (metis sup_ge1)


[STATEMENT]
lemma qbs_prob_integral_real_Markov_inequality:
  assumes "qbs_prob_space_qbs s = \<real>\<^sub>Q"
          "qbs_integrable s f"
      and "0 < c"
    shows "qbs_emeasure s {r. c \<le> \<bar>f r\<bar>} \<le> ennreal (1/c * qbs_prob_integral s (\<lambda>x. \<bar>f x\<bar>))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. qbs_emeasure s {r. c \<le> \<bar>f r\<bar>} \<le> ennreal (1 / c * \<integral>\<^sub>Q x. \<bar>f x\<bar> \<partial>s)
[PROOF STEP]
using qbs_prob_integral_Markov_inequality_abs[OF assms]
[PROOF STATE]
proof (prove)
using this:
qbs_emeasure s {x \<in> qbs_space \<real>\<^sub>Q. c \<le> \<bar>f x\<bar>} \<le> ennreal (1 / c * \<integral>\<^sub>Q x. \<bar>f x\<bar> \<partial>s)

goal (1 subgoal):
 1. qbs_emeasure s {r. c \<le> \<bar>f r\<bar>} \<le> ennreal (1 / c * \<integral>\<^sub>Q x. \<bar>f x\<bar> \<partial>s)
[PROOF STEP]
by simp


[STATEMENT]
lemma add_mult_one_time_pad:
  assumes "s0 < order \<G>"
    and "s0 \<noteq> 0"
  shows "map_spmf (\<lambda> c\<^sub>v'. (((b* r0) + (s0 * c\<^sub>v')) mod(order \<G>))) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_spmf (\<lambda>c\<^sub>v'. (b * r0 + s0 * c\<^sub>v') mod order \<G>) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_spmf (\<lambda>c\<^sub>v'. (b * r0 + s0 * c\<^sub>v') mod order \<G>) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)
[PROOF STEP]
have "gcd s0 (order \<G>) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd s0 (order \<G>) = 1
[PROOF STEP]
using assms prime_field
[PROOF STATE]
proof (prove)
using this:
s0 < order \<G>
s0 \<noteq> 0
\<lbrakk>?a < order \<G>; ?a \<noteq> 0\<rbrakk> \<Longrightarrow> coprime ?a (order \<G>)

goal (1 subgoal):
 1. gcd s0 (order \<G>) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd s0 (order \<G>) = 1

goal (1 subgoal):
 1. map_spmf (\<lambda>c\<^sub>v'. (b * r0 + s0 * c\<^sub>v') mod order \<G>) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
gcd s0 (order \<G>) = 1

goal (1 subgoal):
 1. map_spmf (\<lambda>c\<^sub>v'. (b * r0 + s0 * c\<^sub>v') mod order \<G>) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)
[PROOF STEP]
using add_mult_one_time_pad
[PROOF STATE]
proof (prove)
using this:
gcd s0 (order \<G>) = 1
coprime ?x ?q \<Longrightarrow> map_spmf (\<lambda>b. (?y + ?x * b) mod ?q) (sample_uniform ?q) = sample_uniform ?q

goal (1 subgoal):
 1. map_spmf (\<lambda>c\<^sub>v'. (b * r0 + s0 * c\<^sub>v') mod order \<G>) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
map_spmf (\<lambda>c\<^sub>v'. (b * r0 + s0 * c\<^sub>v') mod order \<G>) (sample_uniform (order \<G>)) = sample_uniform (order \<G>)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in sigma_algebra) countable_UN'':
  "\<lbrakk> countable X; \<And>x y. x \<in> X \<Longrightarrow> A x \<in> M \<rbrakk> \<Longrightarrow> (\<Union>x\<in>X. A x) \<in> M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>countable X; \<And>x y. x \<in> X \<Longrightarrow> A x \<in> M\<rbrakk> \<Longrightarrow> \<Union> (A ` X) \<in> M
[PROOF STEP]
by(erule countable_UN')(auto)


[STATEMENT]
lemma poly_ring_car_mono'[simp]:
  shows "carrier (R[\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R[\<X>\<^bsub>Suc n\<^esub>])"
        "carrier (R[\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R[\<X>\<^bsub>n+m\<^esub>])"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier (R [\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>Suc n\<^esub>]) &&& carrier (R [\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>n + m\<^esub>])
[PROOF STEP]
using poly_ring_car_mono
[PROOF STATE]
proof (prove)
using this:
?n \<le> ?m \<Longrightarrow> carrier (R [\<X>\<^bsub>?n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>?m\<^esub>])

goal (1 subgoal):
 1. carrier (R [\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>Suc n\<^esub>]) &&& carrier (R [\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>n + m\<^esub>])
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. carrier (R [\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>n + m\<^esub>])
[PROOF STEP]
using poly_ring_car_mono
[PROOF STATE]
proof (prove)
using this:
?n \<le> ?m \<Longrightarrow> carrier (R [\<X>\<^bsub>?n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>?m\<^esub>])

goal (1 subgoal):
 1. carrier (R [\<X>\<^bsub>n\<^esub>]) \<subseteq> carrier (R [\<X>\<^bsub>n + m\<^esub>])
[PROOF STEP]
by simp


[STATEMENT]
lemma nth_sorted_list_of_set_greaterThanAtMost:
  "n < j - i \<Longrightarrow> sorted_list_of_set {i<..j} ! n = Suc (i+n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < j - i \<Longrightarrow> sorted_list_of_set {i<..j} ! n = Suc (i + n)
[PROOF STEP]
using nth_sorted_list_of_set_greaterThanLessThan [of n "Suc j" i]
[PROOF STATE]
proof (prove)
using this:
n < Suc j - Suc i \<Longrightarrow> sorted_list_of_set {i<..<Suc j} ! n = Suc (i + n)

goal (1 subgoal):
 1. n < j - i \<Longrightarrow> sorted_list_of_set {i<..j} ! n = Suc (i + n)
[PROOF STEP]
by (simp add: greaterThanAtMost_def greaterThanLessThan_eq lessThan_Suc_atMost)


[STATEMENT]
lemma mkuexpr_minus [mkuexpr]: "mk\<^sub>e (\<lambda> s. f s - g s) = mk\<^sub>e f - mk\<^sub>e g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. mk\<^sub>e (\<lambda>s. f s - g s) = mk\<^sub>e f - mk\<^sub>e g
[PROOF STEP]
by (simp add: minus_uexpr_def, transfer, simp)


[STATEMENT]
lemma cong_commutativity:
  assumes "Cong A B C D"
  shows "Cong B A D C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cong B A D C
[PROOF STEP]
using assms cong_3421
[PROOF STATE]
proof (prove)
using this:
Cong A B C D
Cong ?A ?B ?C ?D \<Longrightarrow> Cong ?C ?D ?B ?A

goal (1 subgoal):
 1. Cong B A D C
[PROOF STEP]
by blast


[STATEMENT]
lemma one_eq_prime_power_iff [simp]: "prime p \<Longrightarrow> 1 = p ^ n \<longleftrightarrow> n = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime p \<Longrightarrow> ((1::'a) = p ^ n) = (n = 0)
[PROOF STEP]
using prime_power_inj[of p 0 n]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>prime p; p ^ 0 = p ^ n\<rbrakk> \<Longrightarrow> 0 = n

goal (1 subgoal):
 1. prime p \<Longrightarrow> ((1::'a) = p ^ n) = (n = 0)
[PROOF STEP]
by auto


[STATEMENT]
lemma add_first_row_to_multiple_index:
  assumes "i < dim_row M" and "j < dim_col M"
  shows "i = 0 \<Longrightarrow> (add_row_to_multiple a [1..<dim_row M] 0 M) $$ (i, j) = M $$ (i, j)"
  and "i \<noteq> 0 \<Longrightarrow> (add_row_to_multiple a [1..<dim_row M] 0 M) $$ (i, j) = (a * M$$(0, j)) + M$$(i,j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (i = 0 \<Longrightarrow> add_row_to_multiple a [1..<dim_row M] 0 M $$ (i, j) = M $$ (i, j)) &&& (i \<noteq> 0 \<Longrightarrow> add_row_to_multiple a [1..<dim_row M] 0 M $$ (i, j) = a * M $$ (0, j) + M $$ (i, j))
[PROOF STEP]
using assms add_row_to_multiple_index_change_bounds[of i "M" j 1 "dim_row M" 0 "a"]
[PROOF STATE]
proof (prove)
using this:
i < dim_row M
j < dim_col M
\<lbrakk>i < dim_row M; j < dim_col M; 1 \<le> i; i < dim_row M; 0 < 1 \<or> dim_row M \<le> 0; 0 < dim_row M\<rbrakk> \<Longrightarrow> add_row_to_multiple a [1..<dim_row M] 0 M $$ (i, j) = a * M $$ (0, j) + M $$ (i, j)

goal (1 subgoal):
 1. (i = 0 \<Longrightarrow> add_row_to_multiple a [1..<dim_row M] 0 M $$ (i, j) = M $$ (i, j)) &&& (i \<noteq> 0 \<Longrightarrow> add_row_to_multiple a [1..<dim_row M] 0 M $$ (i, j) = a * M $$ (0, j) + M $$ (i, j))
[PROOF STEP]
by (simp,linarith)


[STATEMENT]
lemma has_fps_expansion_binomial_complex [fps_expansion_intros]:
  fixes c :: complex
  shows "(\<lambda>x. (1 + x) powr c) has_fps_expansion fps_binomial c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. (1 + x) powr c) has_fps_expansion fps_binomial c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. (1 + x) powr c) has_fps_expansion fps_binomial c
[PROOF STEP]
have *: "eventually (\<lambda>z::complex. z \<in> eball 0 1) (nhds 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F z in nhds 0. z \<in> eball 0 1
[PROOF STEP]
by (intro eventually_nhds_in_open) auto
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F z in nhds 0. z \<in> eball 0 1

goal (1 subgoal):
 1. (\<lambda>x. (1 + x) powr c) has_fps_expansion fps_binomial c
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F z in nhds 0. z \<in> eball 0 1

goal (1 subgoal):
 1. (\<lambda>x. (1 + x) powr c) has_fps_expansion fps_binomial c
[PROOF STEP]
by (auto simp: has_fps_expansion_def eval_fps_binomial fps_conv_radius_binomial
             intro!: eventually_mono [OF *])
[PROOF STATE]
proof (state)
this:
(\<lambda>x. (1 + x) powr c) has_fps_expansion fps_binomial c

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma ereal_mult_less_0_iff:
  fixes a b :: ereal
  shows "a * b < 0 \<longleftrightarrow> (0 < a \<and> b < 0) \<or> (a < 0 \<and> 0 < b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a * b < 0) = (0 < a \<and> b < 0 \<or> a < 0 \<and> 0 < b)
[PROOF STEP]
by (cases rule: ereal2_cases[of a b]) (simp_all add: mult_less_0_iff)


[STATEMENT]
lemma infdist_triangle_side [mono_intros]:
  assumes "geodesic_segment_between G x (y::'a)"
  shows "infdist z G \<le> Gromov_product_at z x y + 2 * deltaG(TYPE('a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infdist z G \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. infdist z G \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)
[PROOF STEP]
have "infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
geodesic_segment_between G x y

goal (1 subgoal):
 1. infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))
[PROOF STEP]
by (auto intro!: infdist_le)
[PROOF STATE]
proof (state)
this:
infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))

goal (1 subgoal):
 1. infdist z G \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))

goal (1 subgoal):
 1. infdist z G \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)
[PROOF STEP]
using dist_triangle_side_middle[OF assms, of z]
[PROOF STATE]
proof (prove)
using this:
infdist z G \<le> dist z (geodesic_segment_param G x (Gromov_product_at x z y))
dist z (geodesic_segment_param G x (Gromov_product_at x z y)) \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)

goal (1 subgoal):
 1. infdist z G \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
infdist z G \<le> Gromov_product_at z x y + 2 * deltaG TYPE('a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma card_gr0_imp_not_empty: "(0 < card A) \<Longrightarrow> A \<noteq> {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < card A \<Longrightarrow> A \<noteq> {}
[PROOF STEP]
by (rule ccontr, simp)


[STATEMENT]
lemma comp_isotone:
  "x \<le> y \<Longrightarrow> w \<le> z \<Longrightarrow> x * w \<le> y * z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<le> y; w \<le> z\<rbrakk> \<Longrightarrow> x * w \<le> y * z
[PROOF STEP]
using comp_left_isotone comp_right_isotone order.trans
[PROOF STATE]
proof (prove)
using this:
?x \<le> ?y \<Longrightarrow> ?x * ?z \<le> ?y * ?z
?x \<le> ?y \<Longrightarrow> ?z * ?x \<le> ?z * ?y
\<lbrakk>?a \<le> ?b; ?b \<le> ?c\<rbrakk> \<Longrightarrow> ?a \<le> ?c

goal (1 subgoal):
 1. \<lbrakk>x \<le> y; w \<le> z\<rbrakk> \<Longrightarrow> x * w \<le> y * z
[PROOF STEP]
by blast