[STATEMENT]
lemma primitive_pythagorean_tripleE_int:
  assumes "z ^ 2 = x ^ 2 + y ^ 2"
  assumes "coprime x y"
  obtains u v :: int
    where "coprime u v" and "\<not>(odd u \<and> odd v)"
      and "x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2  \<or>  x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "\<not>(even x \<and> even y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (even x \<and> even y)
[PROOF STEP]
using not_coprimeI[of 2 x y] \<open>coprime x y\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>even x; even y; \<not> is_unit 2\<rbrakk> \<Longrightarrow> \<not> coprime x y
coprime x y

goal (1 subgoal):
 1. \<not> (even x \<and> even y)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<not> (even x \<and> even y)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<not> (even x \<and> even y)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "\<not>(odd x \<and> odd y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (odd x \<and> odd y)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>odd x; odd y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "odd x" "odd y"
[PROOF STATE]
proof (state)
this:
odd x
odd y

goal (1 subgoal):
 1. \<lbrakk>odd x; odd y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "[x ^ 2 + y ^ 2 = 1 + 1] (mod 4)"
[PROOF STATE]
proof (prove)
using this:
odd x
odd y

goal (1 subgoal):
 1. [x\<^sup>2 + y\<^sup>2 = 1 + 1] (mod 4)
[PROOF STEP]
by (intro cong_add odd_square_cong_4_int)
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 + y\<^sup>2 = 1 + 1] (mod 4)

goal (1 subgoal):
 1. \<lbrakk>odd x; odd y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "[z ^ 2 = 2] (mod 4)"
[PROOF STATE]
proof (prove)
using this:
[x\<^sup>2 + y\<^sup>2 = 1 + 1] (mod 4)

goal (1 subgoal):
 1. [z\<^sup>2 = 2] (mod 4)
[PROOF STEP]
by (simp add: assms)
[PROOF STATE]
proof (state)
this:
[z\<^sup>2 = 2] (mod 4)

goal (1 subgoal):
 1. \<lbrakk>odd x; odd y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
[z\<^sup>2 = 2] (mod 4)

goal (1 subgoal):
 1. \<lbrakk>odd x; odd y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
have "[z ^ 2 = 0] (mod 4) \<or> [z ^ 2 = 1] (mod 4)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [z\<^sup>2 = 0] (mod 4) \<or> [z\<^sup>2 = 1] (mod 4)
[PROOF STEP]
using even_square_cong_4_int[of z] odd_square_cong_4_int[of z]
[PROOF STATE]
proof (prove)
using this:
even z \<Longrightarrow> [z\<^sup>2 = 0] (mod 4)
odd z \<Longrightarrow> [z\<^sup>2 = 1] (mod 4)

goal (1 subgoal):
 1. [z\<^sup>2 = 0] (mod 4) \<or> [z\<^sup>2 = 1] (mod 4)
[PROOF STEP]
by (cases "even z") auto
[PROOF STATE]
proof (state)
this:
[z\<^sup>2 = 0] (mod 4) \<or> [z\<^sup>2 = 1] (mod 4)

goal (1 subgoal):
 1. \<lbrakk>odd x; odd y\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
[z\<^sup>2 = 2] (mod 4)
[z\<^sup>2 = 0] (mod 4) \<or> [z\<^sup>2 = 1] (mod 4)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
[z\<^sup>2 = 2] (mod 4)
[z\<^sup>2 = 0] (mod 4) \<or> [z\<^sup>2 = 1] (mod 4)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> (odd x \<and> odd y)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<not> (even x \<and> even y)
\<not> (odd x \<and> odd y)
[PROOF STEP]
have "even y \<longleftrightarrow> odd x"
[PROOF STATE]
proof (prove)
using this:
\<not> (even x \<and> even y)
\<not> (odd x \<and> odd y)

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

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "even z \<longleftrightarrow> even (z ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even z = even (z\<^sup>2)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
even z = even (z\<^sup>2)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
even z = even (z\<^sup>2)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "even (z ^ 2) \<longleftrightarrow> even (x ^ 2 + y ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even (z\<^sup>2) = even (x\<^sup>2 + y\<^sup>2)
[PROOF STEP]
by (subst assms(1)) auto
[PROOF STATE]
proof (state)
this:
even (z\<^sup>2) = even (x\<^sup>2 + y\<^sup>2)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
even z = even (x\<^sup>2 + y\<^sup>2)
[PROOF STEP]
have "odd z"
[PROOF STATE]
proof (prove)
using this:
even z = even (x\<^sup>2 + y\<^sup>2)

goal (1 subgoal):
 1. odd z
[PROOF STEP]
by (cases "even x") (auto simp: \<open>even y \<longleftrightarrow> \<not>even x\<close>)
[PROOF STATE]
proof (state)
this:
odd z

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
define t where "t = of_int x + \<i>\<^sub>\<int> * of_int y"
[PROOF STATE]
proof (state)
this:
t = of_int x + gauss_i * of_int y

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
z\<^sup>2 = x\<^sup>2 + y\<^sup>2
coprime x y
[PROOF STEP]
have t_mult_cnj: "t * gauss_cnj t = of_int z ^ 2"
[PROOF STATE]
proof (prove)
using this:
z\<^sup>2 = x\<^sup>2 + y\<^sup>2
coprime x y

goal (1 subgoal):
 1. t * gauss_cnj t = (of_int z)\<^sup>2
[PROOF STEP]
by (simp add: t_def power2_eq_square algebra_simps flip: of_int_mult of_int_add)
[PROOF STATE]
proof (state)
this:
t * gauss_cnj t = (of_int z)\<^sup>2

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "gauss_int_norm t = z ^ 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. int (gauss_int_norm t) = z\<^sup>2
[PROOF STEP]
by (simp add: gauss_int_norm_def t_def assms)
[PROOF STATE]
proof (state)
this:
int (gauss_int_norm t) = z\<^sup>2

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
with \<open>coprime x y\<close> and \<open>odd z\<close>
[PROOF STATE]
proof (chain)
picking this:
coprime x y
odd z
int (gauss_int_norm t) = z\<^sup>2
[PROOF STEP]
have "coprime t (gauss_cnj t)"
[PROOF STATE]
proof (prove)
using this:
coprime x y
odd z
int (gauss_int_norm t) = z\<^sup>2

goal (1 subgoal):
 1. coprime t (gauss_cnj t)
[PROOF STEP]
by (intro coprime_self_gauss_cnj)
       (auto simp: t_def gauss_int_norm_def assms(1) [symmetric] even_nat_iff)
[PROOF STATE]
proof (state)
this:
coprime t (gauss_cnj t)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
coprime t (gauss_cnj t)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "is_square (t * gauss_cnj t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_square (t * gauss_cnj t)
[PROOF STEP]
by (subst t_mult_cnj) auto
[PROOF STATE]
proof (state)
this:
is_square (t * gauss_cnj t)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
hence "is_nth_power_upto_unit 2 (t * gauss_cnj t)"
[PROOF STATE]
proof (prove)
using this:
is_square (t * gauss_cnj t)

goal (1 subgoal):
 1. is_nth_power_upto_unit 2 (t * gauss_cnj t)
[PROOF STEP]
by (auto intro: is_nth_power_upto_unit_base)
[PROOF STATE]
proof (state)
this:
is_nth_power_upto_unit 2 (t * gauss_cnj t)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
coprime t (gauss_cnj t)
is_nth_power_upto_unit 2 (t * gauss_cnj t)
[PROOF STEP]
have "is_nth_power_upto_unit 2 t"
[PROOF STATE]
proof (prove)
using this:
coprime t (gauss_cnj t)
is_nth_power_upto_unit 2 (t * gauss_cnj t)

goal (1 subgoal):
 1. is_nth_power_upto_unit 2 t
[PROOF STEP]
by (rule is_nth_power_upto_unit_mult_coprimeD1)
[PROOF STATE]
proof (state)
this:
is_nth_power_upto_unit 2 t

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_nth_power_upto_unit 2 t
[PROOF STEP]
obtain a b where ab: "is_unit a" "a * t = b ^ 2"
[PROOF STATE]
proof (prove)
using this:
is_nth_power_upto_unit 2 t

