[STATEMENT]
lemma infinite_ascending: assumes nf: \<open>\<not> finite (A::nat set)\<close> obtains f where \<open>range f = A\<close> \<open>\<forall> i. f i < f (Suc i)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
let \<open>?f\<close> = \<open>\<lambda> i. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)\<close>
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
obtain a where \<open>a \<in> A\<close> \<open>card (A \<inter> {..<a}) = i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof (induction \<open>i\<close> arbitrary: \<open>thesis\<close>)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:
\<lbrakk>?a \<in> A; card (A \<inter> {..<?a}) = 0\<rbrakk> \<Longrightarrow> thesis

goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
let \<open>?a0\<close> = \<open>(LEAST a. a \<in> A)\<close>
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have \<open>?a0 \<in> A\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST a. a \<in> A) \<in> A
[PROOF STEP]
by (metis LeastI empty_iff finite.emptyI nf set_eq_iff)
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A) \<in> A

goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A) \<in> A

goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have \<open>\<And>b. b \<in> A \<Longrightarrow> ?a0 \<le> b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>b. b \<in> A \<Longrightarrow> (LEAST a. a \<in> A) \<le> b
[PROOF STEP]
by (metis Least_le)
[PROOF STATE]
proof (state)
this:
?b \<in> A \<Longrightarrow> (LEAST a. a \<in> A) \<le> ?b

goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence \<open>card (A \<inter> {..<?a}) = 0\<close>
[PROOF STATE]
proof (prove)
using this:
?b \<in> A \<Longrightarrow> (LEAST a. a \<in> A) \<le> ?b

goal (1 subgoal):
 1. card (A \<inter> {..<LEAST a. a \<in> A}) = 0
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
card (A \<inter> {..<LEAST a. a \<in> A}) = 0

goal (2 subgoals):
 1. \<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = 0\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
 2. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(LEAST a. a \<in> A) \<in> A
card (A \<inter> {..<LEAST a. a \<in> A}) = 0
[PROOF STEP]
show \<open>?case\<close>
[PROOF STATE]
proof (prove)
using this:
(LEAST a. a \<in> A) \<in> A
card (A \<inter> {..<LEAST a. a \<in> A}) = 0

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using 0
[PROOF STATE]
proof (prove)
using this:
(LEAST a. a \<in> A) \<in> A
card (A \<inter> {..<LEAST a. a \<in> A}) = 0
\<lbrakk>?a \<in> A; card (A \<inter> {..<?a}) = 0\<rbrakk> \<Longrightarrow> thesis

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

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
case (Suc i)
[PROOF STATE]
proof (state)
this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis
\<lbrakk>?a \<in> A; card (A \<inter> {..<?a}) = Suc i\<rbrakk> \<Longrightarrow> thesis

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
obtain a where aa: \<open>a \<in> A\<close> and card: \<open>card (A \<inter> {..<a}) = i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Suc.IH
[PROOF STATE]
proof (prove)
using this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
a \<in> A
card (A \<inter> {..<a}) = i

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have nf': \<open>~ finite (A - {..a})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite (A - {..a})
[PROOF STEP]
using nf
[PROOF STATE]
proof (prove)
using this:
infinite A

goal (1 subgoal):
 1. infinite (A - {..a})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
infinite (A - {..a})

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
let \<open>?b\<close> = \<open>LEAST b. b \<in> A - {..a}\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have bin: \<open>?b \<in> A-{..a}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST b. b \<in> A - {..a}) \<in> A - {..a}
[PROOF STEP]
by (metis LeastI empty_iff finite.emptyI nf' set_eq_iff)
[PROOF STATE]
proof (state)
this:
(LEAST b. b \<in> A - {..a}) \<in> A - {..a}

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have le: \<open>\<And>c. c \<in> A-{..a} \<Longrightarrow> ?b \<le> c\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>c. c \<in> A - {..a} \<Longrightarrow> (LEAST b. b \<in> A - {..a}) \<le> c
[PROOF STEP]
by (metis Least_le)
[PROOF STATE]
proof (state)
this:
?c \<in> A - {..a} \<Longrightarrow> (LEAST b. b \<in> A - {..a}) \<le> ?c

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have ab: \<open>a < ?b\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a < (LEAST b. b \<in> A - {..a})
[PROOF STEP]
using bin
[PROOF STATE]
proof (prove)
using this:
(LEAST b. b \<in> A - {..a}) \<in> A - {..a}

goal (1 subgoal):
 1. a < (LEAST b. b \<in> A - {..a})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a < (LEAST b. b \<in> A - {..a})

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
have \<open>\<And> c. c \<in> A \<Longrightarrow> c < ?b \<Longrightarrow> c \<le> a\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>c. \<lbrakk>c \<in> A; c < (LEAST b. b \<in> A - {..a})\<rbrakk> \<Longrightarrow> c \<le> a
[PROOF STEP]
using le
[PROOF STATE]
proof (prove)
using this:
?c \<in> A - {..a} \<Longrightarrow> (LEAST b. b \<in> A - {..a}) \<le> ?c

goal (1 subgoal):
 1. \<And>c. \<lbrakk>c \<in> A; c < (LEAST b. b \<in> A - {..a})\<rbrakk> \<Longrightarrow> c \<le> a
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
\<lbrakk>?c \<in> A; ?c < (LEAST b. b \<in> A - {..a})\<rbrakk> \<Longrightarrow> ?c \<le> a

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence \<open>A \<inter> {..<?b} = insert a (A \<inter> {..<a})\<close>
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?c \<in> A; ?c < (LEAST b. b \<in> A - {..a})\<rbrakk> \<Longrightarrow> ?c \<le> a

goal (1 subgoal):
 1. A \<inter> {..<LEAST b. b \<in> A - {..a}} = insert a (A \<inter> {..<a})
[PROOF STEP]
using bin ab aa
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>?c \<in> A; ?c < (LEAST b. b \<in> A - {..a})\<rbrakk> \<Longrightarrow> ?c \<le> a
(LEAST b. b \<in> A - {..a}) \<in> A - {..a}
a < (LEAST b. b \<in> A - {..a})
a \<in> A

goal (1 subgoal):
 1. A \<inter> {..<LEAST b. b \<in> A - {..a}} = insert a (A \<inter> {..<a})
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
A \<inter> {..<LEAST b. b \<in> A - {..a}} = insert a (A \<inter> {..<a})

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
hence \<open>card (A \<inter>{..<?b}) = Suc i\<close>
[PROOF STATE]
proof (prove)
using this:
A \<inter> {..<LEAST b. b \<in> A - {..a}} = insert a (A \<inter> {..<a})

goal (1 subgoal):
 1. card (A \<inter> {..<LEAST b. b \<in> A - {..a}}) = Suc i
[PROOF STEP]
using card
[PROOF STATE]
proof (prove)
using this:
A \<inter> {..<LEAST b. b \<in> A - {..a}} = insert a (A \<inter> {..<a})
card (A \<inter> {..<a}) = i

goal (1 subgoal):
 1. card (A \<inter> {..<LEAST b. b \<in> A - {..a}}) = Suc i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (A \<inter> {..<LEAST b. b \<in> A - {..a}}) = Suc i

goal (1 subgoal):
 1. \<And>i thesis. \<lbrakk>\<And>thesis. (\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis; \<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = Suc i\<rbrakk> \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
thus \<open>?case\<close>
[PROOF STATE]
proof (prove)
using this:
card (A \<inter> {..<LEAST b. b \<in> A - {..a}}) = Suc i

goal (1 subgoal):
 1. thesis
[PROOF STEP]
using Suc.prems bin
[PROOF STATE]
proof (prove)
using this:
card (A \<inter> {..<LEAST b. b \<in> A - {..a}}) = Suc i
\<lbrakk>?a \<in> A; card (A \<inter> {..<?a}) = Suc i\<rbrakk> \<Longrightarrow> thesis
(LEAST b. b \<in> A - {..a}) \<in> A - {..a}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a \<in> A
card (A \<inter> {..<a}) = i

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
note \<open>\<And> thesis. ((\<And>a. a \<in> A \<Longrightarrow> card (A \<inter> {..<a}) = i \<Longrightarrow> thesis) \<Longrightarrow> thesis)\<close>
[PROOF STATE]
proof (state)
this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = i\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = ?i8\<rbrakk> \<Longrightarrow> ?thesisb5) \<Longrightarrow> ?thesisb5

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
note ex = this
[PROOF STATE]
proof (state)
this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = ?i8\<rbrakk> \<Longrightarrow> ?thesisb5) \<Longrightarrow> ?thesisb5

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = ?i8\<rbrakk> \<Longrightarrow> ?thesisb5) \<Longrightarrow> ?thesisb5

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
obtain a where a: \<open>a \<in> A \<and> card (A \<inter>{..<a}) = i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a. a \<in> A \<and> card (A \<inter> {..<a}) = i \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex
[PROOF STATE]
proof (prove)
using this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = ?i8\<rbrakk> \<Longrightarrow> ?thesisb5) \<Longrightarrow> ?thesisb5

