[STATEMENT]
theorem pell_solution_exists: "\<exists>(x::nat) (y::nat). y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define S where "S = {(t :: int, u :: nat). u > 0 \<and> coprime u t \<and> \<bar>t - u * sqrt D\<bar> < 1 / u}"
[PROOF STATE]
proof (state)
this:
S = {(t, u). 0 < u \<and> coprime (int u) t \<and> \<bar>real_of_int t - real u * sqrt (real D)\<bar> < 1 / real u}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
let ?f = "\<lambda>(t :: int, u :: nat). t\<^sup>2 - u\<^sup>2 * D"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define M where "M = \<lfloor>1 + 2 * sqrt D\<rfloor>"
[PROOF STATE]
proof (state)
this:
M = \<lfloor>1 + 2 * sqrt (real D)\<rfloor>

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have infinite: "\<not>finite S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite S
[PROOF STEP]
unfolding S_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite {(t, u). 0 < u \<and> coprime (int u) t \<and> \<bar>real_of_int t - real u * sqrt (real D)\<bar> < 1 / real u}
[PROOF STEP]
by (intro pell_approximation_corollary irrat_sqrt_nonsquare nonsquare_D)
[PROOF STATE]
proof (state)
this:
infinite S

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have subset: "?f ` S \<subseteq> {-M..M}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S \<subseteq> {- M..M}
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
fix u :: nat and t :: int
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
assume tu: "(t, u) \<in> S"
[PROOF STATE]
proof (state)
this:
(t, u) \<in> S

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
from tu
[PROOF STATE]
proof (chain)
picking this:
(t, u) \<in> S
[PROOF STEP]
have [simp]: "u > 0"
[PROOF STATE]
proof (prove)
using this:
(t, u) \<in> S

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

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<bar>t + u * sqrt D\<bar> = \<bar>t - u * sqrt D + 2 * u * sqrt D\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>real_of_int t + real u * sqrt (real D)\<bar> = \<bar>real_of_int t - real u * sqrt (real D) + real (2 * u) * sqrt (real D)\<bar>
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t + real u * sqrt (real D)\<bar> = \<bar>real_of_int t - real u * sqrt (real D) + real (2 * u) * sqrt (real D)\<bar>

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t + real u * sqrt (real D)\<bar> = \<bar>real_of_int t - real u * sqrt (real D) + real (2 * u) * sqrt (real D)\<bar>

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<dots> \<le> \<bar>t - u * sqrt D\<bar> + \<bar>2 * u * sqrt D\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>real_of_int t - real u * sqrt (real D) + real (2 * u) * sqrt (real D)\<bar> \<le> \<bar>real_of_int t - real u * sqrt (real D)\<bar> + \<bar>real (2 * u) * sqrt (real D)\<bar>
[PROOF STEP]
by (rule abs_triangle_ineq)
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t - real u * sqrt (real D) + real (2 * u) * sqrt (real D)\<bar> \<le> \<bar>real_of_int t - real u * sqrt (real D)\<bar> + \<bar>real (2 * u) * sqrt (real D)\<bar>

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t - real u * sqrt (real D) + real (2 * u) * sqrt (real D)\<bar> \<le> \<bar>real_of_int t - real u * sqrt (real D)\<bar> + \<bar>real (2 * u) * sqrt (real D)\<bar>

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<bar>2 * u * sqrt D\<bar> = 2 * u * sqrt D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>real (2 * u) * sqrt (real D)\<bar> = real (2 * u) * sqrt (real D)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<bar>real (2 * u) * sqrt (real D)\<bar> = real (2 * u) * sqrt (real D)

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>real (2 * u) * sqrt (real D)\<bar> = real (2 * u) * sqrt (real D)

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<bar>t - u * sqrt D\<bar> \<le> 1 / u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>real_of_int t - real u * sqrt (real D)\<bar> \<le> 1 / real u
[PROOF STEP]
using tu
[PROOF STATE]
proof (prove)
using this:
(t, u) \<in> S

goal (1 subgoal):
 1. \<bar>real_of_int t - real u * sqrt (real D)\<bar> \<le> 1 / real u
[PROOF STEP]
by (simp add: S_def)
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t - real u * sqrt (real D)\<bar> \<le> 1 / real u

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>x y. x \<le> y \<Longrightarrow> x + real (2 * u) * sqrt (real D) \<le> y + real (2 * u) * sqrt (real D)) \<Longrightarrow> \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u + real (2 * u) * sqrt (real D)
[PROOF STEP]
have le: "\<bar>t + u * sqrt D\<bar> \<le> 1 / u + 2 * u * sqrt D"
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> x + real (2 * u) * sqrt (real D) \<le> y + real (2 * u) * sqrt (real D)) \<Longrightarrow> \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u + real (2 * u) * sqrt (real D)

