[STATEMENT]
lemma poincare_between_poincare_line_uzv:
  assumes "u \<noteq> v" and "u \<in> unit_disc" and "v \<in> unit_disc" and
          "z \<in> unit_disc" "poincare_between u z v"
  shows "z \<in> circline_set (poincare_line u v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z \<in> circline_set (poincare_line u v)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
u \<noteq> v
u \<in> unit_disc
v \<in> unit_disc
z \<in> unit_disc
poincare_between u z v

goal (1 subgoal):
 1. z \<in> circline_set (poincare_line u v)
[PROOF STEP]
using poincare_between_poincare_collinear[of u z v]
[PROOF STATE]
proof (prove)
using this:
u \<noteq> v
u \<in> unit_disc
v \<in> unit_disc
z \<in> unit_disc
poincare_between u z v
\<lbrakk>u \<in> unit_disc; z \<in> unit_disc; v \<in> unit_disc; poincare_between u z v\<rbrakk> \<Longrightarrow> poincare_collinear {u, z, v}

goal (1 subgoal):
 1. z \<in> circline_set (poincare_line u v)
[PROOF STEP]
using unique_poincare_line[OF assms(1-3)]
[PROOF STATE]
proof (prove)
using this:
u \<noteq> v
u \<in> unit_disc
v \<in> unit_disc
z \<in> unit_disc
poincare_between u z v
\<lbrakk>u \<in> unit_disc; z \<in> unit_disc; v \<in> unit_disc; poincare_between u z v\<rbrakk> \<Longrightarrow> poincare_collinear {u, z, v}
\<lbrakk>u \<in> circline_set ?l; v \<in> circline_set ?l; is_poincare_line ?l\<rbrakk> \<Longrightarrow> ?l = poincare_line u v

goal (1 subgoal):
 1. z \<in> circline_set (poincare_line u v)
[PROOF STEP]
unfolding poincare_collinear_def
[PROOF STATE]
proof (prove)
using this:
u \<noteq> v
u \<in> unit_disc
v \<in> unit_disc
z \<in> unit_disc
poincare_between u z v
\<lbrakk>u \<in> unit_disc; z \<in> unit_disc; v \<in> unit_disc; poincare_between u z v\<rbrakk> \<Longrightarrow> \<exists>p. is_poincare_line p \<and> {u, z, v} \<subseteq> circline_set p
\<lbrakk>u \<in> circline_set ?l; v \<in> circline_set ?l; is_poincare_line ?l\<rbrakk> \<Longrightarrow> ?l = poincare_line u v

goal (1 subgoal):
 1. z \<in> circline_set (poincare_line u v)
[PROOF STEP]
by auto