goal (1 subgoal):
 1. (\<And>a. a \<in> A \<and> card (A \<inter> {..<a}) = i \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a \<in> A \<and> card (A \<inter> {..<a}) = i

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
have ina: \<open>?f i \<in> A\<close> and card: \<open>card (A \<inter>{..<?f i}) = i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<in> A &&& card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}) = i
[PROOF STEP]
using LeastI[of \<open>\<lambda> a. a \<in> A \<and> card (A \<inter>{..<a}) = i\<close> \<open>a\<close>, OF a]
[PROOF STATE]
proof (prove)
using this:
(LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = i) \<in> A \<and> card (A \<inter> {..<LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = i}) = i

goal (1 subgoal):
 1. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<in> A &&& card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}) = i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<in> A
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}) = i

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
obtain b where b: \<open>b \<in> A \<and> card (A \<inter>{..<b}) = Suc i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b. b \<in> A \<and> card (A \<inter> {..<b}) = Suc i \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex
[PROOF STATE]
proof (prove)
using this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = ?i8\<rbrakk> \<Longrightarrow> ?thesisb5) \<Longrightarrow> ?thesisb5

goal (1 subgoal):
 1. (\<And>b. b \<in> A \<and> card (A \<inter> {..<b}) = Suc i \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
b \<in> A \<and> card (A \<inter> {..<b}) = Suc i

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
have inab: \<open>?f (Suc i) \<in> A\<close> and cardb: \<open>card (A \<inter>{..<?f (Suc i)}) = Suc i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<in> A &&& card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) = Suc i
[PROOF STEP]
using LeastI[of \<open>\<lambda> a. a \<in> A \<and> card (A \<inter>{..<a}) = Suc i\<close> \<open>b\<close>, OF b]
[PROOF STATE]
proof (prove)
using this:
(LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = Suc i) \<in> A \<and> card (A \<inter> {..<LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = Suc i}) = Suc i

goal (1 subgoal):
 1. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<in> A &&& card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) = Suc i
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<in> A
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) = Suc i

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
have \<open>?f i < ?f (Suc i)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<Longrightarrow> False
[PROOF STEP]
assume \<open>\<not> ?f i < ?f (Suc i)\<close>
[PROOF STATE]
proof (state)
this:
\<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)

goal (1 subgoal):
 1. \<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<Longrightarrow> False
[PROOF STEP]
hence \<open>A \<inter>{..<?f (Suc i)} \<subseteq> A \<inter>{..<?f i}\<close>
[PROOF STATE]
proof (prove)
using this:
\<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)

goal (1 subgoal):
 1. A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i} \<subseteq> A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i} \<subseteq> A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}

goal (1 subgoal):
 1. \<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i} \<subseteq> A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}

goal (1 subgoal):
 1. \<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<Longrightarrow> False
[PROOF STEP]
have \<open>finite (A \<inter>{..<?f i})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})

goal (1 subgoal):
 1. \<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i} \<subseteq> A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}
finite (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})
[PROOF STEP]
have \<open>card(A \<inter>{..<?f (Suc i)}) \<le> card (A \<inter>{..<?f i})\<close>
[PROOF STATE]
proof (prove)
using this:
A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i} \<subseteq> A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}
finite (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})

goal (1 subgoal):
 1. card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) \<le> card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})
[PROOF STEP]
by (metis (erased, lifting) card_mono)
[PROOF STATE]
proof (state)
this:
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) \<le> card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})

goal (1 subgoal):
 1. \<not> (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i) \<Longrightarrow> False
[PROOF STEP]
thus \<open>False\<close>
[PROOF STATE]
proof (prove)
using this:
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) \<le> card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})

goal (1 subgoal):
 1. False
[PROOF STEP]
using card cardb
[PROOF STATE]
proof (prove)
using this:
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) \<le> card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i})
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i}) = i
card (A \<inter> {..<LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i}) = Suc i

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
note this ina
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<in> A

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc ?i2)
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) \<in> A

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
note b = this
[PROOF STATE]
proof (state)
this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc ?i2)
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) \<in> A

goal (2 subgoals):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range ?f2 = A
 2. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> \<forall>i. ?f2 i < ?f2 (Suc i)
[PROOF STEP]
thus \<open>\<forall> i. ?f i < ?f (Suc i)\<close>
[PROOF STATE]
proof (prove)
using this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc ?i2)
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) \<in> A

goal (1 subgoal):
 1. \<forall>i. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>i. (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc i)

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
have *: \<open>range ?f \<subseteq> A\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A
[PROOF STEP]
using b
[PROOF STATE]
proof (prove)
using this:
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) < (LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = Suc ?i2)
(LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = ?i2) \<in> A