goal (1 subgoal):
 1. (\<And>a b. \<lbrakk>is_unit a; a * t = b\<^sup>2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (auto simp: is_nth_power_upto_unit_def is_nth_power_def)
[PROOF STATE]
proof (state)
this:
is_unit a
a * t = b\<^sup>2

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
from ab(1)
[PROOF STATE]
proof (chain)
picking this:
is_unit a
[PROOF STEP]
have "a \<in> {1, -1, \<i>\<^sub>\<int>, -\<i>\<^sub>\<int>}"
[PROOF STATE]
proof (prove)
using this:
is_unit a

goal (1 subgoal):
 1. a \<in> {1, - 1, gauss_i, - gauss_i}
[PROOF STEP]
by (auto simp: is_unit_gauss_int_iff)
[PROOF STATE]
proof (state)
this:
a \<in> {1, - 1, gauss_i, - gauss_i}

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<in> {1, - 1, gauss_i, - gauss_i}
[PROOF STEP]
obtain u v :: int where "ReZ t = 2 * u * v \<and> ImZ t = u ^ 2 - v ^ 2 \<or>
                                ImZ t = 2 * u * v \<and> ReZ t = u ^ 2 - v ^ 2"
[PROOF STATE]
proof (prove)
using this:
a \<in> {1, - 1, gauss_i, - gauss_i}

goal (1 subgoal):
 1. (\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (4 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 4. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
assume [simp]: "a = 1"
[PROOF STATE]
proof (state)
this:
a = 1

goal (4 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 4. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "ReZ t = ReZ b ^ 2 - ImZ b ^ 2" "ImZ t = 2 * ReZ b * ImZ b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ReZ t = (ReZ b)\<^sup>2 - (ImZ b)\<^sup>2 &&& ImZ t = 2 * ReZ b * ImZ b
[PROOF STEP]
using ab(2)
[PROOF STATE]
proof (prove)
using this:
a * t = b\<^sup>2

goal (1 subgoal):
 1. ReZ t = (ReZ b)\<^sup>2 - (ImZ b)\<^sup>2 &&& ImZ t = 2 * ReZ b * ImZ b
[PROOF STEP]
by (auto simp: gauss_int_eq_iff power2_eq_square)
[PROOF STATE]
proof (state)
this:
ReZ t = (ReZ b)\<^sup>2 - (ImZ b)\<^sup>2
ImZ t = 2 * ReZ b * ImZ b

goal (4 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 4. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ReZ t = (ReZ b)\<^sup>2 - (ImZ b)\<^sup>2
ImZ t = 2 * ReZ b * ImZ b

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
ReZ t = (ReZ b)\<^sup>2 - (ImZ b)\<^sup>2
ImZ t = 2 * ReZ b * ImZ b
ReZ t = 2 * ?u * ?v \<and> ImZ t = ?u\<^sup>2 - ?v\<^sup>2 \<or> ImZ t = 2 * ?u * ?v \<and> ReZ t = ?u\<^sup>2 - ?v\<^sup>2 \<Longrightarrow> thesis

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

goal (3 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
assume [simp]: "a = -1"
[PROOF STATE]
proof (state)
this:
a = - 1

goal (3 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have "ReZ t = ImZ b ^ 2 - (-ReZ b) ^ 2" "ImZ t = 2 * ImZ b * (-ReZ b)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ReZ t = (ImZ b)\<^sup>2 - (- ReZ b)\<^sup>2 &&& ImZ t = 2 * ImZ b * - ReZ b
[PROOF STEP]
using ab(2)
[PROOF STATE]
proof (prove)
using this:
a * t = b\<^sup>2

goal (1 subgoal):
 1. ReZ t = (ImZ b)\<^sup>2 - (- ReZ b)\<^sup>2 &&& ImZ t = 2 * ImZ b * - ReZ b
[PROOF STEP]
by (auto simp: gauss_int_eq_iff power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
ReZ t = (ImZ b)\<^sup>2 - (- ReZ b)\<^sup>2
ImZ t = 2 * ImZ b * - ReZ b

goal (3 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - 1\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 3. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ReZ t = (ImZ b)\<^sup>2 - (- ReZ b)\<^sup>2
ImZ t = 2 * ImZ b * - ReZ b

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
ReZ t = (ImZ b)\<^sup>2 - (- ReZ b)\<^sup>2
ImZ t = 2 * ImZ b * - ReZ b
ReZ t = 2 * ?u * ?v \<and> ImZ t = ?u\<^sup>2 - ?v\<^sup>2 \<or> ImZ t = 2 * ?u * ?v \<and> ReZ t = ?u\<^sup>2 - ?v\<^sup>2 \<Longrightarrow> thesis

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

goal (2 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
assume [simp]: "a = \<i>\<^sub>\<int>"
[PROOF STATE]
proof (state)
this:
a = gauss_i

goal (2 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence "ImZ t = ImZ b ^ 2 - ReZ b ^ 2" "ReZ t = 2 * ImZ b * ReZ b"
[PROOF STATE]
proof (prove)
using this:
a = gauss_i

goal (1 subgoal):
 1. ImZ t = (ImZ b)\<^sup>2 - (ReZ b)\<^sup>2 &&& ReZ t = 2 * ImZ b * ReZ b
[PROOF STEP]
using ab(2)
[PROOF STATE]
proof (prove)
using this:
a = gauss_i
a * t = b\<^sup>2

goal (1 subgoal):
 1. ImZ t = (ImZ b)\<^sup>2 - (ReZ b)\<^sup>2 &&& ReZ t = 2 * ImZ b * ReZ b
[PROOF STEP]
by (auto simp: gauss_int_eq_iff power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
ImZ t = (ImZ b)\<^sup>2 - (ReZ b)\<^sup>2
ReZ t = 2 * ImZ b * ReZ b

goal (2 subgoals):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = gauss_i\<rbrakk> \<Longrightarrow> thesis
 2. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ImZ t = (ImZ b)\<^sup>2 - (ReZ b)\<^sup>2
ReZ t = 2 * ImZ b * ReZ b

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
ImZ t = (ImZ b)\<^sup>2 - (ReZ b)\<^sup>2
ReZ t = 2 * ImZ b * ReZ b
ReZ t = 2 * ?u * ?v \<and> ImZ t = ?u\<^sup>2 - ?v\<^sup>2 \<or> ImZ t = 2 * ?u * ?v \<and> ReZ t = ?u\<^sup>2 - ?v\<^sup>2 \<Longrightarrow> thesis

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

goal (1 subgoal):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
assume [simp]: "a = -\<i>\<^sub>\<int>"
[PROOF STATE]
proof (state)
this:
a = - gauss_i

goal (1 subgoal):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence "ImZ t = (-ReZ b) ^ 2 - ImZ b ^ 2" "ReZ t = 2 * (-ReZ b) * ImZ b"
[PROOF STATE]
proof (prove)
using this:
a = - gauss_i

goal (1 subgoal):
 1. ImZ t = (- ReZ b)\<^sup>2 - (ImZ b)\<^sup>2 &&& ReZ t = 2 * - ReZ b * ImZ b
[PROOF STEP]
using ab(2)
[PROOF STATE]
proof (prove)
using this:
a = - gauss_i
a * t = b\<^sup>2

goal (1 subgoal):
 1. ImZ t = (- ReZ b)\<^sup>2 - (ImZ b)\<^sup>2 &&& ReZ t = 2 * - ReZ b * ImZ b
[PROOF STEP]
by (auto simp: gauss_int_eq_iff power2_eq_square algebra_simps)
[PROOF STATE]
proof (state)
this:
ImZ t = (- ReZ b)\<^sup>2 - (ImZ b)\<^sup>2
ReZ t = 2 * - ReZ b * ImZ b

goal (1 subgoal):
 1. \<lbrakk>\<And>u v. ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2 \<Longrightarrow> thesis; a = - gauss_i\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
ImZ t = (- ReZ b)\<^sup>2 - (ImZ b)\<^sup>2
ReZ t = 2 * - ReZ b * ImZ b

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
ImZ t = (- ReZ b)\<^sup>2 - (ImZ b)\<^sup>2
ReZ t = 2 * - ReZ b * ImZ b
ReZ t = 2 * ?u * ?v \<and> ImZ t = ?u\<^sup>2 - ?v\<^sup>2 \<or> ImZ t = 2 * ?u * ?v \<and> ReZ t = ?u\<^sup>2 - ?v\<^sup>2 \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ReZ t = 2 * u * v \<and> ImZ t = u\<^sup>2 - v\<^sup>2 \<or> ImZ t = 2 * u * v \<and> ReZ t = u\<^sup>2 - v\<^sup>2

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "ReZ t = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ReZ t = x
[PROOF STEP]
by (simp add: t_def)
[PROOF STATE]
proof (state)
this:
ReZ t = x

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
ReZ t = x

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "ImZ t = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ImZ t = y
[PROOF STEP]
by (simp add: t_def)
[PROOF STATE]
proof (state)
this:
ImZ t = y

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> y = 2 * u * v \<and> x = u\<^sup>2 - v\<^sup>2
[PROOF STEP]
have xy: "x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v"
[PROOF STATE]
proof (prove)
using this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> y = 2 * u * v \<and> x = u\<^sup>2 - v\<^sup>2

goal (1 subgoal):
 1. x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have not_both_odd: "\<not>(odd u \<and> odd v)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<not> (odd u \<and> odd v)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>odd u; odd v\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "odd u" "odd v"
[PROOF STATE]
proof (state)
this:
odd u
odd v

goal (1 subgoal):
 1. \<lbrakk>odd u; odd v\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
hence "even x" "even y"
[PROOF STATE]
proof (prove)
using this:
odd u
odd v

goal (1 subgoal):
 1. even x &&& even y
[PROOF STEP]
using xy
[PROOF STATE]
proof (prove)
using this:
odd u
odd v
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v

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

goal (1 subgoal):
 1. \<lbrakk>odd u; odd v\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
with \<open>coprime x y\<close>
[PROOF STATE]
proof (chain)
picking this:
coprime x y
even x
even y
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
coprime x y
even x
even y

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<not> (odd u \<and> odd v)

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "coprime u v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime u v
[PROOF STEP]
proof (rule coprimeI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd u; c dvd v\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
fix d
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd u; c dvd v\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
assume "d dvd u" "d dvd v"
[PROOF STATE]
proof (state)
this:
d dvd u
d dvd v

goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd u; c dvd v\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
hence "d dvd (u\<^sup>2 - v\<^sup>2)" "d dvd 2 * u * v"
[PROOF STATE]
proof (prove)
using this:
d dvd u
d dvd v

goal (1 subgoal):
 1. d dvd u\<^sup>2 - v\<^sup>2 &&& d dvd 2 * u * v
[PROOF STEP]
by (auto simp: power2_eq_square)
[PROOF STATE]
proof (state)
this:
d dvd u\<^sup>2 - v\<^sup>2
d dvd 2 * u * v

goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd u; c dvd v\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
with xy
[PROOF STATE]
proof (chain)
picking this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v
d dvd u\<^sup>2 - v\<^sup>2
d dvd 2 * u * v
[PROOF STEP]
have "d dvd x" "d dvd y"
[PROOF STATE]
proof (prove)
using this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v
d dvd u\<^sup>2 - v\<^sup>2
d dvd 2 * u * v

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

goal (1 subgoal):
 1. \<And>c. \<lbrakk>c dvd u; c dvd v\<rbrakk> \<Longrightarrow> is_unit c
[PROOF STEP]
with \<open>coprime x y\<close>
[PROOF STATE]
proof (chain)
picking this:
coprime x y
d dvd x
d dvd y
[PROOF STEP]
show "is_unit d"
[PROOF STATE]
proof (prove)
using this:
coprime x y
d dvd x
d dvd y

goal (1 subgoal):
 1. is_unit d
[PROOF STEP]
using not_coprimeI
[PROOF STATE]
proof (prove)
using this:
coprime x y
d dvd x
d dvd y
\<lbrakk>?c dvd ?a; ?c dvd ?b; \<not> is_unit ?c\<rbrakk> \<Longrightarrow> \<not> coprime ?a ?b

goal (1 subgoal):
 1. is_unit d
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
is_unit d

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

goal (1 subgoal):
 1. (\<And>u v. \<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
with xy not_both_odd
[PROOF STATE]
proof (chain)
picking this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v
\<not> (odd u \<and> odd v)
coprime u v
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v
\<not> (odd u \<and> odd v)
coprime u v

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using that[of u v]
[PROOF STATE]
proof (prove)
using this:
x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v
\<not> (odd u \<and> odd v)
coprime u v
\<lbrakk>coprime u v; \<not> (odd u \<and> odd v); x = 2 * u * v \<and> y = u\<^sup>2 - v\<^sup>2 \<or> x = u\<^sup>2 - v\<^sup>2 \<and> y = 2 * u * v\<rbrakk> \<Longrightarrow> thesis

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma foldli_prod_divmod_conv':
    "foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) = foldli [0..<N*M] ctd (\<lambda>i. f (i div N) (i mod N))"
    (is "?lhs=?rhs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) = foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N))
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) = foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N))
[PROOF STEP]
have "RETURN (?lhs s) = RETURN (?rhs s)" for s
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. RETURN (foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) s) = RETURN (foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N)) s)
[PROOF STEP]
apply (subst foldli_eq_nfoldli)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nfoldli [0..<M] ctd (\<lambda>x. nfoldli [0..<N] ctd (\<lambda>xa s. RETURN (f x xa s))) s = nfoldli [0..<N * M] ctd (\<lambda>x s. RETURN (f (x div N) (x mod N) s)) s
[PROOF STEP]
apply (subst nfoldli_prod_divmod_conv')
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nfoldli [0..<N * M] ctd (\<lambda>i s. RETURN (f (i div N) (i mod N) s)) s = nfoldli [0..<N * M] ctd (\<lambda>x s. RETURN (f (x div N) (x mod N) s)) s
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
RETURN (foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) ?s) = RETURN (foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N)) ?s)

goal (1 subgoal):
 1. foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) = foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N))
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
RETURN (foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) ?s) = RETURN (foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N)) ?s)

goal (1 subgoal):
 1. foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) = foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
