[STATEMENT]
theorem arith_prog_rel_primes_solution:
  fixes n :: nat
  assumes \<open>n > 1\<close>
  shows \<open>(prime n \<or> (\<exists> k. n = 2^k) \<or> n = 6) \<longleftrightarrow>
(\<exists> a b m. m \<noteq> 0 \<and> {x | x. x < n \<and> coprime x n} = {a+j*b| j::nat. j < m})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
have \<open> (prime n \<or> (\<exists> k. n = 2^k) \<or>  n = 6) \<longleftrightarrow>
 (\<exists> b m. m \<noteq> 0 \<and> {x | x :: nat. x < n \<and> coprime x n} = {1+j*b| j::nat. j < m})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m})
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6 \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
 2. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m} \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
show "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
      if "prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
        if "prime n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>\<exists>m.   m \<noteq> 0 \<and> {x | x :: nat. x < n \<and> coprime x n} = {1+j| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} =  {x | x :: nat. x \<noteq> 0 \<and> x < n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {x |x. x \<noteq> 0 \<and> x < n}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {x |x. x < n \<and> coprime x n} \<subseteq> {x |x. x \<noteq> 0 \<and> x < n}
 2. {x |x. x \<noteq> 0 \<and> x < n} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
show "{x |x. x < n \<and> coprime x n} \<subseteq> {x |x. x \<noteq> 0 \<and> x < n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} \<subseteq> {x |x. x \<noteq> 0 \<and> x < n}
[PROOF STEP]
by (smt Collect_mono not_le ord_0_nat ord_eq_0 order_refl prime_gt_1_nat that zero_neq_one)
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} \<subseteq> {x |x. x \<noteq> 0 \<and> x < n}

goal (1 subgoal):
 1. {x |x. x \<noteq> 0 \<and> x < n} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
show "{x |x. x \<noteq> 0 \<and> x < n} \<subseteq> {x |x. x < n \<and> coprime x n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x \<noteq> 0 \<and> x < n} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using coprime_commute prime_nat_iff'' that
[PROOF STATE]
proof (prove)
using this:
coprime ?b ?a = coprime ?a ?b
prime ?p = (?p \<noteq> 0 \<and> ?p \<noteq> 1 \<and> (\<forall>m. 0 < m \<and> m < ?p \<longrightarrow> coprime ?p m))
prime n

goal (1 subgoal):
 1. {x |x. x \<noteq> 0 \<and> x < n} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
{x |x. x \<noteq> 0 \<and> x < n} \<subseteq> {x |x. x < n \<and> coprime x n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {x |x. x \<noteq> 0 \<and> x < n}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
obtain m where \<open>m+1 = n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. m + 1 = n \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using add.commute assms less_imp_add_positive
[PROOF STATE]
proof (prove)
using this:
?a + ?b = ?b + ?a
1 < n
?i < ?j \<Longrightarrow> \<exists>k>0. ?i + k = ?j

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

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
have \<open>{1+j| j::nat. j < (m::nat)} =  {x | x :: nat. x \<noteq> 0 \<and> x < m+1}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1 + j |j. j < m} = {x |x. x \<noteq> 0 \<and> x < m + 1}
[PROOF STEP]
by (metis Suc_eq_plus1   \<open>m + 1 = n\<close> gr0_implies_Suc le_simps(3)   less_nat_zero_code   linorder_not_less nat.simps(3) nat_neq_iff  plus_1_eq_Suc )
[PROOF STATE]
proof (state)
this:
{1 + j |j. j < m} = {x |x. x \<noteq> 0 \<and> x < m + 1}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
hence  \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j| j::nat. j < (m::nat)}\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j |j. j < m} = {x |x. x \<noteq> 0 \<and> x < m + 1}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
using \<open>{x | x :: nat. x < n \<and> coprime x n} =  {x | x :: nat. x \<noteq> 0 \<and> x < n}\<close>  \<open>m+1 = n\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j |j. j < m} = {x |x. x \<noteq> 0 \<and> x < m + 1}
{x |x. x < n \<and> coprime x n} = {x |x. x \<noteq> 0 \<and> x < n}
m + 1 = n

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
from \<open>n > 1\<close>
[PROOF STATE]
proof (chain)
picking this:
1 < n
[PROOF STEP]
have \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. m \<noteq> 0
[PROOF STEP]
using \<open>m + 1 = n\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n
m + 1 = n

goal (1 subgoal):
 1. m \<noteq> 0
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
m \<noteq> 0

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
using Suc_eq_plus1 \<open>1 < n\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
Suc ?n = ?n + 1
1 < n
{x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
hence \<open>(\<exists> m.  m \<noteq> 0 \<and> {x | x :: nat. x < n \<and> coprime x n} = {1+j| j::nat. j < m})\<close>
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
m \<noteq> 0

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
hence \<open>\<exists>m.  m \<noteq> 0 \<and> {x | x :: nat. x < n \<and> coprime x n} = {1+j*1| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j |j. j < m}

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * 1 |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * 1 |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * 1 |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
prime n \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
prime n \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
        if "\<exists>k. n = 2 ^ k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
obtain k where \<open>n = 2 ^ k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>k. n = 2 ^ k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>\<exists>k. n = 2 ^ k\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>k. n = 2 ^ k

goal (1 subgoal):
 1. (\<And>k. n = 2 ^ k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n = 2 ^ k

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>k \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. k \<noteq> 0
[PROOF STEP]
by (metis \<open>1 < n\<close> \<open>n = 2 ^ k\<close> nat_less_le power.simps(1))
[PROOF STATE]
proof (state)
this:
k \<noteq> 0

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
obtain t where \<open>Suc t = k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>t. Suc t = k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis \<open>k \<noteq> 0\<close> fib.cases)
[PROOF STATE]
proof (state)
this:
Suc t = k

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>n = 2^(Suc t)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 ^ Suc t
[PROOF STEP]
by (simp add: \<open>Suc t = k\<close> \<open>n = 2 ^ k\<close>)
[PROOF STATE]
proof (state)
this:
n = 2 ^ Suc t

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j*2| j::nat. j < 2^t}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {x |x. x < n \<and> coprime x n} \<subseteq> {1 + j * 2 |j. j < 2 ^ t}
 2. {1 + j * 2 |j. j < 2 ^ t} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
show "{x |x. x < n \<and> coprime x n} \<subseteq> {1 + j * 2 |j. j < 2^t}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} \<subseteq> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
fix x
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
assume \<open>x \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (state)
this:
x \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
hence \<open>x < n\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < n \<and> coprime x n}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
have \<open>coprime x n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime x n
[PROOF STEP]
using \<open>x \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < n \<and> coprime x n}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
hence \<open>coprime x (2^(Suc k))\<close>
[PROOF STATE]
proof (prove)
using this:
coprime x n

goal (1 subgoal):
 1. coprime x (2 ^ Suc k)
[PROOF STEP]
by (simp add: \<open>k \<noteq> 0\<close> \<open>n = 2 ^ k\<close>)
[PROOF STATE]
proof (state)
this:
coprime x (2 ^ Suc k)

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
have \<open>odd x\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd x
[PROOF STEP]
using \<open>coprime x n\<close> \<open>k \<noteq> 0\<close> \<open>n = 2 ^ k\<close>
[PROOF STATE]
proof (prove)
using this:
coprime x n
k \<noteq> 0
n = 2 ^ k

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
odd x
[PROOF STEP]
obtain j where \<open>x = 1+j*2\<close>
[PROOF STATE]
proof (prove)
using this:
odd x

goal (1 subgoal):
 1. (\<And>j. x = 1 + j * 2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis add.commute add.left_commute left_add_twice mult_2_right oddE)
[PROOF STATE]
proof (state)
this:
x = 1 + j * 2

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
have \<open>x < 2^k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < 2 ^ k
[PROOF STEP]
using \<open>n = 2 ^ k\<close> \<open>x < n\<close> \<open>x = 1+j*2\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2 ^ k
x < n
x = 1 + j * 2

goal (1 subgoal):
 1. x < 2 ^ k
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
x < 2 ^ k

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
hence \<open>1+j*2 < 2^k\<close>
[PROOF STATE]
proof (prove)
using this:
x < 2 ^ k

goal (1 subgoal):
 1. 1 + j * 2 < 2 ^ k
[PROOF STEP]
using \<open>x = 1+j*2\<close>
[PROOF STATE]
proof (prove)
using this:
x < 2 ^ k
x = 1 + j * 2

goal (1 subgoal):
 1. 1 + j * 2 < 2 ^ k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + j * 2 < 2 ^ k

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
hence \<open>j < 2^t\<close>
[PROOF STATE]
proof (prove)
using this:
1 + j * 2 < 2 ^ k

goal (1 subgoal):
 1. j < 2 ^ t
[PROOF STEP]
using \<open>Suc t = k\<close>
[PROOF STATE]
proof (prove)
using this:
1 + j * 2 < 2 ^ k
Suc t = k

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < n \<and> coprime x n} \<Longrightarrow> x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
thus \<open>x \<in> {1 + j * 2 |j. j < 2^t}\<close>
[PROOF STATE]
proof (prove)
using this:
j < 2 ^ t

goal (1 subgoal):
 1. x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
using \<open>x = 1+j*2\<close>
[PROOF STATE]
proof (prove)
using this:
j < 2 ^ t
x = 1 + j * 2

goal (1 subgoal):
 1. x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {1 + j * 2 |j. j < 2 ^ t}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} \<subseteq> {1 + j * 2 |j. j < 2 ^ t}

goal (1 subgoal):
 1. {1 + j * 2 |j. j < 2 ^ t} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