[STATEMENT]
lemma (in Ring) sum_ideals_la1:"\<lbrakk>ideal R I1; ideal R I2\<rbrakk> \<Longrightarrow> I1 \<subseteq> (I1 \<minusplus> I2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>ideal R I1; ideal R I2\<rbrakk> \<Longrightarrow> I1 \<subseteq> I1 \<minusplus> I2
[PROOF STEP]
apply (cut_tac ring_is_ag)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>ideal R I1; ideal R I2; aGroup R\<rbrakk> \<Longrightarrow> I1 \<subseteq> I1 \<minusplus> I2
[PROOF STEP]
apply (rule subsetI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>ideal R I1; ideal R I2; aGroup R; x \<in> I1\<rbrakk> \<Longrightarrow> x \<in> I1 \<minusplus> I2
[PROOF STEP]
apply (frule ideal_zero[of "I2"],
       frule_tac h = x in ideal_subset[of "I1"], assumption+,
       frule_tac x = x in aGroup.ag_r_zero[of "R"], assumption+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. \<lbrakk>ideal R I1; ideal R I2; aGroup R; x \<in> I1; \<zero> \<in> I2; x \<in> carrier R; x \<plusminus> \<zero> = x\<rbrakk> \<Longrightarrow> x \<in> I1 \<minusplus> I2
[PROOF STEP]
apply (subst aGroup.set_sum, assumption,
       simp add:ideal_subset1, simp add:ideal_subset1, simp,
       frule sym, thin_tac "x \<plusminus> \<zero> = x", blast)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma iterate_add_distrib[simp]: \<open>iterate_add (m+n) a = iterate_add m a + iterate_add n a\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. iterate_add (m + n) a = iterate_add m a + iterate_add n a
[PROOF STEP]
by (induction n) (auto simp: ac_simps)


[STATEMENT]
lemma scaleR_nonneg_nonneg: "0 \<le> a \<Longrightarrow> 0 \<le> x \<Longrightarrow> 0 \<le> a *\<^sub>R x"
  for x :: "'a::ordered_real_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 \<le> a; (0::'a) \<le> x\<rbrakk> \<Longrightarrow> (0::'a) \<le> a *\<^sub>R x
[PROOF STEP]
using scaleR_left_mono [of 0 x a]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>(0::'a) \<le> x; 0 \<le> a\<rbrakk> \<Longrightarrow> a *\<^sub>R (0::'a) \<le> a *\<^sub>R x

goal (1 subgoal):
 1. \<lbrakk>0 \<le> a; (0::'a) \<le> x\<rbrakk> \<Longrightarrow> (0::'a) \<le> a *\<^sub>R x
[PROOF STEP]
by simp


[STATEMENT]
theorem (in IrrFinGroupRepresentation) Schur1 :
  assumes   "IrrFinGroupRepresentation G smult' W"
            "GRepHom smult' T" "T ` V \<subseteq> W" "T ` V \<noteq> 0"
  shows     "GRepIso smult' T W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. GRepIso smult' T W
[PROOF STEP]
proof (rule FGModuleIso.intro, rule assms(2), unfold_locales)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. bij_betw T V W
[PROOF STEP]
show "bij_betw T V W"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. bij_betw T V W
[PROOF STEP]
using     IrrFinGroupRepresentation_axioms assms
              IrrFinGroupRepresentation.axioms(1)[of G]
              FinGroupRepresentation.Schur_Im[of G]
              IrrFinGroupRepresentation.Schur_Ker[of G smult V smult' T]
[PROOF STATE]
proof (prove)
using this:
IrrFinGroupRepresentation G (\<cdot>) V
IrrFinGroupRepresentation G smult' W
GRepHom smult' T
T ` V \<subseteq> W
T ` V \<noteq> 0
IrrFinGroupRepresentation G ?smult ?V \<Longrightarrow> FinGroupRepresentation G ?smult ?V
\<lbrakk>FinGroupRepresentation G ?smult ?V; IrrFinGroupRepresentation G ?smult' ?W; FGModuleHom G ?smult ?V ?smult' ?T; ?T ` ?V \<subseteq> ?W; ?T ` ?V \<noteq> 0\<rbrakk> \<Longrightarrow> ?T ` ?V = ?W
\<lbrakk>IrrFinGroupRepresentation G (\<cdot>) V; GRepHom smult' T; T ` V \<noteq> 0\<rbrakk> \<Longrightarrow> inj_on T V

goal (1 subgoal):
 1. bij_betw T V W
[PROOF STEP]
unfolding bij_betw_def
[PROOF STATE]
proof (prove)
using this:
IrrFinGroupRepresentation G (\<cdot>) V
IrrFinGroupRepresentation G smult' W
GRepHom smult' T
T ` V \<subseteq> W
T ` V \<noteq> 0
IrrFinGroupRepresentation G ?smult ?V \<Longrightarrow> FinGroupRepresentation G ?smult ?V
\<lbrakk>FinGroupRepresentation G ?smult ?V; IrrFinGroupRepresentation G ?smult' ?W; FGModuleHom G ?smult ?V ?smult' ?T; ?T ` ?V \<subseteq> ?W; ?T ` ?V \<noteq> 0\<rbrakk> \<Longrightarrow> ?T ` ?V = ?W
\<lbrakk>IrrFinGroupRepresentation G (\<cdot>) V; GRepHom smult' T; T ` V \<noteq> 0\<rbrakk> \<Longrightarrow> inj_on T V

goal (1 subgoal):
 1. inj_on T V \<and> T ` V = W
[PROOF STEP]
by        fast
[PROOF STATE]
proof (state)
this:
bij_betw T V W

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma algebraic_add_cancel_left [simp]:
  assumes "algebraic x"
  shows   "algebraic (x + y) \<longleftrightarrow> algebraic y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. algebraic (x + y) = algebraic y
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. algebraic (x + y) \<Longrightarrow> algebraic y
 2. algebraic y \<Longrightarrow> algebraic (x + y)
[PROOF STEP]
assume "algebraic (x + y)"
[PROOF STATE]
proof (state)
this:
algebraic (x + y)

goal (2 subgoals):
 1. algebraic (x + y) \<Longrightarrow> algebraic y
 2. algebraic y \<Longrightarrow> algebraic (x + y)
[PROOF STEP]
hence "algebraic (x + y - x)"
[PROOF STATE]
proof (prove)
using this:
algebraic (x + y)

goal (1 subgoal):
 1. algebraic (x + y - x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
algebraic (x + y)
algebraic x

goal (1 subgoal):
 1. algebraic (x + y - x)
[PROOF STEP]
by (intro algebraic_minus) auto
[PROOF STATE]
proof (state)
this:
algebraic (x + y - x)

goal (2 subgoals):
 1. algebraic (x + y) \<Longrightarrow> algebraic y
 2. algebraic y \<Longrightarrow> algebraic (x + y)
[PROOF STEP]
thus "algebraic y"
[PROOF STATE]
proof (prove)
using this:
algebraic (x + y - x)

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

goal (1 subgoal):
 1. algebraic y \<Longrightarrow> algebraic (x + y)
[PROOF STEP]
qed (auto intro: algebraic_plus assms)


[STATEMENT]
lemma continuous_on_divide[continuous_intros]:
  fixes f :: "'a::topological_space \<Rightarrow> 'b::real_normed_field"
  assumes "continuous_on s f" "continuous_on s g"
    and "\<forall>x\<in>s. g x \<noteq> 0"
  shows "continuous_on s (\<lambda>x. (f x) / (g x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on s (\<lambda>x. f x / g x)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
continuous_on s f
continuous_on s g
\<forall>x\<in>s. g x \<noteq> (0::'b)

goal (1 subgoal):
 1. continuous_on s (\<lambda>x. f x / g x)
[PROOF STEP]
unfolding continuous_on_def
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>s. (f \<longlongrightarrow> f x) (at x within s)
\<forall>x\<in>s. (g \<longlongrightarrow> g x) (at x within s)
\<forall>x\<in>s. g x \<noteq> (0::'b)

goal (1 subgoal):
 1. \<forall>x\<in>s. ((\<lambda>x. f x / g x) \<longlongrightarrow> f x / g x) (at x within s)
[PROOF STEP]
by (blast intro: tendsto_divide)


[STATEMENT]
lemma sorted_wrt_mergesort_by_rel_merge [simp]:
  assumes lin : "\<And>x y. (R x y) \<or> (R y x)"
      and trans_R: "\<And>x y z. R x y \<Longrightarrow> R y z \<Longrightarrow> R x z"
  shows  "sorted_wrt R (mergesort_by_rel_merge R xs ys) \<longleftrightarrow>
          sorted_wrt R xs \<and> sorted_wrt R ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel_merge R xs ys) = (sorted_wrt R xs \<and> sorted_wrt R ys)
[PROOF STEP]
proof (induct xs ys rule: mergesort_by_rel_merge_induct[where R = R])
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<And>xs. sorted_wrt R (mergesort_by_rel_merge R xs []) = (sorted_wrt R xs \<and> sorted_wrt R [])
 2. \<And>ys. sorted_wrt R (mergesort_by_rel_merge R [] ys) = (sorted_wrt R [] \<and> sorted_wrt R ys)
 3. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 4. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
case Nil1
[PROOF STATE]
proof (state)
this:

goal (4 subgoals):
 1. \<And>xs. sorted_wrt R (mergesort_by_rel_merge R xs []) = (sorted_wrt R xs \<and> sorted_wrt R [])
 2. \<And>ys. sorted_wrt R (mergesort_by_rel_merge R [] ys) = (sorted_wrt R [] \<and> sorted_wrt R ys)
 3. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 4. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel_merge R xs_ []) = (sorted_wrt R xs_ \<and> sorted_wrt R [])
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel_merge R xs_ []) = (sorted_wrt R xs_ \<and> sorted_wrt R [])

goal (3 subgoals):
 1. \<And>ys. sorted_wrt R (mergesort_by_rel_merge R [] ys) = (sorted_wrt R [] \<and> sorted_wrt R ys)
 2. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 3. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<And>ys. sorted_wrt R (mergesort_by_rel_merge R [] ys) = (sorted_wrt R [] \<and> sorted_wrt R ys)
 2. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 3. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
case Nil2
[PROOF STATE]
proof (state)
this:

goal (3 subgoals):
 1. \<And>ys. sorted_wrt R (mergesort_by_rel_merge R [] ys) = (sorted_wrt R [] \<and> sorted_wrt R ys)
 2. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 3. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel_merge R [] ys_) = (sorted_wrt R [] \<and> sorted_wrt R ys_)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel_merge R [] ys_) = (sorted_wrt R [] \<and> sorted_wrt R ys_)

goal (2 subgoals):
 1. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 2. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 2. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
case (Cons1 x xs y ys)
[PROOF STATE]
proof (state)
this:
R x y
sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))

goal (2 subgoals):
 1. \<And>x xs y ys. \<lbrakk>R x y; sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
 2. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
R x y
sorted_wrt R (mergesort_by_rel_merge R xs (y # ys)) = (sorted_wrt R xs \<and> sorted_wrt R (y # ys))

goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
by (simp add: Ball_def) (metis trans_R)
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))

goal (1 subgoal):
 1. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
case (Cons2 x xs y ys)
[PROOF STATE]
proof (state)
this:
\<not> R x y
sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)

goal (1 subgoal):
 1. \<And>x xs y ys. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)\<rbrakk> \<Longrightarrow> sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
thus ?case
[PROOF STATE]
proof (prove)
using this:
\<not> R x y
sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys) = (sorted_wrt R (x # xs) \<and> sorted_wrt R ys)

goal (1 subgoal):
 1. sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))
[PROOF STEP]
apply (auto simp add: Ball_def)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys); \<forall>xa. xa \<in> set xs \<longrightarrow> R x xa; sorted_wrt R xs; \<forall>x. x \<in> set ys \<longrightarrow> R y x; sorted_wrt R ys\<rbrakk> \<Longrightarrow> R y x
 2. \<And>xa. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys); \<forall>xa. xa \<in> set xs \<longrightarrow> R x xa; sorted_wrt R xs; \<forall>x. x \<in> set ys \<longrightarrow> R y x; sorted_wrt R ys; xa \<in> set xs\<rbrakk> \<Longrightarrow> R y xa
[PROOF STEP]
apply (metis lin)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>xa. \<lbrakk>\<not> R x y; sorted_wrt R (mergesort_by_rel_merge R (x # xs) ys); \<forall>xa. xa \<in> set xs \<longrightarrow> R x xa; sorted_wrt R xs; \<forall>x. x \<in> set ys \<longrightarrow> R y x; sorted_wrt R ys; xa \<in> set xs\<rbrakk> \<Longrightarrow> R y xa
[PROOF STEP]
apply (metis lin trans_R)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
sorted_wrt R (mergesort_by_rel_merge R (x # xs) (y # ys)) = (sorted_wrt R (x # xs) \<and> sorted_wrt R (y # ys))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma (in group) generate_idem'_right:
  assumes "A \<subseteq> carrier G" "B \<subseteq> carrier G"
  shows "generate G (A \<union> generate G B) = generate G (A \<union> B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. generate G (A \<union> generate G B) = generate G (A \<union> B)
[PROOF STEP]
using generate_idem'[OF assms(2) assms(1)]
[PROOF STATE]
proof (prove)
using this:
generate G (generate G B \<union> A) = generate G (B \<union> A)

goal (1 subgoal):
 1. generate G (A \<union> generate G B) = generate G (A \<union> B)
[PROOF STEP]
by (simp add: sup_commute)


[STATEMENT]
lemma first_take_pop [simp]: "\<lbrakk>\<not>is_empty stack; 0 < x\<rbrakk>
   \<Longrightarrow> first stack # take (x - Suc 0) (list (pop stack)) = take x (list stack)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<not> is_empty stack; 0 < x\<rbrakk> \<Longrightarrow> first stack # take (x - Suc 0) (list (pop stack)) = take x (list stack)
[PROOF STEP]
by(induction stack rule: pop.induct) (auto simp: take_Cons')


[STATEMENT]
lemma floor_minus: "\<lfloor>- x\<rfloor> = - \<lceil>x\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>- x\<rfloor> = - \<lceil>x\<rceil>
[PROOF STEP]
unfolding ceiling_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lfloor>- x\<rfloor> = - (- \<lfloor>- x\<rfloor>)
[PROOF STEP]
by simp


[STATEMENT]
lemma pell_valuation_solution_pos_nat:
  fixes z :: "nat \<times> nat"
  assumes "solution z"
  shows   "pell_valuation z > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
solution z
[PROOF STEP]
have "z \<noteq> (0, 0)"
[PROOF STATE]
proof (prove)
using this:
solution z

goal (1 subgoal):
 1. z \<noteq> (0, 0)
[PROOF STEP]
by (intro notI) auto
[PROOF STATE]
proof (state)
this:
z \<noteq> (0, 0)

goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
hence "pell_valuation z \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
z \<noteq> (0, 0)

goal (1 subgoal):
 1. pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y)) \<noteq> 0
[PROOF STEP]
by (auto split: prod.splits)
[PROOF STATE]
proof (state)
this:
pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y)) \<noteq> 0

goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y)) \<noteq> 0

goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
have "pell_valuation z \<ge> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 \<le> pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
by (intro pell_valuation_nonneg) (auto split: prod.splits)
[PROOF STATE]
proof (state)
this:
0 \<le> pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))

goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y)) \<noteq> 0
0 \<le> pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y)) \<noteq> 0
0 \<le> pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))

goal (1 subgoal):
 1. 0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
0 < pell_valuation (case z of (x, y) \<Rightarrow> (int x, int y))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma inner_zero_right [simp]: "inner x 0 = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inner x (0::'a) = 0
[PROOF STEP]
using inner_zero_left [of x]
[PROOF STATE]
proof (prove)
using this:
inner (0::'a) x = 0

goal (1 subgoal):
 1. inner x (0::'a) = 0
[PROOF STEP]
by (simp only: inner_commute)


[STATEMENT]
lemma filtermap_nhds_minus: "filtermap (\<lambda>x. - x) (nhds a) = nhds (- a)"
  for a :: "'a::real_normed_vector"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. filtermap uminus (nhds a) = nhds (- a)
[PROOF STEP]
by (rule filtermap_fun_inverse[where g=uminus])
    (auto intro!: tendsto_eq_intros filterlim_ident)


[STATEMENT]
lemma map_of_sorted_list_of_map[simp]:
    assumes FIN: "finite (dom m)"
    shows "map_of (sorted_list_of_map m) = m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_of (sorted_list_of_map m) = m
[PROOF STEP]
unfolding sorted_list_of_map_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m
[PROOF STEP]
have "set (sorted_list_of_set (dom m)) = dom m"
      and DIST: "distinct (sorted_list_of_set (dom m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (sorted_list_of_set (dom m)) = dom m &&& distinct (sorted_list_of_set (dom m))
[PROOF STEP]
by (simp_all add: FIN)
[PROOF STATE]
proof (state)
this:
set (sorted_list_of_set (dom m)) = dom m
distinct (sorted_list_of_set (dom m))

goal (1 subgoal):
 1. map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m
[PROOF STEP]
have [simp]: "(fst \<circ> (\<lambda>k. (k, the (m k)))) = id"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst \<circ> (\<lambda>k. (k, the (m k))) = id
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
fst \<circ> (\<lambda>k. (k, the (m k))) = id

goal (1 subgoal):
 1. map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m
[PROOF STEP]
have [simp]: "(\<lambda>k. (k, the (m k))) ` dom m = map_to_set m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>k. (k, the (m k))) ` dom m = map_to_set m
[PROOF STEP]
by (auto simp: map_to_set_def)
[PROOF STATE]
proof (state)
this:
(\<lambda>k. (k, the (m k))) ` dom m = map_to_set m

goal (1 subgoal):
 1. map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m
[PROOF STEP]
show "map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m
[PROOF STEP]
apply (subst set_to_map_set_is_map_of[symmetric])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct (map fst (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))))
 2. set_to_map (set (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m)))) = m