foldli [0..<M] ctd (\<lambda>i. foldli [0..<N] ctd (f i)) = foldli [0..<N * M] ctd (\<lambda>i. f (i div N) (i mod N))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma fact_diff_Suc: "n < Suc m \<Longrightarrow> fact (Suc m - n) = (Suc m - n) * fact (m - n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n < Suc m \<Longrightarrow> fact (Suc m - n) = (Suc m - n) * fact (m - n)
[PROOF STEP]
by (subst fact_reduce) auto


[STATEMENT]
lemma to_fun_res_ltrm:
  assumes "a \<in> carrier Zp"
  assumes "b \<in> carrier Zp"
  assumes "f \<in> carrier Zp_x"
  assumes "a k = b k"
  shows "((ltrm f)\<bullet>a) k = ((ltrm f)\<bullet>b) k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (monom (UP Zp) (f (deg Zp f)) (deg Zp f) \<bullet> a) k = (monom (UP Zp) (f (deg Zp f)) (deg Zp f) \<bullet> b) k
[PROOF STEP]
by (simp add: lcf_closed assms(1) assms(2) assms(3) assms(4) res_to_fun_monom)


[STATEMENT]
lemma Infinitesimal_add_cancel: "y \<in> Infinitesimal \<Longrightarrow> x + y \<approx> z \<Longrightarrow> x \<approx> z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>y \<in> Infinitesimal; x + y \<approx> z\<rbrakk> \<Longrightarrow> x \<approx> z
[PROOF STEP]
using Infinitesimal_add_approx approx_trans
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?y \<in> Infinitesimal; ?x + ?y = ?z\<rbrakk> \<Longrightarrow> ?x \<approx> ?z
\<lbrakk>?x \<approx> ?y; ?y \<approx> ?z\<rbrakk> \<Longrightarrow> ?x \<approx> ?z

goal (1 subgoal):
 1. \<lbrakk>y \<in> Infinitesimal; x + y \<approx> z\<rbrakk> \<Longrightarrow> x \<approx> z
[PROOF STEP]
by blast


[STATEMENT]
theorem main: \<open>valid p \<longleftrightarrow> (\<turnstile> p)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. valid p = (\<turnstile> p)
[PROOF STEP]
using completeness soundness
[PROOF STATE]
proof (prove)
using this:
valid ?p \<Longrightarrow> \<turnstile> ?p
\<turnstile> ?p \<Longrightarrow> \<lbrakk>?E, ?F, ?G\<rbrakk> ?p

goal (1 subgoal):
 1. valid p = (\<turnstile> p)
[PROOF STEP]
by blast


[STATEMENT]
lemma homeomorphism_on_homeomorphic:
  assumes "homeomorphism_on S f"
  shows "S homeomorphic (f`S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S homeomorphic f ` S
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
homeomorphism_on S f

goal (1 subgoal):
 1. S homeomorphic f ` S
[PROOF STEP]
unfolding homeomorphism_on_def homeomorphic_def
[PROOF STATE]
proof (prove)
using this:
Ex (homeomorphism S (f ` S) f)