goal (1 subgoal):
 1. \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u + real (2 * u) * sqrt (real D)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u + real (2 * u) * sqrt (real D)

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<bar>t\<^sup>2 - u\<^sup>2 * D\<bar> = \<bar>t - u * sqrt D\<bar> * \<bar>t + u * sqrt D\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> = \<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar>
[PROOF STEP]
by (subst abs_mult [symmetric]) (simp add: algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> = \<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar>

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> = \<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar>

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<dots> \<le> 1 / u * (1 / u + 2 * u * sqrt D)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u * (1 / real u + real (2 * u) * sqrt (real D))
[PROOF STEP]
using tu
[PROOF STATE]
proof (prove)
using this:
(t, u) \<in> S

goal (1 subgoal):
 1. \<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u * (1 / real u + real (2 * u) * sqrt (real D))
[PROOF STEP]
by (intro mult_mono le) (auto simp: S_def)
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u * (1 / real u + real (2 * u) * sqrt (real D))

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<bar>real_of_int t - real u * sqrt (real D)\<bar> * \<bar>real_of_int t + real u * sqrt (real D)\<bar> \<le> 1 / real u * (1 / real u + real (2 * u) * sqrt (real D))

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
have "\<dots> = 1 / real u ^ 2 + 2 * sqrt D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 / real u * (1 / real u + real (2 * u) * sqrt (real D)) = 1 / (real u)\<^sup>2 + 2 * sqrt (real D)
[PROOF STEP]
by (simp add: algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
1 / real u * (1 / real u + real (2 * u) * sqrt (real D)) = 1 / (real u)\<^sup>2 + 2 * sqrt (real D)

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 / real u * (1 / real u + real (2 * u) * sqrt (real D)) = 1 / (real u)\<^sup>2 + 2 * sqrt (real D)

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
from \<open>u > 0\<close>
[PROOF STATE]
proof (chain)
picking this:
0 < u
[PROOF STEP]
have "real u \<ge> 1"
[PROOF STATE]
proof (prove)
using this:
0 < u

goal (1 subgoal):
 1. 1 \<le> real u
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 \<le> real u

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
hence "1 / real u ^ 2 \<le> 1 / 1 ^ 2"
[PROOF STATE]
proof (prove)
using this:
1 \<le> real u

goal (1 subgoal):
 1. 1 / (real u)\<^sup>2 \<le> 1 / 1\<^sup>2
[PROOF STEP]
by (intro divide_left_mono power_mono) auto
[PROOF STATE]
proof (state)
this:
1 / (real u)\<^sup>2 \<le> 1 / 1\<^sup>2

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(\<And>x y. x \<le> y \<Longrightarrow> x + 2 * sqrt (real D) \<le> y + 2 * sqrt (real D)) \<Longrightarrow> real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> \<le> 1 / 1\<^sup>2 + 2 * sqrt (real D)
[PROOF STEP]
have "\<bar>t\<^sup>2 - u\<^sup>2 * D\<bar> \<le> 1 + 2 * sqrt D"
[PROOF STATE]
proof (prove)
using this:
(\<And>x y. x \<le> y \<Longrightarrow> x + 2 * sqrt (real D) \<le> y + 2 * sqrt (real D)) \<Longrightarrow> real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> \<le> 1 / 1\<^sup>2 + 2 * sqrt (real D)

goal (1 subgoal):
 1. real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> \<le> 1 + 2 * sqrt (real D)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> \<le> 1 + 2 * sqrt (real D)

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
hence "t\<^sup>2 - u\<^sup>2 * D \<ge> -M" "t\<^sup>2 - u\<^sup>2 * D \<le> M"
[PROOF STATE]
proof (prove)
using this:
real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> \<le> 1 + 2 * sqrt (real D)

goal (1 subgoal):
 1. - M \<le> t\<^sup>2 - int (u\<^sup>2 * D) &&& t\<^sup>2 - int (u\<^sup>2 * D) \<le> M
[PROOF STEP]
unfolding M_def
[PROOF STATE]
proof (prove)
using this:
real_of_int \<bar>t\<^sup>2 - int (u\<^sup>2 * D)\<bar> \<le> 1 + 2 * sqrt (real D)

goal (1 subgoal):
 1. - \<lfloor>1 + 2 * sqrt (real D)\<rfloor> \<le> t\<^sup>2 - int (u\<^sup>2 * D) &&& t\<^sup>2 - int (u\<^sup>2 * D) \<le> \<lfloor>1 + 2 * sqrt (real D)\<rfloor>
[PROOF STEP]
by linarith+
[PROOF STATE]
proof (state)
this:
- M \<le> t\<^sup>2 - int (u\<^sup>2 * D)
t\<^sup>2 - int (u\<^sup>2 * D) \<le> M

goal (1 subgoal):
 1. \<And>x a b. (a, b) \<in> S \<Longrightarrow> a\<^sup>2 - int (b\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
thus "t\<^sup>2 - u\<^sup>2 * D \<in> {-M..M}"
[PROOF STATE]
proof (prove)
using this:
- M \<le> t\<^sup>2 - int (u\<^sup>2 * D)
t\<^sup>2 - int (u\<^sup>2 * D) \<le> M

goal (1 subgoal):
 1. t\<^sup>2 - int (u\<^sup>2 * D) \<in> {- M..M}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
t\<^sup>2 - int (u\<^sup>2 * D) \<in> {- M..M}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S \<subseteq> {- M..M}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
hence fin: "finite (?f ` S)"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S \<subseteq> {- M..M}

goal (1 subgoal):
 1. finite ((\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S)
[PROOF STEP]
by (rule finite_subset) auto
[PROOF STATE]
proof (state)
this:
finite ((\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from pigeonhole_infinite[OF infinite fin]
[PROOF STATE]
proof (chain)
picking this:
\<exists>a0\<in>S. infinite {a \<in> S. (case a of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = (case a0 of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))}
[PROOF STEP]
obtain z where z: "z \<in> S" "infinite {z' \<in> S. ?f z' = ?f z}"
[PROOF STATE]
proof (prove)
using this:
\<exists>a0\<in>S. infinite {a \<in> S. (case a of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = (case a0 of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))}

goal (1 subgoal):
 1. (\<And>z. \<lbrakk>z \<in> S; infinite {z' \<in> S. (case z' of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z \<in> S
infinite {z' \<in> S. (case z' of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define k where "k = ?f z"
[PROOF STATE]
proof (state)
this:
k = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
with subset and z
[PROOF STATE]
proof (chain)
picking this:
(\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S \<subseteq> {- M..M}
z \<in> S
infinite {z' \<in> S. (case z' of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))}
k = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))
[PROOF STEP]
have k: "k \<in> {-M..M}" "infinite {z\<in>S. ?f z = k}"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>(t, u). t\<^sup>2 - int (u\<^sup>2 * D)) ` S \<subseteq> {- M..M}
z \<in> S
infinite {z' \<in> S. (case z' of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))}
k = (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D))

goal (1 subgoal):
 1. k \<in> {- M..M} &&& infinite {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}
[PROOF STEP]
by (auto simp: k_def)
[PROOF STATE]
proof (state)
this:
k \<in> {- M..M}
infinite {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have k_nz: "k \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<noteq> 0
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. k = 0 \<Longrightarrow> False
[PROOF STEP]
assume [simp]: "k = 0"
[PROOF STATE]
proof (state)
this:
k = 0

goal (1 subgoal):
 1. k = 0 \<Longrightarrow> False
[PROOF STEP]
note k(2)
[PROOF STATE]
proof (state)
this:
infinite {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}

goal (1 subgoal):
 1. k = 0 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
infinite {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}

goal (1 subgoal):
 1. k = 0 \<Longrightarrow> False
[PROOF STEP]
have "?f z \<noteq> 0" if "z \<in> S" for z
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) \<noteq> 0
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
assume *: "?f z = 0"
[PROOF STATE]
proof (state)
this:
(case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
obtain t u where [simp]: "z = (t, u)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t u. z = (t, u) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (cases z)
[PROOF STATE]
proof (state)
this:
z = (t, u)

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
from *
[PROOF STATE]
proof (chain)
picking this:
(case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0
[PROOF STEP]
have "t ^ 2 = int u ^ 2 * int D"
[PROOF STATE]
proof (prove)
using this:
(case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0

goal (1 subgoal):
 1. t\<^sup>2 = (int u)\<^sup>2 * int D
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
t\<^sup>2 = (int u)\<^sup>2 * int D

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
hence "int u ^ 2 dvd t ^ 2"
[PROOF STATE]
proof (prove)
using this:
t\<^sup>2 = (int u)\<^sup>2 * int D

goal (1 subgoal):
 1. (int u)\<^sup>2 dvd t\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(int u)\<^sup>2 dvd t\<^sup>2

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
hence "int u dvd t"
[PROOF STATE]
proof (prove)
using this:
(int u)\<^sup>2 dvd t\<^sup>2

goal (1 subgoal):
 1. int u dvd t
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
int u dvd t

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
int u dvd t
[PROOF STEP]
obtain k where [simp]: "t = int u * k"
[PROOF STATE]
proof (prove)
using this:
int u dvd t

goal (1 subgoal):
 1. (\<And>k. t = int u * k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto elim!: dvdE)
[PROOF STATE]
proof (state)
this:
t = int u * k

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
from * and \<open>z \<in> S\<close>
[PROOF STATE]
proof (chain)
picking this:
(case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0
z \<in> S
[PROOF STEP]
have "k ^ 2 = int D"
[PROOF STATE]
proof (prove)
using this:
(case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0
z \<in> S

goal (1 subgoal):
 1. k\<^sup>2 = int D
[PROOF STEP]
by (auto simp: power_mult_distrib S_def)
[PROOF STATE]
proof (state)
this:
k\<^sup>2 = int D

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k\<^sup>2 = int D

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
have "k ^ 2 = int (nat \<bar>k\<bar> ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k\<^sup>2 = int ((nat \<bar>k\<bar>)\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k\<^sup>2 = int ((nat \<bar>k\<bar>)\<^sup>2)

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
int ((nat \<bar>k\<bar>)\<^sup>2) = int D
[PROOF STEP]
have "D = nat \<bar>k\<bar> ^ 2"
[PROOF STATE]
proof (prove)
using this:
int ((nat \<bar>k\<bar>)\<^sup>2) = int D

goal (1 subgoal):
 1. D = (nat \<bar>k\<bar>)\<^sup>2
[PROOF STEP]
by (simp only: of_nat_eq_iff)
[PROOF STATE]
proof (state)
this:
D = (nat \<bar>k\<bar>)\<^sup>2

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
hence "is_square D"
[PROOF STATE]
proof (prove)
using this:
D = (nat \<bar>k\<bar>)\<^sup>2

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

goal (1 subgoal):
 1. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = 0 \<Longrightarrow> False
[PROOF STEP]
with nonsquare_D
[PROOF STATE]
proof (chain)
picking this:
\<not> is_square D
is_square D
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<not> is_square D
is_square D

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?z \<in> S \<Longrightarrow> (case ?z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) \<noteq> 0

goal (1 subgoal):
 1. k = 0 \<Longrightarrow> False
[PROOF STEP]
hence "{z\<in>S. ?f z = k} = {}"
[PROOF STATE]
proof (prove)
using this:
?z \<in> S \<Longrightarrow> (case ?z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) \<noteq> 0

goal (1 subgoal):
 1. {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k} = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k} = {}

goal (1 subgoal):
 1. k = 0 \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
infinite {}
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
infinite {}

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

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

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
let ?h = "\<lambda>(t :: int, u :: nat). (t mod (abs k), u mod (abs k))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "?h ` {z\<in>S. ?f z = k} \<subseteq> {0..<abs k} \<times> {0..< abs k}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>(t, x). (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) ` {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k} \<subseteq> {0..<\<bar>k\<bar>} \<times> {0..<\<bar>k\<bar>}
[PROOF STEP]
using k_nz
[PROOF STATE]
proof (prove)
using this:
k \<noteq> 0

goal (1 subgoal):
 1. (\<lambda>(t, x). (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) ` {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k} \<subseteq> {0..<\<bar>k\<bar>} \<times> {0..<\<bar>k\<bar>}
[PROOF STEP]
by (auto simp: case_prod_unfold)
[PROOF STATE]
proof (state)
this:
(\<lambda>(t, x). (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) ` {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k} \<subseteq> {0..<\<bar>k\<bar>} \<times> {0..<\<bar>k\<bar>}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
hence "finite (?h ` {z\<in>S. ?f z = k})"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>(t, x). (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) ` {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k} \<subseteq> {0..<\<bar>k\<bar>} \<times> {0..<\<bar>k\<bar>}

goal (1 subgoal):
 1. finite ((\<lambda>(t, x). (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) ` {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k})
[PROOF STEP]
by (rule finite_subset) auto
[PROOF STATE]
proof (state)
this:
finite ((\<lambda>(t, x). (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) ` {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k})

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from pigeonhole_infinite[OF k(2) this]
[PROOF STATE]
proof (chain)
picking this:
\<exists>a0\<in>{z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. infinite {a \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case a of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case a0 of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))}
[PROOF STEP]
obtain z'
    where z': "z' \<in> S" "?f z' = k" "infinite {z''\<in>{z\<in>S. ?f z = k}. ?h z'' = ?h z'}"
[PROOF STATE]
proof (prove)
using this:
\<exists>a0\<in>{z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. infinite {a \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case a of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case a0 of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))}

goal (1 subgoal):
 1. (\<And>z'. \<lbrakk>z' \<in> S; (case z' of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k; infinite {z'' \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case z'' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
z' \<in> S
(case z' of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k
infinite {z'' \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case z'' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define l1 and l2 where "l1 = fst (?h z')" and "l2 = snd (?h z')"
[PROOF STATE]
proof (state)
this:
l1 = fst (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))
l2 = snd (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define S' where "S' = {(t,u) \<in> S. ?f (t,u) = k \<and> t mod abs k = l1 \<and> u mod abs k = l2}"
[PROOF STATE]
proof (state)
this:
S' = {(t, u). (t, u) \<in> S \<and> (case (t, u) of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k \<and> t mod \<bar>k\<bar> = l1 \<and> int u mod \<bar>k\<bar> = l2}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
note z'(3)
[PROOF STATE]
proof (state)
this:
infinite {z'' \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case z'' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
infinite {z'' \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case z'' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "{z''\<in>{z\<in>S. ?f z = k}. ?h z'' = ?h z'} = S'"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {z'' \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case z'' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))} = S'
[PROOF STEP]
by (auto simp: l1_def l2_def case_prod_unfold S'_def)
[PROOF STATE]
proof (state)
this:
{z'' \<in> {z \<in> S. (case z of (t, u) \<Rightarrow> t\<^sup>2 - int (u\<^sup>2 * D)) = k}. (case z'' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>)) = (case z' of (t, x) \<Rightarrow> (t mod \<bar>k\<bar>, int x mod \<bar>k\<bar>))} = S'

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
infinite S'
[PROOF STEP]
have infinite: "infinite S'"
[PROOF STATE]
proof (prove)
using this:
infinite S'

goal (1 subgoal):
 1. infinite S'
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
infinite S'

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from z'(1) and k_nz
[PROOF STATE]
proof (chain)
picking this:
z' \<in> S
k \<noteq> 0
[PROOF STEP]
have l12: "l1 \<in> {0..<abs k}" "l2 \<in> {0..<abs k}"
[PROOF STATE]
proof (prove)
using this:
z' \<in> S
k \<noteq> 0

goal (1 subgoal):
 1. l1 \<in> {0..<\<bar>k\<bar>} &&& l2 \<in> {0..<\<bar>k\<bar>}
[PROOF STEP]
by (auto simp: l1_def l2_def case_prod_unfold)
[PROOF STATE]
proof (state)
this:
l1 \<in> {0..<\<bar>k\<bar>}
l2 \<in> {0..<\<bar>k\<bar>}

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from infinite_arbitrarily_large[OF infinite]
[PROOF STATE]
proof (chain)
picking this:
\<exists>B. finite B \<and> card B = ?n \<and> B \<subseteq> S'
[PROOF STEP]
obtain X where X: "finite X" "card X = 2" "X \<subseteq> S'"
[PROOF STATE]
proof (prove)
using this:
\<exists>B. finite B \<and> card B = ?n \<and> B \<subseteq> S'

goal (1 subgoal):
 1. (\<And>X. \<lbrakk>finite X; card X = 2; X \<subseteq> S'\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite X
card X = 2
X \<subseteq> S'

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from finite_distinct_list[OF this(1)]
[PROOF STATE]
proof (chain)
picking this:
\<exists>xs. set xs = X \<and> distinct xs
[PROOF STEP]
obtain xs where xs: "set xs = X" "distinct xs"
[PROOF STATE]
proof (prove)
using this:
\<exists>xs. set xs = X \<and> distinct xs

goal (1 subgoal):
 1. (\<And>xs. \<lbrakk>set xs = X; distinct xs\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
set xs = X
distinct xs

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
with X
[PROOF STATE]
proof (chain)
picking this:
finite X
card X = 2
X \<subseteq> S'
set xs = X
distinct xs
[PROOF STEP]
have "length xs = 2"
[PROOF STATE]
proof (prove)
using this:
finite X
card X = 2
X \<subseteq> S'
set xs = X
distinct xs

goal (1 subgoal):
 1. length xs = 2
[PROOF STEP]
using distinct_card[of xs]
[PROOF STATE]
proof (prove)
using this:
finite X
card X = 2
X \<subseteq> S'
set xs = X
distinct xs
distinct xs \<Longrightarrow> card (set xs) = length xs

goal (1 subgoal):
 1. length xs = 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
length xs = 2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
length xs = 2
[PROOF STEP]
obtain z1 z2 where [simp]: "xs = [z1, z2]"
[PROOF STATE]
proof (prove)
using this:
length xs = 2

goal (1 subgoal):
 1. (\<And>z1 z2. xs = [z1, z2] \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: length_Suc_conv eval_nat_numeral)
[PROOF STATE]
proof (state)
this:
xs = [z1, z2]

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from X xs
[PROOF STATE]
proof (chain)
picking this:
finite X
card X = 2
X \<subseteq> S'
set xs = X
distinct xs
[PROOF STEP]
have S': "z1 \<in> S'" "z2 \<in> S'" and neq: "z1 \<noteq> z2"
[PROOF STATE]
proof (prove)
using this:
finite X
card X = 2
X \<subseteq> S'
set xs = X
distinct xs

goal (1 subgoal):
 1. (z1 \<in> S' &&& z2 \<in> S') &&& z1 \<noteq> z2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
z1 \<in> S'
z2 \<in> S'
z1 \<noteq> z2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define t1 u1 t2 u2 where "t1 = fst z1" and "u1 = snd z1" and "t2 = fst z2" and "u2 = snd z2"
[PROOF STATE]
proof (state)
this:
t1 = fst z1
u1 = snd z1
t2 = fst z2
u2 = snd z2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have [simp]: "z1 = (t1, u1)" "z2 = (t2, u2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z1 = (t1, u1) &&& z2 = (t2, u2)
[PROOF STEP]
by (simp_all add: t1_def u1_def t2_def u2_def)
[PROOF STATE]
proof (state)
this:
z1 = (t1, u1)
z2 = (t2, u2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from S'
[PROOF STATE]
proof (chain)
picking this:
z1 \<in> S'
z2 \<in> S'
[PROOF STEP]
have * [simp]: "t1 mod abs k = l1" "t2 mod abs k = l1" "u1 mod abs k = l2" "u2 mod abs k = l2"
[PROOF STATE]
proof (prove)
using this:
z1 \<in> S'
z2 \<in> S'

goal (1 subgoal):
 1. (t1 mod \<bar>k\<bar> = l1 &&& t2 mod \<bar>k\<bar> = l1) &&& int u1 mod \<bar>k\<bar> = l2 &&& int u2 mod \<bar>k\<bar> = l2
[PROOF STEP]
by (simp_all add: S'_def)
[PROOF STATE]
proof (state)
this:
t1 mod \<bar>k\<bar> = l1
t2 mod \<bar>k\<bar> = l1
int u1 mod \<bar>k\<bar> = l2
int u2 mod \<bar>k\<bar> = l2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define x where "x = (t1 * t2 - D * u1 * u2) div k"
[PROOF STATE]
proof (state)
this:
x = (t1 * t2 - int (D * u1 * u2)) div k

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
define y where "y = (t1 * u2 - t2 * u1) div k"
[PROOF STATE]
proof (state)
this:
y = (t1 * int u2 - t2 * int u1) div k

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from S'
[PROOF STATE]
proof (chain)
picking this:
z1 \<in> S'
z2 \<in> S'
[PROOF STEP]
have "(t1\<^sup>2 - u1\<^sup>2 * D) = k" "(t2\<^sup>2 - u2\<^sup>2 * D) = k"
[PROOF STATE]
proof (prove)
using this:
z1 \<in> S'
z2 \<in> S'

goal (1 subgoal):
 1. t1\<^sup>2 - int (u1\<^sup>2 * D) = k &&& t2\<^sup>2 - int (u2\<^sup>2 * D) = k
[PROOF STEP]
by (auto simp: S'_def)
[PROOF STATE]
proof (state)
this:
t1\<^sup>2 - int (u1\<^sup>2 * D) = k
t2\<^sup>2 - int (u2\<^sup>2 * D) = k

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
hence "(t1\<^sup>2 - u1\<^sup>2 * D) * (t2\<^sup>2 - u2\<^sup>2 * D) = k ^ 2"
[PROOF STATE]
proof (prove)
using this:
t1\<^sup>2 - int (u1\<^sup>2 * D) = k
t2\<^sup>2 - int (u2\<^sup>2 * D) = k

goal (1 subgoal):
 1. (t1\<^sup>2 - int (u1\<^sup>2 * D)) * (t2\<^sup>2 - int (u2\<^sup>2 * D)) = k\<^sup>2
[PROOF STEP]
unfolding power2_eq_square
[PROOF STATE]
proof (prove)
using this:
t1 * t1 - int (u1 * u1 * D) = k
t2 * t2 - int (u2 * u2 * D) = k

goal (1 subgoal):
 1. (t1 * t1 - int (u1 * u1 * D)) * (t2 * t2 - int (u2 * u2 * D)) = k * k
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(t1\<^sup>2 - int (u1\<^sup>2 * D)) * (t2\<^sup>2 - int (u2\<^sup>2 * D)) = k\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(t1\<^sup>2 - int (u1\<^sup>2 * D)) * (t2\<^sup>2 - int (u2\<^sup>2 * D)) = k\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "(t1\<^sup>2 - u1\<^sup>2 * D) * (t2\<^sup>2 - u2\<^sup>2 * D) =
               (t1 * t2 - D * u1 * u2) ^ 2 - D * (t1 * u2 - t2 * u1) ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (t1\<^sup>2 - int (u1\<^sup>2 * D)) * (t2\<^sup>2 - int (u2\<^sup>2 * D)) = (t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2
[PROOF STEP]
by (simp add: power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
(t1\<^sup>2 - int (u1\<^sup>2 * D)) * (t2\<^sup>2 - int (u2\<^sup>2 * D)) = (t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2
[PROOF STEP]
have eq: "(t1 * t2 - D * u1 * u2)\<^sup>2 - D * (t1 * u2 - t2 * u1)\<^sup>2 = k\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2

goal (1 subgoal):
 1. (t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "(t1 * u2 - t2 * u1) mod abs k = (l1 * l2 - l1 * l2) mod abs k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (t1 * int u2 - t2 * int u1) mod \<bar>k\<bar> = (l1 * l2 - l1 * l2) mod \<bar>k\<bar>
[PROOF STEP]
using l12
[PROOF STATE]
proof (prove)
using this:
l1 \<in> {0..<\<bar>k\<bar>}
l2 \<in> {0..<\<bar>k\<bar>}

goal (1 subgoal):
 1. (t1 * int u2 - t2 * int u1) mod \<bar>k\<bar> = (l1 * l2 - l1 * l2) mod \<bar>k\<bar>
[PROOF STEP]
by (intro mod_diff_cong mod_mult_cong) (auto simp: mod_pos_pos_trivial)
[PROOF STATE]
proof (state)
this:
(t1 * int u2 - t2 * int u1) mod \<bar>k\<bar> = (l1 * l2 - l1 * l2) mod \<bar>k\<bar>

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
hence dvd1: "k dvd t1 * u2 - t2 * u1"
[PROOF STATE]
proof (prove)
using this:
(t1 * int u2 - t2 * int u1) mod \<bar>k\<bar> = (l1 * l2 - l1 * l2) mod \<bar>k\<bar>

goal (1 subgoal):
 1. k dvd t1 * int u2 - t2 * int u1
[PROOF STEP]
by (simp add: mod_eq_0_iff_dvd)
[PROOF STATE]
proof (state)
this:
k dvd t1 * int u2 - t2 * int u1

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "k\<^sup>2 dvd k\<^sup>2 + D * (t1 * u2 - t2 * u1)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k\<^sup>2 dvd k\<^sup>2 + int D * (t1 * int u2 - t2 * int u1)\<^sup>2
[PROOF STEP]
using dvd1
[PROOF STATE]
proof (prove)
using this:
k dvd t1 * int u2 - t2 * int u1

goal (1 subgoal):
 1. k\<^sup>2 dvd k\<^sup>2 + int D * (t1 * int u2 - t2 * int u1)\<^sup>2
[PROOF STEP]
by (intro dvd_add) auto
[PROOF STATE]
proof (state)
this:
k\<^sup>2 dvd k\<^sup>2 + int D * (t1 * int u2 - t2 * int u1)\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
k\<^sup>2 dvd k\<^sup>2 + int D * (t1 * int u2 - t2 * int u1)\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from eq
[PROOF STATE]
proof (chain)
picking this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2
[PROOF STEP]
have "\<dots> = (t1 * t2 - D * u1 * u2)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2

goal (1 subgoal):
 1. k\<^sup>2 + int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = (t1 * t2 - int (D * u1 * u2))\<^sup>2
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
k\<^sup>2 + int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = (t1 * t2 - int (D * u1 * u2))\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
k\<^sup>2 dvd (t1 * t2 - int (D * u1 * u2))\<^sup>2
[PROOF STEP]
have dvd2: "k dvd t1 * t2 - D * u1 * u2"
[PROOF STATE]
proof (prove)
using this:
k\<^sup>2 dvd (t1 * t2 - int (D * u1 * u2))\<^sup>2

goal (1 subgoal):
 1. k dvd t1 * t2 - int (D * u1 * u2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
k dvd t1 * t2 - int (D * u1 * u2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
note eq
[PROOF STATE]
proof (state)
this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(t1 * t2 - int (D * u1 * u2))\<^sup>2 - int D * (t1 * int u2 - t2 * int u1)\<^sup>2 = k\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from dvd2
[PROOF STATE]
proof (chain)
picking this:
k dvd t1 * t2 - int (D * u1 * u2)
[PROOF STEP]
have "t1 * t2 - D * u1 * u2 = k * x"
[PROOF STATE]
proof (prove)
using this:
k dvd t1 * t2 - int (D * u1 * u2)

goal (1 subgoal):
 1. t1 * t2 - int (D * u1 * u2) = k * x
[PROOF STEP]
by (simp add: x_def)
[PROOF STATE]
proof (state)
this:
t1 * t2 - int (D * u1 * u2) = k * x

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
t1 * t2 - int (D * u1 * u2) = k * x

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
from dvd1
[PROOF STATE]
proof (chain)
picking this:
k dvd t1 * int u2 - t2 * int u1
[PROOF STEP]
have "t1 * u2 - t2 * u1 = k * y"
[PROOF STATE]
proof (prove)
using this:
k dvd t1 * int u2 - t2 * int u1

goal (1 subgoal):
 1. t1 * int u2 - t2 * int u1 = k * y
[PROOF STEP]
by (simp add: y_def)
[PROOF STATE]
proof (state)
this:
t1 * int u2 - t2 * int u1 = k * y

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
t1 * int u2 - t2 * int u1 = k * y

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "(k * x)\<^sup>2 - D * (k * y)\<^sup>2 = k\<^sup>2 * (x\<^sup>2 - D * y\<^sup>2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (k * x)\<^sup>2 - int D * (k * y)\<^sup>2 = k\<^sup>2 * (x\<^sup>2 - int D * y\<^sup>2)
[PROOF STEP]
by (simp add: power_mult_distrib algebra_simps)
[PROOF STATE]
proof (state)
this:
(k * x)\<^sup>2 - int D * (k * y)\<^sup>2 = k\<^sup>2 * (x\<^sup>2 - int D * y\<^sup>2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
k\<^sup>2 * (x\<^sup>2 - int D * y\<^sup>2) = k\<^sup>2
[PROOF STEP]
have eq': "x\<^sup>2 - D * y\<^sup>2 = 1"
[PROOF STATE]
proof (prove)
using this:
k\<^sup>2 * (x\<^sup>2 - int D * y\<^sup>2) = k\<^sup>2

goal (1 subgoal):
 1. x\<^sup>2 - int D * y\<^sup>2 = 1
[PROOF STEP]
using k_nz
[PROOF STATE]
proof (prove)
using this:
k\<^sup>2 * (x\<^sup>2 - int D * y\<^sup>2) = k\<^sup>2
k \<noteq> 0

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

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
hence "x\<^sup>2 = 1 + D * y\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>2 - int D * y\<^sup>2 = 1

goal (1 subgoal):
 1. x\<^sup>2 = 1 + int D * y\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x\<^sup>2 = 1 + int D * y\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x\<^sup>2 = 1 + int D * y\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "x\<^sup>2 = int (nat \<bar>x\<bar> ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x\<^sup>2 = int ((nat \<bar>x\<bar>)\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
x\<^sup>2 = int ((nat \<bar>x\<bar>)\<^sup>2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
x\<^sup>2 = int ((nat \<bar>x\<bar>)\<^sup>2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "1 + D * y\<^sup>2 = int (1 + D * nat \<bar>y\<bar> ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + int D * y\<^sup>2 = int (1 + D * (nat \<bar>y\<bar>)\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 + int D * y\<^sup>2 = int (1 + D * (nat \<bar>y\<bar>)\<^sup>2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
1 + int D * y\<^sup>2 = int (1 + D * (nat \<bar>y\<bar>)\<^sup>2)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
note of_nat_eq_iff
[PROOF STATE]
proof (state)
this:
(of_nat ?m = of_nat ?n) = (?m = ?n)

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2
[PROOF STEP]
have eq'': "(nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
(nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2

goal (1 subgoal):
 1. (nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
(nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
have "t1 * u2 \<noteq> t2 * u1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t1 * int u2 \<noteq> t2 * int u1
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
assume *: "t1 * u2 = t2 * u1"
[PROOF STATE]
proof (state)
this:
t1 * int u2 = t2 * int u1

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
hence "\<bar>t1\<bar> * \<bar>u2\<bar> = \<bar>t2\<bar> * \<bar>u1\<bar>"
[PROOF STATE]
proof (prove)
using this:
t1 * int u2 = t2 * int u1

goal (1 subgoal):
 1. \<bar>t1\<bar> * \<bar>int u2\<bar> = \<bar>t2\<bar> * \<bar>int u1\<bar>
[PROOF STEP]
by (simp only: abs_mult [symmetric])
[PROOF STATE]
proof (state)
this:
\<bar>t1\<bar> * \<bar>int u2\<bar> = \<bar>t2\<bar> * \<bar>int u1\<bar>

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<bar>t1\<bar> * \<bar>int u2\<bar> = \<bar>t2\<bar> * \<bar>int u1\<bar>

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
from S'
[PROOF STATE]
proof (chain)
picking this:
z1 \<in> S'
z2 \<in> S'
[PROOF STEP]
have "coprime u1 t1" "coprime u2 t2"
[PROOF STATE]
proof (prove)
using this:
z1 \<in> S'
z2 \<in> S'

goal (1 subgoal):
 1. coprime (int u1) t1 &&& coprime (int u2) t2
[PROOF STEP]
by (auto simp: S'_def S_def)
[PROOF STATE]
proof (state)
this:
coprime (int u1) t1
coprime (int u2) t2

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<bar>t1\<bar> * \<bar>int u2\<bar> = \<bar>t2\<bar> * \<bar>int u1\<bar>
coprime (int u1) t1
coprime (int u2) t2
[PROOF STEP]
have eq: "\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2"
[PROOF STATE]
proof (prove)
using this:
\<bar>t1\<bar> * \<bar>int u2\<bar> = \<bar>t2\<bar> * \<bar>int u1\<bar>
coprime (int u1) t1
coprime (int u2) t2

goal (1 subgoal):
 1. \<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2
[PROOF STEP]
by (subst (asm) coprime_crossproduct_int) (auto simp: S'_def S_def gcd.commute coprime_commute)
[PROOF STATE]
proof (state)
this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
from S'
[PROOF STATE]
proof (chain)
picking this:
z1 \<in> S'
z2 \<in> S'
[PROOF STEP]
have "u1 \<noteq> 0" "u2 \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
z1 \<in> S'
z2 \<in> S'

goal (1 subgoal):
 1. u1 \<noteq> 0 &&& u2 \<noteq> 0
[PROOF STEP]
by (auto simp: S'_def S_def)
[PROOF STATE]
proof (state)
this:
u1 \<noteq> 0
u2 \<noteq> 0

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2
u1 \<noteq> 0
u2 \<noteq> 0
[PROOF STEP]
have "t1 = t2"
[PROOF STATE]
proof (prove)
using this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2
u1 \<noteq> 0
u2 \<noteq> 0

goal (1 subgoal):
 1. t1 = t2
[PROOF STEP]
using *
[PROOF STATE]
proof (prove)
using this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2
u1 \<noteq> 0
u2 \<noteq> 0
t1 * int u2 = t2 * int u1

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

goal (1 subgoal):
 1. t1 * int u2 = t2 * int u1 \<Longrightarrow> False
[PROOF STEP]
with eq and neq
[PROOF STATE]
proof (chain)
picking this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2
z1 \<noteq> z2
t1 = t2
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
\<bar>t1\<bar> = \<bar>t2\<bar> \<and> u1 = u2
z1 \<noteq> z2
t1 = t2

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:
t1 * int u2 \<noteq> t2 * int u1

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
with dvd1
[PROOF STATE]
proof (chain)
picking this:
k dvd t1 * int u2 - t2 * int u1
t1 * int u2 \<noteq> t2 * int u1
[PROOF STEP]
have "y \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
k dvd t1 * int u2 - t2 * int u1
t1 * int u2 \<noteq> t2 * int u1

goal (1 subgoal):
 1. y \<noteq> 0
[PROOF STEP]
by (auto simp add: y_def dvd_div_eq_0_iff)
[PROOF STATE]
proof (state)
this:
y \<noteq> 0

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
hence "nat \<bar>y\<bar> \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
y \<noteq> 0

goal (1 subgoal):
 1. nat \<bar>y\<bar> \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nat \<bar>y\<bar> \<noteq> 0

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
with eq''
[PROOF STATE]
proof (chain)
picking this:
(nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2
nat \<bar>y\<bar> \<noteq> 0
[PROOF STEP]
show "\<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2"
[PROOF STATE]
proof (prove)
using this:
(nat \<bar>x\<bar>)\<^sup>2 = 1 + D * (nat \<bar>y\<bar>)\<^sup>2
nat \<bar>y\<bar> \<noteq> 0

goal (1 subgoal):
 1. \<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>x y. y \<noteq> 0 \<and> x\<^sup>2 = 1 + D * y\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma drop_zero_ms:
  assumes "eventually (\<lambda>x. eval C x = 0) at_top"
  assumes "is_expansion (MS (MSLCons (C, e) xs) f) basis"
  shows   "is_expansion (MS xs f) basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_expansion (MS xs f) basis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in at_top. eval C x = 0
is_expansion (MS (MSLCons (C, e) xs) f) basis

goal (1 subgoal):
 1. is_expansion (MS xs f) basis
[PROOF STEP]
by (auto simp: is_expansion_ms_def intro: drop_zero_ms_aux)


[STATEMENT]
lemma all_edges_between_Un2:
  "all_edges_between X (Y \<union> Z) G = all_edges_between X Y G \<union> all_edges_between X Z G"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. all_edges_between X (Y \<union> Z) G = all_edges_between X Y G \<union> all_edges_between X Z G
[PROOF STEP]
by (auto simp: all_edges_between_def)


[STATEMENT]
lemma continuous_cosh [continuous_intros]:
  fixes f :: "_ \<Rightarrow>'a::{real_normed_field,banach}"
  assumes "continuous F f"
  shows   "continuous F (\<lambda>x. cosh (f x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous F (\<lambda>x. cosh (f x))
[PROOF STEP]
unfolding cosh_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous F (\<lambda>x. (exp (f x) + exp (- f x)) /\<^sub>R 2)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous F f

goal (1 subgoal):
 1. continuous F (\<lambda>x. (exp (f x) + exp (- f x)) /\<^sub>R 2)
[PROOF STEP]
by (intro continuous_intros)


[STATEMENT]
lemma function_comp_is_closed_seq:
  assumes "s \<in> closed_seqs R"
  assumes "f \<in> carrier (Fun R)"
  shows "f \<circ> s \<in> closed_seqs R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<circ> s \<in> carrier R\<^bsup>\<omega>\<^esup>
[PROOF STEP]
apply(rule closed_seqs_memI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. (f \<circ> s) k \<in> carrier R
[PROOF STEP]
using assms(1) assms(2) closed_seqs_memE
[PROOF STATE]
proof (prove)
using this:
s \<in> carrier R\<^bsup>\<omega>\<^esup>
f \<in> carrier (function_ring (carrier R) R)
?s \<in> carrier ?R\<^bsup>\<omega>\<^esup> \<Longrightarrow> ?s ?k \<in> carrier ?R

goal (1 subgoal):
 1. \<And>k. (f \<circ> s) k \<in> carrier R
[PROOF STEP]
by (metis comp_apply fun_add_eval_closed fun_add_zeroR function_zero_closed)


[STATEMENT]
lemma measure_distr:
  "f \<in> measurable M N \<Longrightarrow> S \<in> sets N \<Longrightarrow> measure (distr M N f) S = measure M (f -` S \<inter> space M)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> M \<rightarrow>\<^sub>M N; S \<in> sets N\<rbrakk> \<Longrightarrow> Sigma_Algebra.measure (distr M N f) S = Sigma_Algebra.measure M (f -` S \<inter> space M)
[PROOF STEP]
by (simp add: emeasure_distr measure_def)


[STATEMENT]
lemma arr_mset_append:
  "l \<le> r \<Longrightarrow> arr_mset arr l (r + 1) = arr_mset arr l r + {#arr r#}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. l \<le> r \<Longrightarrow> arr_mset arr l (r + 1) = arr_mset arr l r + {#arr r#}
[PROOF STEP]
using arr_mset_remove_last[of l r arr]
[PROOF STATE]
proof (prove)
using this:
l \<le> r \<Longrightarrow> arr_mset arr l r = arr_mset arr l (r + 1) - {#arr r#}

goal (1 subgoal):
 1. l \<le> r \<Longrightarrow> arr_mset arr l (r + 1) = arr_mset arr l r + {#arr r#}
[PROOF STEP]
by simp


[STATEMENT]
lemma divmod_integer_eq_cases:
  "divmod_integer k l =
    (if k = 0 then (0, 0) else if l = 0 then (0, k) else
    (apsnd \<circ> times \<circ> sgn) l (if sgn k = sgn l
      then divmod_abs k l
      else (let (r, s) = divmod_abs k l in
        if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s))))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divmod_integer k l = (if k = 0 then (0, 0) else if l = 0 then (0, k) else (apsnd \<circ> (*) \<circ> sgn) l (if sgn k = sgn l then divmod_abs k l else let (r, s) = divmod_abs k l in if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s)))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. divmod_integer k l = (if k = 0 then (0, 0) else if l = 0 then (0, k) else (apsnd \<circ> (*) \<circ> sgn) l (if sgn k = sgn l then divmod_abs k l else let (r, s) = divmod_abs k l in if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s)))
[PROOF STEP]
have *: "sgn k = sgn l \<longleftrightarrow> k = 0 \<and> l = 0 \<or> 0 < l \<and> 0 < k \<or> l < 0 \<and> k < 0" for k l :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sgn k = sgn l) = (k = 0 \<and> l = 0 \<or> 0 < l \<and> 0 < k \<or> l < 0 \<and> k < 0)
[PROOF STEP]
by (auto simp add: sgn_if)
[PROOF STATE]
proof (state)
this:
(sgn ?k = sgn ?l) = (?k = 0 \<and> ?l = 0 \<or> 0 < ?l \<and> 0 < ?k \<or> ?l < 0 \<and> ?k < 0)

goal (1 subgoal):
 1. divmod_integer k l = (if k = 0 then (0, 0) else if l = 0 then (0, k) else (apsnd \<circ> (*) \<circ> sgn) l (if sgn k = sgn l then divmod_abs k l else let (r, s) = divmod_abs k l in if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s)))
[PROOF STEP]
have **: "- k = l * q \<longleftrightarrow> k = - (l * q)" for k l q :: int
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (- k = l * q) = (k = - (l * q))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(- ?k = ?l * ?q) = (?k = - (?l * ?q))

goal (1 subgoal):
 1. divmod_integer k l = (if k = 0 then (0, 0) else if l = 0 then (0, k) else (apsnd \<circ> (*) \<circ> sgn) l (if sgn k = sgn l then divmod_abs k l else let (r, s) = divmod_abs k l in if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s)))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. divmod_integer k l = (if k = 0 then (0, 0) else if l = 0 then (0, k) else (apsnd \<circ> (*) \<circ> sgn) l (if sgn k = sgn l then divmod_abs k l else let (r, s) = divmod_abs k l in if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s)))
[PROOF STEP]
by (simp add: divmod_integer_def divmod_abs_def)
      (transfer, auto simp add: * ** not_less zdiv_zminus1_eq_if zmod_zminus1_eq_if div_minus_right mod_minus_right)
[PROOF STATE]
proof (state)
this:
divmod_integer k l = (if k = 0 then (0, 0) else if l = 0 then (0, k) else (apsnd \<circ> (*) \<circ> sgn) l (if sgn k = sgn l then divmod_abs k l else let (r, s) = divmod_abs k l in if s = 0 then (- r, 0) else (- r - 1, \<bar>l\<bar> - s)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma divide_nonpos_nonneg:
  "x \<le> 0 \<Longrightarrow> 0 \<le> y \<Longrightarrow> x / y \<le> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x \<le> (0::'a); (0::'a) \<le> y\<rbrakk> \<Longrightarrow> x / y \<le> (0::'a)
[PROOF STEP]
using local.divide_nonpos_pos local.dual_order.order_iff_strict
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x \<le> (0::'a); (0::'a) < ?y\<rbrakk> \<Longrightarrow> ?x / ?y \<le> (0::'a)
(?b \<le> ?a) = (?b < ?a \<or> ?a = ?b)

goal (1 subgoal):
 1. \<lbrakk>x \<le> (0::'a); (0::'a) \<le> y\<rbrakk> \<Longrightarrow> x / y \<le> (0::'a)
[PROOF STEP]
by auto


[STATEMENT]
lemma Succ_Shift: "Succ (Shift Kl k) kl = Succ Kl (k # kl)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Succ (Shift Kl k) kl = Succ Kl (k # kl)
[PROOF STEP]
unfolding Succ_def Shift_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {ka. kl @ [ka] \<in> {kl. k # kl \<in> Kl}} = {ka. (k # kl) @ [ka] \<in> Kl}
[PROOF STEP]
by auto


[STATEMENT]
lemma reduced_homology_group_nsphere_aux:
  "if p = int n then reduced_homology_group n (nsphere n) \<cong> integer_group
                     else trivial_group(reduced_homology_group p (nsphere n))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))
[PROOF STEP]
proof (induction n arbitrary: p)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
let ?a = "\<lambda>i::nat. if i = 0 then 1 else (0::real)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
let ?b = "\<lambda>i::nat. if i = 0 then -1 else (0::real)"
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have st: "subtopology (powertop_real UNIV) {?a, ?b} = nsphere 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0
[PROOF STEP]
have "{?a, ?b} = {x. (x 0)\<^sup>2 = 1 \<and> (\<forall>i>0. x i = 0)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = {x. (x 0)\<^sup>2 = 1 \<and> (\<forall>i>0. x i = 0)}
[PROOF STEP]
using power2_eq_iff
[PROOF STATE]
proof (prove)
using this:
(?x\<^sup>2 = ?y\<^sup>2) = (?x = ?y \<or> ?x = - ?y)

goal (1 subgoal):
 1. {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = {x. (x 0)\<^sup>2 = 1 \<and> (\<forall>i>0. x i = 0)}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
{\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = {x. (x 0)\<^sup>2 = 1 \<and> (\<forall>i>0. x i = 0)}

goal (1 subgoal):
 1. subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
{\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = {x. (x 0)\<^sup>2 = 1 \<and> (\<forall>i>0. x i = 0)}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = {x. (x 0)\<^sup>2 = 1 \<and> (\<forall>i>0. x i = 0)}

goal (1 subgoal):
 1. subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0
[PROOF STEP]
by (simp add: nsphere)
[PROOF STATE]
proof (state)
this:
subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0

goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have *: "reduced_homology_group p (subtopology (powertop_real UNIV) {?a, ?b}) \<cong>
        homology_group p (subtopology (powertop_real UNIV) {?a})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduced_homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0}) \<cong> homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0})
[PROOF STEP]
apply (rule reduced_homology_group_pair)
[PROOF STATE]
proof (prove)
goal (4 subgoals):
 1. t1_space (powertop_real UNIV)
 2. (\<lambda>i. if i = 0 then 1 else 0) \<in> topspace (powertop_real UNIV)
 3. (\<lambda>i. if i = 0 then - 1 else 0) \<in> topspace (powertop_real UNIV)
 4. (\<lambda>i. if i = 0 then 1 else 0) \<noteq> (\<lambda>i. if i = 0 then - 1 else 0)
[PROOF STEP]
apply (simp_all add: fun_eq_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t1_space (powertop_real UNIV)
[PROOF STEP]
apply (simp add: open_fun_def separation_t1 t1_space_def)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
reduced_homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0}) \<cong> homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0})

goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have "reduced_homology_group 0 (nsphere 0) \<cong> integer_group" if "p=0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
have "reduced_homology_group 0 (nsphere 0) \<cong> homology_group 0 (top_of_set {?a})" if "p=0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> homology_group 0 (top_of_set {\<lambda>i. if i = 0 then 1 else 0})
[PROOF STEP]
by (metis * euclidean_product_topology st that)
[PROOF STATE]
proof (state)
this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> homology_group 0 (top_of_set {\<lambda>i. if i = 0 then 1 else 0})

goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> homology_group 0 (top_of_set {\<lambda>i. if i = 0 then 1 else 0})

goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
have "\<dots> \<cong> integer_group"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homology_group 0 (top_of_set {\<lambda>i. if i = 0 then 1 else 0}) \<cong> integer_group
[PROOF STEP]
by (simp add: homology_coefficients)
[PROOF STATE]
proof (state)
this:
homology_group 0 (top_of_set {\<lambda>i. if i = 0 then 1 else 0}) \<cong> integer_group

goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group

goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group
p = 0

goal (1 subgoal):
 1. reduced_homology_group 0 (nsphere 0) \<cong> integer_group
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
reduced_homology_group 0 (nsphere 0) \<cong> integer_group

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group

goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group

goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have "trivial_group (reduced_homology_group p (nsphere 0))" if "p\<noteq>0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trivial_group (reduced_homology_group p (nsphere 0))
[PROOF STEP]
using * that homology_dimension_axiom [of "subtopology (powertop_real UNIV) {?a}" ?a p]
[PROOF STATE]
proof (prove)
using this:
reduced_homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0}) \<cong> homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0})
p \<noteq> 0
\<lbrakk>topspace (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0}) = {\<lambda>i. if i = 0 then 1 else 0}; p \<noteq> 0\<rbrakk> \<Longrightarrow> trivial_group (homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0}))

goal (1 subgoal):
 1. trivial_group (reduced_homology_group p (nsphere 0))
[PROOF STEP]
using isomorphic_group_triviality st
[PROOF STATE]
proof (prove)
using this:
reduced_homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0}) \<cong> homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0})
p \<noteq> 0
\<lbrakk>topspace (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0}) = {\<lambda>i. if i = 0 then 1 else 0}; p \<noteq> 0\<rbrakk> \<Longrightarrow> trivial_group (homology_group p (subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0}))
\<lbrakk>?G \<cong> ?H; Group.group ?G; Group.group ?H\<rbrakk> \<Longrightarrow> trivial_group ?G = trivial_group ?H
subtopology (powertop_real UNIV) {\<lambda>i. if i = 0 then 1 else 0, \<lambda>i. if i = 0 then - 1 else 0} = nsphere 0

goal (1 subgoal):
 1. trivial_group (reduced_homology_group p (nsphere 0))
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
p \<noteq> 0 \<Longrightarrow> trivial_group (reduced_homology_group p (nsphere 0))

goal (2 subgoals):
 1. \<And>p. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
 2. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group
p \<noteq> 0 \<Longrightarrow> trivial_group (reduced_homology_group p (nsphere 0))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
p = 0 \<Longrightarrow> reduced_homology_group 0 (nsphere 0) \<cong> integer_group
p \<noteq> 0 \<Longrightarrow> trivial_group (reduced_homology_group p (nsphere 0))

goal (1 subgoal):
 1. if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
if p = int 0 then reduced_homology_group (int 0) (nsphere 0) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere 0))

goal (1 subgoal):
 1. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
if ?p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group ?p (nsphere n))

goal (1 subgoal):
 1. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have eq: "reduced_homology_group (int n) (nsphere n) \<cong> integer_group" if "p-1 = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduced_homology_group (int n) (nsphere n) \<cong> integer_group
[PROOF STEP]
by (simp add: Suc.IH)
[PROOF STATE]
proof (state)
this:
p - 1 = int n \<Longrightarrow> reduced_homology_group (int n) (nsphere n) \<cong> integer_group

goal (1 subgoal):
 1. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have neq: "trivial_group (reduced_homology_group (p-1) (nsphere n))" if "p-1 \<noteq> n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. trivial_group (reduced_homology_group (p - 1) (nsphere n))
[PROOF STEP]
by (simp add: Suc.IH that)
[PROOF STATE]
proof (state)
this:
p - 1 \<noteq> int n \<Longrightarrow> trivial_group (reduced_homology_group (p - 1) (nsphere n))

goal (1 subgoal):
 1. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
have iso: "reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p-1) (nsphere n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)
[PROOF STEP]
using reduced_homology_group_nsphere_step [of "p-1" n]  group.iso_sym [OF _ is_isoI] group_reduced_homology_group
[PROOF STATE]
proof (prove)
using this:
\<exists>f\<in>Group.iso (reduced_homology_group (p - 1) (nsphere n)) (reduced_homology_group (1 + (p - 1)) (nsphere (Suc n))). \<forall>c\<in>carrier (reduced_homology_group (p - 1) (nsphere n)). hom_induced (1 + (p - 1)) (nsphere (Suc n)) {} (nsphere (Suc n)) {} (\<lambda>x i. if i = 0 then - x i else x i) (f c) = f (hom_induced (p - 1) (nsphere n) {} (nsphere n) {} (\<lambda>x i. if i = 0 then - x i else x i) c)
\<lbrakk>Group.group ?G; ?h1 \<in> Group.iso ?G ?H\<rbrakk> \<Longrightarrow> ?H \<cong> ?G
Group.group (reduced_homology_group ?p ?X)

goal (1 subgoal):
 1. reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)

goal (1 subgoal):
 1. \<And>n p. (\<And>p. if p = int n then reduced_homology_group (int n) (nsphere n) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere n))) \<Longrightarrow> if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)

goal (1 subgoal):
 1. if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
using eq iso_trans iso isomorphic_group_triviality neq
[PROOF STATE]
proof (prove)
using this:
reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)
p - 1 = int n \<Longrightarrow> reduced_homology_group (int n) (nsphere n) \<cong> integer_group
\<lbrakk>?G \<cong> ?H; ?H \<cong> ?I\<rbrakk> \<Longrightarrow> ?G \<cong> ?I
reduced_homology_group p (nsphere (Suc n)) \<cong> reduced_homology_group (p - 1) (nsphere n)
\<lbrakk>?G \<cong> ?H; Group.group ?G; Group.group ?H\<rbrakk> \<Longrightarrow> trivial_group ?G = trivial_group ?H
p - 1 \<noteq> int n \<Longrightarrow> trivial_group (reduced_homology_group (p - 1) (nsphere n))

goal (1 subgoal):
 1. if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))
[PROOF STEP]
by (metis (no_types, opaque_lifting) add.commute add_left_cancel diff_add_cancel group_reduced_homology_group of_nat_Suc)
[PROOF STATE]
proof (state)
this:
if p = int (Suc n) then reduced_homology_group (int (Suc n)) (nsphere (Suc n)) \<cong> integer_group else trivial_group (reduced_homology_group p (nsphere (Suc n)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma push_list_singleton: "push_list a [n] = push a n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. push_list a [n] = push a n
[PROOF STEP]
unfolding push_list_def push_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>i. if i < length [n] then [n] ! i else a (i - length [n])) = (\<lambda>i. if i = 0 then n else a (i - 1))
[PROOF STEP]
by auto


[STATEMENT]
lemma bv_to_nat_rew_msb: "bv_msb w = \<one> ==> bv_to_nat w = 2 ^ (length w - 1) + bv_to_nat (tl w)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bv_msb w = \<one> \<Longrightarrow> bv_to_nat w = 2 ^ (length w - 1) + bv_to_nat (tl w)
[PROOF STEP]
by (rule bit_list_cases [of w]) simp_all


[STATEMENT]
lemma real_of_ereal_eq_0:
  fixes x :: ereal
  shows "real_of_ereal x = 0 \<longleftrightarrow> x = \<infinity> \<or> x = -\<infinity> \<or> x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (real_of_ereal x = 0) = (x = \<infinity> \<or> x = - \<infinity> \<or> x = 0)
[PROOF STEP]
by (cases x) auto


[STATEMENT]
lemma count_image_mset':
  \<open>count (image_mset f X) y = (\<Sum>x | x \<in># X \<and> y = f x. count X x)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. count (image_mset f X) y = (\<Sum>x | x \<in># X \<and> y = f x. count X x)
[PROOF STEP]
by (auto simp add: count_image_mset simp flip: singleton_conv2 simp add: Collect_conj_eq ac_simps)


[STATEMENT]
lemma zero_vec_Suc: "0\<^sub>v (Suc n) = vCons 0 (0\<^sub>v n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0\<^sub>v (Suc n) = vCons (0::'a) (0\<^sub>v n)
[PROOF STEP]
by (auto simp: zero_vec_def vec_Suc o_def)


[STATEMENT]
lemma pt_list_append:
  fixes pi1 :: "'x prm"
  and   pi2 :: "'x prm"
  and   xs  :: "'a list"
  assumes pt: "pt TYPE('a) TYPE ('x)"
  shows "(pi1@pi2)\<bullet>xs = pi1\<bullet>(pi2\<bullet>xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (pi1 @ pi2) \<bullet> xs = pi1 \<bullet> pi2 \<bullet> xs
[PROOF STEP]
apply(induct_tac xs)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. (pi1 @ pi2) \<bullet> [] = pi1 \<bullet> pi2 \<bullet> []
 2. \<And>a list. (pi1 @ pi2) \<bullet> list = pi1 \<bullet> pi2 \<bullet> list \<Longrightarrow> (pi1 @ pi2) \<bullet> (a # list) = pi1 \<bullet> pi2 \<bullet> (a # list)
[PROOF STEP]
apply(simp_all add: pt2[OF pt])
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma fold_id: "(\<And>x. x \<in> set xs \<Longrightarrow> f x = id) \<Longrightarrow> fold f xs = id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> set xs \<Longrightarrow> f x = id) \<Longrightarrow> fold f xs = id
[PROOF STEP]
by (induct xs) simp_all


[STATEMENT]
theorem Carmichael_number_iff:
  "Carmichael_number n \<longleftrightarrow>
     n \<noteq> 1 \<and> \<not>prime n \<and> squarefree n \<and> (\<forall>p\<in>prime_factors n. p - 1 dvd n - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Carmichael_number n = (n \<noteq> 1 \<and> \<not> prime n \<and> squarefree n \<and> (\<forall>p\<in>#prime_factorization n. p - 1 dvd n - 1))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Carmichael_number n = (n \<noteq> 1 \<and> \<not> prime n \<and> squarefree n \<and> (\<forall>p\<in>#prime_factorization n. p - 1 dvd n - 1))
[PROOF STEP]
consider "n = 0" | "n = 1" | "n > 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>n = 0 \<Longrightarrow> thesis; n = 1 \<Longrightarrow> thesis; 1 < n \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<lbrakk>n = 0 \<Longrightarrow> ?thesis; n = 1 \<Longrightarrow> ?thesis; 1 < n \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. Carmichael_number n = (n \<noteq> 1 \<and> \<not> prime n \<and> squarefree n \<and> (\<forall>p\<in>#prime_factorization n. p - 1 dvd n - 1))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n = 0 \<Longrightarrow> ?thesis; n = 1 \<Longrightarrow> ?thesis; 1 < n \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. Carmichael_number n = (n \<noteq> 1 \<and> \<not> prime n \<and> squarefree n \<and> (\<forall>p\<in>#prime_factorization n. p - 1 dvd n - 1))
[PROOF STEP]
using Carmichael_numberI[of n] Carmichael_number_imp_dvd[of n]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>n = 0 \<Longrightarrow> ?thesis; n = 1 \<Longrightarrow> ?thesis; 1 < n \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
\<lbrakk>\<not> prime n; squarefree n; 1 < n; \<And>p. p \<in># prime_factorization n \<Longrightarrow> p - 1 dvd n - 1\<rbrakk> \<Longrightarrow> Carmichael_number n
\<lbrakk>Carmichael_number n; prime ?p; ?p dvd n\<rbrakk> \<Longrightarrow> ?p - 1 dvd n - 1

goal (1 subgoal):
 1. Carmichael_number n = (n \<noteq> 1 \<and> \<not> prime n \<and> squarefree n \<and> (\<forall>p\<in>#prime_factorization n. p - 1 dvd n - 1))
[PROOF STEP]
by cases (auto simp: Carmichael_number_not_prime Carmichael_number_imp_squarefree)
[PROOF STATE]
proof (state)
this:
Carmichael_number n = (n \<noteq> 1 \<and> \<not> prime n \<and> squarefree n \<and> (\<forall>p\<in>#prime_factorization n. p - 1 dvd n - 1))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma isDERIV_FDERIV_floatarith_linear:
  fixes x h::"'a::executable_euclidean_space"
  assumes "\<And>k. k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith k fa) xs"
  assumes "max_Var_floatarith fa \<le> DIM('a)"
  assumes [simp]: "length xs = DIM('a)" "length hs = DIM('a)"
  shows "isDERIV i (FDERIV_floatarith fa [0..<DIM('a)] (map Var [DIM('a)..<2 * DIM('a)]))
            (xs @ hs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. isDERIV i (FDERIV_floatarith fa [0..<DIM('a)] (map Var [DIM('a)..<2 * DIM('a)])) (xs @ hs)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith ?k fa) xs
max_Var_floatarith fa \<le> DIM('a)
length xs = DIM('a)
length hs = DIM('a)

goal (1 subgoal):
 1. isDERIV i (FDERIV_floatarith fa [0..<DIM('a)] (map Var [DIM('a)..<2 * DIM('a)])) (xs @ hs)
[PROOF STEP]
apply (auto simp: FDERIV_floatarith_def isDERIV_inner_iff)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k. \<lbrakk>\<And>k. k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith k fa) xs; max_Var_floatarith fa \<le> DIM('a); k < DIM('a)\<rbrakk> \<Longrightarrow> isDERIV i (fold_const_fa (DERIV_floatarith k fa)) (xs @ hs)
[PROOF STEP]
apply (rule isDERIV_max_Var_floatarithI)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<And>k. \<lbrakk>\<And>k. k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith k fa) xs; max_Var_floatarith fa \<le> DIM('a); k < DIM('a)\<rbrakk> \<Longrightarrow> isDERIV i (fold_const_fa (DERIV_floatarith k fa)) (?ys7 k)
 2. \<And>k ia. \<lbrakk>\<And>k. k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith k fa) xs; max_Var_floatarith fa \<le> DIM('a); k < DIM('a); ia < max_Var_floatarith (fold_const_fa (DERIV_floatarith k fa))\<rbrakk> \<Longrightarrow> (xs @ hs) ! ia = ?ys7 k ! ia
[PROOF STEP]
apply force
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k ia. \<lbrakk>\<And>k. k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith k fa) xs; max_Var_floatarith fa \<le> DIM('a); k < DIM('a); ia < max_Var_floatarith (fold_const_fa (DERIV_floatarith k fa))\<rbrakk> \<Longrightarrow> (xs @ hs) ! ia = xs ! ia
[PROOF STEP]
apply (auto simp: nth_append)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>k ia. \<lbrakk>\<And>k. k < DIM('a) \<Longrightarrow> isDERIV i (DERIV_floatarith k fa) xs; max_Var_floatarith fa \<le> DIM('a); k < DIM('a); ia < max_Var_floatarith (fold_const_fa (DERIV_floatarith k fa)); \<not> ia < DIM('a)\<rbrakk> \<Longrightarrow> hs ! (ia - DIM('a)) = xs ! ia
[PROOF STEP]
by (metis add_diff_inverse_nat leD max_Var_floatarith_DERIV_floatarith
      max_Var_floatarith_fold_const_fa trans_le_add1)


[STATEMENT]
lemma deriv_zeta_eq:
  assumes s: "s \<noteq> 1"
  shows   "deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
from s
[PROOF STATE]
proof (chain)
picking this:
s \<noteq> 1
[PROOF STEP]
have ev: "eventually (\<lambda>z. z \<noteq> 1) (nhds s)"
[PROOF STATE]
proof (prove)
using this:
s \<noteq> 1

goal (1 subgoal):
 1. \<forall>\<^sub>F z in nhds s. z \<noteq> 1
[PROOF STEP]
by (intro t1_space_nhds)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F z in nhds s. z \<noteq> 1

goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
have [derivative_intros]: "(pre_zeta 1 has_field_derivative deriv (pre_zeta 1) s) (at s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (pre_zeta 1 has_field_derivative deriv (pre_zeta 1) s) (at s)
[PROOF STEP]
by (intro holomorphic_derivI[of _ UNIV] holomorphic_intros) auto
[PROOF STATE]
proof (state)
this:
(pre_zeta 1 has_field_derivative deriv (pre_zeta 1) s) (at s)

goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
have "((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative
          (deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2)) (at s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)
[PROOF STEP]
using s
[PROOF STATE]
proof (prove)
using this:
s \<noteq> 1

goal (1 subgoal):
 1. ((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)
[PROOF STEP]
by (auto intro!: derivative_eq_intros simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)

goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)

goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
have "?this \<longleftrightarrow> (zeta has_field_derivative (deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2)) (at s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s) = (zeta has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)
[PROOF STEP]
by (intro has_field_derivative_cong_ev eventually_mono[OF ev])
       (auto simp: zeta_def hurwitz_zeta_def)
[PROOF STATE]
proof (state)
this:
((\<lambda>s. pre_zeta 1 s + 1 / (s - 1)) has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s) = (zeta has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)

goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
(zeta has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(zeta has_field_derivative deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2) (at s)

goal (1 subgoal):
 1. deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2
[PROOF STEP]
by (rule DERIV_imp_deriv)
[PROOF STATE]
proof (state)
this:
deriv zeta s = deriv (pre_zeta 1) s - 1 / (s - 1)\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Int_card2: "finite B \<Longrightarrow> card (A \<inter> B) \<le> card B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite B \<Longrightarrow> card (A \<inter> B) \<le> card B
[PROOF STEP]
by (simp only: Int_commute[of A], rule Int_card1)


[STATEMENT]
lemma integral_linear:
  "f integrable_on S \<Longrightarrow> bounded_linear h \<Longrightarrow> integral S (h \<circ> f) = h (integral S f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f integrable_on S; bounded_linear h\<rbrakk> \<Longrightarrow> integral S (h \<circ> f) = h (integral S f)
[PROOF STEP]
by (meson has_integral_iff has_integral_linear)


[STATEMENT]
lemma Sigma_mset_empty_iff: "(SIGMAMSET i\<in>#I. X i) = {#} \<longleftrightarrow> (\<forall>i\<in>#I. X i = {#})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Sigma_mset I X = {#}) = (\<forall>i\<in>#I. X i = {#})
[PROOF STEP]
by (auto simp: Sigma_mset_def)


[STATEMENT]
lemma map_prod_app[simp]: "(f ** g)\<cdot>x = (f\<cdot>(cfst\<cdot>x), g\<cdot>(csnd\<cdot>x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f ** g)\<cdot>x = (f\<cdot>(cfst\<cdot>x), g\<cdot>(csnd\<cdot>x))
[PROOF STEP]
unfolding map_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Lambda> f g (x, y). (f\<cdot>x, g\<cdot>y))\<cdot>f\<cdot>g\<cdot>x = (f\<cdot>(cfst\<cdot>x), g\<cdot>(csnd\<cdot>x))
[PROOF STEP]
by (cases x) (clarsimp simp: cfun_eq_iff)


[STATEMENT]
lemma subspace_with:
  "subspace = (\<lambda>X. subspace_with (+) 0 scale X)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.subspace = subspace_with (+) (0::'b) (*s)
[PROOF STEP]
unfolding subspace_def subspace_with_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>S. (0::'b) \<in> S \<and> (\<forall>x\<in>S. \<forall>y\<in>S. x + y \<in> S) \<and> (\<forall>c. \<forall>x\<in>S. c *s x \<in> S)) = (\<lambda>X. (0::'b) \<in> X \<and> (\<forall>x\<in>X. \<forall>y\<in>X. x + y \<in> X) \<and> (\<forall>c. \<forall>x\<in>X. c *s x \<in> X))
[PROOF STEP]
..


[STATEMENT]
lemma f_g_eq_f_imp_f_comp_g_eq_f[simp]: "(\<And>x. f (g x) = f x) \<Longrightarrow> (f \<circ> g) = f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. f (g x) = f x) \<Longrightarrow> f \<circ> g = f
[PROOF STEP]
by (simp add: comp_def)


[STATEMENT]
lemma ssubst_insert_if:
  "finite V \<Longrightarrow>
     ssubst t (insert i V) F = (if i \<in> V then ssubst t V F
                                         else subst i (F i) (ssubst t V F))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite V \<Longrightarrow> ssubst t (insert i V) F = (if i \<in> V then ssubst t V F else subst i (F i) (ssubst t V F))
[PROOF STEP]
by (simp add: ssubst_insert insert_absorb)


[STATEMENT]
lemma lex_pp_antisym: "lex_pp s t \<Longrightarrow> lex_pp t s \<Longrightarrow> s = t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>lex_pp s t; lex_pp t s\<rbrakk> \<Longrightarrow> s = t
[PROOF STEP]
by (transfer, intro lex_pm_antisym)


[STATEMENT]
lemma digit_less_base: "digit x i < base"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. digit x i < base
[PROOF STEP]
using base_pos
[PROOF STATE]
proof (prove)
using this:
0 < base

goal (1 subgoal):
 1. digit x i < base
[PROOF STEP]
by (auto simp: digit_altdef)


[STATEMENT]
lemma lift_leadsTo:
     "(lift i F \<in> (lift_set i A) leadsTo (lift_set i B)) =
      (F \<in> A leadsTo B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (lift i F \<in> lift_set i A \<longmapsto> lift_set i B) = (F \<in> A \<longmapsto> B)
[PROOF STEP]
by (simp add: lift_def lift_set_def rename_leadsTo)