goal (1 subgoal):
 1. range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
{
[PROOF STATE]
proof (state)
this:
range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
fix a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
assume ina: \<open>a \<in> A\<close>
[PROOF STATE]
proof (state)
this:
a \<in> A

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
let \<open>?i\<close> = \<open>card (A \<inter> {..<a})\<close>
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
obtain b where b: \<open>b \<in> A \<and> card (A \<inter>{..<b}) = ?i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b. b \<in> A \<and> card (A \<inter> {..<b}) = card (A \<inter> {..<a}) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using ex
[PROOF STATE]
proof (prove)
using this:
(\<And>a. \<lbrakk>a \<in> A; card (A \<inter> {..<a}) = ?i8\<rbrakk> \<Longrightarrow> ?thesisb5) \<Longrightarrow> ?thesisb5

goal (1 subgoal):
 1. (\<And>b. b \<in> A \<and> card (A \<inter> {..<b}) = card (A \<inter> {..<a}) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
b \<in> A \<and> card (A \<inter> {..<b}) = card (A \<inter> {..<a})

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
have inab: \<open>?f ?i \<in> A\<close> and cardb: \<open>card (A \<inter>{..<?f ?i}) = ?i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A &&& card (A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})}) = card (A \<inter> {..<a})
[PROOF STEP]
using LeastI[of \<open>\<lambda> a. a \<in> A \<and> card (A \<inter>{..<a}) = ?i\<close> \<open>b\<close>, OF b]
[PROOF STATE]
proof (prove)
using this:
(LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = card (A \<inter> {..<a})) \<in> A \<and> card (A \<inter> {..<LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = card (A \<inter> {..<a})}) = card (A \<inter> {..<a})

goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A &&& card (A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})}) = card (A \<inter> {..<a})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A
card (A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})}) = card (A \<inter> {..<a})

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
have le: \<open>?f ?i \<le> a\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<le> a
[PROOF STEP]
using Least_le[of \<open>\<lambda> a. a \<in> A \<and> card (A \<inter>{..<a}) = ?i\<close> \<open>a\<close>] ina
[PROOF STATE]
proof (prove)
using this:
a \<in> A \<and> card (A \<inter> {..<a}) = card (A \<inter> {..<a}) \<Longrightarrow> (LEAST x. x \<in> A \<and> card (A \<inter> {..<x}) = card (A \<inter> {..<a})) \<le> a
a \<in> A

goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<le> a
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<le> a

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
have \<open>a = ?f ?i\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a = (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a}))
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
have fin: \<open>finite (A \<inter> {..<a})\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (A \<inter> {..<a})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (A \<inter> {..<a})

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
assume \<open>a \<noteq> ?f ?i\<close>
[PROOF STATE]
proof (state)
this:
a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a}))

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
hence \<open>?f ?i < a\<close>
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a}))

goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) < a
[PROOF STEP]
using le
[PROOF STATE]
proof (prove)
using this:
a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a}))
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<le> a

goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) < a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) < a

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
hence \<open>?f ?i \<in> A \<inter> {..<a}\<close>
[PROOF STATE]
proof (prove)
using this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) < a

goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A \<inter> {..<a}
[PROOF STEP]
using inab
[PROOF STATE]
proof (prove)
using this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) < a
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A

goal (1 subgoal):
 1. (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A \<inter> {..<a}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A \<inter> {..<a}

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A \<inter> {..<a}

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
have \<open>A \<inter> {..<?f ?i} \<subseteq> A \<inter> {..<a}\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} \<subseteq> A \<inter> {..<a}
[PROOF STEP]
using le
[PROOF STATE]
proof (prove)
using this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<le> a

goal (1 subgoal):
 1. A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} \<subseteq> A \<inter> {..<a}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} \<subseteq> A \<inter> {..<a}

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
hence \<open>A \<inter> {..<?f ?i} = A \<inter> {..<a}\<close>
[PROOF STATE]
proof (prove)
using this:
A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} \<subseteq> A \<inter> {..<a}

goal (1 subgoal):
 1. A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} = A \<inter> {..<a}
[PROOF STEP]
using cardb card_subset_eq[OF fin]
[PROOF STATE]
proof (prove)
using this:
A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} \<subseteq> A \<inter> {..<a}
card (A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})}) = card (A \<inter> {..<a})
\<lbrakk>?A \<subseteq> A \<inter> {..<a}; card ?A = card (A \<inter> {..<a})\<rbrakk> \<Longrightarrow> ?A = A \<inter> {..<a}

goal (1 subgoal):
 1. A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} = A \<inter> {..<a}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} = A \<inter> {..<a}

goal (1 subgoal):
 1. a \<noteq> (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<Longrightarrow> False
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A \<inter> {..<a}
A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} = A \<inter> {..<a}
[PROOF STEP]
show \<open>False\<close>
[PROOF STATE]
proof (prove)
using this:
(LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})) \<in> A \<inter> {..<a}
A \<inter> {..<LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a})} = A \<inter> {..<a}

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a = (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a}))

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
hence \<open>a \<in> range ?f\<close>
[PROOF STATE]
proof (prove)
using this:
a = (LEAST aa. aa \<in> A \<and> card (A \<inter> {..<aa}) = card (A \<inter> {..<a}))

goal (1 subgoal):
 1. a \<in> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a \<in> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
}
[PROOF STATE]
proof (state)
this:
?a2 \<in> A \<Longrightarrow> ?a2 \<in> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
hence \<open>A \<subseteq> range ?f\<close>
[PROOF STATE]
proof (prove)
using this:
?a2 \<in> A \<Longrightarrow> ?a2 \<in> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)

goal (1 subgoal):
 1. A \<subseteq> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
A \<subseteq> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f = A; \<forall>i. f i < f (Suc i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A
A \<subseteq> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)
[PROOF STEP]
show \<open>range ?f = A\<close>
[PROOF STATE]
proof (prove)
using this:
range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) \<subseteq> A
A \<subseteq> range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i)

goal (1 subgoal):
 1. range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
range (\<lambda>i. LEAST a. a \<in> A \<and> card (A \<inter> {..<a}) = i) = A

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma square_minus_one_cong_one:
  fixes n x :: nat
  assumes "1 < n" "[x = n - 1](mod n)"
  shows "[x^2 = 1](mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