goal (1 subgoal):
 1. \<exists>fa g. homeomorphism S (f ` S) fa g
[PROOF STEP]
by auto


[STATEMENT]
lemma CARD_list [card_simps]: "CARD('a list) = card_list CARD('a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. CARD('a list) = card_list CARD('a)
[PROOF STEP]
by(simp add: card_list_def infinite_UNIV_listI)


[STATEMENT]
lemma map_le_member:
  "f \<subseteq>\<^sub>m g \<longleftrightarrow> (\<forall> x y. (x,y) \<in>\<^sub>m f \<longrightarrow> (x,y) \<in>\<^sub>m g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f \<subseteq>\<^sub>m g) = (\<forall>x y. (x, y) \<in>\<^sub>m f \<longrightarrow> (x, y) \<in>\<^sub>m g)
[PROOF STEP]
by (force simp add: map_le_def)


[STATEMENT]
lemma hermitean_mat_cnj:
  shows "hermitean H \<longleftrightarrow> hermitean (mat_cnj H)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. hermitean H = hermitean (mat_cnj H)
[PROOF STEP]
by (cases H) (auto simp add:  hermitean_def mat_adj_def mat_cnj_def)


[STATEMENT]
lemma triangle_num_0 [simp]: "triangle_num 0 = 0"
  and triangle_num_1 [simp]: "triangle_num 1 = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. triangle_num 0 = 0 &&& triangle_num 1 = 1
[PROOF STEP]
by (simp_all add: triangle_num_def)


[STATEMENT]
lemma ceiling_mono: "x \<ge> y \<Longrightarrow> \<lceil>x\<rceil> \<ge> \<lceil>y\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> x \<Longrightarrow> \<lceil>y\<rceil> \<le> \<lceil>x\<rceil>
[PROOF STEP]
unfolding ceiling_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. y \<le> x \<Longrightarrow> - \<lfloor>- y\<rfloor> \<le> - \<lfloor>- x\<rfloor>
[PROOF STEP]
by (simp add: floor_mono)


[STATEMENT]
lemma inj_on_from_nat_into: "inj_on from_nat_into ({A. A \<noteq> {} \<and> countable A})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on from_nat_into {A. A \<noteq> {} \<and> countable A}
[PROOF STEP]
unfolding inj_on_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{A. A \<noteq> {} \<and> countable A}. \<forall>y\<in>{A. A \<noteq> {} \<and> countable A}. from_nat_into x = from_nat_into y \<longrightarrow> x = y
[PROOF STEP]
by auto


[STATEMENT]
lemma conductor_geI: "(\<And>d. induced_modulus d \<Longrightarrow> d \<ge> a) \<Longrightarrow> conductor \<ge> a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>d. induced_modulus d \<Longrightarrow> a \<le> d) \<Longrightarrow> a \<le> conductor
[PROOF STEP]
by (subst conductor_ge_iff) auto


[STATEMENT]
lemma sum_Bernstein [simp]: "(\<Sum>k\<le>n. Bernstein n k x) = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>k\<le>n. Bernstein n k x) = 1
[PROOF STEP]
using binomial_ring [of x "1-x" n]
[PROOF STATE]
proof (prove)
using this:
(x + (1 - x)) ^ n = (\<Sum>k\<le>n. real (n choose k) * x ^ k * (1 - x) ^ (n - k))

goal (1 subgoal):
 1. (\<Sum>k\<le>n. Bernstein n k x) = 1
[PROOF STEP]
by (simp add: Bernstein_def)


[STATEMENT]
lemma matrix_one_implies_membership:
"I \<subseteq> {..< \<v>} \<Longrightarrow> j < size \<B> \<Longrightarrow> \<forall>i\<in>I. N $$ (i, j) = 1 \<Longrightarrow> i \<in> I \<Longrightarrow> \<V>s ! i \<in> \<B>s ! j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>I \<subseteq> {..<\<v>}; j < \<b>; \<forall>i\<in>I. N $$ (i, j) = 1; i \<in> I\<rbrakk> \<Longrightarrow> \<V>s ! i \<in> \<B>s ! j
[PROOF STEP]
by (simp add: matrix_point_in_block_iff subset_iff)


[STATEMENT]
lemma aux1[intro]: "\<lbrakk> set l \<subset> {0..<N}; distinct l \<rbrakk> \<Longrightarrow> length l < N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>set l \<subset> {0..<N}; distinct l\<rbrakk> \<Longrightarrow> length l < N
[PROOF STEP]
apply (simp add: distinct_card[symmetric])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>set l \<subset> {0..<N}; distinct l\<rbrakk> \<Longrightarrow> card (set l) < N
[PROOF STEP]
apply (drule psubset_card_mono[rotated])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. distinct l \<Longrightarrow> finite {0..<N}
 2. \<lbrakk>distinct l; card (set l) < card {0..<N}\<rbrakk> \<Longrightarrow> card (set l) < N
[PROOF STEP]
apply auto
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma (in aGroup) nsum_split1:"\<lbrakk>\<forall>j \<le> m. f j \<in> carrier A; n < m\<rbrakk> \<Longrightarrow>
                   nsum A f m = nsum A f n \<plusminus> (fSum A f (Suc n) m)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>j\<le>m. f j \<in> carrier A; n < m\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e A f m = \<Sigma>\<^sub>e A f n \<plusminus> \<Sigma>\<^sub>f A f Suc n m
[PROOF STEP]
apply (cut_tac nsum_split[of n "m - n - Suc 0" f])
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<forall>j\<le>m. f j \<in> carrier A; n < m; \<Sigma>\<^sub>e A f Suc (n + (m - n - Suc 0)) = \<Sigma>\<^sub>e A f n \<plusminus> \<Sigma>\<^sub>e A cmp f (slide (Suc n)) (m - n - Suc 0)\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e A f m = \<Sigma>\<^sub>e A f n \<plusminus> \<Sigma>\<^sub>f A f Suc n m
 2. \<lbrakk>\<forall>j\<le>m. f j \<in> carrier A; n < m\<rbrakk> \<Longrightarrow> \<forall>j\<le>Suc (n + (m - n - Suc 0)). f j \<in> carrier A
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>\<forall>j\<le>m. f j \<in> carrier A; n < m; \<Sigma>\<^sub>e A f m = \<Sigma>\<^sub>e A f n \<plusminus> \<Sigma>\<^sub>e A cmp f (slide (Suc n)) (m - Suc n)\<rbrakk> \<Longrightarrow> \<Sigma>\<^sub>e A f n \<plusminus> \<Sigma>\<^sub>e A cmp f (slide (Suc n)) (m - Suc n) = \<Sigma>\<^sub>e A f n \<plusminus> \<Sigma>\<^sub>f A f Suc n m
 2. \<lbrakk>\<forall>j\<le>m. f j \<in> carrier A; n < m\<rbrakk> \<Longrightarrow> \<forall>j\<le>Suc (n + (m - n - Suc 0)). f j \<in> carrier A
[PROOF STEP]
apply (simp add:fSum_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<forall>j\<le>m. f j \<in> carrier A; n < m\<rbrakk> \<Longrightarrow> \<forall>j\<le>Suc (n + (m - n - Suc 0)). f j \<in> carrier A
[PROOF STEP]
apply simp
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma sqmatrix_mult_1_right [simp]:
  "(A::('a::{semiring_0,monoid_mult},'m::len) sqmatrix) * 1 = A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<cdot> 1 = A
[PROOF STEP]
by (cases A, simp add: one_sqmatrix_def)


[STATEMENT]
lemma forall_pos_mono:
  "(\<And>d e::real. d < e \<Longrightarrow> P d \<Longrightarrow> P e) \<Longrightarrow>
    (\<And>n::nat. n \<noteq> 0 \<Longrightarrow> P (inverse (real n))) \<Longrightarrow> (\<And>e. 0 < e \<Longrightarrow> P e)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<And>d e. \<lbrakk>d < e; P d\<rbrakk> \<Longrightarrow> P e; \<And>n. n \<noteq> 0 \<Longrightarrow> P (inverse (real n))\<rbrakk> \<Longrightarrow> (\<And>e. 0 < e \<Longrightarrow> P e)
[PROOF STEP]
by (metis real_arch_inverse)


[STATEMENT]
lemma full_chain_length_pos: "full_chain R xs \<Longrightarrow> llength xs > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. full_chain R xs \<Longrightarrow> 0 < llength xs
[PROOF STEP]
by (fact chain_length_pos[OF full_chain_imp_chain])


[STATEMENT]
lemma transpose_singleton[simp]: "transpose_matrix (singleton_matrix j i a) = singleton_matrix i j a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. transpose_matrix (singleton_matrix j i a) = singleton_matrix i j a
[PROOF STEP]
apply (subst Rep_matrix_inject[symmetric], (rule ext)+)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x xa. Rep_matrix (transpose_matrix (singleton_matrix j i a)) x xa = Rep_matrix (singleton_matrix i j a) x xa
[PROOF STEP]
apply (simp)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma Complex_scale3:
  shows "Complex (a / b) (a / c) = cor a * Complex (1 / b) (1 / c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex (a / b) (a / c) = cor a * Complex (1 / b) (1 / c)
[PROOF STEP]
unfolding complex_of_real_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Complex (a / b) (a / c) = Complex a 0 * Complex (1 / b) (1 / c)
[PROOF STEP]
unfolding Complex_eq
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cor (a / b) + \<i> * cor (a / c) = (cor a + \<i> * cor 0) * (cor (1 / b) + \<i> * cor (1 / c))
[PROOF STEP]
by (auto simp add: field_simps)


[STATEMENT]
lemma rbt_comp_minus: "rbt_comp_minus = ord.rbt_minus (lt_of_comp c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. local.rbt_comp_minus = ord.rbt_minus (lt_of_comp c)
[PROOF STEP]
by (rule ext)+ (auto simp: rbt_comp_minus_def ord.rbt_minus_def comp_minus)


[STATEMENT]
lemma conjugate_iff_residuated: "conjugation_pair f g = residuated_pair f (\<lambda>x. -g(-x))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. conjugation_pair f g = residuated_pair f (\<lambda>x. - g (- x))
[PROOF STEP]
apply (clarsimp simp: conjugation_pair_def residuated_pair_def inf_bot_iff_le)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x y. (f x \<le> - y) = (x \<le> - g y)) = (\<forall>x y. (f x \<le> y) = (x \<le> - g (- y)))
[PROOF STEP]
by (metis double_compl)


[STATEMENT]
lemma is_path_rev: "is_path xs \<longleftrightarrow> is_path (rev xs)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. is_path xs = is_path (rev xs)
[PROOF STEP]
unfolding is_path_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (is_open_walk xs \<and> distinct xs) = (is_open_walk (rev xs) \<and> distinct (rev xs))
[PROOF STEP]
using is_open_walk_rev
[PROOF STATE]
proof (prove)
using this:
is_open_walk ?xs = is_open_walk (rev ?xs)

goal (1 subgoal):
 1. (is_open_walk xs \<and> distinct xs) = (is_open_walk (rev xs) \<and> distinct (rev xs))
[PROOF STEP]
by (metis distinct_rev)


[STATEMENT]
lemma inj_on_xa_A: "inj_on (\<lambda>x. x * a) A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. inj_on (\<lambda>x. x * a) A
[PROOF STEP]
using a_nonzero
[PROOF STATE]
proof (prove)
using this:
0 < a

goal (1 subgoal):
 1. inj_on (\<lambda>x. x * a) A
[PROOF STEP]
by (simp add: A_def inj_on_def)


[STATEMENT]
lemma length_rev [simp]: "length (rev xs) = length xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. length (rev xs) = length xs
[PROOF STEP]
by (induct xs) auto


[STATEMENT]
lemma cblinfun_of_mat_adjoint:
  defines "nA \<equiv> length (canonical_basis :: 'a::onb_enum list)"
    and "nB \<equiv> length (canonical_basis :: 'b::onb_enum list)"
  fixes M:: "complex mat"
  assumes "M \<in> carrier_mat nB nA"
  shows "((cblinfun_of_mat (mat_adjoint M)) :: 'b \<Rightarrow>\<^sub>C\<^sub>L 'a) = (cblinfun_of_mat M)*"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cblinfun_of_mat (mat_adjoint M) = cblinfun_of_mat M*
[PROOF STEP]
proof (rule adjoint_eqI)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x y. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
show "(cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)"
    for x::'b and y::'a
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
define u where "u = vec_of_basis_enum x"
[PROOF STATE]
proof (state)
this:
u = vec_of_basis_enum x

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
define v where "v = vec_of_basis_enum y"
[PROOF STATE]
proof (state)
this:
v = vec_of_basis_enum y

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
have c1: "vec_of_basis_enum ((cblinfun_of_mat (mat_adjoint M) *\<^sub>V x)::'a) = (mat_adjoint M) *\<^sub>v u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = mat_adjoint M *\<^sub>v u
[PROOF STEP]
unfolding u_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = mat_adjoint M *\<^sub>v vec_of_basis_enum x
[PROOF STEP]
by (metis (mono_tags, lifting) assms(3) cblinfun_of_mat_inverse map_carrier_mat mat_adjoint_def' mat_of_cblinfun_cblinfun_apply nA_def nB_def transpose_carrier_mat)
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = mat_adjoint M *\<^sub>v u

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
have c2: "(vec_of_basis_enum ((cblinfun_of_mat M *\<^sub>V y)::'b))
        = M *\<^sub>v v"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) = M *\<^sub>v v
[PROOF STEP]
by (metis assms(3) cblinfun_of_mat_inverse mat_of_cblinfun_cblinfun_apply nA_def nB_def v_def)
[PROOF STATE]
proof (state)
this:
vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) = M *\<^sub>v v

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
have c3: "dim_vec v = nA"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec v = nA
[PROOF STEP]
unfolding v_def nA_def vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec_of_list (map (crepresentation (set canonical_basis) y) canonical_basis)) = length canonical_basis
[PROOF STEP]
by (simp add:)
[PROOF STATE]
proof (state)
this:
dim_vec v = nA

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
have c4: "dim_vec u = nB"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec u = nB
[PROOF STEP]
unfolding u_def nB_def vec_of_basis_enum_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dim_vec (vec_of_list (map (crepresentation (set canonical_basis) x) canonical_basis)) = length canonical_basis
[PROOF STEP]
by (simp add:)
[PROOF STATE]
proof (state)
this:
dim_vec u = nB

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
have "v \<bullet>c ((mat_adjoint M) *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. v \<bullet>c (mat_adjoint M *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u
[PROOF STEP]
using c3 c4 cscalar_prod_adjoint assms(3)
[PROOF STATE]
proof (prove)
using this:
dim_vec v = nA
dim_vec u = nB
\<lbrakk>?M \<in> carrier_mat ?nB ?nA; dim_vec ?v = ?nA; dim_vec ?u = ?nB\<rbrakk> \<Longrightarrow> ?v \<bullet>c (mat_adjoint ?M *\<^sub>v ?u) = (?M *\<^sub>v ?v) \<bullet>c ?u
M \<in> carrier_mat nB nA

goal (1 subgoal):
 1. v \<bullet>c (mat_adjoint M *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
v \<bullet>c (mat_adjoint M *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
hence "v \<bullet>c (vec_of_basis_enum ((cblinfun_of_mat (mat_adjoint M) *\<^sub>V x)::'a))
        = (vec_of_basis_enum ((cblinfun_of_mat M *\<^sub>V y)::'b)) \<bullet>c u"
[PROOF STATE]
proof (prove)
using this:
v \<bullet>c (mat_adjoint M *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u

goal (1 subgoal):
 1. v \<bullet>c vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) \<bullet>c u
[PROOF STEP]
using c1 c2
[PROOF STATE]
proof (prove)
using this:
v \<bullet>c (mat_adjoint M *\<^sub>v u) = (M *\<^sub>v v) \<bullet>c u
vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = mat_adjoint M *\<^sub>v u
vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) = M *\<^sub>v v

goal (1 subgoal):
 1. v \<bullet>c vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) \<bullet>c u
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
v \<bullet>c vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) \<bullet>c u

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
thus "(cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)"
[PROOF STATE]
proof (prove)
using this:
v \<bullet>c vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) \<bullet>c u

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
unfolding u_def v_def
[PROOF STATE]
proof (prove)
using this:
vec_of_basis_enum y \<bullet>c vec_of_basis_enum (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) = vec_of_basis_enum (cblinfun_of_mat M *\<^sub>V y) \<bullet>c vec_of_basis_enum x

goal (1 subgoal):
 1. (cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)
[PROOF STEP]
by (simp add: cscalar_prod_vec_of_basis_enum)
[PROOF STATE]
proof (state)
this:
(cblinfun_of_mat (mat_adjoint M) *\<^sub>V x) \<bullet>\<^sub>C y = x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V y)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(cblinfun_of_mat (mat_adjoint M) *\<^sub>V ?x) \<bullet>\<^sub>C ?y = ?x \<bullet>\<^sub>C (cblinfun_of_mat M *\<^sub>V ?y)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma nat_infinite_iff:
  fixes N :: "nat set"
  shows "infinite N \<longleftrightarrow> (\<exists>f::nat\<Rightarrow>nat. N = range f \<and> strict_mono f)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite N = (\<exists>f. N = range f \<and> strict_mono f)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. infinite N \<Longrightarrow> \<exists>f. N = range f \<and> strict_mono f
 2. \<And>f. \<lbrakk>strict_mono f; N = range f; finite (range f)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "infinite N"
[PROOF STATE]
proof (state)
this:
infinite N

goal (2 subgoals):
 1. infinite N \<Longrightarrow> \<exists>f. N = range f \<and> strict_mono f
 2. \<And>f. \<lbrakk>strict_mono f; N = range f; finite (range f)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
infinite N
[PROOF STEP]
show "\<exists>f. N = range (f::nat \<Rightarrow> nat) \<and> strict_mono f"
[PROOF STATE]
proof (prove)
using this:
infinite N

goal (1 subgoal):
 1. \<exists>f. N = range f \<and> strict_mono f
[PROOF STEP]
by (metis bij_betw_imp_surj_on bij_enumerate enumerate_mono strict_mono_def)
[PROOF STATE]
proof (state)
this:
\<exists>f. N = range f \<and> strict_mono f

goal (1 subgoal):
 1. \<And>f. \<lbrakk>strict_mono f; N = range f; finite (range f)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. \<lbrakk>strict_mono f; N = range f; finite (range f)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
fix f :: "nat \<Rightarrow> nat"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f. \<lbrakk>strict_mono f; N = range f; finite (range f)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
assume "strict_mono f" and "N = range f" and "finite (range f)"
[PROOF STATE]
proof (state)
this:
strict_mono f
N = range f
finite (range f)

goal (1 subgoal):
 1. \<And>f. \<lbrakk>strict_mono f; N = range f; finite (range f)\<rbrakk> \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
strict_mono f
N = range f
finite (range f)
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
strict_mono f
N = range f
finite (range f)

goal (1 subgoal):
 1. False
[PROOF STEP]
using range_inj_infinite strict_mono_imp_inj_on
[PROOF STATE]
proof (prove)
using this:
strict_mono f
N = range f
finite (range f)
inj ?f \<Longrightarrow> infinite (range ?f)
strict_mono ?f \<Longrightarrow> inj_on ?f ?A

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma factor_mset_prod:
  assumes "finite A"
  assumes "f ` A \<subseteq> carrier G"
  shows "factor_mset G (\<Otimes>a \<in> A. f a) =
    (\<Sum>a \<in> A. factor_mset G (f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factor_mset G (finprod G f A) = (\<Sum>a\<in>A. factor_mset G (f a))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
finite A
f ` A \<subseteq> carrier G

goal (1 subgoal):
 1. factor_mset G (finprod G f A) = (\<Sum>a\<in>A. factor_mset G (f a))
[PROOF STEP]
proof (induction A rule:finite_induct)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. f ` {} \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f {}) = (\<Sum>a\<in>{}. factor_mset G (f a))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
case empty
[PROOF STATE]
proof (state)
this:
f ` {} \<subseteq> carrier G

goal (2 subgoals):
 1. f ` {} \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f {}) = (\<Sum>a\<in>{}. factor_mset G (f a))
 2. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
f ` {} \<subseteq> carrier G
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
f ` {} \<subseteq> carrier G

goal (1 subgoal):
 1. factor_mset G (finprod G f {}) = (\<Sum>a\<in>{}. factor_mset G (f a))
[PROOF STEP]
by (simp add:factor_mset_unit)
[PROOF STATE]
proof (state)
this:
factor_mset G (finprod G f {}) = (\<Sum>a\<in>{}. factor_mset G (f a))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
case (insert x F)
[PROOF STATE]
proof (state)
this:
finite F
x \<notin> F
f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a))
f ` insert x F \<subseteq> carrier G

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
have "factor_mset G (finprod G f (insert x F)) =
    factor_mset G (f x \<otimes> finprod G f F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factor_mset G (finprod G f (insert x F)) = factor_mset G (f x \<otimes> finprod G f F)
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
finite F
x \<notin> F
f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a))
f ` insert x F \<subseteq> carrier G