[PROOF STEP]
apply (simp add: DIST)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_map (set (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m)))) = m
[PROOF STEP]
apply (subst set_map)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_to_map ((\<lambda>k. (k, the (m k))) ` set (sorted_list_of_set (dom m))) = m
[PROOF STEP]
apply (simp add: FIN map_to_set_inverse)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
map_of (map (\<lambda>k. (k, the (m k))) (sorted_list_of_set (dom m))) = m

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma llist_all2_lnthD:
  "\<lbrakk> llist_all2 P xs ys; enat n < llength xs \<rbrakk> \<Longrightarrow> P (lnth xs n) (lnth ys n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>llist_all2 P xs ys; enat n < llength xs\<rbrakk> \<Longrightarrow> P (lnth xs n) (lnth ys n)
[PROOF STEP]
by(fastforce simp add: llist_all2_conv_lzip lset_lzip)


[STATEMENT]
lemma evimage_const [simp]: "((\<lambda>x. c) \<inverse>\<^bsub>n\<^esub> A) = (if c \<in> A then carrier (R\<^bsup>n\<^esup>) else {})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. c) \<inverse>\<^bsub>n\<^esub> A = (if c \<in> A then carrier (R\<^bsup>n\<^esup>) else {})
[PROOF STEP]
unfolding evimage_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. c) -` A \<inter> carrier (R\<^bsup>n\<^esup>) = (if c \<in> A then carrier (R\<^bsup>n\<^esup>) else {})
[PROOF STEP]
using vimage_const[of c A]
[PROOF STATE]
proof (prove)
using this:
(\<lambda>x. c) -` A = (if c \<in> A then UNIV else {})

goal (1 subgoal):
 1. (\<lambda>x. c) -` A \<inter> carrier (R\<^bsup>n\<^esup>) = (if c \<in> A then carrier (R\<^bsup>n\<^esup>) else {})
[PROOF STEP]
by (smt Int_commute inf_bot_right inf_top.right_neutral)


[STATEMENT]
lemma joinableE:
  assumes "(x, y) \<in> joinable R"
  obtains z where "(x, z) \<in> R" and "(y, z) \<in> R"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>z. \<lbrakk>(x, z) \<in> R; (y, z) \<in> R\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
(x, y) \<in> joinable R

goal (1 subgoal):
 1. (\<And>z. \<lbrakk>(x, z) \<in> R; (y, z) \<in> R\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding joinable_simp
[PROOF STATE]
proof (prove)
using this:
\<exists>z. (x, z) \<in> R \<and> (y, z) \<in> R

goal (1 subgoal):
 1. (\<And>z. \<lbrakk>(x, z) \<in> R; (y, z) \<in> R\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast


[STATEMENT]
lemma exists_bezout_ext_aux:
  fixes a and b
  shows "\<exists>p q u v d. (p * a + q * b = d)
                    \<and> (d dvd a)
                    \<and> (d dvd b)
                    \<and> (\<forall>d'. (d' dvd a \<and> d' dvd b) \<longrightarrow> d' dvd d) \<and> d * u = -b \<and> d * v = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
obtain p q d where prems01: "(p * a + q * b = d)
                    \<and> (d dvd a)
                    \<and> (d dvd b)
                    \<and> (\<forall>d'. (d' dvd a \<and> d' dvd b) \<longrightarrow> d' dvd d)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p q d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using exists_bezout [of a b]
[PROOF STATE]
proof (prove)
using this:
\<exists>p q d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d)

goal (1 subgoal):
 1. (\<And>p q d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d)

goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
hence db: "d dvd b" and da: "d dvd a"
[PROOF STATE]
proof (prove)
using this:
p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d)

goal (1 subgoal):
 1. d dvd b &&& d dvd a
[PROOF STEP]
by blast+
[PROOF STATE]
proof (state)
this:
d dvd b
d dvd a

goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
obtain u v where prems02: "d * u = -b" and prems03: "d * v = a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>d * u = - b; d * v = a\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using db and da
[PROOF STATE]
proof (prove)
using this:
d dvd b
d dvd a

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>d * u = - b; d * v = a\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis local.dvdE local.minus_mult_right)
[PROOF STATE]
proof (state)
this:
d * u = - b
d * v = a

goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
using exI [of _ "(p,q,u,v,d)"] prems01 prems02 prems03
[PROOF STATE]
proof (prove)
using this:
?P (p, q, u, v, d) \<Longrightarrow> \<exists>x. ?P x
p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d)
d * u = - b
d * v = a

goal (1 subgoal):
 1. \<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<exists>p q u v d. p * a + q * b = d \<and> d dvd a \<and> d dvd b \<and> (\<forall>d'. d' dvd a \<and> d' dvd b \<longrightarrow> d' dvd d) \<and> d * u = - b \<and> d * v = a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem nat_euclid_pyth_triples:
  assumes abc: "(a::nat)^2 + b^2 = c^2" and ab_relprime: "coprime a b" and aodd: "odd a"
  shows "\<exists> p q. a = p^2 - q^2 \<and> b = 2*p*q \<and> c = p^2 + q^2 \<and> coprime p q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have two0: "(2::nat) \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 \<noteq> 0

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
from abc
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 + b\<^sup>2 = c\<^sup>2
[PROOF STEP]
have a2cb: "a^2 = c^2 - b^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 + b\<^sup>2 = c\<^sup>2

goal (1 subgoal):
 1. a\<^sup>2 = c\<^sup>2 - b\<^sup>2
[PROOF STEP]
by arith
  \<comment> \<open>factor $a^2$ in coprime factors $(c-b)$ and $(c+b)$; hence both are squares\<close>
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have a2factor: "a^2 = (c-b)*(c+b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
have "c*b - c*b = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * b - c * b = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c * b - c * b = 0

goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
with a2cb
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
c * b - c * b = 0
[PROOF STEP]
have "a^2 = c*c + c*b - c*b - b*b"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
c * b - c * b = 0

goal (1 subgoal):
 1. a\<^sup>2 = c * c + c * b - c * b - b * b
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = c * c + c * b - c * b - b * b

goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = c * c + c * b - c * b - b * b

goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
have "\<dots> = c*(c+b) - b*(c+b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c * c + c * b - c * b - b * b = c * (c + b) - b * (c + b)
[PROOF STEP]
by (simp add: add_mult_distrib2 add_mult_distrib mult.commute)
[PROOF STATE]
proof (state)
this:
c * c + c * b - c * b - b * b = c * (c + b) - b * (c + b)

goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = c * (c + b) - b * (c + b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = c * (c + b) - b * (c + b)

goal (1 subgoal):
 1. a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
by (simp only: diff_mult_distrib)
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = (c - b) * (c + b)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = (c - b) * (c + b)

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have a_nonzero: "a \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<noteq> 0
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> a \<noteq> 0 \<Longrightarrow> False
[PROOF STEP]
assume "\<not> a \<noteq> 0"
[PROOF STATE]
proof (state)
this:
\<not> a \<noteq> 0

goal (1 subgoal):
 1. \<not> a \<noteq> 0 \<Longrightarrow> False
[PROOF STEP]
hence "a = 0"
[PROOF STATE]
proof (prove)
using this:
\<not> a \<noteq> 0

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

goal (1 subgoal):
 1. \<not> a \<noteq> 0 \<Longrightarrow> False
[PROOF STEP]
with aodd
[PROOF STATE]
proof (chain)
picking this:
odd a
a = 0
[PROOF STEP]
have "odd (0::nat)"
[PROOF STATE]
proof (prove)
using this:
odd a
a = 0

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

goal (1 subgoal):
 1. \<not> a \<noteq> 0 \<Longrightarrow> False
[PROOF STEP]
thus False
[PROOF STATE]
proof (prove)
using this:
odd 0

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:
a \<noteq> 0

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have b_less_c: "b < c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b < c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b < c
[PROOF STEP]
from abc
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 + b\<^sup>2 = c\<^sup>2
[PROOF STEP]
have "b^2 \<le> c^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 + b\<^sup>2 = c\<^sup>2

goal (1 subgoal):
 1. b\<^sup>2 \<le> c\<^sup>2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
b\<^sup>2 \<le> c\<^sup>2

goal (1 subgoal):
 1. b < c
[PROOF STEP]
with two0
[PROOF STATE]
proof (chain)
picking this:
2 \<noteq> 0
b\<^sup>2 \<le> c\<^sup>2
[PROOF STEP]
have "b \<le> c"
[PROOF STATE]
proof (prove)
using this:
2 \<noteq> 0
b\<^sup>2 \<le> c\<^sup>2

goal (1 subgoal):
 1. b \<le> c
[PROOF STEP]
by (rule_tac n="2" in nat_power_le_imp_le_base)
[PROOF STATE]
proof (state)
this:
b \<le> c

goal (1 subgoal):
 1. b < c
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b \<le> c

goal (1 subgoal):
 1. b < c
[PROOF STEP]
have"b \<noteq> c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> c
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = c \<Longrightarrow> False
[PROOF STEP]
assume "b=c"
[PROOF STATE]
proof (state)
this:
b = c

goal (1 subgoal):
 1. b = c \<Longrightarrow> False
[PROOF STEP]
with a2cb
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
b = c
[PROOF STEP]
have "a^2 = 0"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
b = c

goal (1 subgoal):
 1. a\<^sup>2 = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = 0

goal (1 subgoal):
 1. b = c \<Longrightarrow> False
[PROOF STEP]
with a_nonzero
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> 0
a\<^sup>2 = 0
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
a \<noteq> 0
a\<^sup>2 = 0

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

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

goal (1 subgoal):
 1. b < c
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
b \<le> c
b \<noteq> c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
b \<le> c
b \<noteq> c

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b < c

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
hence b2_le_c2: "b^2 \<le> c^2"
[PROOF STATE]
proof (prove)
using this:
b < c

goal (1 subgoal):
 1. b\<^sup>2 \<le> c\<^sup>2
[PROOF STEP]
by (simp add: power_mono)
[PROOF STATE]
proof (state)
this:
b\<^sup>2 \<le> c\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have bc_relprime: "coprime b c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
from b2_le_c2
[PROOF STATE]
proof (chain)
picking this:
b\<^sup>2 \<le> c\<^sup>2
[PROOF STEP]
have cancelb2: "c^2-b^2+b^2 = c^2"
[PROOF STATE]
proof (prove)
using this:
b\<^sup>2 \<le> c\<^sup>2

goal (1 subgoal):
 1. c\<^sup>2 - b\<^sup>2 + b\<^sup>2 = c\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c\<^sup>2 - b\<^sup>2 + b\<^sup>2 = c\<^sup>2

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
let ?g = "gcd b c"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
have "?g^2 = gcd (b^2) (c^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2)

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
with cancelb2
[PROOF STATE]
proof (chain)
picking this:
c\<^sup>2 - b\<^sup>2 + b\<^sup>2 = c\<^sup>2
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2)
[PROOF STEP]
have "?g^2 = gcd (b^2) (c^2-b^2+b^2)"
[PROOF STATE]
proof (prove)
using this:
c\<^sup>2 - b\<^sup>2 + b\<^sup>2 = c\<^sup>2
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2)

goal (1 subgoal):
 1. (gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2 + b\<^sup>2)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2 + b\<^sup>2)

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
hence "?g^2 = gcd (b^2) (c^2-b^2)"
[PROOF STATE]
proof (prove)
using this:
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2 + b\<^sup>2)

goal (1 subgoal):
 1. (gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2)
[PROOF STEP]
using gcd_add2[of "b^2" "c^2 - b^2"]
[PROOF STATE]
proof (prove)
using this:
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2 + b\<^sup>2)
gcd (b\<^sup>2) (b\<^sup>2 + (c\<^sup>2 - b\<^sup>2)) = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2)

goal (1 subgoal):
 1. (gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2)
[PROOF STEP]
by (simp add: algebra_simps del: gcd_add1)
[PROOF STATE]
proof (state)
this:
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2)

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
with a2cb
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2)
[PROOF STEP]
have "?g^2 dvd a^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
(gcd b c)\<^sup>2 = gcd (b\<^sup>2) (c\<^sup>2 - b\<^sup>2)

goal (1 subgoal):
 1. (gcd b c)\<^sup>2 dvd a\<^sup>2
[PROOF STEP]
by (simp only: gcd_dvd2)
[PROOF STATE]
proof (state)
this:
(gcd b c)\<^sup>2 dvd a\<^sup>2

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
hence "?g dvd a \<and> ?g dvd b"
[PROOF STATE]
proof (prove)
using this:
(gcd b c)\<^sup>2 dvd a\<^sup>2