have "[x^2 = (n - 1) * (n - 1)] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [x\<^sup>2 = (n - 1) * (n - 1)] (mod n)
[PROOF STEP]
using cong_mult[OF assms(2) assms(2)]
[PROOF STATE]
proof (prove)
using this:
[x * x = (n - 1) * (n - 1)] (mod n)

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

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[x\<^sup>2 = (n - 1) * (n - 1)] (mod n)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
have "[(n - 1) * (n - 1) = Suc (n * n) - (n + n)] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [(n - 1) * (n - 1) = Suc (n * n) - (n + n)] (mod n)
[PROOF STEP]
using power2_diff_nat[of 1 n] \<open>1 < n\<close>
[PROOF STATE]
proof (prove)
using this:
1 \<le> n \<Longrightarrow> (n - 1)\<^sup>2 = n\<^sup>2 + 1\<^sup>2 - 2 * n * 1
1 < n

goal (1 subgoal):
 1. [(n - 1) * (n - 1) = Suc (n * n) - (n + n)] (mod n)
[PROOF STEP]
by (simp add: algebra_simps power2_eq_square)
[PROOF STATE]
proof (state)
this:
[(n - 1) * (n - 1) = Suc (n * n) - (n + n)] (mod n)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[(n - 1) * (n - 1) = Suc (n * n) - (n + n)] (mod n)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
have "[Suc (n * n) - (n + n) = Suc (n * n)] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
have "n * n + 0 * n = n * n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n * n + 0 * n = n * n
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
n * n + 0 * n = n * n

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
n * n + 0 * n = n * n

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
have "n * n - (n + n) + (n + n) = n * n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. n * n - (n + n) + (n + n) = n * n
[PROOF STEP]
using square_inequality[OF \<open>1 < n\<close>] le_add_diff_inverse2
[PROOF STATE]
proof (prove)
using this:
n + n \<le> n * n
?b \<le> ?a \<Longrightarrow> ?a - ?b + ?b = ?a

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

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
n * n - (n + n) + (n + n) = n * n

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
have "(Suc 0 + 1) * n = n + n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (Suc 0 + 1) * n = n + n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(Suc 0 + 1) * n = n + n

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
n * n + 0 * n = n * n
n * n - (n + n) + (n + n) = n * n
(Suc 0 + 1) * n = n + n
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n * n + 0 * n = n * n
n * n - (n + n) + (n + n) = n * n
(Suc 0 + 1) * n = n + n

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
using square_inequality[OF \<open>1 < n\<close>]
[PROOF STATE]
proof (prove)
using this:
n * n + 0 * n = n * n
n * n - (n + n) + (n + n) = n * n
(Suc 0 + 1) * n = n + n
n + n \<le> n * n

goal (1 subgoal):
 1. [Suc (n * n) - (n + n) = Suc (n * n)] (mod n)
[PROOF STEP]
by (metis (no_types) Suc_diff_le add_Suc cong_iff_lin_nat)
[PROOF STATE]
proof (state)
this:
[Suc (n * n) - (n + n) = Suc (n * n)] (mod n)

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

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
[Suc (n * n) - (n + n) = Suc (n * n)] (mod n)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
have "[Suc (n * n) = 1] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [Suc (n * n) = 1] (mod n)
[PROOF STEP]
using cong_to_1'_nat
[PROOF STATE]
proof (prove)
using this:
[?a = 1] (mod ?n) = (?a = 0 \<and> ?n = 1 \<or> (\<exists>m. ?a = 1 + m * ?n))

goal (1 subgoal):
 1. [Suc (n * n) = 1] (mod n)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
[Suc (n * n) = 1] (mod n)