goal (1 subgoal):
 1. factor_mset G (finprod G f (insert x F)) = factor_mset G (f x \<otimes> finprod G f F)
[PROOF STEP]
by (subst finprod_insert) auto
[PROOF STATE]
proof (state)
this:
factor_mset G (finprod G f (insert x F)) = factor_mset G (f x \<otimes> finprod G f F)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
factor_mset G (finprod G f (insert x F)) = factor_mset G (f x \<otimes> finprod G f F)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
have "... = factor_mset G (f x) + factor_mset G (finprod G f F)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factor_mset G (f x \<otimes> finprod G f F) = factor_mset G (f x) + factor_mset G (finprod G f F)
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
finite F
x \<notin> F
f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a))
f ` insert x F \<subseteq> carrier G

goal (1 subgoal):
 1. factor_mset G (f x \<otimes> finprod G f F) = factor_mset G (f x) + factor_mset G (finprod G f F)
[PROOF STEP]
by (intro factor_mset_mult finprod_closed) auto
[PROOF STATE]
proof (state)
this:
factor_mset G (f x \<otimes> finprod G f F) = factor_mset G (f x) + factor_mset G (finprod G f F)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
factor_mset G (f x \<otimes> finprod G f F) = factor_mset G (f x) + factor_mset G (finprod G f F)

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
have
    "... = factor_mset G (f x) + (\<Sum>a \<in> F. factor_mset G (f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factor_mset G (f x) + factor_mset G (finprod G f F) = factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a))
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
finite F
x \<notin> F
f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a))
f ` insert x F \<subseteq> carrier G