goal (1 subgoal):
 1. gcd b c dvd a \<and> gcd b c dvd b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd b c dvd a \<and> gcd b c dvd b

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
hence "?g dvd gcd a b"
[PROOF STATE]
proof (prove)
using this:
gcd b c dvd a \<and> gcd b c dvd b

goal (1 subgoal):
 1. gcd b c dvd gcd a b
[PROOF STEP]
by (simp only: gcd_greatest)
[PROOF STATE]
proof (state)
this:
gcd b c dvd gcd a b

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
with ab_relprime
[PROOF STATE]
proof (chain)
picking this:
coprime a b
gcd b c dvd gcd a b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
coprime a b
gcd b c dvd gcd a b

goal (1 subgoal):
 1. coprime b c
[PROOF STEP]
by (simp add: ac_simps gcd_eq_1_imp_coprime)
[PROOF STATE]
proof (state)
this:
coprime b c

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime b c

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have p2: "prime (2::nat)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prime 2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have factors_odd: "odd (c-b) \<and> odd (c+b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd (c - b) \<and> odd (c + b)
[PROOF STEP]
proof (auto simp only: ccontr)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. even (c - b) \<Longrightarrow> False
 2. even (c + b) \<Longrightarrow> False
[PROOF STEP]
assume "even (c-b)"
[PROOF STATE]
proof (state)
this:
even (c - b)

goal (2 subgoals):
 1. even (c - b) \<Longrightarrow> False
 2. even (c + b) \<Longrightarrow> False
[PROOF STEP]
with a2factor
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = (c - b) * (c + b)
even (c - b)
[PROOF STEP]
have "2 dvd a^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = (c - b) * (c + b)
even (c - b)

goal (1 subgoal):
 1. even (a\<^sup>2)
[PROOF STEP]
by (simp only: dvd_mult2)
[PROOF STATE]
proof (state)
this:
even (a\<^sup>2)

goal (2 subgoals):
 1. even (c - b) \<Longrightarrow> False
 2. even (c + b) \<Longrightarrow> False
[PROOF STEP]
with p2
[PROOF STATE]
proof (chain)
picking this:
prime 2
even (a\<^sup>2)
[PROOF STEP]
have "2 dvd a"
[PROOF STATE]
proof (prove)
using this:
prime 2
even (a\<^sup>2)

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

goal (2 subgoals):
 1. even (c - b) \<Longrightarrow> False
 2. even (c + b) \<Longrightarrow> False
[PROOF STEP]
with aodd
[PROOF STATE]
proof (chain)
picking this:
odd a
even a
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
odd a
even a

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

goal (1 subgoal):
 1. even (c + b) \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. even (c + b) \<Longrightarrow> False
[PROOF STEP]
assume "even (c+b)"
[PROOF STATE]
proof (state)
this:
even (c + b)

goal (1 subgoal):
 1. even (c + b) \<Longrightarrow> False
[PROOF STEP]
with a2factor
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = (c - b) * (c + b)
even (c + b)
[PROOF STEP]
have "2 dvd a^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = (c - b) * (c + b)
even (c + b)

goal (1 subgoal):
 1. even (a\<^sup>2)
[PROOF STEP]
by (simp only: dvd_mult)
[PROOF STATE]
proof (state)
this:
even (a\<^sup>2)

goal (1 subgoal):
 1. even (c + b) \<Longrightarrow> False
[PROOF STEP]
with p2
[PROOF STATE]
proof (chain)
picking this:
prime 2
even (a\<^sup>2)
[PROOF STEP]
have "2 dvd a"
[PROOF STATE]
proof (prove)
using this:
prime 2
even (a\<^sup>2)

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

goal (1 subgoal):
 1. even (c + b) \<Longrightarrow> False
[PROOF STEP]
with aodd
[PROOF STATE]
proof (chain)
picking this:
odd a
even a
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
odd a
even a

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:
odd (c - b) \<and> odd (c + b)

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have cb1: "c-b + (c+b) = 2*c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
have "c-b + (c+b) = ((c-b)+b)+c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c - b + (c + b) = c - b + b + c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = c - b + b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = c - b + b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
with b_less_c
[PROOF STATE]
proof (chain)
picking this:
b < c
c - b + (c + b) = c - b + b + c
[PROOF STEP]
have "\<dots> = (c+b-b)+c"
[PROOF STATE]
proof (prove)
using this:
b < c
c - b + (c + b) = c - b + b + c

goal (1 subgoal):
 1. c - b + b + c = c + b - b + c
[PROOF STEP]
by (simp only: diff_add_assoc2)
[PROOF STATE]
proof (state)
this:
c - b + b + c = c + b - b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c - b + b + c = c + b - b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
have "\<dots> = c+c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c + b - b + c = c + c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c + b - b + c = c + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
c - b + (c + b) = c + c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c - b + (c + b) = c + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = 2 * c

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = 2 * c

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have cb2: "2*b + (c-b) = c+b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
have "2*b + (c-b) = b+b + (c - b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * b + (c - b) = b + b + (c - b)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 * b + (c - b) = b + b + (c - b)

goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * b + (c - b) = b + b + (c - b)

goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
have "\<dots> = b + ((c-b)+b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b + b + (c - b) = b + (c - b + b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
b + b + (c - b) = b + (c - b + b)

goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
b + b + (c - b) = b + (c - b + b)

goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
with b_less_c
[PROOF STATE]
proof (chain)
picking this:
b < c
b + b + (c - b) = b + (c - b + b)
[PROOF STEP]
have " \<dots> = b + (c+b-b)"
[PROOF STATE]
proof (prove)
using this:
b < c
b + b + (c - b) = b + (c - b + b)

goal (1 subgoal):
 1. b + (c - b + b) = b + (c + b - b)
[PROOF STEP]
by (simp only: diff_add_assoc2)
[PROOF STATE]
proof (state)
this:
b + (c - b + b) = b + (c + b - b)

goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 * b + (c - b) = b + (c + b - b)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 * b + (c - b) = b + (c + b - b)

goal (1 subgoal):
 1. 2 * b + (c - b) = c + b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * b + (c - b) = c + b

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
2 * b + (c - b) = c + b

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have factors_relprime: "coprime (c-b) (c+b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
let ?g = "gcd (c-b) (c+b)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
have cb1: "c-b + (c+b) = 2*c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
have "c-b + (c+b) = ((c-b)+b)+c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c - b + (c + b) = c - b + b + c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = c - b + b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = c - b + b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
with b_less_c
[PROOF STATE]
proof (chain)
picking this:
b < c
c - b + (c + b) = c - b + b + c
[PROOF STEP]
have "\<dots> = (c+b-b)+c"
[PROOF STATE]
proof (prove)
using this:
b < c
c - b + (c + b) = c - b + b + c

goal (1 subgoal):
 1. c - b + b + c = c + b - b + c
[PROOF STEP]
by (simp only: diff_add_assoc2)
[PROOF STATE]
proof (state)
this:
c - b + b + c = c + b - b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
c - b + b + c = c + b - b + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
have "\<dots> = c+c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c + b - b + c = c + c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c + b - b + c = c + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
c - b + (c + b) = c + c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c - b + (c + b) = c + c

goal (1 subgoal):
 1. c - b + (c + b) = 2 * c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = 2 * c

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
c - b + (c + b) = 2 * c

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
have "?g = gcd (c-b + (c+b)) (c+b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (c - b) (c + b) = gcd (c - b + (c + b)) (c + b)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = gcd (c - b + (c + b)) (c + b)

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
with cb1
[PROOF STATE]
proof (chain)
picking this:
c - b + (c + b) = 2 * c
gcd (c - b) (c + b) = gcd (c - b + (c + b)) (c + b)
[PROOF STEP]
have "?g = gcd (2*c) (c+b)"
[PROOF STATE]
proof (prove)
using this:
c - b + (c + b) = 2 * c
gcd (c - b) (c + b) = gcd (c - b + (c + b)) (c + b)

goal (1 subgoal):
 1. gcd (c - b) (c + b) = gcd (2 * c) (c + b)
[PROOF STEP]
by (rule_tac a="c-b + (c+b)" in back_subst)
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = gcd (2 * c) (c + b)

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
hence g2c: "?g dvd 2*c"
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) = gcd (2 * c) (c + b)

goal (1 subgoal):
 1. gcd (c - b) (c + b) dvd 2 * c