goal (1 subgoal):
 1. [x\<^sup>2 = 1] (mod n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
[x\<^sup>2 = 1] (mod n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
[x\<^sup>2 = 1] (mod n)

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dist_of_int: "dist (of_int m) (of_int n :: 'a :: real_normed_algebra_1) = of_int \<bar>m - n\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
have "dist (of_int m) (of_int n :: 'a) = dist (of_int m :: 'a) (of_int m - (of_int (m - n)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (of_int m) (of_int n) = dist (of_int m) (of_int m - of_int (m - n))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
dist (of_int m) (of_int n) = dist (of_int m) (of_int m - of_int (m - n))

goal (1 subgoal):
 1. dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
dist (of_int m) (of_int n) = dist (of_int m) (of_int m - of_int (m - n))

goal (1 subgoal):
 1. dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
have "\<dots> = of_int \<bar>m - n\<bar>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. dist (of_int m) (of_int m - of_int (m - n)) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
by (subst dist_diff, subst norm_of_int) simp
[PROOF STATE]
proof (state)
this:
dist (of_int m) (of_int m - of_int (m - n)) = real_of_int \<bar>m - n\<bar>

goal (1 subgoal):
 1. dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>

goal (1 subgoal):
 1. dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
dist (of_int m) (of_int n) = real_of_int \<bar>m - n\<bar>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma lemma_4_13_ii: "b r\<rightarrow> a = a \<Longrightarrow> a = 1 \<or> b = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b r\<rightarrow> a = a \<Longrightarrow> a = (1::'a) \<or> b = (1::'a)
[PROOF STEP]
apply safe
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>b r\<rightarrow> a = a; b \<noteq> (1::'a)\<rbrakk> \<Longrightarrow> a = (1::'a)
[PROOF STEP]
apply (drule_tac a = b and b = a in lemma_4_12_i_iii)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>b r\<rightarrow> a = a; \<exists>n. b ^ n \<le> a\<rbrakk> \<Longrightarrow> a = (1::'a)
[PROOF STEP]
apply safe
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>b r\<rightarrow> a = a; b ^ n \<le> a\<rbrakk> \<Longrightarrow> a = (1::'a)
[PROOF STEP]
apply (subst (asm) right_lesseq)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>b r\<rightarrow> a = a; b ^ n r\<rightarrow> a = (1::'a)\<rbrakk> \<Longrightarrow> a = (1::'a)
[PROOF STEP]
apply (drule_tac n = n in power_impr)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>b ^ n r\<rightarrow> a = (1::'a); b ^ n r\<rightarrow> a = a\<rbrakk> \<Longrightarrow> a = (1::'a)
[PROOF STEP]
by simp


[STATEMENT]
lemma remove1_retains_prod:
  fixes a and xs::"'a :: comm_ring_1 list"
  shows "a : set xs \<longrightarrow> \<Prod>:xs = \<Prod>:(remove1 a xs) * a"
  (is "?P xs")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a
[PROOF STEP]
proof (induct xs)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a \<in> set [] \<longrightarrow> prod_list [] = prod_list (remove1 a []) * a
 2. \<And>aa xs. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a \<Longrightarrow> a \<in> set (aa # xs) \<longrightarrow> prod_list (aa # xs) = prod_list (remove1 a (aa # xs)) * a
[PROOF STEP]
case Nil
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. a \<in> set [] \<longrightarrow> prod_list [] = prod_list (remove1 a []) * a
 2. \<And>aa xs. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a \<Longrightarrow> a \<in> set (aa # xs) \<longrightarrow> prod_list (aa # xs) = prod_list (remove1 a (aa # xs)) * a
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> set [] \<longrightarrow> prod_list [] = prod_list (remove1 a []) * a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a \<in> set [] \<longrightarrow> prod_list [] = prod_list (remove1 a []) * a

goal (1 subgoal):
 1. \<And>aa xs. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a \<Longrightarrow> a \<in> set (aa # xs) \<longrightarrow> prod_list (aa # xs) = prod_list (remove1 a (aa # xs)) * a
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>aa xs. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a \<Longrightarrow> a \<in> set (aa # xs) \<longrightarrow> prod_list (aa # xs) = prod_list (remove1 a (aa # xs)) * a
[PROOF STEP]
case (Cons aa list)
[PROOF STATE]
proof (state)
this:
a \<in> set list \<longrightarrow> prod_list list = prod_list (remove1 a list) * a

goal (1 subgoal):
 1. \<And>aa xs. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a \<Longrightarrow> a \<in> set (aa # xs) \<longrightarrow> prod_list (aa # xs) = prod_list (remove1 a (aa # xs)) * a
[PROOF STEP]
assume plist: "?P list"
[PROOF STATE]
proof (state)
this:
a \<in> set list \<longrightarrow> prod_list list = prod_list (remove1 a list) * a

goal (1 subgoal):
 1. \<And>aa xs. a \<in> set xs \<longrightarrow> prod_list xs = prod_list (remove1 a xs) * a \<Longrightarrow> a \<in> set (aa # xs) \<longrightarrow> prod_list (aa # xs) = prod_list (remove1 a (aa # xs)) * a
[PROOF STEP]
show "?P (aa#list)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a \<in> set (aa # list) \<longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<in> set (aa # list) \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
assume aml: "a : set(aa#list)"
[PROOF STATE]
proof (state)
this:
a \<in> set (aa # list)

goal (1 subgoal):
 1. a \<in> set (aa # list) \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
show "\<Prod>:(aa # list) = \<Prod>:remove1 a (aa # list) * a"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
proof (cases)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
 2. \<not> ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
assume aeq: "a = aa"
[PROOF STATE]
proof (state)
this:
a = aa

goal (2 subgoals):
 1. ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
 2. \<not> ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
hence
        "remove1 a (aa#list) = list"
[PROOF STATE]
proof (prove)
using this:
a = aa

goal (1 subgoal):
 1. remove1 a (aa # list) = list
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
remove1 a (aa # list) = list

goal (2 subgoals):
 1. ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
 2. \<not> ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
hence
        "\<Prod>:(remove1 a (aa#list)) = \<Prod>:list"
[PROOF STATE]
proof (prove)
using this:
remove1 a (aa # list) = list

goal (1 subgoal):
 1. prod_list (remove1 a (aa # list)) = prod_list list
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod_list (remove1 a (aa # list)) = prod_list list

goal (2 subgoals):
 1. ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
 2. \<not> ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
prod_list (remove1 a (aa # list)) = prod_list list

goal (2 subgoals):
 1. ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
 2. \<not> ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
with aeq
[PROOF STATE]
proof (chain)
picking this:
a = aa
prod_list (remove1 a (aa # list)) = prod_list list
[PROOF STEP]
have
        "\<Prod>:(aa#list) = \<Prod>:list * a"
[PROOF STATE]
proof (prove)
using this:
a = aa
prod_list (remove1 a (aa # list)) = prod_list list

goal (1 subgoal):
 1. prod_list (aa # list) = prod_list list * a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod_list (aa # list) = prod_list list * a

goal (2 subgoals):
 1. ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
 2. \<not> ?P \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
prod_list (remove1 a (aa # list)) = prod_list list
prod_list (aa # list) = prod_list list * a
[PROOF STEP]
show
        "\<Prod>:(aa#list) = \<Prod>:remove1 a (aa # list) * a"
[PROOF STATE]
proof (prove)
using this:
prod_list (remove1 a (aa # list)) = prod_list list
prod_list (aa # list) = prod_list list * a

goal (1 subgoal):
 1. prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
assume naeq: "a \<noteq> aa"
[PROOF STATE]
proof (state)
this:
a \<noteq> aa

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
with aml
[PROOF STATE]
proof (chain)
picking this:
a \<in> set (aa # list)
a \<noteq> aa
[PROOF STEP]
have aml2: "a : set list"
[PROOF STATE]
proof (prove)
using this:
a \<in> set (aa # list)
a \<noteq> aa

goal (1 subgoal):
 1. a \<in> set list
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a \<in> set list

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
from naeq
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> aa
[PROOF STEP]
have
        "remove1 a (aa#list) = aa#(remove1 a list)"
[PROOF STATE]
proof (prove)
using this:
a \<noteq> aa

goal (1 subgoal):
 1. remove1 a (aa # list) = aa # remove1 a list
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
remove1 a (aa # list) = aa # remove1 a list

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
remove1 a (aa # list) = aa # remove1 a list

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
hence
        "\<Prod>:(remove1 a (aa#list)) = aa * \<Prod>:(remove1 a list)"
[PROOF STATE]
proof (prove)
using this:
remove1 a (aa # list) = aa # remove1 a list

goal (1 subgoal):
 1. prod_list (remove1 a (aa # list)) = aa * prod_list (remove1 a list)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod_list (remove1 a (aa # list)) = aa * prod_list (remove1 a list)

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
prod_list (remove1 a (aa # list)) = aa * prod_list (remove1 a list)

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
from aml2 plist
[PROOF STATE]
proof (chain)
picking this:
a \<in> set list
a \<in> set list \<longrightarrow> prod_list list = prod_list (remove1 a list) * a
[PROOF STEP]
have
        "\<Prod>:list = \<Prod>:(remove1 a list) * a"
[PROOF STATE]
proof (prove)
using this:
a \<in> set list
a \<in> set list \<longrightarrow> prod_list list = prod_list (remove1 a list) * a

goal (1 subgoal):
 1. prod_list list = prod_list (remove1 a list) * a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod_list list = prod_list (remove1 a list) * a

goal (1 subgoal):
 1. a \<noteq> aa \<Longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
remove1 a (aa # list) = aa # remove1 a list
prod_list (remove1 a (aa # list)) = aa * prod_list (remove1 a list)
prod_list list = prod_list (remove1 a list) * a
[PROOF STEP]
show
        "\<Prod>:(aa#list) = \<Prod>:remove1 a (aa # list) * a"
[PROOF STATE]
proof (prove)
using this:
remove1 a (aa # list) = aa # remove1 a list
prod_list (remove1 a (aa # list)) = aa * prod_list (remove1 a list)
prod_list list = prod_list (remove1 a list) * a

goal (1 subgoal):
 1. prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
a \<in> set (aa # list) \<longrightarrow> prod_list (aa # list) = prod_list (remove1 a (aa # list)) * a

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Sources_singleDSource:
  assumes "DSources i S = {C}"
  shows    "Sources i S = {C} \<union> Sources i C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sources i S = {C} \<union> Sources i C
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Sources i S = {C} \<union> Sources i C
[PROOF STEP]
have sDef:  "(Sources i S) = (DSources i S) \<union> (\<Union> Z \<in> (DSources i S). (Sources i Z))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Sources i S = DSources i S \<union> \<Union> (Sources i ` DSources i S)
[PROOF STEP]
by (rule SourcesDef)
[PROOF STATE]
proof (state)
this:
Sources i S = DSources i S \<union> \<Union> (Sources i ` DSources i S)

goal (1 subgoal):
 1. Sources i S = {C} \<union> Sources i C
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
DSources i S = {C}
[PROOF STEP]
have "(\<Union> Z \<in> (DSources i S). (Sources i Z)) = Sources i C"
[PROOF STATE]
proof (prove)
using this:
DSources i S = {C}

goal (1 subgoal):
 1. \<Union> (Sources i ` DSources i S) = Sources i C
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<Union> (Sources i ` DSources i S) = Sources i C

goal (1 subgoal):
 1. Sources i S = {C} \<union> Sources i C
[PROOF STEP]
with sDef assms
[PROOF STATE]
proof (chain)
picking this:
Sources i S = DSources i S \<union> \<Union> (Sources i ` DSources i S)
DSources i S = {C}
\<Union> (Sources i ` DSources i S) = Sources i C
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
Sources i S = DSources i S \<union> \<Union> (Sources i ` DSources i S)
DSources i S = {C}
\<Union> (Sources i ` DSources i S) = Sources i C

goal (1 subgoal):
 1. Sources i S = {C} \<union> Sources i C
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
Sources i S = {C} \<union> Sources i C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma neville_aitken_interpolation_poly: assumes dist: "distinct (map fst xs_ys)"
  and p: "p = neville_aitken_interpolation_poly xs_ys"
  and xy: "(x,y) \<in> set xs_ys"
  shows "poly p x = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly p x = y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. poly p x = y
[PROOF STEP]
have p: "p = neville_aitken (\<lambda> i. fst (xs_ys ! i)) (\<lambda> i. snd (xs_ys ! i)) (length xs_ys - 1)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. p = neville_aitken (\<lambda>i. fst (xs_ys ! i)) (\<lambda>i. snd (xs_ys ! i)) (length xs_ys - 1)
[PROOF STEP]
unfolding p
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. neville_aitken_interpolation_poly xs_ys = neville_aitken (\<lambda>i. fst (xs_ys ! i)) (\<lambda>i. snd (xs_ys ! i)) (length xs_ys - 1)
[PROOF STEP]
by (rule neville_aitken_interpolation_impl, insert xy, auto)
[PROOF STATE]
proof (state)
this:
p = neville_aitken (\<lambda>i. fst (xs_ys ! i)) (\<lambda>i. snd (xs_ys ! i)) (length xs_ys - 1)

goal (1 subgoal):
 1. poly p x = y
[PROOF STEP]
from xy
[PROOF STATE]
proof (chain)
picking this:
(x, y) \<in> set xs_ys
[PROOF STEP]
obtain i where i: "i < length xs_ys" and x: "x = fst (xs_ys ! i)" and y: "y = snd (xs_ys ! i)"
[PROOF STATE]
proof (prove)
using this:
(x, y) \<in> set xs_ys

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < length xs_ys; x = fst (xs_ys ! i); y = snd (xs_ys ! i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding set_conv_nth
[PROOF STATE]
proof (prove)
using this:
(x, y) \<in> {xs_ys ! i |i. i < length xs_ys}

goal (1 subgoal):
 1. (\<And>i. \<lbrakk>i < length xs_ys; x = fst (xs_ys ! i); y = snd (xs_ys ! i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis fst_conv in_set_conv_nth snd_conv xy)
[PROOF STATE]
proof (state)
this:
i < length xs_ys
x = fst (xs_ys ! i)
y = snd (xs_ys ! i)

goal (1 subgoal):
 1. poly p x = y
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly p x = y
[PROOF STEP]
unfolding p x y
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. poly (neville_aitken (\<lambda>i. fst (xs_ys ! i)) (\<lambda>i. snd (xs_ys ! i)) (length xs_ys - 1)) (fst (xs_ys ! i)) = snd (xs_ys ! i)
[PROOF STEP]
proof (rule neville_aitken)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < j; j \<le> length xs_ys - 1\<rbrakk> \<Longrightarrow> fst (xs_ys ! i) \<noteq> fst (xs_ys ! j)
 2. i \<le> length xs_ys - 1
[PROOF STEP]
fix i j
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i j. \<lbrakk>i < j; j \<le> length xs_ys - 1\<rbrakk> \<Longrightarrow> fst (xs_ys ! i) \<noteq> fst (xs_ys ! j)
 2. i__ \<le> length xs_ys - 1
[PROOF STEP]
show "i < j \<Longrightarrow> j \<le> length xs_ys - 1 \<Longrightarrow> fst (xs_ys ! i) \<noteq> fst (xs_ys ! j)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>i < j; j \<le> length xs_ys - 1\<rbrakk> \<Longrightarrow> fst (xs_ys ! i) \<noteq> fst (xs_ys ! j)
[PROOF STEP]
using dist
[PROOF STATE]
proof (prove)
using this:
distinct (map fst xs_ys)

goal (1 subgoal):
 1. \<lbrakk>i < j; j \<le> length xs_ys - 1\<rbrakk> \<Longrightarrow> fst (xs_ys ! i) \<noteq> fst (xs_ys ! j)
[PROOF STEP]
by (metis (mono_tags, lifting) One_nat_def diff_less dual_order.strict_trans2 length_map
        length_pos_if_in_set lessI less_or_eq_imp_le neq_iff nth_eq_iff_index_eq nth_map xy)
[PROOF STATE]
proof (state)
this:
\<lbrakk>i < j; j \<le> length xs_ys - 1\<rbrakk> \<Longrightarrow> fst (xs_ys ! i) \<noteq> fst (xs_ys ! j)

goal (1 subgoal):
 1. i__ \<le> length xs_ys - 1
[PROOF STEP]
qed (insert i, auto)
[PROOF STATE]
proof (state)
this:
poly p x = y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infinite_infinite_partition:
  assumes "infinite A"
  obtains C :: "nat \<Rightarrow> 'a set"
    where "pairwise (\<lambda>i j. disjnt (C i) (C j)) UNIV" "(\<Union>i. C i) \<subseteq> A" "\<And>i. infinite (C i)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>C. \<lbrakk>pairwise (\<lambda>i j. disjnt (C i) (C j)) UNIV; \<Union> (range C) \<subseteq> A; \<And>i. infinite (C i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>C. \<lbrakk>pairwise (\<lambda>i j. disjnt (C i) (C j)) UNIV; \<Union> (range C) \<subseteq> A; \<And>i. infinite (C i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
obtain f :: "nat\<Rightarrow>'a" where "range f \<subseteq> A" "inj f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f \<subseteq> A; inj f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms infinite_countable_subset
[PROOF STATE]
proof (prove)
using this:
infinite A
infinite ?S \<Longrightarrow> \<exists>f. inj f \<and> range f \<subseteq> ?S

goal (1 subgoal):
 1. (\<And>f. \<lbrakk>range f \<subseteq> A; inj f\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
range f \<subseteq> A
inj f

goal (1 subgoal):
 1. (\<And>C. \<lbrakk>pairwise (\<lambda>i j. disjnt (C i) (C j)) UNIV; \<Union> (range C) \<subseteq> A; \<And>i. infinite (C i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
let ?C = "\<lambda>i. range (\<lambda>j. f (prod_encode (i,j)))"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>C. \<lbrakk>pairwise (\<lambda>i j. disjnt (C i) (C j)) UNIV; \<Union> (range C) \<subseteq> A; \<And>i. infinite (C i)\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
show thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. thesis
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (3 subgoals):
 1. pairwise (\<lambda>i j. disjnt (?C i) (?C j)) UNIV
 2. \<Union> (range ?C) \<subseteq> A
 3. \<And>i. infinite (?C i)
[PROOF STEP]
show "pairwise (\<lambda>i j. disjnt (?C i) (?C j)) UNIV"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. pairwise (\<lambda>i j. disjnt (range (\<lambda>j. f (prod_encode (i, j)))) (range (\<lambda>ja. f (prod_encode (j, ja))))) UNIV
[PROOF STEP]
by (auto simp: pairwise_def disjnt_def inj_on_eq_iff [OF \<open>inj f\<close>] inj_on_eq_iff [OF inj_prod_encode, of _ UNIV])
[PROOF STATE]
proof (state)
this:
pairwise (\<lambda>i j. disjnt (range (\<lambda>j. f (prod_encode (i, j)))) (range (\<lambda>ja. f (prod_encode (j, ja))))) UNIV

goal (2 subgoals):
 1. (\<Union>i. range (\<lambda>j. f (prod_encode (i, j)))) \<subseteq> A
 2. \<And>i. infinite (range (\<lambda>j. f (prod_encode (i, j))))
[PROOF STEP]
show "(\<Union>i. ?C i) \<subseteq> A"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Union>i. range (\<lambda>j. f (prod_encode (i, j)))) \<subseteq> A
[PROOF STEP]
using \<open>range f \<subseteq> A\<close>
[PROOF STATE]
proof (prove)
using this:
range f \<subseteq> A

goal (1 subgoal):
 1. (\<Union>i. range (\<lambda>j. f (prod_encode (i, j)))) \<subseteq> A
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
(\<Union>i. range (\<lambda>j. f (prod_encode (i, j)))) \<subseteq> A

goal (1 subgoal):
 1. \<And>i. infinite (range (\<lambda>j. f (prod_encode (i, j))))
[PROOF STEP]
have "infinite (range (\<lambda>j. f (prod_encode (i, j))))" for i
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. infinite (range (\<lambda>j. f (prod_encode (i, j))))
[PROOF STEP]
by (rule range_inj_infinite) (meson Pair_inject \<open>inj f\<close> inj_def prod_encode_eq)
[PROOF STATE]
proof (state)
this:
infinite (range (\<lambda>j. f (prod_encode (?i, j))))

goal (1 subgoal):
 1. \<And>i. infinite (range (\<lambda>j. f (prod_encode (i, j))))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
infinite (range (\<lambda>j. f (prod_encode (?i, j))))
[PROOF STEP]
show "\<And>i. infinite (?C i)"
[PROOF STATE]
proof (prove)
using this:
infinite (range (\<lambda>j. f (prod_encode (?i, j))))

goal (1 subgoal):
 1. \<And>i. infinite (range (\<lambda>j. f (prod_encode (i, j))))
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
infinite (range (\<lambda>j. f (prod_encode (?i, j))))
\<lbrakk>pairwise (\<lambda>i j. disjnt (?C i) (?C j)) UNIV; \<Union> (range ?C) \<subseteq> A; \<And>i. infinite (?C i)\<rbrakk> \<Longrightarrow> thesis

goal (1 subgoal):
 1. \<And>i. infinite (range (\<lambda>j. f (prod_encode (i, j))))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
infinite (range (\<lambda>j. f (prod_encode (?i, j))))

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sorted_wrt_insort_key_rel:
   \<open>total_on R (insert x (set xs)) \<Longrightarrow> transp R \<Longrightarrow> reflp R \<Longrightarrow>
    sorted_wrt R xs \<Longrightarrow> sorted_wrt R (insort_key_rel R x xs)\<close>
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Restricted_Predicates.total_on R (insert x (set xs)); transp R; reflp R; sorted_wrt R xs\<rbrakk> \<Longrightarrow> sorted_wrt R (insort_key_rel R x xs)
[PROOF STEP]
by (induction xs)
   (auto dest: transpD reflpD simp: Restricted_Predicates.total_on_def)


[STATEMENT]
lemma landau_sum_1:
  assumes "eventually (\<lambda>x. g1 x \<ge> (0::real)) F"
  assumes "eventually (\<lambda>x. g2 x \<ge> 0) F"
  assumes "f \<in> O[F](g1)"
  shows "f \<in> O[F](\<lambda>x. g1 x + g2 x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
have "f = (\<lambda>x. f x + 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f = (\<lambda>x. f x + 0)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f = (\<lambda>x. f x + 0)

goal (1 subgoal):
 1. f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
f = (\<lambda>x. f x + 0)

goal (1 subgoal):
 1. f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
have "... \<in> O[F](\<lambda>x. g1 x + g2 x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. f x + 0) \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
using assms zero_in_bigo
[PROOF STATE]
proof (prove)
using this:
\<forall>\<^sub>F x in F. 0 \<le> g1 x
\<forall>\<^sub>F x in F. 0 \<le> g2 x
f \<in> O[F](g1)
(\<lambda>_. 0::?'b) \<in> O[?F](?f)

goal (1 subgoal):
 1. (\<lambda>x. f x + 0) \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
by (intro landau_sum)
[PROOF STATE]
proof (state)
this:
(\<lambda>x. f x + 0) \<in> O[F](\<lambda>x. g1 x + g2 x)

goal (1 subgoal):
 1. f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f \<in> O[F](\<lambda>x. g1 x + g2 x)

goal (1 subgoal):
 1. f \<in> O[F](\<lambda>x. g1 x + g2 x)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
f \<in> O[F](\<lambda>x. g1 x + g2 x)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma dist_less_imp_nth_equal:
  assumes "dist f g < inverse (2 ^ i)"
    and"j \<le> i"
  shows "f $ j = g $ j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f $ j = g $ j
[PROOF STEP]
proof (rule ccontr)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. f $ j \<noteq> g $ j \<Longrightarrow> False
[PROOF STEP]
assume "f $ j \<noteq> g $ j"
[PROOF STATE]
proof (state)
this:
f $ j \<noteq> g $ j

goal (1 subgoal):
 1. f $ j \<noteq> g $ j \<Longrightarrow> False
[PROOF STEP]
hence "f \<noteq> g"
[PROOF STATE]
proof (prove)
using this:
f $ j \<noteq> g $ j

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

goal (1 subgoal):
 1. f $ j \<noteq> g $ j \<Longrightarrow> False
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
dist f g < inverse (2 ^ i)
j \<le> i
f \<noteq> g
[PROOF STEP]
have "i < subdegree (f - g)"
[PROOF STATE]
proof (prove)
using this:
dist f g < inverse (2 ^ i)
j \<le> i
f \<noteq> g

goal (1 subgoal):
 1. i < subdegree (f - g)
[PROOF STEP]
by (simp add: if_split_asm dist_fps_def)
[PROOF STATE]
proof (state)
this:
i < subdegree (f - g)

goal (1 subgoal):
 1. f $ j \<noteq> g $ j \<Longrightarrow> False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
i < subdegree (f - g)

goal (1 subgoal):
 1. f $ j \<noteq> g $ j \<Longrightarrow> False
[PROOF STEP]
have "\<dots> \<le> j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. subdegree (f - g) \<le> j
[PROOF STEP]
using \<open>f $ j \<noteq> g $ j\<close>
[PROOF STATE]
proof (prove)
using this:
f $ j \<noteq> g $ j

goal (1 subgoal):
 1. subdegree (f - g) \<le> j
[PROOF STEP]
by (intro subdegree_leI) simp_all
[PROOF STATE]
proof (state)
this:
subdegree (f - g) \<le> j

goal (1 subgoal):
 1. f $ j \<noteq> g $ j \<Longrightarrow> False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
i < j
[PROOF STEP]
show False
[PROOF STATE]
proof (prove)
using this:
i < j

goal (1 subgoal):
 1. False
[PROOF STEP]
using \<open>j \<le> i\<close>
[PROOF STATE]
proof (prove)
using this:
i < j
j \<le> i

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma q63_infinite_def: "q63 = (\<lambda>k. k\<^sup>2 mod 63) ` {0..}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. q63 = (\<lambda>k. k\<^sup>2 mod 63) ` {0..}
[PROOF STEP]
unfolding q63_upto_def image_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y. \<exists>x\<in>{..<63}. y = x\<^sup>2 mod 63} = {y. \<exists>x\<in>{0..}. y = x\<^sup>2 mod 63}
[PROOF STEP]
proof (auto, goal_cases)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>xa. \<exists>x\<in>{..<63}. xa\<^sup>2 mod 63 = x\<^sup>2 mod 63
[PROOF STEP]
case (1 xa)
[PROOF STATE]
proof (state)
this:

goal (1 subgoal):
 1. \<And>xa. \<exists>x\<in>{..<63}. xa\<^sup>2 mod 63 = x\<^sup>2 mod 63
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>x\<in>{..<63}. xa\<^sup>2 mod 63 = x\<^sup>2 mod 63
[PROOF STEP]
using square_mod_lower[of 63 xa "xa\<^sup>2 mod 63"]
      ex_nat_less_eq[of 63 "\<lambda>x. xa\<^sup>2 mod 63 = x\<^sup>2 mod 63"]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < 63; xa\<^sup>2 mod 63 = xa\<^sup>2 mod 63\<rbrakk> \<Longrightarrow> \<exists>q'<63. q'\<^sup>2 mod 63 = xa\<^sup>2 mod 63
(\<exists>m<63. xa\<^sup>2 mod 63 = m\<^sup>2 mod 63) = (\<exists>m\<in>{0..<63}. xa\<^sup>2 mod 63 = m\<^sup>2 mod 63)

goal (1 subgoal):
 1. \<exists>x\<in>{..<63}. xa\<^sup>2 mod 63 = x\<^sup>2 mod 63
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<exists>x\<in>{..<63}. xa\<^sup>2 mod 63 = x\<^sup>2 mod 63

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma finite_Prefixes:
  shows "finite (Prefixes s)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (Prefixes s)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. finite (Prefixes s)
[PROOF STEP]
have "finite (Suffixes (rev s))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (Suffixes (rev s))
[PROOF STEP]
by (rule finite_Suffixes)
[PROOF STATE]
proof (state)
this:
finite (Suffixes (rev s))

goal (1 subgoal):
 1. finite (Prefixes s)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite (Suffixes (rev s))
[PROOF STEP]
have "finite (rev ` Suffixes (rev s))"
[PROOF STATE]
proof (prove)
using this:
finite (Suffixes (rev s))

goal (1 subgoal):
 1. finite (rev ` Suffixes (rev s))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
finite (rev ` Suffixes (rev s))

goal (1 subgoal):
 1. finite (Prefixes s)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
finite (rev ` Suffixes (rev s))

goal (1 subgoal):
 1. finite (Prefixes s)
[PROOF STEP]
have "rev ` (Suffixes (rev s)) = Prefixes s"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. rev ` Suffixes (rev s) = Prefixes s
[PROOF STEP]
unfolding suffix_def prefix_def image_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {y. \<exists>x\<in>{s'. \<exists>zs. rev s = zs @ s'}. y = rev x} = {s'. \<exists>zs. s = s' @ zs}
[PROOF STEP]
by (auto)(metis rev_append rev_rev_ident)+
[PROOF STATE]
proof (state)
this:
rev ` Suffixes (rev s) = Prefixes s

goal (1 subgoal):
 1. finite (Prefixes s)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
finite (rev ` Suffixes (rev s))
rev ` Suffixes (rev s) = Prefixes s
[PROOF STEP]
show "finite (Prefixes s)"
[PROOF STATE]
proof (prove)
using this:
finite (rev ` Suffixes (rev s))
rev ` Suffixes (rev s) = Prefixes s

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

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma infinite_chain_mono:
  assumes "S \<subseteq> T" "\<exists>f. \<forall>i::nat. (f i, f (Suc i)) \<in> S"
  shows "\<exists>f. \<forall>i::nat. (f i, f (Suc i)) \<in> T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>f. \<forall>i. (f i, f (Suc i)) \<in> T
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
S \<subseteq> T
\<exists>f. \<forall>i. (f i, f (Suc i)) \<in> S

goal (1 subgoal):
 1. \<exists>f. \<forall>i. (f i, f (Suc i)) \<in> T
[PROOF STEP]
by auto