goal (1 subgoal):
 1. factor_mset G (f x) + factor_mset G (finprod G f F) = factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
factor_mset G (f x) + factor_mset G (finprod G f F) = factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
factor_mset G (f x) + factor_mset G (finprod G f F) = factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
have "... = (\<Sum>a\<in>insert x F. factor_mset G (f a))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
using insert
[PROOF STATE]
proof (prove)
using this:
finite F
x \<notin> F
f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a))
f ` insert x F \<subseteq> carrier G

goal (1 subgoal):
 1. factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
factor_mset G (f x) + (\<Sum>a\<in>F. factor_mset G (f a)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))

goal (1 subgoal):
 1. \<And>x F. \<lbrakk>finite F; x \<notin> F; f ` F \<subseteq> carrier G \<Longrightarrow> factor_mset G (finprod G f F) = (\<Sum>a\<in>F. factor_mset G (f a)); f ` insert x F \<subseteq> carrier G\<rbrakk> \<Longrightarrow> factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))

goal (1 subgoal):
 1. factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
factor_mset G (finprod G f (insert x F)) = (\<Sum>a\<in>insert x F. factor_mset G (f a))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lsc_hull_of_convex_determined:
  fixes f g :: "'a::euclidean_space \<Rightarrow> ereal"
  assumes "convex_on UNIV f" "convex_on UNIV g"
  assumes "rel_interior (domain f) = rel_interior (domain g)"
  assumes "\<forall>x\<in>rel_interior (domain f). f x = g x"
  shows "lsc_hull f = lsc_hull g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lsc_hull f = lsc_hull g
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. lsc_hull f = lsc_hull g
[PROOF STEP]
have "rel_interior (Epigraph UNIV f) = rel_interior (Epigraph UNIV g)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rel_interior (Epigraph UNIV f) = rel_interior (Epigraph UNIV g)
[PROOF STEP]
apply (subst rel_interior_EpigraphI, metis assms)+
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {(x, z) |x z. x \<in> rel_interior (domain f) \<and> f x < ereal z} = {(x, z) |x z. x \<in> rel_interior (domain g) \<and> g x < ereal z}
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Lower_Semicontinuous.convex_on UNIV f
Lower_Semicontinuous.convex_on UNIV g
rel_interior (domain f) = rel_interior (domain g)
\<forall>x\<in>rel_interior (domain f). f x = g x

goal (1 subgoal):
 1. {(x, z) |x z. x \<in> rel_interior (domain f) \<and> f x < ereal z} = {(x, z) |x z. x \<in> rel_interior (domain g) \<and> g x < ereal z}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
rel_interior (Epigraph UNIV f) = rel_interior (Epigraph UNIV g)

goal (1 subgoal):
 1. lsc_hull f = lsc_hull g
[PROOF STEP]
hence "closure (Epigraph UNIV f) = closure (Epigraph UNIV g)"
[PROOF STATE]
proof (prove)
using this:
rel_interior (Epigraph UNIV f) = rel_interior (Epigraph UNIV g)

goal (1 subgoal):
 1. closure (Epigraph UNIV f) = closure (Epigraph UNIV g)
[PROOF STEP]
by (metis assms convex_EpigraphI convex_UNIV convex_closure_rel_interior)
[PROOF STATE]
proof (state)
this:
closure (Epigraph UNIV f) = closure (Epigraph UNIV g)

goal (1 subgoal):
 1. lsc_hull f = lsc_hull g
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
closure (Epigraph UNIV f) = closure (Epigraph UNIV g)

goal (1 subgoal):
 1. lsc_hull f = lsc_hull g
[PROOF STEP]
by (metis lsc_hull_expl)
[PROOF STATE]
proof (state)
this:
lsc_hull f = lsc_hull g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma linorder_lattice_sup_ge1: "sup (x::'a::linorder_lattice) y \<ge> x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> sup x y
[PROOF STEP]
unfolding sup_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<le> (if y \<le> x then x else y)
[PROOF STEP]
by (metis (full_types) linorder_linear)


[STATEMENT]
lemma skelInp_def2:
assumes "goodInp inp"
shows "skelInp inp = lift skel inp"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. skelInp inp = lift skel inp
[PROOF STEP]
unfolding skelInp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. qSkelInp (pickInp inp) = lift skel inp
[PROOF STEP]
unfolding qSkelInp_def pickInp_def skel_def[abs_def]
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lift qSkel (lift pick inp) = lift (\<lambda>X. qSkel (pick X)) inp
[PROOF STEP]
unfolding lift_comp comp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. lift (\<lambda>x. qSkel (pick x)) inp = lift (\<lambda>X. qSkel (pick X)) inp
[PROOF STEP]
by simp


[STATEMENT]
lemma set_mult_consistent [simp]: \<^marker>\<open>contributor \<open>Paulo Em?lio de Vilhena\<close>\<close>
  "N <#>\<^bsub>(G \<lparr> carrier := H \<rparr>)\<^esub> K = N <#>\<^bsub>G\<^esub> K"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. N <#>\<^bsub>G\<lparr>carrier := H\<rparr>\<^esub> K = N <#>\<^bsub>G\<^esub> K
[PROOF STEP]
unfolding set_mult_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>h\<in>N. \<Union>k\<in>K. {h \<otimes>\<^bsub>G\<lparr>carrier := H\<rparr>\<^esub> k}) = (\<Union>h\<in>N. \<Union>k\<in>K. {h \<otimes>\<^bsub>G\<^esub> k})
[PROOF STEP]
by simp


[STATEMENT]
lemma sum_mset_mset_mono:
  assumes "(\<And>x. x \<in># A \<Longrightarrow> f x \<subseteq># g x)"
  shows   "(\<Sum>x\<in>#A. f x) \<subseteq># (\<Sum>x\<in>#A. g x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Sum>\<^sub># (image_mset f A) \<subseteq># \<Sum>\<^sub># (image_mset g A)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
?x \<in># A \<Longrightarrow> f ?x \<subseteq># g ?x

goal (1 subgoal):
 1. \<Sum>\<^sub># (image_mset f A) \<subseteq># \<Sum>\<^sub># (image_mset g A)
[PROOF STEP]
by (induction A) (auto intro!: subset_mset.add_mono)


[STATEMENT]
lemma fls_regpart_minus [simp]: "fls_regpart (f - g) = fls_regpart f - fls_regpart g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fls_regpart (f - g) = fls_regpart f - fls_regpart g
[PROOF STEP]
by (intro fps_ext) simp


[STATEMENT]
lemma summable_moebius_over_square:
  "summable (\<lambda>n. moebius_mu n / real n ^ 2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. summable (\<lambda>n. moebius_mu n / (real n)\<^sup>2)
[PROOF STEP]
using norm_summable_moebius_over_square
[PROOF STATE]
proof (prove)
using this:
summable (\<lambda>n. norm (moebius_mu n / (real n)\<^sup>2))

goal (1 subgoal):
 1. summable (\<lambda>n. moebius_mu n / (real n)\<^sup>2)
[PROOF STEP]
by (rule summable_norm_cancel)


[STATEMENT]
lemma of_rat_ceiling [simp]:
  "\<lceil>of_rat r\<rceil> = \<lceil>r\<rceil>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lceil>of_rat r\<rceil> = \<lceil>r\<rceil>
[PROOF STEP]
using of_rat_floor [of "- r"]
[PROOF STATE]
proof (prove)
using this:
\<lfloor>of_rat (- r)\<rfloor> = \<lfloor>- r\<rfloor>

goal (1 subgoal):
 1. \<lceil>of_rat r\<rceil> = \<lceil>r\<rceil>
[PROOF STEP]
by (simp add: of_rat_minus ceiling_def)


[STATEMENT]
lemma app_insf_Seq: "Seq s k \<Longrightarrow> app (insf s k y) k = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Seq s k \<Longrightarrow> app (insf s k y) k = y
[PROOF STEP]
by (metis Seq_def hfunction_insf app_equality hmem_hinsert insf_def)


[STATEMENT]
lemma mset_removeAll[simp, code]: "removeAll_mset C (mset L) = mset (removeAll C L)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. removeAll_mset C (mset L) = mset (removeAll C L)
[PROOF STEP]
by (induction L) (auto simp: ac_simps multiset_eq_iff split: if_split_asm)


[STATEMENT]
lemma fmlookup_fold_not_mem: "x \<notin> set k1 \<Longrightarrow>
  fmlookup (foldl (\<lambda>lp v. add_monom (get_var_coeff P1 v) v lp) P2 k1) x
    = fmlookup P2 x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<notin> set k1 \<Longrightarrow> fmlookup (foldl (\<lambda>lp v. add_monom (get_var_coeff P1 v) v lp) P2 k1) x = fmlookup P2 x
[PROOF STEP]
by (induct k1 arbitrary: P2, auto simp: lookup_add_monom)


[STATEMENT]
lemma rbt_unionw_is_rbt: "\<lbrakk> is_rbt lt; is_rbt rt \<rbrakk> \<Longrightarrow> is_rbt (rbt_union_with f lt rt)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>is_rbt lt; is_rbt rt\<rbrakk> \<Longrightarrow> is_rbt (rbt_union_with f lt rt)
[PROOF STEP]
by(simp add: rbt_union_with_def)


[STATEMENT]
lemma chain_homotopic_simplicial_subdivision1:
  "\<lbrakk>simplicial_chain p (standard_simplex q) c; simplicial_simplex q (standard_simplex r) g\<rbrakk>
       \<Longrightarrow> chain_map (Suc p) g (subd p c) = subd p (chain_map p g c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>simplicial_chain p (standard_simplex q) c; simplicial_simplex q (standard_simplex r) g\<rbrakk> \<Longrightarrow> chain_map (Suc p) g (subd p c) = subd p (chain_map p g c)
[PROOF STEP]
by (simp add: subd)


[STATEMENT]
theorem RothArithmeticProgressions:
  assumes "upper_asymptotic_density A > 0"
  shows "\<exists>k d. d>0 \<and> progression3 k d \<subseteq> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>k d. 0 < d \<and> progression3 k d \<subseteq> A
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A \<Longrightarrow> False
[PROOF STEP]
assume non: "\<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A"
[PROOF STATE]
proof (state)
this:
\<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A

goal (1 subgoal):
 1. \<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A \<Longrightarrow> False
[PROOF STEP]
obtain M where X: "\<forall>N \<ge> M. \<forall>A' \<subseteq> {..<N}. (\<nexists>k d. d>0 \<and> progression3 k d \<subseteq> A')
                          \<longrightarrow> card A' < upper_asymptotic_density A / 2 * real N"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>M. \<forall>N\<ge>M. \<forall>A'\<subseteq>{..<N}. (\<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A') \<longrightarrow> real (card A') < upper_asymptotic_density A / 2 * real N \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis half_gt_zero RothArithmeticProgressions_aux assms)
[PROOF STATE]
proof (state)
this:
\<forall>N\<ge>M. \<forall>A'\<subseteq>{..<N}. (\<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A') \<longrightarrow> real (card A') < upper_asymptotic_density A / 2 * real N

goal (1 subgoal):
 1. \<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>N\<ge>M. \<forall>A'\<subseteq>{..<N}. (\<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A') \<longrightarrow> real (card A') < upper_asymptotic_density A / 2 * real N
[PROOF STEP]
have "\<forall>N \<ge> M. card (A \<inter> {..<N}) < upper_asymptotic_density A / 2 * N"
[PROOF STATE]
proof (prove)
using this:
\<forall>N\<ge>M. \<forall>A'\<subseteq>{..<N}. (\<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A') \<longrightarrow> real (card A') < upper_asymptotic_density A / 2 * real N

goal (1 subgoal):
 1. \<forall>N\<ge>M. real (card (A \<inter> {..<N})) < upper_asymptotic_density A / 2 * real N
[PROOF STEP]
by (meson order_trans inf_le1 inf_le2 non)
[PROOF STATE]
proof (state)
this:
\<forall>N\<ge>M. real (card (A \<inter> {..<N})) < upper_asymptotic_density A / 2 * real N

goal (1 subgoal):
 1. \<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A \<Longrightarrow> False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>N\<ge>M. real (card (A \<inter> {..<N})) < upper_asymptotic_density A / 2 * real N
[PROOF STEP]
have "upper_asymptotic_density A \<le> upper_asymptotic_density A / 2"
[PROOF STATE]
proof (prove)
using this:
\<forall>N\<ge>M. real (card (A \<inter> {..<N})) < upper_asymptotic_density A / 2 * real N

goal (1 subgoal):
 1. upper_asymptotic_density A \<le> upper_asymptotic_density A / 2
[PROOF STEP]
by (force simp add: eventually_sequentially less_eq_real_def intro!: upper_asymptotic_densityI)
[PROOF STATE]
proof (state)
this:
upper_asymptotic_density A \<le> upper_asymptotic_density A / 2

goal (1 subgoal):
 1. \<nexists>k d. 0 < d \<and> progression3 k d \<subseteq> A \<Longrightarrow> False
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < upper_asymptotic_density A
upper_asymptotic_density A \<le> upper_asymptotic_density A / 2
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
0 < upper_asymptotic_density A
upper_asymptotic_density A \<le> upper_asymptotic_density A / 2

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem Hset1_natural: "Hset1 o Hmap f1 f2 = image f1 o Hset1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Hset1 \<circ> Hmap f1 f2 = (`) f1 \<circ> Hset1
[PROOF STEP]
by (tactic \<open>BNF_Comp_Tactics.mk_comp_set_map0_tac @{context} @{thm refl} @{thm G.map_comp0} @{thm G.map_cong0}
  @{thm G.collect_set_map} @{thms F1.set_map0(1) F2.set_map0(1) F3.set_map0(1)}\<close>)