show "{1 + j * 2 |j. j < 2 ^ t} \<subseteq> {x |x. x < n \<and> coprime x n}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1 + j * 2 |j. j < 2 ^ t} \<subseteq> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
fix x::nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
assume \<open>x \<in> {1 + j * 2 |j. j < 2 ^ t}\<close>
[PROOF STATE]
proof (state)
this:
x \<in> {1 + j * 2 |j. j < 2 ^ t}

goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {1 + j * 2 |j. j < 2 ^ t}
[PROOF STEP]
obtain j where \<open>x = 1 + j * 2\<close> and \<open>j < 2 ^ t\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {1 + j * 2 |j. j < 2 ^ t}

goal (1 subgoal):
 1. (\<And>j. \<lbrakk>x = 1 + j * 2; j < 2 ^ t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x = 1 + j * 2
j < 2 ^ t

goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
have \<open>x < 2*(2^t)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < 2 * 2 ^ t
[PROOF STEP]
using  \<open>x = 1 + j * 2\<close>  \<open>j < 2 ^ t\<close>
[PROOF STATE]
proof (prove)
using this:
x = 1 + j * 2
j < 2 ^ t

goal (1 subgoal):
 1. x < 2 * 2 ^ t
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
x < 2 * 2 ^ t

goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
hence \<open>x < n\<close>
[PROOF STATE]
proof (prove)
using this:
x < 2 * 2 ^ t

goal (1 subgoal):
 1. x < n
[PROOF STEP]
by (simp add: \<open>n = 2 ^ Suc t\<close>)
[PROOF STATE]
proof (state)
this:
x < n

goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
x < n

goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
have \<open>coprime x n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime x n
[PROOF STEP]
by (metis (no_types) \<open>\<And>thesis. (\<And>j. \<lbrakk>x = 1 + j * 2; j < 2 ^ t\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis\<close> \<open>n = 2 ^ k\<close> coprime_Suc_left_nat coprime_mult_right_iff coprime_power_right_iff plus_1_eq_Suc)
[PROOF STATE]
proof (state)
this:
coprime x n

goal (1 subgoal):
 1. \<And>x. x \<in> {1 + j * 2 |j. j < 2 ^ t} \<Longrightarrow> x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
x < n
coprime x n
[PROOF STEP]
show \<open>x \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
x < n
coprime x n

goal (1 subgoal):
 1. x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {x |x. x < n \<and> coprime x n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{1 + j * 2 |j. j < 2 ^ t} \<subseteq> {x |x. x < n \<and> coprime x n}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < 2 ^ t}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>(2::nat)^(t::nat) \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ t \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 ^ t \<noteq> 0

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
obtain m where \<open>m = (2::nat)^t\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. m = 2 ^ t \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m = 2 ^ t

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m \<noteq> 0
[PROOF STEP]
using \<open>m = 2 ^ t\<close>
[PROOF STATE]
proof (prove)
using this:
m = 2 ^ t

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

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j*2| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}
[PROOF STEP]
using \<open>m = 2 ^ t\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < 2 ^ t}\<close>
[PROOF STATE]
proof (prove)
using this:
m = 2 ^ t
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < 2 ^ t}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
from  \<open>m \<noteq> 0\<close>  \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j*2| j::nat. j < m}\<close>
[PROOF STATE]
proof (chain)
picking this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>k. n = 2 ^ k \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<exists>k. n = 2 ^ k \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
        if "n = 6"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have  \<open>{x | x. x < 6 \<and> coprime x 6} = {1+j*4| j::nat. j < 2}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
[PROOF STEP]
have \<open>{x | x::nat. x < 6 \<and> coprime x 6} = {1, 5}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1, 5}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. {x |x. x < 6 \<and> coprime x 6} \<subseteq> {1, 5}
 2. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
show "{u. \<exists>x. u = (x::nat) \<and> x < 6 \<and> coprime x 6} \<subseteq> {1, 5}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} \<subseteq> {1, 5}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
fix u::nat
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
assume \<open>u \<in> {u. \<exists>x. u = x \<and> x < 6 \<and> coprime x 6}\<close>
[PROOF STATE]
proof (state)
this:
u \<in> {x |x. x < 6 \<and> coprime x 6}

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
hence \<open>coprime u 6\<close>
[PROOF STATE]
proof (prove)
using this:
u \<in> {x |x. x < 6 \<and> coprime x 6}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
have \<open>u < 6\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u < 6
[PROOF STEP]
using \<open>u \<in> {u. \<exists>x. u = x \<and> x < 6 \<and> coprime x 6}\<close>
[PROOF STATE]
proof (prove)
using this:
u \<in> {x |x. x < 6 \<and> coprime x 6}

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
u < 6

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
have \<open>u \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<noteq> 0
[PROOF STEP]
using \<open>coprime u 6\<close> ord_eq_0
[PROOF STATE]
proof (prove)
using this:
coprime u 6
(ord ?n ?a = 0) = (\<not> coprime ?n ?a)

goal (1 subgoal):
 1. u \<noteq> 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
u \<noteq> 0

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
u \<noteq> 0

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
have \<open>u \<noteq> 2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<noteq> 2
[PROOF STEP]
using \<open>coprime u 6\<close>
[PROOF STATE]
proof (prove)
using this:
coprime u 6

goal (1 subgoal):
 1. u \<noteq> 2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u \<noteq> 2

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
u \<noteq> 2

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
have \<open>u \<noteq> 3\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<noteq> 3
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. u \<noteq> 3
[PROOF STEP]
have \<open>gcd (3::nat) 6 = 3\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd 3 6 = 3
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
gcd 3 6 = 3

goal (1 subgoal):
 1. u \<noteq> 3
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
gcd 3 6 = 3

goal (1 subgoal):
 1. u \<noteq> 3
[PROOF STEP]
by (metis (no_types) \<open>coprime u 6\<close> \<open>gcd 3 6 = 3\<close> coprime_iff_gcd_eq_1
                      numeral_eq_one_iff semiring_norm(86))
[PROOF STATE]
proof (state)
this:
u \<noteq> 3

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
u \<noteq> 3

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
have \<open>u \<noteq> 4\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. u \<noteq> 4
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. u \<noteq> 4
[PROOF STEP]
have \<open>gcd (4::nat) 6 = 2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd 4 6 = 2
[PROOF STEP]
by (metis (no_types, lifting) add_numeral_left gcd_add1 gcd_add2 gcd_nat.idem
                      numeral_Bit0 numeral_One one_plus_numeral semiring_norm(4) semiring_norm(5))
[PROOF STATE]
proof (state)
this:
gcd 4 6 = 2

goal (1 subgoal):
 1. u \<noteq> 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
gcd 4 6 = 2

goal (1 subgoal):
 1. u \<noteq> 4
[PROOF STEP]
using \<open>coprime u 6\<close> coprime_iff_gcd_eq_1
[PROOF STATE]
proof (prove)
using this:
gcd 4 6 = 2
coprime u 6
coprime ?a ?b = (gcd ?a ?b = (1::?'a))

goal (1 subgoal):
 1. u \<noteq> 4
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u \<noteq> 4

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

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
u < 6
u \<noteq> 0
u \<noteq> 2
u \<noteq> 3
u \<noteq> 4
[PROOF STEP]
have \<open>u = 1 \<or> u = 5\<close>
[PROOF STATE]
proof (prove)
using this:
u < 6
u \<noteq> 0
u \<noteq> 2
u \<noteq> 3
u \<noteq> 4

goal (1 subgoal):
 1. u = 1 \<or> u = 5
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
u = 1 \<or> u = 5

goal (1 subgoal):
 1. \<And>x. x \<in> {x |x. x < 6 \<and> coprime x 6} \<Longrightarrow> x \<in> {1, 5}
[PROOF STEP]
thus \<open>u \<in> {1, 5}\<close>
[PROOF STATE]
proof (prove)
using this:
u = 1 \<or> u = 5

goal (1 subgoal):
 1. u \<in> {1, 5}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
u \<in> {1, 5}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < 6 \<and> coprime x 6} \<subseteq> {1, 5}

goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
show "{1::nat, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
have \<open>(1::nat) \<in> {x |x. x < 6 \<and> coprime x 6}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<in> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
1 \<in> {x |x. x < 6 \<and> coprime x 6}

goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
1 \<in> {x |x. x < 6 \<and> coprime x 6}

goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
have \<open>(5::nat) \<in> {x |x. x < 6 \<and> coprime x 6}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 5 \<in> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
by (metis Suc_numeral coprime_Suc_right_nat less_add_one mem_Collect_eq
                    numeral_plus_one semiring_norm(5) semiring_norm(8))
[PROOF STATE]
proof (state)
this:
5 \<in> {x |x. x < 6 \<and> coprime x 6}

goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
1 \<in> {x |x. x < 6 \<and> coprime x 6}
5 \<in> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
1 \<in> {x |x. x < 6 \<and> coprime x 6}
5 \<in> {x |x. x < 6 \<and> coprime x 6}

goal (1 subgoal):
 1. {1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{1, 5} \<subseteq> {x |x. x < 6 \<and> coprime x 6}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < 6 \<and> coprime x 6} = {1, 5}

goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{x |x. x < 6 \<and> coprime x 6} = {1, 5}

goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
[PROOF STEP]
have \<open>{1+j*4| j::nat. j < 2} = {1, 5}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1 + j * 4 |j. j < 2} = {1, 5}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{1 + j * 4 |j. j < 2} = {1, 5}

goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{x |x. x < 6 \<and> coprime x 6} = {1, 5}
{1 + j * 4 |j. j < 2} = {1, 5}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
{x |x. x < 6 \<and> coprime x 6} = {1, 5}
{1 + j * 4 |j. j < 2} = {1, 5}

goal (1 subgoal):
 1. {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
{x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>(2::nat) \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
2 \<noteq> 0

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
{x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
2 \<noteq> 0
[PROOF STEP]
have \<open>\<exists> m.  m \<noteq> 0 \<and> {x | x :: nat. x < 6 \<and> coprime x 6} = {1+j*4| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
{x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < 2}
2 \<noteq> 0

goal (1 subgoal):
 1. \<exists>m. m \<noteq> 0 \<and> {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
\<exists>m. m \<noteq> 0 \<and> {x |x. x < 6 \<and> coprime x 6} = {1 + j * 4 |j. j < m}
n = 6

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n = 6 \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
prime n \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
\<exists>k. n = 2 ^ k \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
n = 6 \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
prime n \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
\<exists>k. n = 2 ^ k \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
n = 6 \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
prime n \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
\<exists>k. n = 2 ^ k \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
n = 6 \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6 \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m} \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
show "prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6"
      if "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
obtain b m where \<open>m \<noteq> 0\<close> and \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m b. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>m b. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
proof(cases \<open>n = 2\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. n = 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
 2. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
n = 2

goal (2 subgoals):
 1. n = 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
 2. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 2

goal (1 subgoal):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
n \<noteq> 2

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
have \<open>b \<le> 4\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
proof(cases \<open>odd b\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. odd b \<Longrightarrow> b \<le> 4
 2. \<not> odd b \<Longrightarrow> b \<le> 4
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
odd b

goal (2 subgoals):
 1. odd b \<Longrightarrow> b \<le> 4
 2. \<not> odd b \<Longrightarrow> b \<le> 4
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
proof(rule classical)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
assume \<open>\<not>(b \<le> 4)\<close>
[PROOF STATE]
proof (state)
this:
\<not> b \<le> 4

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>b > 4\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> b \<le> 4

goal (1 subgoal):
 1. 4 < b
[PROOF STEP]
using le_less_linear
[PROOF STATE]
proof (prove)
using this:
\<not> b \<le> 4
?x \<le> ?y \<or> ?y < ?x

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
obtain m where \<open>m \<noteq> 0\<close>
              and \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
using \<open>4 < b\<close>
[PROOF STATE]
proof (prove)
using this:
4 < b

goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
b \<noteq> 0

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>n = 2 + (m-1)*b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>n-1 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>n-1 \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close>
                  \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain i::nat where \<open>n-1 = 1+i*b\<close> and \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>n - 1 = 1 + i * b; i < m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 = 1 + i * b
i < m

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>i \<le> m-1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> m - 1
[PROOF STEP]
using \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
i < m

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

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>1 + (m-1)*b \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<in> {x | x::nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 1 + (m - 1) * b < n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> n-1\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> n - 1
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> 1+i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
using \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1
n - 1 = 1 + i * b

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>(m-1)*b \<le> i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>m-1 \<le> i\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
using \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b
b \<noteq> 0

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>m-1 = i\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
using \<open>i \<le> m - 1\<close> le_antisym
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i
i \<le> m - 1
\<lbrakk>?m \<le> ?n; ?n \<le> ?m\<rbrakk> \<Longrightarrow> ?m = ?n

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = i
m \<noteq> 0
n - 1 = 1 + i * b

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

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>m \<ge> 2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<le> m
[PROOF STEP]
using \<open>n = 2 + (m - 1)*b\<close> \<open>n \<noteq> 2\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2 + (m - 1) * b
n \<noteq> 2

goal (1 subgoal):
 1. 2 \<le> m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 \<le> m

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>1+b \<in> {1+j*b| j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<le> m

goal (1 subgoal):
 1. 1 + b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
1 + b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence  \<open>1+b \<in> {x | x::nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + b \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>coprime (1+b) n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. coprime (1 + b) n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
coprime (1 + b) n

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>(2::nat) dvd (1+b)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even (1 + b)
[PROOF STEP]
using \<open>odd b\<close>
[PROOF STATE]
proof (prove)
using this:
odd b

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>coprime (2::nat) n\<close>
[PROOF STATE]
proof (prove)
using this:
even (1 + b)

goal (1 subgoal):
 1. coprime 2 n
[PROOF STEP]
using \<open>coprime (1 + b) n\<close> coprime_common_divisor coprime_left_2_iff_odd odd_one
[PROOF STATE]
proof (prove)
using this:
even (1 + b)
coprime (1 + b) n
\<lbrakk>coprime ?a ?b; ?c dvd ?a; ?c dvd ?b\<rbrakk> \<Longrightarrow> is_unit ?c
coprime (2::?'a) ?a = odd ?a
odd (1::?'a)

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>(2::nat) < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 < n
[PROOF STEP]
using \<open>1 < n\<close> \<open>n \<noteq> 2\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n
n \<noteq> 2

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>2 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>2 < n\<close> \<open>coprime 2 n\<close>
[PROOF STATE]
proof (prove)
using this:
2 < n
coprime 2 n

goal (1 subgoal):
 1. 2 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence  \<open>2 \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 2 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 2 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain j::nat where \<open>2 = 1+j*b\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {1 + j * b |j. j < m}

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have  \<open>1 = j*b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 = j * b
[PROOF STEP]
using \<open>2 = 1+j*b\<close>
[PROOF STATE]
proof (prove)
using this:
2 = 1 + j * b

goal (1 subgoal):
 1. 1 = j * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 = j * b

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
1 = j * b

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

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

goal (1 subgoal):
 1. \<not> odd b \<Longrightarrow> b \<le> 4
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> odd b \<Longrightarrow> b \<le> 4
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> odd b

goal (1 subgoal):
 1. \<not> odd b \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>even b\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> odd b

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

goal (1 subgoal):
 1. \<not> odd b \<Longrightarrow> b \<le> 4
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
proof(rule classical)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
assume \<open>\<not>(b \<le> 4)\<close>
[PROOF STATE]
proof (state)
this:
\<not> b \<le> 4

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>b > 4\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> b \<le> 4

goal (1 subgoal):
 1. 4 < b
[PROOF STEP]
using le_less_linear
[PROOF STATE]
proof (prove)
using this:
\<not> b \<le> 4
?x \<le> ?y \<or> ?y < ?x

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
obtain m where  \<open> m \<noteq> 0\<close>
              and \<open>{x | x::nat. x < n \<and> coprime x n} = {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
using \<open>4 < b\<close>
[PROOF STATE]
proof (prove)
using this:
4 < b

goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
b \<noteq> 0

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>n = 2 + (m-1)*b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>n-1 \<in> {x | x::nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>n-1 \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close>
                  \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain i::nat where \<open>n-1 = 1+i*b\<close> and \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>n - 1 = 1 + i * b; i < m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 = 1 + i * b
i < m

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>i \<le> m-1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> m - 1
[PROOF STEP]
using \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
i < m

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

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>1 + (m-1)*b \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 1 + (m - 1) * b < n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> n-1\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> n - 1
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> 1+i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
using \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1
n - 1 = 1 + i * b

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>(m-1)*b \<le> i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>m-1 \<le> i\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
using \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b
b \<noteq> 0

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>m-1 = i\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
using \<open>i \<le> m - 1\<close> le_antisym
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i
i \<le> m - 1
\<lbrakk>?m \<le> ?n; ?n \<le> ?m\<rbrakk> \<Longrightarrow> ?m = ?n

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = i
m \<noteq> 0
n - 1 = 1 + i * b

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

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
obtain k :: nat where \<open>b = 2*k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>k. b = 2 * k \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>even b\<close>
[PROOF STATE]
proof (prove)
using this:
even b

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>n = 2*(1 + (m-1)*k)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 * (1 + (m - 1) * k)
[PROOF STEP]
using  \<open>n = 2 + (m-1)*b\<close>  \<open>b = 2*k\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2 + (m - 1) * b
b = 2 * k

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

goal (1 subgoal):
 1. \<not> b \<le> 4 \<Longrightarrow> b \<le> 4
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
proof (cases \<open>odd m\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
odd m

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>odd m\<close>
[PROOF STATE]
proof (prove)
using this:
odd m

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

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
odd m
[PROOF STEP]
obtain t::nat where \<open>m-1 = 2*t\<close>
[PROOF STATE]
proof (prove)
using this:
odd m

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

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
have  \<open>n = 2*(1 + b*t)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 * (1 + b * t)
[PROOF STEP]
using \<open>m - 1 = 2 * t\<close> \<open>n = 2 + (m - 1) * b\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = 2 * t
n = 2 + (m - 1) * b

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

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>t < m\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t < m
[PROOF STEP]
using \<open>m - 1 = 2 * t\<close> \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = 2 * t
m \<noteq> 0

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

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>1 + b*t \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + b * t \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>t < m\<close>
[PROOF STATE]
proof (prove)
using this:
t < m

goal (1 subgoal):
 1. 1 + b * t \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + b * t \<in> {1 + j * b |j. j < m}

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>1 + b*t \<in> {x | x::nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + b * t \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + b * t \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + b * t \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + b * t \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + b * t \<in> {x |x. x < n \<and> coprime x n}

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>coprime (1 + b*t) n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + b * t \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. coprime (1 + b * t) n
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
coprime (1 + b * t) n

goal (2 subgoals):
 1. odd m \<Longrightarrow> b \<le> 4
 2. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
coprime (1 + b * t) n

goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
by (metis (no_types, lifting) \<open>b = 2 * k\<close> \<open>n = 2 * (1 + (m - 1) * k)\<close> \<open>n = 2 * (1 + b * t)\<close> \<open>n = 2 + (m - 1) * b\<close> \<open>n \<noteq> 2\<close> add_cancel_right_right coprime_mult_right_iff coprime_self mult_cancel_left mult_is_0 nat_dvd_1_iff_1)
[PROOF STATE]
proof (state)
this:
b \<le> 4

goal (1 subgoal):
 1. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> odd m

goal (1 subgoal):
 1. \<not> odd m \<Longrightarrow> b \<le> 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> odd m

goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
proof(cases \<open>odd k\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
odd k

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>odd k\<close>
[PROOF STATE]
proof (prove)
using this:
odd k

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

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>even (1 + (m - 1) * k)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even (1 + (m - 1) * k)
[PROOF STEP]
by (simp add: False True \<open>m \<noteq> 0\<close>)
[PROOF STATE]
proof (state)
this:
even (1 + (m - 1) * k)

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>coprime (2 + (m - 1) * k) (1 + (m - 1) * k)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (2 + (m - 1) * k) (1 + (m - 1) * k)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
coprime (2 + (m - 1) * k) (1 + (m - 1) * k)

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>coprime (2 + (m - 1) * k) n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (2 + (m - 1) * k) n
[PROOF STEP]
using \<open>coprime (2 + (m - 1) * k) (1 + (m - 1) * k)\<close> \<open>even (1 + (m - 1) * k)\<close>
                    \<open>n = 2 * (1 + (m - 1) * k)\<close> coprime_common_divisor coprime_mult_right_iff
                    coprime_right_2_iff_odd odd_one
[PROOF STATE]
proof (prove)
using this:
coprime (2 + (m - 1) * k) (1 + (m - 1) * k)
even (1 + (m - 1) * k)
n = 2 * (1 + (m - 1) * k)
\<lbrakk>coprime ?a ?b; ?c dvd ?a; ?c dvd ?b\<rbrakk> \<Longrightarrow> is_unit ?c
coprime ?c (?a * ?b) = (coprime ?c ?a \<and> coprime ?c ?b)
coprime ?a (2::?'a) = odd ?a
odd (1::?'a)

goal (1 subgoal):
 1. coprime (2 + (m - 1) * k) n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
coprime (2 + (m - 1) * k) n

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>2 + (m - 1) * k < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 + (m - 1) * k < n
[PROOF STEP]
by (metis (no_types, lifting) \<open>even (1 + (m - 1) * k)\<close> \<open>n = 2 * (1 + (m - 1) * k)\<close>
                      add_gr_0 add_mono_thms_linordered_semiring(1) dvd_add_left_iff dvd_add_triv_left_iff dvd_imp_le le_add2 le_neq_implies_less less_numeral_extra(1) mult_2 odd_one)
[PROOF STATE]
proof (state)
this:
2 + (m - 1) * k < n

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>2 + (m - 1) * k  \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>2 + (m - 1) * k < n\<close> \<open>coprime (2 + (m - 1) * k) n\<close>
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k < n
coprime (2 + (m - 1) * k) n

goal (1 subgoal):
 1. 2 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>2 + (m - 1) * k  \<in> {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 2 + (m - 1) * k \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 2 + (m - 1) * k \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 + (m - 1) * k \<in> {1 + j * b |j. j < m}

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 + (m - 1) * k \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain j::nat where  \<open>2 + (m - 1) * k  = 1 + j * b\<close> and \<open>j < m\<close>
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>j. \<lbrakk>2 + (m - 1) * k = 1 + j * b; j < m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 + (m - 1) * k = 1 + j * b
j < m

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have  \<open>1 + (m - 1) * k  = j * b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (m - 1) * k = j * b
[PROOF STEP]
using \<open>2 + (m - 1) * k  = 1 + j * b\<close>
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k = 1 + j * b

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

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence  \<open>1 + (m - 1) * k  = j * (2*k)\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * k = j * b

goal (1 subgoal):
 1. 1 + (m - 1) * k = j * (2 * k)
[PROOF STEP]
using \<open>b = 2 * k\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * k = j * b
b = 2 * k

goal (1 subgoal):
 1. 1 + (m - 1) * k = j * (2 * k)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * k = j * (2 * k)

goal (2 subgoals):
 1. \<lbrakk>\<not> odd m; odd k\<rbrakk> \<Longrightarrow> b \<le> 4
 2. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * k = j * (2 * k)

goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
by (metis \<open>b = 2 * k\<close> \<open>even b\<close> \<open>n = 2 * (1 + (m - 1) * k)\<close> \<open>n = 2 + (m - 1) * b\<close> dvd_add_times_triv_right_iff dvd_antisym dvd_imp_le dvd_triv_right even_numeral mult_2 zero_less_numeral)
[PROOF STATE]
proof (state)
this:
b \<le> 4

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
\<not> odd k

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>even k\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> odd k

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

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>odd (1 + (m - 1) * k)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd (1 + (m - 1) * k)
[PROOF STEP]
by (simp add: \<open>even k\<close> )
[PROOF STATE]
proof (state)
this:
odd (1 + (m - 1) * k)

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>coprime (3 + (m - 1) * k) (1 + (m - 1) * k)\<close>
[PROOF STATE]
proof (prove)
using this:
odd (1 + (m - 1) * k)

goal (1 subgoal):
 1. coprime (3 + (m - 1) * k) (1 + (m - 1) * k)
[PROOF STEP]
by (smt add_numeral_left coprime_common_divisor coprime_right_2_iff_odd dvd_add_left_iff not_coprimeE numeral_Bit1 numeral_One numeral_plus_one one_add_one)
[PROOF STATE]
proof (state)
this:
coprime (3 + (m - 1) * k) (1 + (m - 1) * k)

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>coprime (3 + (m - 1) * k) n\<close>
[PROOF STATE]
proof (prove)
using this:
coprime (3 + (m - 1) * k) (1 + (m - 1) * k)

goal (1 subgoal):
 1. coprime (3 + (m - 1) * k) n
[PROOF STEP]
by (metis \<open>even k\<close> \<open>n = 2 * (1 + (m - 1) * k)\<close> coprime_mult_right_iff coprime_right_2_iff_odd even_add even_mult_iff odd_numeral)
[PROOF STATE]
proof (state)
this:
coprime (3 + (m - 1) * k) n

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>3 + (m - 1) * k < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 + (m - 1) * k < n
[PROOF STEP]
by (smt Groups.add_ac(2) \<open>even k\<close> \<open>n = 2 * (1 + (m - 1) * k)\<close> \<open>n = 2 + (m - 1) * b\<close> \<open>n \<noteq> 2\<close> add_Suc_right add_cancel_right_right add_mono_thms_linordered_semiring(1) dvd_imp_le even_add even_mult_iff le_add2 le_neq_implies_less left_add_twice mult_2 neq0_conv numeral_Bit1 numeral_One odd_numeral one_add_one plus_1_eq_Suc)
[PROOF STATE]
proof (state)
this:
3 + (m - 1) * k < n

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>3 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>3 + (m - 1) * k < n\<close> \<open>coprime (3 + (m - 1) * k) n\<close>
[PROOF STATE]
proof (prove)
using this:
3 + (m - 1) * k < n
coprime (3 + (m - 1) * k) n

goal (1 subgoal):
 1. 3 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
3 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence \<open>3 + (m - 1) * k \<in> {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
3 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 3 + (m - 1) * k \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
3 + (m - 1) * k \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 3 + (m - 1) * k \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
3 + (m - 1) * k \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
3 + (m - 1) * k \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain j::nat where \<open>3 + (m - 1) * k = 1 + j * b\<close>
[PROOF STATE]
proof (prove)
using this:
3 + (m - 1) * k \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>j. 3 + (m - 1) * k = 1 + j * b \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
3 + (m - 1) * k = 1 + j * b

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
have \<open>2 + (m - 1) * k = j * b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 + (m - 1) * k = j * b
[PROOF STEP]
using \<open>3 + (m - 1) * k = 1 + j * b\<close>
[PROOF STATE]
proof (prove)
using this:
3 + (m - 1) * k = 1 + j * b

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

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
hence  \<open>2 + (m - 1) * k = j * 2*k\<close>
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k = j * b

goal (1 subgoal):
 1. 2 + (m - 1) * k = j * 2 * k
[PROOF STEP]
by (simp add: \<open>b = 2 * k\<close>)
[PROOF STATE]
proof (state)
this:
2 + (m - 1) * k = j * 2 * k

goal (1 subgoal):
 1. \<lbrakk>\<not> odd m; \<not> odd k\<rbrakk> \<Longrightarrow> b \<le> 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
2 + (m - 1) * k = j * 2 * k

goal (1 subgoal):
 1. b \<le> 4
[PROOF STEP]
by (metis \<open>4 < b\<close> \<open>b = 2 * k\<close> \<open>even k\<close> dvd_add_times_triv_right_iff dvd_antisym
                      dvd_triv_right mult_2 nat_neq_iff numeral_Bit0)
[PROOF STATE]
proof (state)
this:
b \<le> 4

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

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

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

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

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b \<le> 4

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
have \<open>b \<noteq> 3\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> 3
[PROOF STEP]
proof (rule classical)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
assume \<open>\<not> (b \<noteq> 3)\<close>
[PROOF STATE]
proof (state)
this:
\<not> b \<noteq> 3

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open>b = 3\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> b \<noteq> 3

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
obtain m where  \<open>m \<noteq> 0\<close> and
            \<open>{x | x::nat. x < n \<and> coprime x n} = {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>m. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
by (simp add: \<open>b = 3\<close>)
[PROOF STATE]
proof (state)
this:
b \<noteq> 0

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>n = 2 + (m-1)*b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>n-1 \<in> {x | x::nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>n-1 \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close>
                \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain i::nat where \<open>n-1 = 1+i*b\<close> and \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>n - 1 = 1 + i * b; i < m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 = 1 + i * b
i < m

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>i \<le> m-1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> m - 1
[PROOF STEP]
using \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
i < m

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

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
have \<open>1 + (m-1)*b \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 1 + (m - 1) * b < n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> n-1\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> n - 1
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> 1+i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
using \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1
n - 1 = 1 + i * b

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>(m-1)*b \<le> i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>m-1 \<le> i\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
using \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b
b \<noteq> 0

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
hence \<open>m-1 = i\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
using \<open>i \<le> m - 1\<close> le_antisym
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i
i \<le> m - 1
\<lbrakk>?m \<le> ?n; ?n \<le> ?m\<rbrakk> \<Longrightarrow> ?m = ?n

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * b
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = i
m \<noteq> 0
n - 1 = 1 + i * b

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

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>n > 2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 < n
[PROOF STEP]
using \<open>1 < n\<close> \<open>n \<noteq> 2\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n
n \<noteq> 2

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open> m \<ge> 2 \<close>
[PROOF STATE]
proof (prove)
using this:
2 < n

goal (1 subgoal):
 1. 2 \<le> m
[PROOF STEP]
using  \<open>n = 2 + (m-1)*b\<close> \<open>b = 3\<close>
[PROOF STATE]
proof (prove)
using this:
2 < n
n = 2 + (m - 1) * b
b = 3

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>4 \<in> {1+j*(b::nat)| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>2 \<le> m\<close> \<open>b = 3\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<le> m
b = 3

goal (1 subgoal):
 1. 4 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
4 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open>(4::nat) \<in>  {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
4 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 4 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
4 \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 4 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
4 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open>coprime (4::nat) n\<close>
[PROOF STATE]
proof (prove)
using this:
4 \<in> {x |x. x < n \<and> coprime x n}

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>(2::nat) dvd 4\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. even 4
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
even 4

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open>coprime (2::nat) n\<close>
[PROOF STATE]
proof (prove)
using this:
even 4

goal (1 subgoal):
 1. coprime 2 n
[PROOF STEP]
using \<open>coprime (4::nat) n\<close> coprime_divisors dvd_refl
[PROOF STATE]
proof (prove)
using this:
even 4
coprime 4 n
\<lbrakk>?a dvd ?c; ?b dvd ?d; coprime ?c ?d\<rbrakk> \<Longrightarrow> coprime ?a ?b
?a dvd ?a

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>4 < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 < n
[PROOF STEP]
using \<open>4 \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
4 \<in> {x |x. x < n \<and> coprime x n}

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have \<open>2 < (4::nat)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 < 4
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 < 4

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
have  \<open>2 < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 < n
[PROOF STEP]
by (simp add: \<open>2 < n\<close>)
[PROOF STATE]
proof (state)
this:
2 < n

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open>2 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
2 < n

goal (1 subgoal):
 1. 2 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using  \<open>coprime (2::nat) n\<close>
[PROOF STATE]
proof (prove)
using this:
2 < n
coprime 2 n

goal (1 subgoal):
 1. 2 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence  \<open>2 \<in> {1+j*(b::nat)| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 2 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 2 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
2 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain j::nat where \<open>2 = 1+j*3\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>j. 2 = 1 + j * 3 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>b = 3\<close>
[PROOF STATE]
proof (prove)
using this:
2 \<in> {1 + j * b |j. j < m}
b = 3

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

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
from  \<open>2 = 1+j*3\<close>
[PROOF STATE]
proof (chain)
picking this:
2 = 1 + j * 3
[PROOF STEP]
have  \<open>1 = j*3\<close>
[PROOF STATE]
proof (prove)
using this:
2 = 1 + j * 3

goal (1 subgoal):
 1. 1 = j * 3
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 = j * 3

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
hence \<open>3 dvd 1\<close>
[PROOF STATE]
proof (prove)
using this:
1 = j * 3

goal (1 subgoal):
 1. (3::'a) dvd (1::'a)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(3::?'a1) dvd (1::?'a1)

goal (1 subgoal):
 1. \<not> b \<noteq> 3 \<Longrightarrow> b \<noteq> 3
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
(3::?'a1) dvd (1::?'a1)

goal (1 subgoal):
 1. b \<noteq> 3
[PROOF STEP]
using nat_dvd_1_iff_1 numeral_eq_one_iff
[PROOF STATE]
proof (prove)
using this:
(3::?'a1) dvd (1::?'a1)
is_unit ?m = (?m = 1)
(numeral ?n = (1::?'a)) = (?n = num.One)

goal (1 subgoal):
 1. b \<noteq> 3
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
b \<noteq> 3

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

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
b \<le> 4
b \<noteq> 3
[PROOF STEP]
have \<open>b = 0 \<or> b = 1 \<or> b = 2 \<or> b = 4\<close>
[PROOF STATE]
proof (prove)
using this:
b \<le> 4
b \<noteq> 3

goal (1 subgoal):
 1. b = 0 \<or> b = 1 \<or> b = 2 \<or> b = 4
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
b = 0 \<or> b = 1 \<or> b = 2 \<or> b = 4

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b = 0 \<or> b = 1 \<or> b = 2 \<or> b = 4

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
have \<open>b = 0 \<Longrightarrow> \<exists>k. n = 2^k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
assume \<open>b = 0\<close>
[PROOF STATE]
proof (state)
this:
b = 0

goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
have \<open>{1 + j * b |j. j < m} = {1}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1 + j * b |j. j < m} = {1}
[PROOF STEP]
using \<open>b = 0\<close> \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
b = 0
m \<noteq> 0

goal (1 subgoal):
 1. {1 + j * b |j. j < m} = {1}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{1 + j * b |j. j < m} = {1}

goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
hence \<open>{x |x. x < n \<and> coprime x n} = {1}\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j * b |j. j < m} = {1}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j * b |j. j < m} = {1}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {1}

goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
hence \<open>n = 2\<close>
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {1}

goal (1 subgoal):
 1. n = 2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1} \<Longrightarrow> n = 2
[PROOF STEP]
have \<open>n-1 \<in>  {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1} \<Longrightarrow> n = 2
[PROOF STEP]
have \<open>n-1 \<in> {1}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {1}
[PROOF STEP]
using \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close> \<open>{x |x. x < n \<and> coprime x n} = {1}\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1}

goal (1 subgoal):
 1. n - 1 \<in> {1}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {1}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1} \<Longrightarrow> n = 2
[PROOF STEP]
hence \<open>n-1 = 1\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {1}

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

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1} \<Longrightarrow> n = 2
[PROOF STEP]
hence \<open>n = 2\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 = 1

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

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1} \<Longrightarrow> n = 2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 2

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n = 2

goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
hence \<open>n = 2^1\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2

goal (1 subgoal):
 1. n = 2 ^ 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n = 2 ^ 1

goal (1 subgoal):
 1. b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 2 ^ 1

goal (1 subgoal):
 1. \<exists>k. n = 2 ^ k
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>k. n = 2 ^ k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
have \<open>b = 1 \<Longrightarrow> prime n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = 1 \<Longrightarrow> prime n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = 1 \<Longrightarrow> prime n
[PROOF STEP]
assume \<open>b = 1\<close>
[PROOF STATE]
proof (state)
this:
b = 1

goal (1 subgoal):
 1. b = 1 \<Longrightarrow> prime n
[PROOF STEP]
have \<open>x < n \<Longrightarrow> x \<noteq> 0 \<Longrightarrow> coprime x n\<close>
            for x
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
assume \<open>x < n\<close> and \<open>x \<noteq> 0\<close>
[PROOF STATE]
proof (state)
this:
x < n
x \<noteq> 0

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>{1+j| j::nat. j < m} = {x | x::nat. x < m+1 \<and> x \<noteq> 0}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {1 + j |j. j < m} = {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
by (metis (full_types) Suc_eq_plus1  add_mono1 less_Suc_eq_0_disj  nat.simps(3) plus_1_eq_Suc )
[PROOF STATE]
proof (state)
this:
{1 + j |j. j < m} = {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
hence \<open>{x | x :: nat. x < n \<and> coprime x n} = {x | x :: nat. x < m+1 \<and> x \<noteq> 0}\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j |j. j < m} = {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
using \<open>b = 1\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j |j. j < m} = {x |x. x < m + 1 \<and> x \<noteq> 0}
b = 1
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>coprime (n-1) n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (n - 1) n
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

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

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>n-1 < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 < n
[PROOF STEP]
using \<open>1 < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n

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

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>n-1 \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>coprime (n - 1) n\<close> \<open>n - 1 < n\<close>
[PROOF STATE]
proof (prove)
using this:
coprime (n - 1) n
n - 1 < n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>n-1 \<le> m\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<le> m
[PROOF STEP]
by (metis (no_types, lifting) CollectD Suc_eq_plus1 Suc_less_eq2 \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close> \<open>{x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}\<close>   leD  le_less_linear not_less_eq_eq )
[PROOF STATE]
proof (state)
this:
n - 1 \<le> m

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>m \<in>  {x | x :: nat. x < m+1 \<and> x \<noteq> 0}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. m \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>m \<in> {x |x. x < n \<and> coprime x n} \<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>m \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}\<close>
                \<open>{x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}\<close>
[PROOF STATE]
proof (prove)
using this:
m \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}
{x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. m \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>m < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m < n
[PROOF STEP]
using \<open>m \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
m \<in> {x |x. x < n \<and> coprime x n}

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

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>m+1 = n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. m + 1 = n
[PROOF STEP]
using \<open>m < n\<close> \<open>n - 1 \<le> m\<close>
[PROOF STATE]
proof (prove)
using this:
m < n
n - 1 \<le> m

goal (1 subgoal):
 1. m + 1 = n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
m + 1 = n

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>x \<in>  {x | x :: nat. x < m+1 \<and> x \<noteq> 0}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
using \<open>m + 1 = n\<close> \<open>x < n\<close> \<open>x \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m + 1 = n
x < n
x \<noteq> 0

goal (1 subgoal):
 1. x \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
hence \<open>x \<in> {x |x. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < m + 1 \<and> x \<noteq> 0}
{x |x. x < n \<and> coprime x n} = {x |x. x < m + 1 \<and> x \<noteq> 0}

goal (1 subgoal):
 1. x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<lbrakk>x < n; x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime x n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < n \<and> coprime x n}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<lbrakk>?x < n; ?x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime ?x n

goal (1 subgoal):
 1. b = 1 \<Longrightarrow> prime n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x < n; ?x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime ?x n

goal (1 subgoal):
 1. prime n
[PROOF STEP]
using assms coprime_commute nat_neq_iff prime_nat_iff''
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?x < n; ?x \<noteq> 0\<rbrakk> \<Longrightarrow> coprime ?x n
1 < n
coprime ?b ?a = coprime ?a ?b
(?m \<noteq> ?n) = (?m < ?n \<or> ?n < ?m)
prime ?p = (?p \<noteq> 0 \<and> ?p \<noteq> 1 \<and> (\<forall>m. 0 < m \<and> m < ?p \<longrightarrow> coprime ?p m))

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b = 1 \<Longrightarrow> prime n

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b = 1 \<Longrightarrow> prime n

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
have \<open>b = 2 \<Longrightarrow> \<exists> k. n = 2^k\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
assume \<open>b = 2\<close>
[PROOF STATE]
proof (state)
this:
b = 2

goal (1 subgoal):
 1. b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} = {1+j*2| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}
[PROOF STEP]
using \<open>b = 2\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
b = 2
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
have \<open>x < n \<Longrightarrow> coprime x n \<longleftrightarrow> odd x\<close>
            for x::nat
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x < n \<Longrightarrow> coprime x n = odd x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. x < n \<Longrightarrow> coprime x n = odd x
[PROOF STEP]
assume \<open>x < n\<close>
[PROOF STATE]
proof (state)
this:
x < n

goal (1 subgoal):
 1. x < n \<Longrightarrow> coprime x n = odd x
[PROOF STEP]
have \<open>coprime x n \<Longrightarrow> odd x\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime x n \<Longrightarrow> odd x
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. coprime x n \<Longrightarrow> odd x
[PROOF STEP]
assume \<open>coprime x n\<close>
[PROOF STATE]
proof (state)
this:
coprime x n

goal (1 subgoal):
 1. coprime x n \<Longrightarrow> odd x
[PROOF STEP]
have \<open>x \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by (simp add: \<open>coprime x n\<close> \<open>x < n\<close>)
[PROOF STATE]
proof (state)
this:
x \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. coprime x n \<Longrightarrow> odd x
[PROOF STEP]
hence \<open>x \<in> {1+j*2| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. x \<in> {1 + j * 2 |j. j < m}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. x \<in> {1 + j * 2 |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. coprime x n \<Longrightarrow> odd x
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
x \<in> {1 + j * 2 |j. j < m}
[PROOF STEP]
obtain j where \<open>x = 1+j*2\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {1 + j * 2 |j. j < m}

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

goal (1 subgoal):
 1. coprime x n \<Longrightarrow> odd x
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x = 1 + j * 2

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
coprime x n \<Longrightarrow> odd x

goal (1 subgoal):
 1. x < n \<Longrightarrow> coprime x n = odd x
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
coprime x n \<Longrightarrow> odd x

goal (1 subgoal):
 1. x < n \<Longrightarrow> coprime x n = odd x
[PROOF STEP]
have \<open>odd x \<Longrightarrow> coprime x n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
assume \<open>odd x\<close>
[PROOF STATE]
proof (state)
this:
odd x

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
obtain j::nat where \<open>x = 1+j*2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>j. x = 1 + j * 2 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis \<open>odd x\<close> add.commute mult_2_right odd_two_times_div_two_succ one_add_one semiring_normalization_rules(16))
[PROOF STATE]
proof (state)
this:
x = 1 + j * 2

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>j < (n-1)/2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. real j < real (n - 1) / 2
[PROOF STEP]
using \<open>x < n\<close> \<open>x = 1 + j * 2\<close>
[PROOF STATE]
proof (prove)
using this:
x < n
x = 1 + j * 2

goal (1 subgoal):
 1. real j < real (n - 1) / 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
real j < real (n - 1) / 2

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
have \<open>n = 2*m\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 * m
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 2 * m
[PROOF STEP]
have  \<open>(2::nat) \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 \<noteq> 0

goal (1 subgoal):
 1. n = 2 * m
[PROOF STEP]
have \<open>n = 2+(m-1)*2\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
have \<open>n-1 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
have \<open>n-1 \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close>
                      \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain i::nat where \<open>n-1 = 1+i*b\<close> and \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>n - 1 = 1 + i * b; i < m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 = 1 + i * b
i < m

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
have \<open>i \<le> m-1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> m - 1
[PROOF STEP]
using \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
i < m

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

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
have \<open>1 + (m-1)*b \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>1 + (m-1)*b \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>1 + (m-1)*b < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 1 + (m - 1) * b < n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> n-1\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> n - 1
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> 1+i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
using \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1
n - 1 = 1 + i * b

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>(m-1)*b \<le> i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>m-1 \<le> i\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (m - 1) * b \<le> i * b \<Longrightarrow> m - 1 \<le> i
[PROOF STEP]
have \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
using \<open>b = 2\<close>
[PROOF STATE]
proof (prove)
using this:
b = 2

goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
b \<noteq> 0

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b \<Longrightarrow> m - 1 \<le> i
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
using \<open>(m - 1) * b \<le> i * b\<close> mult_le_cancel2
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0
(m - 1) * b \<le> i * b
(?m * ?k \<le> ?n * ?k) = (0 < ?k \<longrightarrow> ?m \<le> ?n)

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
hence \<open>m-1 = i\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
using \<open>i \<le> m - 1\<close> le_antisym
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i
i \<le> m - 1
\<lbrakk>?m \<le> ?n; ?n \<le> ?m\<rbrakk> \<Longrightarrow> ?m = ?n

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = i
m \<noteq> 0
n - 1 = 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * 2
[PROOF STEP]
by (simp add: \<open>b = 2\<close>)
[PROOF STATE]
proof (state)
this:
n = 2 + (m - 1) * 2

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

goal (1 subgoal):
 1. n = 2 * m
[PROOF STEP]
thus  ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 2 + (m - 1) * 2

goal (1 subgoal):
 1. n = 2 * m
[PROOF STEP]
by (simp add: \<open>m \<noteq> 0\<close> \<open>n = 2 + (m - 1) * 2\<close> mult.commute mult_eq_if)
[PROOF STATE]
proof (state)
this:
n = 2 * m

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n = 2 * m

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
hence \<open>j < m\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2 * m

goal (1 subgoal):
 1. j < m
[PROOF STEP]
using \<open>x < n\<close> \<open>x = 1 + j * 2\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2 * m
x < n
x = 1 + j * 2

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

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
hence \<open>x \<in> {1+j*2| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
j < m

goal (1 subgoal):
 1. x \<in> {1 + j * 2 |j. j < m}
[PROOF STEP]
using \<open>x = 1 + j * 2\<close>
[PROOF STATE]
proof (prove)
using this:
j < m
x = 1 + j * 2

goal (1 subgoal):
 1. x \<in> {1 + j * 2 |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
hence \<open>x \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
x \<in> {1 + j * 2 |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * 2 |j. j < m}

goal (1 subgoal):
 1. x \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. odd x \<Longrightarrow> coprime x n
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
x \<in> {x |x. x < n \<and> coprime x n}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
odd x \<Longrightarrow> coprime x n

goal (1 subgoal):
 1. x < n \<Longrightarrow> coprime x n = odd x
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
coprime x n \<Longrightarrow> odd x
odd x \<Longrightarrow> coprime x n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
coprime x n \<Longrightarrow> odd x
odd x \<Longrightarrow> coprime x n

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
?x < n \<Longrightarrow> coprime ?x n = odd ?x

goal (1 subgoal):
 1. b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
?x < n \<Longrightarrow> coprime ?x n = odd ?x

goal (1 subgoal):
 1. \<exists>k. n = 2 ^ k
[PROOF STEP]
using coprime_power2 assms
[PROOF STATE]
proof (prove)
using this:
?x < n \<Longrightarrow> coprime ?x n = odd ?x
\<lbrakk>?n \<noteq> 0; \<And>x. x < ?n \<Longrightarrow> coprime x ?n = odd x\<rbrakk> \<Longrightarrow> \<exists>k. ?n = 2 ^ k
1 < n

goal (1 subgoal):
 1. \<exists>k. n = 2 ^ k
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>k. n = 2 ^ k

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
have \<open>b = 4 \<Longrightarrow> n = 6\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b = 4 \<Longrightarrow> n = 6
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b = 4 \<Longrightarrow> n = 6
[PROOF STEP]
assume \<open>b = 4\<close>
[PROOF STATE]
proof (state)
this:
b = 4

goal (1 subgoal):
 1. b = 4 \<Longrightarrow> n = 6
[PROOF STEP]
have \<open>n = 2 \<or> n = 6\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 \<or> n = 6
[PROOF STEP]
proof(rule classical)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
assume \<open>\<not> (n = 2 \<or> n = 6)\<close>
[PROOF STATE]
proof (state)
this:
\<not> (n = 2 \<or> n = 6)

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have  \<open>(4::nat) \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 4 \<noteq> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
4 \<noteq> 0

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have \<open>n =  2+(m-1)*4\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
have \<open>n-1 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close> coprime_diff_one_left_nat
[PROOF STATE]
proof (prove)
using this:
1 < n
0 < ?n \<Longrightarrow> coprime (?n - 1) ?n

goal (1 subgoal):
 1. n - 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
have \<open>n-1 \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>n - 1 \<in> {x |x. x < n \<and> coprime x n}\<close>
                  \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n - 1 \<in> {1 + j * b |j. j < m}
[PROOF STEP]
obtain i::nat where \<open>n-1 = 1+i*b\<close> and \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
n - 1 \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>n - 1 = 1 + i * b; i < m\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n - 1 = 1 + i * b
i < m

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
have \<open>i \<le> m-1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. i \<le> m - 1
[PROOF STEP]
using \<open>i < m\<close>
[PROOF STATE]
proof (prove)
using this:
i < m

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

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
have \<open>1 + (m-1)*b \<in> {1+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>1 + (m-1)*b \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {1 + j * b |j. j < m}
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>1 + (m-1)*b < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 1 + (m - 1) * b < n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> n-1\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b < n

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> n - 1
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>1 + (m-1)*b \<le> 1+i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
using \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> n - 1
n - 1 = 1 + i * b

goal (1 subgoal):
 1. 1 + (m - 1) * b \<le> 1 + i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>(m-1)*b \<le> i*b\<close>
[PROOF STATE]
proof (prove)
using this:
1 + (m - 1) * b \<le> 1 + i * b

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>m-1 \<le> i\<close>
[PROOF STATE]
proof (prove)
using this:
(m - 1) * b \<le> i * b

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (m - 1) * b \<le> i * b \<Longrightarrow> m - 1 \<le> i
[PROOF STEP]
have \<open>b \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b \<noteq> 0
[PROOF STEP]
using \<open>b = 4\<close>
[PROOF STATE]
proof (prove)
using this:
b = 4

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

goal (1 subgoal):
 1. (m - 1) * b \<le> i * b \<Longrightarrow> m - 1 \<le> i
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
using \<open>(m - 1) * b \<le> i * b\<close> mult_le_cancel2
[PROOF STATE]
proof (prove)
using this:
b \<noteq> 0
(m - 1) * b \<le> i * b
(?m * ?k \<le> ?n * ?k) = (0 < ?k \<longrightarrow> ?m \<le> ?n)

goal (1 subgoal):
 1. m - 1 \<le> i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
m - 1 \<le> i

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
hence \<open>m-1 = i\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
using \<open>i \<le> m - 1\<close> le_antisym
[PROOF STATE]
proof (prove)
using this:
m - 1 \<le> i
i \<le> m - 1
\<lbrakk>?m \<le> ?n; ?n \<le> ?m\<rbrakk> \<Longrightarrow> ?m = ?n

goal (1 subgoal):
 1. m - 1 = i
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
m - 1 = i

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
using \<open>m \<noteq> 0\<close> \<open>n - 1 = 1 + i * b\<close>
[PROOF STATE]
proof (prove)
using this:
m - 1 = i
m \<noteq> 0
n - 1 = 1 + i * b

goal (1 subgoal):
 1. n = 2 + (m - 1) * 4
[PROOF STEP]
by (simp add: \<open>b = 4\<close>)
[PROOF STATE]
proof (state)
this:
n = 2 + (m - 1) * 4

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n = 2 + (m - 1) * 4

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>n = 4*m - 2\<close>
[PROOF STATE]
proof (prove)
using this:
n = 2 + (m - 1) * 4

goal (1 subgoal):
 1. n = 4 * m - 2
[PROOF STEP]
by (simp add: \<open>m \<noteq> 0\<close> mult.commute mult_eq_if)
[PROOF STATE]
proof (state)
this:
n = 4 * m - 2

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have \<open>m \<ge> 3\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 \<le> m
[PROOF STEP]
using \<open>\<not> (n = 2 \<or> n = 6)\<close> \<open>n = 2 + (m - 1) * 4\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> (n = 2 \<or> n = 6)
n = 2 + (m - 1) * 4

goal (1 subgoal):
 1. 3 \<le> m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
3 \<le> m

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open> {1+j*4| j::nat. j < 3} \<subseteq> {1+j*4| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
3 \<le> m

goal (1 subgoal):
 1. {1 + j * 4 |j. j < 3} \<subseteq> {1 + j * 4 |j. j < m}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
{1 + j * 4 |j. j < 3} \<subseteq> {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>9 \<in> {1+j*4| j::nat. j < 3}\<close>
[PROOF STATE]
proof (prove)
using this:
{1 + j * 4 |j. j < 3} \<subseteq> {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. 9 \<in> {1 + j * 4 |j. j < 3}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
9 \<in> {1 + j * 4 |j. j < 3}

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>9 \<in> {1+j*4| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
9 \<in> {1 + j * 4 |j. j < 3}

goal (1 subgoal):
 1. 9 \<in> {1 + j * 4 |j. j < m}
[PROOF STEP]
using  \<open> {1+j*4| j::nat. j < 3} \<subseteq> {1+j*4| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
9 \<in> {1 + j * 4 |j. j < 3}
{1 + j * 4 |j. j < 3} \<subseteq> {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. 9 \<in> {1 + j * 4 |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
9 \<in> {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>9 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
using this:
9 \<in> {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. 9 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>b = 4\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
9 \<in> {1 + j * 4 |j. j < m}
b = 4
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 9 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
9 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>coprime (9::nat) n\<close>
[PROOF STATE]
proof (prove)
using this:
9 \<in> {x |x. x < n \<and> coprime x n}

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

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have \<open>(3::nat) dvd 9\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 dvd 9
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
3 dvd 9

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have  \<open>coprime (3::nat) n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime 3 n
[PROOF STEP]
using  \<open>coprime (9::nat) n\<close> \<open>(3::nat) dvd 9\<close>
[PROOF STATE]
proof (prove)
using this:
coprime 9 n
3 dvd 9

goal (1 subgoal):
 1. coprime 3 n
[PROOF STEP]
by (metis coprime_commute coprime_mult_right_iff dvd_def)
[PROOF STATE]
proof (state)
this:
coprime 3 n

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have \<open>(3::nat) < n\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 < n
[PROOF STEP]
by (metis One_nat_def Suc_lessI \<open>1 < n\<close> \<open>\<not> (n = 2 \<or> n = 6)\<close> \<open>coprime 3 n\<close>
                  coprime_self numeral_2_eq_2 numeral_3_eq_3 less_numeral_extra(1) nat_dvd_not_less)
[PROOF STATE]
proof (state)
this:
3 < n

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have \<open>3 \<in>  {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 3 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>3 < n\<close> \<open>coprime 3 n\<close>
[PROOF STATE]
proof (prove)
using this:
3 < n
coprime 3 n

goal (1 subgoal):
 1. 3 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
3 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence  \<open>(3::nat) \<in> {1+j*4| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
3 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. 3 \<in> {1 + j * 4 |j. j < m}
[PROOF STEP]
using \<open>b = 4\<close> \<open>{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
3 \<in> {x |x. x < n \<and> coprime x n}
b = 4
{x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. 3 \<in> {1 + j * 4 |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
3 \<in> {1 + j * 4 |j. j < m}

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
3 \<in> {1 + j * 4 |j. j < m}
[PROOF STEP]
obtain j::nat where \<open>(3::nat) = 1 + j*4\<close>
[PROOF STATE]
proof (prove)
using this:
3 \<in> {1 + j * 4 |j. j < m}

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

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
have \<open>2 = j*4\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 = j * 4
[PROOF STEP]
using numeral_3_eq_3 \<open>(3::nat) = 1 + j*4\<close>
[PROOF STATE]
proof (prove)
using this:
3 = Suc (Suc (Suc 0))
3 = 1 + j * 4

goal (1 subgoal):
 1. 2 = j * 4
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
2 = j * 4

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>1 = j*2\<close>
[PROOF STATE]
proof (prove)
using this:
2 = j * 4

goal (1 subgoal):
 1. 1 = j * 2
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
1 = j * 2

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
hence \<open>even 1\<close>
[PROOF STATE]
proof (prove)
using this:
1 = j * 2

goal (1 subgoal):
 1. even (1::'a)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
even (1::?'a1)

goal (1 subgoal):
 1. \<not> (n = 2 \<or> n = 6) \<Longrightarrow> n = 2 \<or> n = 6
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
even (1::?'a1)

goal (1 subgoal):
 1. n = 2 \<or> n = 6
[PROOF STEP]
using odd_one
[PROOF STATE]
proof (prove)
using this:
even (1::?'a1)
odd (1::?'a)

goal (1 subgoal):
 1. n = 2 \<or> n = 6
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
n = 2 \<or> n = 6

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
n = 2 \<or> n = 6

goal (1 subgoal):
 1. b = 4 \<Longrightarrow> n = 6
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
n = 2 \<or> n = 6

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
b = 4 \<Longrightarrow> n = 6

goal (1 subgoal):
 1. n \<noteq> 2 \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
b = 0 \<or> b = 1 \<or> b = 2 \<or> b = 4
b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
b = 1 \<Longrightarrow> prime n
b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
b = 4 \<Longrightarrow> n = 6
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
b = 0 \<or> b = 1 \<or> b = 2 \<or> b = 4
b = 0 \<Longrightarrow> \<exists>k. n = 2 ^ k
b = 1 \<Longrightarrow> prime n
b = 2 \<Longrightarrow> \<exists>k. n = 2 ^ k
b = 4 \<Longrightarrow> n = 6

goal (1 subgoal):
 1. prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m} \<Longrightarrow> prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m})

goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m})

goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
have \<open>(\<exists> b m. m \<noteq> 0 \<and> {x | x :: nat. x < n \<and> coprime x n} = {1+j*b| j::nat. j < m})
  \<longleftrightarrow> (\<exists> a b m. m \<noteq> 0 \<and> {x | x :: nat. x < n \<and> coprime x n} = {a+j*b| j::nat. j < m})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m} \<Longrightarrow> \<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}
 2. \<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
show "\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}"
      if "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m} \<Longrightarrow> \<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
show "\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}"
      if "\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
obtain a b m::nat where \<open>m \<noteq> 0\<close>
        and \<open>{x | x :: nat. x < n \<and> coprime x n} = {a+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>m a b. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using \<open>\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

goal (1 subgoal):
 1. (\<And>m a b. \<lbrakk>m \<noteq> 0; {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
have \<open>a = 1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a = 1
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} = {(a::nat)+j*(b::nat)| j::nat. j < m} \<Longrightarrow> a = 1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
[PROOF STEP]
have \<open>Min {x | x :: nat. x < n \<and> coprime x n} = Min {a+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = Min {a + j * b |j. j < m}
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = Min {a + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Min {x |x. x < n \<and> coprime x n} = Min {a + j * b |j. j < m}

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
[PROOF STEP]
have  \<open>Min {x | x :: nat. x < n \<and> coprime x n} = 1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
have \<open>finite {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
have \<open>{x | x :: nat. x < n \<and> coprime x n} \<noteq> {}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} \<noteq> {}
[PROOF STEP]
using \<open>1 < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} \<noteq> {}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} \<noteq> {}

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
have \<open>1 \<in> {x | x :: nat. x < n \<and> coprime x n}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>1 < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 < n

goal (1 subgoal):
 1. 1 \<in> {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 \<in> {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
have \<open>\<forall> x. coprime x n \<longrightarrow> x \<ge> 1\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x. coprime x n \<longrightarrow> 1 \<le> x
[PROOF STEP]
using \<open>1 < n\<close> le_less_linear
[PROOF STATE]
proof (prove)
using this:
1 < n
?x \<le> ?y \<or> ?y < ?x

goal (1 subgoal):
 1. \<forall>x. coprime x n \<longrightarrow> 1 \<le> x
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>x. coprime x n \<longrightarrow> 1 \<le> x

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
hence \<open>\<forall> x.  x < n \<and> coprime x n \<longrightarrow> x \<ge> 1\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x. coprime x n \<longrightarrow> 1 \<le> x

goal (1 subgoal):
 1. \<forall>x. x < n \<and> coprime x n \<longrightarrow> 1 \<le> x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>x. x < n \<and> coprime x n \<longrightarrow> 1 \<le> x

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
hence \<open>\<forall> x \<in> {x | x :: nat. x < n \<and> coprime x n}. x \<ge> 1\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x. x < n \<and> coprime x n \<longrightarrow> 1 \<le> x

goal (1 subgoal):
 1. \<forall>x\<in>{x |x. x < n \<and> coprime x n}. 1 \<le> x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>{x |x. x < n \<and> coprime x n}. 1 \<le> x

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
hence \<open>Min {x | x :: nat. x < n \<and> coprime x n} \<ge> 1\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{x |x. x < n \<and> coprime x n}. 1 \<le> x

goal (1 subgoal):
 1. 1 \<le> Min {x |x. x < n \<and> coprime x n}
[PROOF STEP]
using \<open>finite {x | x :: nat. x < n \<and> coprime x n}\<close> \<open>{x |x. x < n \<and> coprime x n} \<noteq> {}\<close>
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{x |x. x < n \<and> coprime x n}. 1 \<le> x
finite {x |x. x < n \<and> coprime x n}
{x |x. x < n \<and> coprime x n} \<noteq> {}

goal (1 subgoal):
 1. 1 \<le> Min {x |x. x < n \<and> coprime x n}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
1 \<le> Min {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
1 \<le> Min {x |x. x < n \<and> coprime x n}

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
using Min_le \<open>1 \<in> {x |x. x < n \<and> coprime x n}\<close> \<open>finite {x |x. x < n \<and> coprime x n}\<close>
                antisym
[PROOF STATE]
proof (prove)
using this:
1 \<le> Min {x |x. x < n \<and> coprime x n}
\<lbrakk>finite ?A; ?x \<in> ?A\<rbrakk> \<Longrightarrow> Min ?A \<le> ?x
1 \<in> {x |x. x < n \<and> coprime x n}
finite {x |x. x < n \<and> coprime x n}
\<lbrakk>?a \<le> ?b; ?b \<le> ?a\<rbrakk> \<Longrightarrow> ?a = ?b

goal (1 subgoal):
 1. Min {x |x. x < n \<and> coprime x n} = 1
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Min {x |x. x < n \<and> coprime x n} = 1

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Min {x |x. x < n \<and> coprime x n} = 1

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
[PROOF STEP]
have \<open>Min  {a+j*b| j::nat. j < m} = a\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
have f1: "\<exists>n. a = a + n * b \<and> n < m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n. a = a + n * b \<and> n < m
[PROOF STEP]
using \<open>m \<noteq> 0\<close>
[PROOF STATE]
proof (prove)
using this:
m \<noteq> 0

goal (1 subgoal):
 1. \<exists>n. a = a + n * b \<and> n < m
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>n. a = a + n * b \<and> n < m

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
have f2: "\<exists>n. 1 = a + n * b \<and> n < m"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>n. 1 = a + n * b \<and> n < m
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<close> assms coprime_1_left
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}
1 < n
coprime (1::?'a) ?a

goal (1 subgoal):
 1. \<exists>n. 1 = a + n * b \<and> n < m
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>n. 1 = a + n * b \<and> n < m

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
have f3: "\<exists>na. a = na \<and> na < n \<and> coprime na n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>na. a = na \<and> na < n \<and> coprime na n
[PROOF STEP]
using f1 \<open>{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
\<exists>n. a = a + n * b \<and> n < m
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>na. a = na \<and> na < n \<and> coprime na n
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<exists>na. a = na \<and> na < n \<and> coprime na n

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
have "n \<noteq> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n \<noteq> 1
[PROOF STEP]
by (metis (lifting) assms less_irrefl_nat)
[PROOF STATE]
proof (state)
this:
n \<noteq> 1

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 1
[PROOF STEP]
have "\<not> coprime 0 n"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 1

goal (1 subgoal):
 1. \<not> coprime 0 n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<not> coprime 0 n

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> coprime 0 n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> coprime 0 n

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
using f3 f2
[PROOF STATE]
proof (prove)
using this:
\<not> coprime 0 n
\<exists>na. a = na \<and> na < n \<and> coprime na n
\<exists>n. 1 = a + n * b \<and> n < m

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
by (metis \<open>Min {x |x. x < n \<and> coprime x n} = 1\<close> \<open>{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<close> less_one linorder_neqE_nat not_add_less1)
[PROOF STATE]
proof (state)
this:
Min {a + j * b |j. j < m} = a

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Min {a + j * b |j. j < m} = a

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
[PROOF STEP]
hence \<open>Min  {a+j*b| j::nat. j < m} = a\<close>
[PROOF STATE]
proof (prove)
using this:
Min {a + j * b |j. j < m} = a

goal (1 subgoal):
 1. Min {a + j * b |j. j < m} = a
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
Min {a + j * b |j. j < m} = a

goal (1 subgoal):
 1. {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
Min {a + j * b |j. j < m} = a

goal (1 subgoal):
 1. a = 1
[PROOF STEP]
using \<open>Min {x | x :: nat. x < n \<and> coprime x n} = 1\<close> \<open>Min {x | x :: nat. x < n \<and> coprime x n} = Min {a+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
Min {a + j * b |j. j < m} = a
Min {x |x. x < n \<and> coprime x n} = 1
Min {x |x. x < n \<and> coprime x n} = Min {a + j * b |j. j < m}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1

goal (1 subgoal):
 1. a = 1
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1

goal (1 subgoal):
 1. a = 1
[PROOF STEP]
using \<open>{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> a = 1
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a = 1

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
a = 1

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
using  \<open>m \<noteq> 0\<close> \<open>{x | x. x < n \<and> coprime x n} = {a+j*b| j::nat. j < m}\<close>
[PROOF STATE]
proof (prove)
using this:
a = 1
m \<noteq> 0
{x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m}

goal (1 subgoal):
 1. \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m} \<Longrightarrow> \<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})

goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m})
(\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m})
(\<exists>b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {1 + j * b |j. j < m}) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})

goal (1 subgoal):
 1. (prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(prime n \<or> (\<exists>k. n = 2 ^ k) \<or> n = 6) = (\<exists>a b m. m \<noteq> 0 \<and> {x |x. x < n \<and> coprime x n} = {a + j * b |j. j < m})

goal:
No subgoals!
[PROOF STEP]
qed