[PROOF STEP]
by (simp only: gcd_dvd1)
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) dvd 2 * c

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
have "gcd (c-b) (2*b + (c-b)) = gcd (c-b) (2*b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (c - b) (2 * b + (c - b)) = gcd (c - b) (2 * b)
[PROOF STEP]
using gcd_add2[of "c - b" "2*b + (c - b)"]
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c - b + (2 * b + (c - b))) = gcd (c - b) (2 * b + (c - b))

goal (1 subgoal):
 1. gcd (c - b) (2 * b + (c - b)) = gcd (c - b) (2 * b)
[PROOF STEP]
by (simp add: algebra_simps)
[PROOF STATE]
proof (state)
this:
gcd (c - b) (2 * b + (c - b)) = gcd (c - b) (2 * b)

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
with cb2
[PROOF STATE]
proof (chain)
picking this:
2 * b + (c - b) = c + b
gcd (c - b) (2 * b + (c - b)) = gcd (c - b) (2 * b)
[PROOF STEP]
have "?g = gcd (c-b) (2*b)"
[PROOF STATE]
proof (prove)
using this:
2 * b + (c - b) = c + b
gcd (c - b) (2 * b + (c - b)) = gcd (c - b) (2 * b)

goal (1 subgoal):
 1. gcd (c - b) (c + b) = gcd (c - b) (2 * b)
[PROOF STEP]
by (rule_tac a="2*b + (c-b)" in back_subst)
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = gcd (c - b) (2 * b)

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
hence g2b: "?g dvd 2*b"
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) = gcd (c - b) (2 * b)

goal (1 subgoal):
 1. gcd (c - b) (c + b) dvd 2 * b
[PROOF STEP]
by (simp only: gcd_dvd2)
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) dvd 2 * b

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
with g2c
[PROOF STATE]
proof (chain)
picking this:
gcd (c - b) (c + b) dvd 2 * c
gcd (c - b) (c + b) dvd 2 * b
[PROOF STEP]
have "?g dvd 2 * gcd b c"
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) dvd 2 * c
gcd (c - b) (c + b) dvd 2 * b

goal (1 subgoal):
 1. gcd (c - b) (c + b) dvd 2 * gcd b c
[PROOF STEP]
by (simp only: gcd_greatest gcd_mult_distrib_nat)
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) dvd 2 * gcd b c

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
with bc_relprime
[PROOF STATE]
proof (chain)
picking this:
coprime b c
gcd (c - b) (c + b) dvd 2 * gcd b c
[PROOF STEP]
have "?g dvd 2"
[PROOF STATE]
proof (prove)
using this:
coprime b c
gcd (c - b) (c + b) dvd 2 * gcd b c

goal (1 subgoal):
 1. gcd (c - b) (c + b) dvd 2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) dvd 2

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) dvd 2

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
have "?g \<noteq> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (c - b) (c + b) \<noteq> 0
[PROOF STEP]
using b_less_c
[PROOF STATE]
proof (prove)
using this:
b < c

goal (1 subgoal):
 1. gcd (c - b) (c + b) \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) \<noteq> 0

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
gcd (c - b) (c + b) dvd 2
gcd (c - b) (c + b) \<noteq> 0
[PROOF STEP]
have "1 \<le> ?g" "?g \<le> 2"
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) dvd 2
gcd (c - b) (c + b) \<noteq> 0

goal (1 subgoal):
 1. 1 \<le> gcd (c - b) (c + b) &&& gcd (c - b) (c + b) \<le> 2
[PROOF STEP]
by (simp_all add: dvd_imp_le)
[PROOF STATE]
proof (state)
this:
1 \<le> gcd (c - b) (c + b)
gcd (c - b) (c + b) \<le> 2

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
1 \<le> gcd (c - b) (c + b)
gcd (c - b) (c + b) \<le> 2
[PROOF STEP]
have g1or2: "?g = 2 \<or> ?g = 1"
[PROOF STATE]
proof (prove)
using this:
1 \<le> gcd (c - b) (c + b)
gcd (c - b) (c + b) \<le> 2

goal (1 subgoal):
 1. gcd (c - b) (c + b) = 2 \<or> gcd (c - b) (c + b) = 1
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = 2 \<or> gcd (c - b) (c + b) = 1

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = 2 \<or> gcd (c - b) (c + b) = 1

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
have "?g \<noteq> 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (c - b) (c + b) \<noteq> 2
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. gcd (c - b) (c + b) = 2 \<Longrightarrow> False
[PROOF STEP]
assume "?g = 2"
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = 2

goal (1 subgoal):
 1. gcd (c - b) (c + b) = 2 \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) = 2

goal (1 subgoal):
 1. gcd (c - b) (c + b) = 2 \<Longrightarrow> False
[PROOF STEP]
have "?g dvd c - b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (c - b) (c + b) dvd c - b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd (c - b) (c + b) dvd c - b

goal (1 subgoal):
 1. gcd (c - b) (c + b) = 2 \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
gcd (c - b) (c + b) = 2
gcd (c - b) (c + b) dvd c - b
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) = 2
gcd (c - b) (c + b) dvd c - b

goal (1 subgoal):
 1. False
[PROOF STEP]
using factors_odd
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) = 2
gcd (c - b) (c + b) dvd c - b
odd (c - b) \<and> odd (c + b)

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:
gcd (c - b) (c + b) \<noteq> 2

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
gcd (c - b) (c + b) = 2 \<or> gcd (c - b) (c + b) = 1
gcd (c - b) (c + b) \<noteq> 2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
gcd (c - b) (c + b) = 2 \<or> gcd (c - b) (c + b) = 1
gcd (c - b) (c + b) \<noteq> 2

goal (1 subgoal):
 1. coprime (c - b) (c + b)
[PROOF STEP]
by (auto intro: gcd_eq_1_imp_coprime)
[PROOF STATE]
proof (state)
this:
coprime (c - b) (c + b)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime (c - b) (c + b)

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
from a2factor
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
have "(c-b)*(c+b) = a^2" and "(2::nat) >1"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = (c - b) * (c + b)

goal (1 subgoal):
 1. (c - b) * (c + b) = a\<^sup>2 &&& 1 < 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(c - b) * (c + b) = a\<^sup>2
1 < 2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
with factors_relprime
[PROOF STATE]
proof (chain)
picking this:
coprime (c - b) (c + b)
(c - b) * (c + b) = a\<^sup>2
1 < 2
[PROOF STEP]
have "\<exists> k. c-b = k^2"
[PROOF STATE]
proof (prove)
using this:
coprime (c - b) (c + b)
(c - b) * (c + b) = a\<^sup>2
1 < 2

goal (1 subgoal):
 1. \<exists>k. c - b = k\<^sup>2
[PROOF STEP]
by (simp only: nat_relprime_power_divisors)
[PROOF STATE]
proof (state)
this:
\<exists>k. c - b = k\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. c - b = k\<^sup>2
[PROOF STEP]
obtain r where r: "c-b = r^2"
[PROOF STATE]
proof (prove)
using this:
\<exists>k. c - b = k\<^sup>2