[STATEMENT]
lemma extend_bound: \<open>(\<Union>n \<le> m. extend A S f n) = extend A S f m\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (extend A S f ` {..m}) = extend A S f m
[PROOF STEP]
proof (induct m)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
\<Union> (extend A S f ` {..m}) = extend A S f m

goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
have \<open>\<Union> (extend A S f ` {..Suc m}) = \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (extend A S f ` {..Suc m}) = \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m)
[PROOF STEP]
using atMost_Suc
[PROOF STATE]
proof (prove)
using this:
{..Suc ?k} = insert (Suc ?k) {..?k}

goal (1 subgoal):
 1. \<Union> (extend A S f ` {..Suc m}) = \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<Union> (extend A S f ` {..Suc m}) = \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m)

goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Union> (extend A S f ` {..Suc m}) = \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m)

goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
have \<open>\<dots> = extend A S f m \<union> extend A S f (Suc m)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m) = extend A S f m \<union> extend A S f (Suc m)
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
\<Union> (extend A S f ` {..m}) = extend A S f m

goal (1 subgoal):
 1. \<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m) = extend A S f m \<union> extend A S f (Suc m)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m) = extend A S f m \<union> extend A S f (Suc m)

goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
\<Union> (extend A S f ` {..m}) \<union> extend A S f (Suc m) = extend A S f m \<union> extend A S f (Suc m)

goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
have \<open>\<dots> = extend A S f (Suc m)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. extend A S f m \<union> extend A S f (Suc m) = extend A S f (Suc m)
[PROOF STEP]
using extend_chain
[PROOF STATE]
proof (prove)
using this:
extend ?A ?S ?f ?n \<subseteq> extend ?A ?S ?f (Suc ?n)

goal (1 subgoal):
 1. extend A S f m \<union> extend A S f (Suc m) = extend A S f (Suc m)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
extend A S f m \<union> extend A S f (Suc m) = extend A S f (Suc m)

goal (2 subgoals):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
 2. \<And>m. \<Union> (extend A S f ` {..m}) = extend A S f m \<Longrightarrow> \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
\<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
\<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)

goal (1 subgoal):
 1. \<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<Union> (extend A S f ` {..Suc m}) = extend A S f (Suc m)

goal (1 subgoal):
 1. \<Union> (extend A S f ` {..0}) = extend A S f 0
[PROOF STEP]
qed simp


[STATEMENT]
lemma fps_shift_fps_const: "fps_shift n (fps_const c) = (if n = 0 then fps_const c else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fps_shift n (fps_const c) = (if n = 0 then fps_const c else 0)
[PROOF STEP]
by (intro fps_ext) (simp add: fps_shift_def)


[STATEMENT]
lemma homotopic_with_subset_left:
     "\<lbrakk>homotopic_with_canon P X Y f g; Z \<subseteq> X\<rbrakk> \<Longrightarrow> homotopic_with_canon P Z Y f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>homotopic_with_canon P X Y f g; Z \<subseteq> X\<rbrakk> \<Longrightarrow> homotopic_with_canon P Z Y f g
[PROOF STEP]
unfolding homotopic_with_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>\<exists>h. continuous_map (prod_topology (top_of_set {0..1}) (top_of_set X)) (top_of_set Y) h \<and> (\<forall>x. h (0, x) = f x) \<and> (\<forall>x. h (1, x) = g x) \<and> (\<forall>t\<in>{0..1}. P (\<lambda>x. h (t, x))); Z \<subseteq> X\<rbrakk> \<Longrightarrow> \<exists>h. continuous_map (prod_topology (top_of_set {0..1}) (top_of_set Z)) (top_of_set Y) h \<and> (\<forall>x. h (0, x) = f x) \<and> (\<forall>x. h (1, x) = g x) \<and> (\<forall>t\<in>{0..1}. P (\<lambda>x. h (t, x)))
[PROOF STEP]
by (auto elim!: continuous_on_subset ex_forward)


[STATEMENT]
lemma  count_pre_disj:
  fixes i::nat
  assumes "countable B"
  and "i \<noteq> j"
shows "(countable_preimages B Y) i \<inter> (countable_preimages B Y) j = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
proof (cases  "(countable_preimages B Y) i = {} \<or> (countable_preimages B Y) j = {}")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. countable_preimages B Y i = {} \<or> countable_preimages B Y j = {} \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
 2. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}

goal (2 subgoals):
 1. countable_preimages B Y i = {} \<or> countable_preimages B Y j = {} \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
 2. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}

goal (1 subgoal):
 1. countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
countable_preimages B Y i \<inter> countable_preimages B Y j = {}

goal (1 subgoal):
 1. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {})

goal (1 subgoal):
 1. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
hence "Y -` {(from_nat_into B) i} \<noteq> {} \<and> Y -` {(from_nat_into B) j} \<noteq> {}"
[PROOF STATE]
proof (prove)
using this:
\<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {})

goal (1 subgoal):
 1. Y -` {from_nat_into B i} \<noteq> {} \<and> Y -` {from_nat_into B j} \<noteq> {}
[PROOF STEP]
unfolding countable_preimages_def
[PROOF STATE]
proof (prove)
using this:
\<not> ((if infinite B \<or> finite B \<and> i < card B then Y -` {from_nat_into B i} else {}) = {} \<or> (if infinite B \<or> finite B \<and> j < card B then Y -` {from_nat_into B j} else {}) = {})

goal (1 subgoal):
 1. Y -` {from_nat_into B i} \<noteq> {} \<and> Y -` {from_nat_into B j} \<noteq> {}
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
Y -` {from_nat_into B i} \<noteq> {} \<and> Y -` {from_nat_into B j} \<noteq> {}

goal (1 subgoal):
 1. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
have "(infinite B) \<or> (finite B \<and> i < card B \<and> j < card B)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite B \<or> finite B \<and> i < card B \<and> j < card B
[PROOF STEP]
using False
[PROOF STATE]
proof (prove)
using this:
\<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {})

goal (1 subgoal):
 1. infinite B \<or> finite B \<and> i < card B \<and> j < card B
[PROOF STEP]
unfolding countable_preimages_def
[PROOF STATE]
proof (prove)
using this:
\<not> ((if infinite B \<or> finite B \<and> i < card B then Y -` {from_nat_into B i} else {}) = {} \<or> (if infinite B \<or> finite B \<and> j < card B then Y -` {from_nat_into B j} else {}) = {})

goal (1 subgoal):
 1. infinite B \<or> finite B \<and> i < card B \<and> j < card B
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
infinite B \<or> finite B \<and> i < card B \<and> j < card B

goal (1 subgoal):
 1. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
have "(from_nat_into B) i \<noteq> (from_nat_into B) j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from_nat_into B i \<noteq> from_nat_into B j
[PROOF STEP]
by (metis False assms(1) assms(2) bij_betw_def countable_preimages_def from_nat_into_inj from_nat_into_inj_infinite lessThan_iff to_nat_on_finite)
[PROOF STATE]
proof (state)
this:
from_nat_into B i \<noteq> from_nat_into B j

goal (1 subgoal):
 1. \<not> (countable_preimages B Y i = {} \<or> countable_preimages B Y j = {}) \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
from_nat_into B i \<noteq> from_nat_into B j

goal (1 subgoal):
 1. countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. from_nat_into B i \<noteq> from_nat_into B j \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
have f1: "\<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n::'a} else countable_preimages A f n = ({}::'b set)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n} else countable_preimages A f n = {}
[PROOF STEP]
by (meson countable_preimages_def)
[PROOF STATE]
proof (state)
this:
\<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n} else countable_preimages A f n = {}

goal (1 subgoal):
 1. from_nat_into B i \<noteq> from_nat_into B j \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n} else countable_preimages A f n = {}
[PROOF STEP]
have f2: "infinite B \<or> finite B \<and> i < card B"
[PROOF STATE]
proof (prove)
using this:
\<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n} else countable_preimages A f n = {}

goal (1 subgoal):
 1. infinite B \<or> finite B \<and> i < card B
[PROOF STEP]
by (metis (no_types) False)
[PROOF STATE]
proof (state)
this:
infinite B \<or> finite B \<and> i < card B

goal (1 subgoal):
 1. from_nat_into B i \<noteq> from_nat_into B j \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
have "infinite B \<or> finite B \<and> j < card B"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite B \<or> finite B \<and> j < card B
[PROOF STEP]
using f1
[PROOF STATE]
proof (prove)
using this:
\<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n} else countable_preimages A f n = {}

goal (1 subgoal):
 1. infinite B \<or> finite B \<and> j < card B
[PROOF STEP]
by (meson False)
[PROOF STATE]
proof (state)
this:
infinite B \<or> finite B \<and> j < card B

goal (1 subgoal):
 1. from_nat_into B i \<noteq> from_nat_into B j \<Longrightarrow> countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
infinite B \<or> finite B \<and> j < card B
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
infinite B \<or> finite B \<and> j < card B

goal (1 subgoal):
 1. countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
using f2 f1 \<open>from_nat_into B i \<noteq> from_nat_into B j\<close>
[PROOF STATE]
proof (prove)
using this:
infinite B \<or> finite B \<and> j < card B
infinite B \<or> finite B \<and> i < card B
\<forall>A f n. if infinite A \<or> finite A \<and> n < card A then countable_preimages A f n = f -` {from_nat_into A n} else countable_preimages A f n = {}
from_nat_into B i \<noteq> from_nat_into B j

goal (1 subgoal):
 1. countable_preimages B Y i \<inter> countable_preimages B Y j = {}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
countable_preimages B Y i \<inter> countable_preimages B Y j = {}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
countable_preimages B Y i \<inter> countable_preimages B Y j = {}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma scalar_matrix_mult_row_code [code abstract]:
  "vec_nth (scalar_matrix_mult_row c A i) =(% j. c * (A $ i $ j))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ($) (scalar_matrix_mult_row c A i) = (\<lambda>j. c * A $ i $ j)
[PROOF STEP]
by(simp add: scalar_matrix_mult_row_def fun_eq_iff)


[STATEMENT]
lemma evimage_eqI:
  assumes "c \<in> carrier (SA n)"
  shows "c  \<inverse>\<^bsub>n\<^esub> {x \<in> carrier Q\<^sub>p. P x} = {x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>). P (c x)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. c \<inverse>\<^bsub>n\<^esub> {x \<in> carrier Q\<^sub>p. P x} = {x \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>). P (c x)}
[PROOF STEP]
by(rule equalityI', unfold evimage_def mem_Collect_eq Int_iff,  intro conjI, auto
        , rule SA_car_closed[of _ n], auto simp: assms)


[STATEMENT]
lemma sinh_real_zero_iff [simp]: "sinh (x::real) = 0 \<longleftrightarrow> x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
have "(-1 :: real) < 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. - 1 < 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
- 1 < 0

goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
- 1 < 0

goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
have "0 < exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < exp x
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < exp x

goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
- 1 < exp x
[PROOF STEP]
have "exp x \<noteq> -1"
[PROOF STATE]
proof (prove)
using this:
- 1 < exp x

goal (1 subgoal):
 1. exp x \<noteq> - 1
[PROOF STEP]
by (intro notI) simp
[PROOF STATE]
proof (state)
this:
exp x \<noteq> - 1

goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
exp x \<noteq> - 1

goal (1 subgoal):
 1. (sinh x = 0) = (x = 0)
[PROOF STEP]
by (subst sinh_zero_iff) simp
[PROOF STATE]
proof (state)
this:
(sinh x = 0) = (x = 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma field_differentiable_at_tan: "cos z \<noteq> 0 \<Longrightarrow> tan field_differentiable at z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos z \<noteq> (0::'a) \<Longrightarrow> tan field_differentiable at z
[PROOF STEP]
unfolding field_differentiable_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cos z \<noteq> (0::'a) \<Longrightarrow> \<exists>f'. (tan has_field_derivative f') (at z)
[PROOF STEP]
using DERIV_tan
[PROOF STATE]
proof (prove)
using this:
cos ?x \<noteq> (0::?'a) \<Longrightarrow> (tan has_field_derivative inverse ((cos ?x)\<^sup>2)) (at ?x)

goal (1 subgoal):
 1. cos z \<noteq> (0::'a) \<Longrightarrow> \<exists>f'. (tan has_field_derivative f') (at z)
[PROOF STEP]
by blast


[STATEMENT]
lemma BfunI:
  assumes K: "eventually (\<lambda>x. norm (f x) \<le> K) F"
  shows "Bfun f F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Bfun f F
[PROOF STEP]
unfolding Bfun_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>K>0. \<forall>\<^sub>F x in F. norm (f x) \<le> K
[PROOF STEP]
proof (intro exI conjI allI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < ?K
 2. \<forall>\<^sub>F x in F. norm (f x) \<le> ?K
[PROOF STEP]
show "0 < max K 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < max K 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
0 < max K 1

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. norm (f x) \<le> max K 1
[PROOF STEP]
show "eventually (\<lambda>x. norm (f x) \<le> max K 1) F"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. norm (f x) \<le> max K 1
[PROOF STEP]
using K
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. norm (f x) \<le> K

goal (1 subgoal):
 1. \<forall>\<^sub>F x in F. norm (f x) \<le> max K 1
[PROOF STEP]
by (rule eventually_mono) simp
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in F. norm (f x) \<le> max K 1

goal:
No subgoals!
[PROOF STEP]
qed