goal (1 subgoal):
 1. (\<And>r. c - b = r\<^sup>2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c - b = r\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
from a2factor
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = (c - b) * (c + b)
[PROOF STEP]
have "(c+b)*(c-b) = a^2" and "(2::nat) >1"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = (c - b) * (c + b)

goal (1 subgoal):
 1. (c + b) * (c - b) = a\<^sup>2 &&& 1 < 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(c + b) * (c - b) = a\<^sup>2
1 < 2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
with factors_relprime
[PROOF STATE]
proof (chain)
picking this:
coprime (c - b) (c + b)
(c + b) * (c - b) = a\<^sup>2
1 < 2
[PROOF STEP]
have "\<exists> k. c+b = k^2"
[PROOF STATE]
proof (prove)
using this:
coprime (c - b) (c + b)
(c + b) * (c - b) = a\<^sup>2
1 < 2

goal (1 subgoal):
 1. \<exists>k. c + b = k\<^sup>2
[PROOF STEP]
by (simp only: nat_relprime_power_divisors ac_simps)
[PROOF STATE]
proof (state)
this:
\<exists>k. c + b = k\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>k. c + b = k\<^sup>2
[PROOF STEP]
obtain s where s: "c+b = s^2"
[PROOF STATE]
proof (prove)
using this:
\<exists>k. c + b = k\<^sup>2

goal (1 subgoal):
 1. (\<And>s. c + b = s\<^sup>2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
  \<comment> \<open>now $p := (s+r)/2$ and $q := (s-r)/2$ is our solution\<close>
[PROOF STATE]
proof (state)
this:
c + b = s\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have rs_odd: "odd r \<and> odd s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd r \<and> odd s
[PROOF STEP]
proof (auto dest: ccontr)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. even r \<Longrightarrow> False
 2. even s \<Longrightarrow> False
[PROOF STEP]
assume "even r"
[PROOF STATE]
proof (state)
this:
even r

goal (2 subgoals):
 1. even r \<Longrightarrow> False
 2. even s \<Longrightarrow> False
[PROOF STEP]
hence "2 dvd r"
[PROOF STATE]
proof (prove)
using this:
even r

goal (1 subgoal):
 1. even r
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
even r

goal (2 subgoals):
 1. even r \<Longrightarrow> False
 2. even s \<Longrightarrow> False
[PROOF STEP]
with r
[PROOF STATE]
proof (chain)
picking this:
c - b = r\<^sup>2
even r
[PROOF STEP]
have  "2 dvd (c-b)"
[PROOF STATE]
proof (prove)
using this:
c - b = r\<^sup>2
even r

goal (1 subgoal):
 1. even (c - b)
[PROOF STEP]
by (simp only: power2_eq_square dvd_mult)
[PROOF STATE]
proof (state)
this:
even (c - b)

goal (2 subgoals):
 1. even r \<Longrightarrow> False
 2. even s \<Longrightarrow> False
[PROOF STEP]
with factors_odd
[PROOF STATE]
proof (chain)
picking this:
odd (c - b) \<and> odd (c + b)
even (c - b)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
odd (c - b) \<and> odd (c + b)
even (c - b)

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

goal (1 subgoal):
 1. even s \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. even s \<Longrightarrow> False
[PROOF STEP]
assume "even s"
[PROOF STATE]
proof (state)
this:
even s

goal (1 subgoal):
 1. even s \<Longrightarrow> False
[PROOF STEP]
hence "2 dvd s"
[PROOF STATE]
proof (prove)
using this:
even s

goal (1 subgoal):
 1. even s
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
even s

goal (1 subgoal):
 1. even s \<Longrightarrow> False
[PROOF STEP]
with s
[PROOF STATE]
proof (chain)
picking this:
c + b = s\<^sup>2
even s
[PROOF STEP]
have "2 dvd (c+b)"
[PROOF STATE]
proof (prove)
using this:
c + b = s\<^sup>2
even s

goal (1 subgoal):
 1. even (c + b)
[PROOF STEP]
by (simp only: power2_eq_square dvd_mult)
[PROOF STATE]
proof (state)
this:
even (c + b)

goal (1 subgoal):
 1. even s \<Longrightarrow> False
[PROOF STEP]
with factors_odd
[PROOF STATE]
proof (chain)
picking this:
odd (c - b) \<and> odd (c + b)
even (c + b)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
odd (c - b) \<and> odd (c + b)
even (c + b)

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:
odd r \<and> odd s

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
obtain m where m: "m = s-r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. m = s - r \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
m = s - r

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
from r s
[PROOF STATE]
proof (chain)
picking this:
c - b = r\<^sup>2
c + b = s\<^sup>2
[PROOF STEP]
have "r^2 \<le> s^2"
[PROOF STATE]
proof (prove)
using this:
c - b = r\<^sup>2
c + b = s\<^sup>2

goal (1 subgoal):
 1. r\<^sup>2 \<le> s\<^sup>2
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
r\<^sup>2 \<le> s\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
with two0
[PROOF STATE]
proof (chain)
picking this:
2 \<noteq> 0
r\<^sup>2 \<le> s\<^sup>2
[PROOF STEP]
have "r \<le> s"
[PROOF STATE]
proof (prove)
using this:
2 \<noteq> 0
r\<^sup>2 \<le> s\<^sup>2

goal (1 subgoal):
 1. r \<le> s
[PROOF STEP]
by (rule_tac n="2" in nat_power_le_imp_le_base)
[PROOF STATE]
proof (state)
this:
r \<le> s

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
with m
[PROOF STATE]
proof (chain)
picking this:
m = s - r
r \<le> s
[PROOF STEP]
have m2: "s = r + m"
[PROOF STATE]
proof (prove)
using this:
m = s - r
r \<le> s

goal (1 subgoal):
 1. s = r + m
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
s = r + m

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have "even m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even m
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. odd m \<Longrightarrow> False
[PROOF STEP]
assume "odd m"
[PROOF STATE]
proof (state)
this:
odd m

goal (1 subgoal):
 1. odd m \<Longrightarrow> False
[PROOF STEP]
with rs_odd and m2
[PROOF STATE]
proof (chain)
picking this:
odd r \<and> odd s
s = r + m
odd m
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
odd r \<and> odd s
s = r + m
odd m

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

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

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
even m
[PROOF STEP]
obtain q where "m = 2*q"
[PROOF STATE]
proof (prove)
using this:
even m

goal (1 subgoal):
 1. (\<And>q. m = 2 * q \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
m = 2 * q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
with m2
[PROOF STATE]
proof (chain)
picking this:
s = r + m
m = 2 * q
[PROOF STEP]
have q: "s = r + 2*q"
[PROOF STATE]
proof (prove)
using this:
s = r + m
m = 2 * q

goal (1 subgoal):
 1. s = r + 2 * q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
s = r + 2 * q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
obtain p where p: "p = r+q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p. p = r + q \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
p = r + q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have c: "c = p^2 + q^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
from cb1 and r and s
[PROOF STATE]
proof (chain)
picking this:
c - b + (c + b) = 2 * c
c - b = r\<^sup>2
c + b = s\<^sup>2
[PROOF STEP]
have "2*c = r^2 + s^2"
[PROOF STATE]
proof (prove)
using this:
c - b + (c + b) = 2 * c
c - b = r\<^sup>2
c + b = s\<^sup>2

goal (1 subgoal):
 1. 2 * c = r\<^sup>2 + s\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 * c = r\<^sup>2 + s\<^sup>2

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * c = r\<^sup>2 + s\<^sup>2

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
with q
[PROOF STATE]
proof (chain)
picking this:
s = r + 2 * q
2 * c = r\<^sup>2 + s\<^sup>2
[PROOF STEP]
have "\<dots> = 2*r^2+(2*q)^2+2*r*(2*q)"
[PROOF STATE]
proof (prove)
using this:
s = r + 2 * q
2 * c = r\<^sup>2 + s\<^sup>2

goal (1 subgoal):
 1. r\<^sup>2 + s\<^sup>2 = 2 * r\<^sup>2 + (2 * q)\<^sup>2 + 2 * r * (2 * q)
[PROOF STEP]
by algebra
[PROOF STATE]
proof (state)
this:
r\<^sup>2 + s\<^sup>2 = 2 * r\<^sup>2 + (2 * q)\<^sup>2 + 2 * r * (2 * q)

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
r\<^sup>2 + s\<^sup>2 = 2 * r\<^sup>2 + (2 * q)\<^sup>2 + 2 * r * (2 * q)

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
have "\<dots> = 2*r^2+2^2*q^2+2*2*q*r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * r\<^sup>2 + (2 * q)\<^sup>2 + 2 * r * (2 * q) = 2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r
[PROOF STEP]
by (simp add: power_mult_distrib)
[PROOF STATE]
proof (state)
this:
2 * r\<^sup>2 + (2 * q)\<^sup>2 + 2 * r * (2 * q) = 2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * r\<^sup>2 + (2 * q)\<^sup>2 + 2 * r * (2 * q) = 2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
have "\<dots> = 2*(r^2+2*q*r+q^2)+2*q^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r = 2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r = 2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r = 2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
with p
[PROOF STATE]
proof (chain)
picking this:
p = r + q
2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r = 2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2
[PROOF STEP]
have "\<dots> = 2*p^2+2*q^2"
[PROOF STATE]
proof (prove)
using this:
p = r + q
2 * r\<^sup>2 + 2\<^sup>2 * q\<^sup>2 + 2 * 2 * q * r = 2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2

goal (1 subgoal):
 1. 2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2 = 2 * p\<^sup>2 + 2 * q\<^sup>2
[PROOF STEP]
by algebra
[PROOF STATE]
proof (state)
this:
2 * (r\<^sup>2 + 2 * q * r + q\<^sup>2) + 2 * q\<^sup>2 = 2 * p\<^sup>2 + 2 * q\<^sup>2

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 * c = 2 * p\<^sup>2 + 2 * q\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 * c = 2 * p\<^sup>2 + 2 * q\<^sup>2

goal (1 subgoal):
 1. c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
c = p\<^sup>2 + q\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
c = p\<^sup>2 + q\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
c = p\<^sup>2 + q\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have b: "b = 2*p*q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
from cb2 and r and s
[PROOF STATE]
proof (chain)
picking this:
2 * b + (c - b) = c + b
c - b = r\<^sup>2
c + b = s\<^sup>2
[PROOF STEP]
have "2*b = s^2 - r^2"
[PROOF STATE]
proof (prove)
using this:
2 * b + (c - b) = c + b
c - b = r\<^sup>2
c + b = s\<^sup>2

goal (1 subgoal):
 1. 2 * b = s\<^sup>2 - r\<^sup>2
[PROOF STEP]
by arith
[PROOF STATE]
proof (state)
this:
2 * b = s\<^sup>2 - r\<^sup>2

goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
2 * b = s\<^sup>2 - r\<^sup>2

goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
with q
[PROOF STATE]
proof (chain)
picking this:
s = r + 2 * q
2 * b = s\<^sup>2 - r\<^sup>2
[PROOF STEP]
have "\<dots> = (2*q)^2 + 2*r*(2*q)"
[PROOF STATE]
proof (prove)
using this:
s = r + 2 * q
2 * b = s\<^sup>2 - r\<^sup>2

goal (1 subgoal):
 1. s\<^sup>2 - r\<^sup>2 = (2 * q)\<^sup>2 + 2 * r * (2 * q)
[PROOF STEP]
by (simp add: power2_sum)
[PROOF STATE]
proof (state)
this:
s\<^sup>2 - r\<^sup>2 = (2 * q)\<^sup>2 + 2 * r * (2 * q)

goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
s\<^sup>2 - r\<^sup>2 = (2 * q)\<^sup>2 + 2 * r * (2 * q)

goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
with p
[PROOF STATE]
proof (chain)
picking this:
p = r + q
s\<^sup>2 - r\<^sup>2 = (2 * q)\<^sup>2 + 2 * r * (2 * q)
[PROOF STEP]
have "\<dots> = 4*q*p"
[PROOF STATE]
proof (prove)
using this:
p = r + q
s\<^sup>2 - r\<^sup>2 = (2 * q)\<^sup>2 + 2 * r * (2 * q)

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

goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
2 * b = 4 * q * p
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 * b = 4 * q * p

goal (1 subgoal):
 1. b = 2 * p * q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b = 2 * p * q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b = 2 * p * q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b = 2 * p * q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have a: "a = p^2 - q^2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
from p
[PROOF STATE]
proof (chain)
picking this:
p = r + q
[PROOF STEP]
have "p\<ge>q"
[PROOF STATE]
proof (prove)
using this:
p = r + q

goal (1 subgoal):
 1. q \<le> p
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
q \<le> p

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
hence p2_ge_q2: "p^2 \<ge> q^2"
[PROOF STATE]
proof (prove)
using this:
q \<le> p

goal (1 subgoal):
 1. q\<^sup>2 \<le> p\<^sup>2
[PROOF STEP]
by (simp only: power_mono)
[PROOF STATE]
proof (state)
this:
q\<^sup>2 \<le> p\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
from a2cb and b and c
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
b = 2 * p * q
c = p\<^sup>2 + q\<^sup>2
[PROOF STEP]
have "a^2 = (p^2 + q^2)^2 - (2*p*q)^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = c\<^sup>2 - b\<^sup>2
b = 2 * p * q
c = p\<^sup>2 + q\<^sup>2

goal (1 subgoal):
 1. a\<^sup>2 = (p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = (p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a\<^sup>2 = (p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
have "\<dots> = (p^2)^2 + (q^2)^2 - 2*(p^2)*(q^2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2 = (p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2
[PROOF STEP]
by (auto simp add: power2_sum power_mult_distrib ac_simps)
[PROOF STATE]
proof (state)
this:
(p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2 = (p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2 = (p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
with p2_ge_q2
[PROOF STATE]
proof (chain)
picking this:
q\<^sup>2 \<le> p\<^sup>2
(p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2 = (p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2
[PROOF STEP]
have "\<dots> = (p^2 - q^2)^2"
[PROOF STATE]
proof (prove)
using this:
q\<^sup>2 \<le> p\<^sup>2
(p\<^sup>2 + q\<^sup>2)\<^sup>2 - (2 * p * q)\<^sup>2 = (p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2

goal (1 subgoal):
 1. (p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2 = (p\<^sup>2 - q\<^sup>2)\<^sup>2
[PROOF STEP]
by (simp only: nat_power2_diff)
[PROOF STATE]
proof (state)
this:
(p\<^sup>2)\<^sup>2 + (q\<^sup>2)\<^sup>2 - 2 * p\<^sup>2 * q\<^sup>2 = (p\<^sup>2 - q\<^sup>2)\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a\<^sup>2 = (p\<^sup>2 - q\<^sup>2)\<^sup>2
[PROOF STEP]
have "a^2 = (p^2 - q^2)^2"
[PROOF STATE]
proof (prove)
using this:
a\<^sup>2 = (p\<^sup>2 - q\<^sup>2)\<^sup>2

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

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
with two0
[PROOF STATE]
proof (chain)
picking this:
2 \<noteq> 0
a\<^sup>2 = (p\<^sup>2 - q\<^sup>2)\<^sup>2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
2 \<noteq> 0
a\<^sup>2 = (p\<^sup>2 - q\<^sup>2)\<^sup>2

goal (1 subgoal):
 1. a = p\<^sup>2 - q\<^sup>2
[PROOF STEP]
by (rule_tac n="2" in nat_power_inject_base)
[PROOF STATE]
proof (state)
this:
a = p\<^sup>2 - q\<^sup>2

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a = p\<^sup>2 - q\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
a = p\<^sup>2 - q\<^sup>2

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
have "coprime p q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
let ?k = "gcd p q"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
have "?k dvd p \<and> ?k dvd q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd p q dvd p \<and> gcd p q dvd q
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
gcd p q dvd p \<and> gcd p q dvd q

goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
with b and a
[PROOF STATE]
proof (chain)
picking this:
b = 2 * p * q
a = p\<^sup>2 - q\<^sup>2
gcd p q dvd p \<and> gcd p q dvd q
[PROOF STEP]
have "?k dvd a \<and> ?k dvd b"
[PROOF STATE]
proof (prove)
using this:
b = 2 * p * q
a = p\<^sup>2 - q\<^sup>2
gcd p q dvd p \<and> gcd p q dvd q

goal (1 subgoal):
 1. gcd p q dvd a \<and> gcd p q dvd b
[PROOF STEP]
by (simp add: power2_eq_square)
[PROOF STATE]
proof (state)
this:
gcd p q dvd a \<and> gcd p q dvd b

goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
hence "?k dvd gcd a b"
[PROOF STATE]
proof (prove)
using this:
gcd p q dvd a \<and> gcd p q dvd b

goal (1 subgoal):
 1. gcd p q dvd gcd a b
[PROOF STEP]
by (simp only: gcd_greatest)
[PROOF STATE]
proof (state)
this:
gcd p q dvd gcd a b

goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
with ab_relprime
[PROOF STATE]
proof (chain)
picking this:
coprime a b
gcd p q dvd gcd a b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
coprime a b
gcd p q dvd gcd a b

goal (1 subgoal):
 1. coprime p q
[PROOF STEP]
by (auto intro: gcd_eq_1_imp_coprime)
[PROOF STATE]
proof (state)
this:
coprime p q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime p q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
c = p\<^sup>2 + q\<^sup>2
b = 2 * p * q
a = p\<^sup>2 - q\<^sup>2
coprime p q
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c = p\<^sup>2 + q\<^sup>2
b = 2 * p * q
a = p\<^sup>2 - q\<^sup>2
coprime p q

goal (1 subgoal):
 1. \<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>p q. a = p\<^sup>2 - q\<^sup>2 \<and> b = 2 * p * q \<and> c = p\<^sup>2 + q\<^sup>2 \<and> coprime p q

goal:
No subgoals!
[PROOF STEP]
qed