[STATEMENT]
lemma div_sub:
  fixes a b c :: nat
  shows "(a - b) div c = (if(a mod c < b mod c) then a div c - b div c - 1 else  a div c - b div c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
consider (alb) "a<b" | (ageb) "a\<ge>b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>a < b \<Longrightarrow> thesis; b \<le> a \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<lbrakk>a < b \<Longrightarrow> ?thesis; b \<le> a \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>a < b \<Longrightarrow> ?thesis; b \<le> a \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>a < b \<Longrightarrow> ?thesis; b \<le> a \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a < b \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
case alb
[PROOF STATE]
proof (state)
this:
a < b

goal (2 subgoals):
 1. a < b \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a < b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a < b

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
using div_le_mono
[PROOF STATE]
proof (prove)
using this:
a < b
?m \<le> ?n \<Longrightarrow> ?m div ?k \<le> ?n div ?k

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
case ageb
[PROOF STATE]
proof (state)
this:
b \<le> a

goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
obtain a1 a2 where a1_def: "a1 = a div c" and a2_def: "a2 = a mod c" and a_def: "a=a1*c+a2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>a1 a2. \<lbrakk>a1 = a div c; a2 = a mod c; a = a1 * c + a2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using mod_div_decomp
[PROOF STATE]
proof (prove)
using this:
(\<And>q r. \<lbrakk>q = ?a div ?b; r = ?a mod ?b; ?a = q * ?b + r\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>a1 a2. \<lbrakk>a1 = a div c; a2 = a mod c; a = a1 * c + a2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
a1 = a div c
a2 = a mod c
a = a1 * c + a2

goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
obtain b1 b2 where b1_def: "b1 = b div c" and b2_def: "b2 = b mod c" and b_def: "b=b1*c+b2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b1 b2. \<lbrakk>b1 = b div c; b2 = b mod c; b = b1 * c + b2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using mod_div_decomp
[PROOF STATE]
proof (prove)
using this:
(\<And>q r. \<lbrakk>q = ?a div ?b; r = ?a mod ?b; ?a = q * ?b + r\<rbrakk> \<Longrightarrow> ?thesis) \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. (\<And>b1 b2. \<lbrakk>b1 = b div c; b2 = b mod c; b = b1 * c + b2\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
b1 = b div c
b2 = b mod c
b = b1 * c + b2

goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
have a1geb1: "a1\<ge>b1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. b1 \<le> a1
[PROOF STEP]
using ageb a1_def b1_def
[PROOF STATE]
proof (prove)
using this:
b \<le> a
a1 = a div c
b1 = b div c

goal (1 subgoal):
 1. b1 \<le> a1
[PROOF STEP]
using div_le_mono
[PROOF STATE]
proof (prove)
using this:
b \<le> a
a1 = a div c
b1 = b div c
?m \<le> ?n \<Longrightarrow> ?m div ?k \<le> ?n div ?k

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

goal (1 subgoal):
 1. b \<le> a \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
proof(cases "c=0")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. c = 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. c \<noteq> 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
assume "c=0"
[PROOF STATE]
proof (state)
this:
c = 0

goal (2 subgoals):
 1. c = 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. c \<noteq> 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c = 0

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
assume cneq0: "c \<noteq> 0"
[PROOF STATE]
proof (state)
this:
c \<noteq> 0

goal (1 subgoal):
 1. c \<noteq> 0 \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c \<noteq> 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
c \<noteq> 0

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
proof(cases "a2 < b2")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>c \<noteq> 0; a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. \<lbrakk>c \<noteq> 0; \<not> a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
assume a2lb2: "a2 < b2"
[PROOF STATE]
proof (state)
this:
a2 < b2

goal (2 subgoals):
 1. \<lbrakk>c \<noteq> 0; a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. \<lbrakk>c \<noteq> 0; \<not> a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a2 < b2
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a2 < b2

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
proof(cases "a1=b1")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>a2 < b2; a1 = b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a1 = b1

goal (2 subgoals):
 1. \<lbrakk>a2 < b2; a1 = b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
 2. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a1 = b1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a1 = b1

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
using ageb a2lb2 a_def b_def
[PROOF STATE]
proof (prove)
using this:
a1 = b1
b \<le> a
a2 < b2
a = a1 * c + a2
b = b1 * c + b2

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
assume "\<not>(a1=b1)"
[PROOF STATE]
proof (state)
this:
a1 \<noteq> b1

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
hence a1gb1: "a1>b1"
[PROOF STATE]
proof (prove)
using this:
a1 \<noteq> b1

goal (1 subgoal):
 1. b1 < a1
[PROOF STEP]
using a1geb1
[PROOF STATE]
proof (prove)
using this:
a1 \<noteq> b1
b1 \<le> a1

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

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
have boundc: "a2+c-b2<c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a2 + c - b2 < c
[PROOF STEP]
using a2lb2 cneq0
[PROOF STATE]
proof (prove)
using this:
a2 < b2
c \<noteq> 0

goal (1 subgoal):
 1. a2 + c - b2 < c
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
a2 + c - b2 < c

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
have "a-b = (a1 - b1) * c + a2 - b2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a - b = (a1 - b1) * c + a2 - b2
[PROOF STEP]
using a_def b_def a1geb1 nat_diff_add_eq1[of b1 a1 c a2 b2]
[PROOF STATE]
proof (prove)
using this:
a = a1 * c + a2
b = b1 * c + b2
b1 \<le> a1
b1 \<le> a1 \<Longrightarrow> a1 * c + a2 - (b1 * c + b2) = (a1 - b1) * c + a2 - b2

goal (1 subgoal):
 1. a - b = (a1 - b1) * c + a2 - b2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a - b = (a1 - b1) * c + a2 - b2

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a - b = (a1 - b1) * c + a2 - b2

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
have "... = (a1 - b1-1+1) * c + a2 - b2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a1 - b1) * c + a2 - b2 = (a1 - b1 - 1 + 1) * c + a2 - b2
[PROOF STEP]
using a1gb1 Suc_diff_Suc[of b1 a1]
[PROOF STATE]
proof (prove)
using this:
b1 < a1
b1 < a1 \<Longrightarrow> Suc (a1 - Suc b1) = a1 - b1

goal (1 subgoal):
 1. (a1 - b1) * c + a2 - b2 = (a1 - b1 - 1 + 1) * c + a2 - b2
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a1 - b1) * c + a2 - b2 = (a1 - b1 - 1 + 1) * c + a2 - b2

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a1 - b1) * c + a2 - b2 = (a1 - b1 - 1 + 1) * c + a2 - b2

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
have "... = (a1 - b1 - 1) * c + (a2 + c - b2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a1 - b1 - 1 + 1) * c + a2 - b2 = (a1 - b1 - 1) * c + (a2 + c - b2)
[PROOF STEP]
using div_eq_0_iff[of b2 c] mod_div_trivial[of b c] b2_def
[PROOF STATE]
proof (prove)
using this:
(b2 div c = 0) = (b2 < c \<or> c = 0)
b mod c div c = 0
b2 = b mod c

goal (1 subgoal):
 1. (a1 - b1 - 1 + 1) * c + a2 - b2 = (a1 - b1 - 1) * c + (a2 + c - b2)
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(a1 - b1 - 1 + 1) * c + a2 - b2 = (a1 - b1 - 1) * c + (a2 + c - b2)

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a - b = (a1 - b1 - 1) * c + (a2 + c - b2)
[PROOF STEP]
have "(a-b) div c = a1 - b1 - 1 + (a2 + c - b2) div c"
[PROOF STATE]
proof (prove)
using this:
a - b = (a1 - b1 - 1) * c + (a2 + c - b2)

goal (1 subgoal):
 1. (a - b) div c = a1 - b1 - 1 + (a2 + c - b2) div c
[PROOF STEP]
using a_def b_def cneq0
[PROOF STATE]
proof (prove)
using this:
a - b = (a1 - b1 - 1) * c + (a2 + c - b2)
a = a1 * c + a2
b = b1 * c + b2
c \<noteq> 0

goal (1 subgoal):
 1. (a - b) div c = a1 - b1 - 1 + (a2 + c - b2) div c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a - b) div c = a1 - b1 - 1 + (a2 + c - b2) div c

goal (1 subgoal):
 1. \<lbrakk>a2 < b2; a1 \<noteq> b1\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(a - b) div c = a1 - b1 - 1 + (a2 + c - b2) div c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(a - b) div c = a1 - b1 - 1 + (a2 + c - b2) div c

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
using boundc div_less
[PROOF STATE]
proof (prove)
using this:
(a - b) div c = a1 - b1 - 1 + (a2 + c - b2) div c
a2 + c - b2 < c
?m < ?n \<Longrightarrow> ?m div ?n = 0

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
by (simp add: a1_def a2_def b1_def b2_def)
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal (1 subgoal):
 1. \<lbrakk>c \<noteq> 0; \<not> a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>c \<noteq> 0; \<not> a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
assume a2geb2: "\<not> a2 < b2"
[PROOF STATE]
proof (state)
this:
\<not> a2 < b2

goal (1 subgoal):
 1. \<lbrakk>c \<noteq> 0; \<not> a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<not> a2 < b2
[PROOF STEP]
have "(a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c"
[PROOF STATE]
proof (prove)
using this:
\<not> a2 < b2

goal (1 subgoal):
 1. (a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c
[PROOF STEP]
using a1geb1 a_def b_def nat_diff_add_eq1
[PROOF STATE]
proof (prove)
using this:
\<not> a2 < b2
b1 \<le> a1
a = a1 * c + a2
b = b1 * c + b2
?j \<le> ?i \<Longrightarrow> ?i * ?u + ?m - (?j * ?u + ?n) = (?i - ?j) * ?u + ?m - ?n

goal (1 subgoal):
 1. (a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c

goal (1 subgoal):
 1. \<lbrakk>c \<noteq> 0; \<not> a2 < b2\<rbrakk> \<Longrightarrow> (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
(a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
using a2geb2 div_add1_eq[of "(a1-b1)*c" "a2-b2" c]
[PROOF STATE]
proof (prove)
using this:
(a - b) div c = ((a1 - b1) * c + (a2 - b2)) div c
\<not> a2 < b2
((a1 - b1) * c + (a2 - b2)) div c = (a1 - b1) * c div c + (a2 - b2) div c + ((a1 - b1) * c mod c + (a2 - b2) mod c) div c

goal (1 subgoal):
 1. (a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)
[PROOF STEP]
by(auto simp add: b2_def a2_def a1_def b1_def less_imp_diff_less)
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
(a - b) div c = (if a mod c < b mod c then a div c - b div c - 1 else a div c - b div c)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma br_list_rel: "\<langle>br f P\<rangle> list_rel = br (map f) (list_all P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<langle>br f P\<rangle>list_rel = br (map f) (list_all P)
[PROOF STEP]
proof safe
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a b. (a, b) \<in> \<langle>br f P\<rangle>list_rel \<Longrightarrow> (a, b) \<in> br (map f) (list_all P)
 2. \<And>a b. (a, b) \<in> br (map f) (list_all P) \<Longrightarrow> (a, b) \<in> \<langle>br f P\<rangle>list_rel
[PROOF STEP]
fix u v
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>a b. (a, b) \<in> \<langle>br f P\<rangle>list_rel \<Longrightarrow> (a, b) \<in> br (map f) (list_all P)
 2. \<And>a b. (a, b) \<in> br (map f) (list_all P) \<Longrightarrow> (a, b) \<in> \<langle>br f P\<rangle>list_rel
[PROOF STEP]
show "(u, v) \<in> br (map f) (list_all P)" if "(u, v) \<in> \<langle>br f P\<rangle> list_rel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u, v) \<in> br (map f) (list_all P)
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
(u, v) \<in> \<langle>br f P\<rangle>list_rel

goal (1 subgoal):
 1. (u, v) \<in> br (map f) (list_all P)
[PROOF STEP]
unfolding build_rel_def
[PROOF STATE]
proof (prove)
using this:
(u, v) \<in> \<langle>{(c, a). a = f c \<and> P c}\<rangle>list_rel

goal (1 subgoal):
 1. (u, v) \<in> {(c, a). a = map f c \<and> list_all P c}
[PROOF STEP]
by induct auto
[PROOF STATE]
proof (state)
this:
(u, v) \<in> \<langle>br f P\<rangle>list_rel \<Longrightarrow> (u, v) \<in> br (map f) (list_all P)

goal (1 subgoal):
 1. \<And>a b. (a, b) \<in> br (map f) (list_all P) \<Longrightarrow> (a, b) \<in> \<langle>br f P\<rangle>list_rel
[PROOF STEP]
show "(u, v) \<in> \<langle>br f P\<rangle> list_rel" if "(u, v) \<in> br (map f) (list_all P)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u, v) \<in> \<langle>br f P\<rangle>list_rel
[PROOF STEP]
using that
[PROOF STATE]
proof (prove)
using this:
(u, v) \<in> br (map f) (list_all P)

goal (1 subgoal):
 1. (u, v) \<in> \<langle>br f P\<rangle>list_rel
[PROOF STEP]
unfolding build_rel_def
[PROOF STATE]
proof (prove)
using this:
(u, v) \<in> {(c, a). a = map f c \<and> list_all P c}

goal (1 subgoal):
 1. (u, v) \<in> \<langle>{(c, a). a = f c \<and> P c}\<rangle>list_rel
[PROOF STEP]
by (induct u arbitrary: v) (auto)
[PROOF STATE]
proof (state)
this:
(u, v) \<in> br (map f) (list_all P) \<Longrightarrow> (u, v) \<in> \<langle>br f P\<rangle>list_rel

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma convergent_real_imp_convergent_ereal:
  assumes "convergent a"
  shows "convergent (\<lambda>n. ereal (a n))" and "lim (\<lambda>n. ereal (a n)) = ereal (lim a)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. convergent (\<lambda>n. ereal (a n)) &&& lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. convergent (\<lambda>n. ereal (a n))
 2. lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
convergent a
[PROOF STEP]
obtain L where L: "a \<longlonglongrightarrow> L"
[PROOF STATE]
proof (prove)
using this:
convergent a

goal (1 subgoal):
 1. (\<And>L. a \<longlonglongrightarrow> L \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding convergent_def
[PROOF STATE]
proof (prove)
using this:
\<exists>L. a \<longlonglongrightarrow> L

goal (1 subgoal):
 1. (\<And>L. a \<longlonglongrightarrow> L \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
a \<longlonglongrightarrow> L

goal (2 subgoals):
 1. convergent (\<lambda>n. ereal (a n))
 2. lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
hence lim: "(\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L"
[PROOF STATE]
proof (prove)
using this:
a \<longlonglongrightarrow> L

goal (1 subgoal):
 1. (\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L
[PROOF STEP]
using lim_ereal
[PROOF STATE]
proof (prove)
using this:
a \<longlonglongrightarrow> L
((\<lambda>n. ereal (?f n)) \<longlongrightarrow> ereal ?x) ?net = (?f \<longlongrightarrow> ?x) ?net

goal (1 subgoal):
 1. (\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L

goal (2 subgoals):
 1. convergent (\<lambda>n. ereal (a n))
 2. lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
thus "convergent (\<lambda>n. ereal (a n))"
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L

goal (1 subgoal):
 1. convergent (\<lambda>n. ereal (a n))
[PROOF STEP]
unfolding convergent_def
[PROOF STATE]
proof (prove)
using this:
(\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L

goal (1 subgoal):
 1. \<exists>L. (\<lambda>n. ereal (a n)) \<longlonglongrightarrow> L
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
convergent (\<lambda>n. ereal (a n))

goal (1 subgoal):
 1. lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
thus "lim (\<lambda>n. ereal (a n)) = ereal (lim a)"
[PROOF STATE]
proof (prove)
using this:
convergent (\<lambda>n. ereal (a n))

goal (1 subgoal):
 1. lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
using lim L limI
[PROOF STATE]
proof (prove)
using this:
convergent (\<lambda>n. ereal (a n))
(\<lambda>n. ereal (a n)) \<longlonglongrightarrow> ereal L
a \<longlonglongrightarrow> L
?X \<longlonglongrightarrow> ?L \<Longrightarrow> lim ?X = ?L

goal (1 subgoal):
 1. lim (\<lambda>n. ereal (a n)) = ereal (lim a)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
lim (\<lambda>n. ereal (a n)) = ereal (lim a)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma add_scale_img':
  assumes "a \<le> b"
  shows "(\<lambda>x::real. a + (b - a) * x) ` {0 .. 1} = {a .. b}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
proof (cases "a = b")
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. a = b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
 2. a \<noteq> b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
case True
[PROOF STATE]
proof (state)
this:
a = b

goal (2 subgoals):
 1. a = b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
 2. a \<noteq> b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a = b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a = b

goal (1 subgoal):
 1. (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
by force
[PROOF STATE]
proof (state)
this:
(\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}

goal (1 subgoal):
 1. a \<noteq> b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. a \<noteq> b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
case False
[PROOF STATE]
proof (state)
this:
a \<noteq> b

goal (1 subgoal):
 1. a \<noteq> b \<Longrightarrow> (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a \<noteq> b
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a \<noteq> b

goal (1 subgoal):
 1. (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
using add_scale_img assms
[PROOF STATE]
proof (prove)
using this:
a \<noteq> b
?a < ?b \<Longrightarrow> (\<lambda>x. ?a + (?b - ?a) * x) ` {0..1} = {?a..?b}
a \<le> b

goal (1 subgoal):
 1. (\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<lambda>x. a + (b - a) * x) ` {0..1} = {a..b}

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma less_b_least2_impl_zero2: "\<lbrakk>z<y; b_least2 f x y = y\<rbrakk> \<Longrightarrow> f x z = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>z < y; b_least2 f x y = y\<rbrakk> \<Longrightarrow> f x z = 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>z < y; b_least2 f x y = y\<rbrakk> \<Longrightarrow> f x z = 0
[PROOF STEP]
assume  "z < y" and "b_least2 f x y = y"
[PROOF STATE]
proof (state)
this:
z < y
b_least2 f x y = y

goal (1 subgoal):
 1. \<lbrakk>z < y; b_least2 f x y = y\<rbrakk> \<Longrightarrow> f x z = 0
[PROOF STEP]
hence "z < b_least2 f x y"
[PROOF STATE]
proof (prove)
using this:
z < y
b_least2 f x y = y

goal (1 subgoal):
 1. z < b_least2 f x y
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
z < b_least2 f x y

goal (1 subgoal):
 1. \<lbrakk>z < y; b_least2 f x y = y\<rbrakk> \<Longrightarrow> f x z = 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
z < b_least2 f x y

goal (1 subgoal):
 1. f x z = 0
[PROOF STEP]
by (rule less_b_least2_impl_zero)
[PROOF STATE]
proof (state)
this:
f x z = 0

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma Gromov_converging_at_boundary_imp_unbounded:
  assumes "Gromov_converging_at_boundary u"
  shows "(\<lambda>n. dist a (u n)) \<longlonglongrightarrow> \<infinity>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>x. ereal (dist a (u x))) \<longlonglongrightarrow> \<infinity>
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<lambda>x. ereal (dist a (u x))) \<longlonglongrightarrow> \<infinity>
[PROOF STEP]
have "\<exists>N. \<forall>n \<ge> N. dist a (u n) \<ge> M" for M::real
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>N. \<forall>n\<ge>N. M \<le> dist a (u n)
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
Gromov_converging_at_boundary u

goal (1 subgoal):
 1. \<exists>N. \<forall>n\<ge>N. M \<le> dist a (u n)
[PROOF STEP]
unfolding Gromov_converging_at_boundary_def Gromov_product_e_x_x[symmetric]
[PROOF STATE]
proof (prove)
using this:
\<forall>a M. \<exists>N. \<forall>n\<ge>N. \<forall>m\<ge>N. M \<le> Gromov_product_at a (u m) (u n)

goal (1 subgoal):
 1. \<exists>N. \<forall>n\<ge>N. M \<le> Gromov_product_at a (u n) (u n)
[PROOF STEP]
by meson
[PROOF STATE]
proof (state)
this:
\<exists>N. \<forall>n\<ge>N. ?M \<le> dist a (u n)

goal (1 subgoal):
 1. (\<lambda>x. ereal (dist a (u x))) \<longlonglongrightarrow> \<infinity>
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>N. \<forall>n\<ge>N. ?M \<le> dist a (u n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<exists>N. \<forall>n\<ge>N. ?M \<le> dist a (u n)

goal (1 subgoal):
 1. (\<lambda>x. ereal (dist a (u x))) \<longlonglongrightarrow> \<infinity>
[PROOF STEP]
unfolding tendsto_PInfty eventually_sequentially
[PROOF STATE]
proof (prove)
using this:
\<exists>N. \<forall>n\<ge>N. ?M \<le> dist a (u n)

goal (1 subgoal):
 1. \<forall>r. \<exists>N. \<forall>n\<ge>N. ereal r < ereal (dist a (u n))
[PROOF STEP]
by (meson dual_order.strict_trans1 gt_ex less_ereal.simps(1))
[PROOF STATE]
proof (state)
this:
(\<lambda>x. ereal (dist a (u x))) \<longlonglongrightarrow> \<infinity>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma sdrop_siterate[simp]: "sdrop n (siterate f x) = siterate f ((f^^n) x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sdrop n (siterate f x) = siterate f ((f ^^ n) x)
[PROOF STEP]
by (induct n arbitrary: x) (auto simp: funpow_swap1)


[STATEMENT]
lemma incrIndexList_less:
 "incrIndexList ls m nmax \<Longrightarrow> Suc n < |ls| \<Longrightarrow> ls!n \<noteq> ls!Suc n\<Longrightarrow> ls!n < ls!Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>incrIndexList ls m nmax; Suc n < |ls|; ls ! n \<noteq> ls ! Suc n\<rbrakk> \<Longrightarrow> ls ! n < ls ! Suc n
[PROOF STEP]
apply (drule  incrIndexList_less_eq)
[PROOF STATE]
proof (prove)
goal (2 subgoals):
 1. \<lbrakk>Suc n < |ls|; ls ! n \<noteq> ls ! Suc n\<rbrakk> \<Longrightarrow> Suc ?n < |ls|
 2. \<lbrakk>Suc n < |ls|; ls ! n \<noteq> ls ! Suc n; ls ! ?n \<le> ls ! Suc ?n\<rbrakk> \<Longrightarrow> ls ! n < ls ! Suc n
[PROOF STEP]
by auto


[STATEMENT]
lemma connecting_paths_sym: "xs \<in> connecting_paths u v \<longleftrightarrow> rev xs \<in> connecting_paths v u"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (xs \<in> connecting_paths u v) = (rev xs \<in> connecting_paths v u)
[PROOF STEP]
unfolding connecting_paths_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (xs \<in> {xs. connecting_path u v xs}) = (rev xs \<in> {xs. connecting_path v u xs})
[PROOF STEP]
using connecting_path_rev
[PROOF STATE]
proof (prove)
using this:
connecting_path ?u ?v ?xs = connecting_path ?v ?u (rev ?xs)

goal (1 subgoal):
 1. (xs \<in> {xs. connecting_path u v xs}) = (rev xs \<in> {xs. connecting_path v u xs})
[PROOF STEP]
by simp


[STATEMENT]
lemma path_split2: "path v v' (pth1@(e#pth2)) \<longleftrightarrow> path v (edge_begin e) pth1 \<and> path (edge_begin e) v' (e#pth2)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. path v v' (pth1 @ e # pth2) = (path v (edge_begin e) pth1 \<and> path (edge_begin e) v' (e # pth2))
[PROOF STEP]
by (induction pth1 arbitrary: v) (auto simp add: path_cons_simp edge_begin_tup intro: path_empty)


[STATEMENT]
lemma rep_number_g0_exists:
  assumes "B rep x > 0"
  obtains b where "b \<in># B" and "x \<in> b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>b. \<lbrakk>b \<in># B; x \<in> b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<And>b. \<lbrakk>b \<in># B; x \<in> b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
have "size {#b \<in># B . x \<in> b#} > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < size (filter_mset ((\<in>) x) B)
[PROOF STEP]
using assms point_replication_number_def
[PROOF STATE]
proof (prove)
using this:
0 < B rep x
?B rep ?x \<equiv> size (filter_mset ((\<in>) ?x) ?B)

goal (1 subgoal):
 1. 0 < size (filter_mset ((\<in>) x) B)
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
0 < size (filter_mset ((\<in>) x) B)

goal (1 subgoal):
 1. (\<And>b. \<lbrakk>b \<in># B; x \<in> b\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
0 < size (filter_mset ((\<in>) x) B)

goal (1 subgoal):
 1. thesis
[PROOF STEP]
by (metis filter_mset_empty_conv nonempty_has_size that)
[PROOF STATE]
proof (state)
this:
thesis

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma affine_dependent_translation:
  assumes "affine_dependent S"
  shows "affine_dependent ((\<lambda>x. a + x) ` S)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
obtain x where x: "x \<in> S \<and> x \<in> affine hull (S - {x})"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>x. x \<in> S \<and> x \<in> affine hull (S - {x}) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms affine_dependent_def
[PROOF STATE]
proof (prove)
using this:
affine_dependent S
affine_dependent ?s = (\<exists>x\<in>?s. x \<in> affine hull (?s - {x}))

goal (1 subgoal):
 1. (\<And>x. x \<in> S \<and> x \<in> affine hull (S - {x}) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
x \<in> S \<and> x \<in> affine hull (S - {x})

goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
have "(+) a ` (S - {x}) = (+) a ` S - {a + x}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (+) a ` (S - {x}) = (+) a ` S - {a + x}
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(+) a ` (S - {x}) = (+) a ` S - {a + x}

goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(+) a ` (S - {x}) = (+) a ` S - {a + x}
[PROOF STEP]
have "a + x \<in> affine hull ((\<lambda>x. a + x) ` S - {a + x})"
[PROOF STATE]
proof (prove)
using this:
(+) a ` (S - {x}) = (+) a ` S - {a + x}

goal (1 subgoal):
 1. a + x \<in> affine hull ((+) a ` S - {a + x})
[PROOF STEP]
using affine_hull_translation[of a "S - {x}"] x
[PROOF STATE]
proof (prove)
using this:
(+) a ` (S - {x}) = (+) a ` S - {a + x}
affine hull (+) a ` (S - {x}) = (+) a ` (affine hull (S - {x}))
x \<in> S \<and> x \<in> affine hull (S - {x})

goal (1 subgoal):
 1. a + x \<in> affine hull ((+) a ` S - {a + x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a + x \<in> affine hull ((+) a ` S - {a + x})

goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
a + x \<in> affine hull ((+) a ` S - {a + x})

goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
have "a + x \<in> (\<lambda>x. a + x) ` S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a + x \<in> (+) a ` S
[PROOF STEP]
using x
[PROOF STATE]
proof (prove)
using this:
x \<in> S \<and> x \<in> affine hull (S - {x})

goal (1 subgoal):
 1. a + x \<in> (+) a ` S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
a + x \<in> (+) a ` S

goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
a + x \<in> affine hull ((+) a ` S - {a + x})
a + x \<in> (+) a ` S
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
a + x \<in> affine hull ((+) a ` S - {a + x})
a + x \<in> (+) a ` S

goal (1 subgoal):
 1. affine_dependent ((+) a ` S)
[PROOF STEP]
unfolding affine_dependent_def
[PROOF STATE]
proof (prove)
using this:
a + x \<in> affine hull ((+) a ` S - {a + x})
a + x \<in> (+) a ` S

goal (1 subgoal):
 1. \<exists>x\<in>(+) a ` S. x \<in> affine hull ((+) a ` S - {x})
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
affine_dependent ((+) a ` S)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma star_inductl: "z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
assume hyp: "z + x \<cdot> y \<le> y"
[PROOF STATE]
proof (state)
this:
z + x \<cdot> y \<le> y

goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
hence "x \<le> y \<leftarrow> y"
[PROOF STATE]
proof (prove)
using this:
z + x \<cdot> y \<le> y

goal (1 subgoal):
 1. x \<le> y \<leftarrow> y
[PROOF STEP]
by (simp add: local.resl_galois)
[PROOF STATE]
proof (state)
this:
x \<le> y \<leftarrow> y

goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
hence "x\<^sup>\<star> \<le> (y \<leftarrow> y)\<^sup>\<star>"
[PROOF STATE]
proof (prove)
using this:
x \<le> y \<leftarrow> y

goal (1 subgoal):
 1. x\<^sup>\<star> \<le> (y \<leftarrow> y)\<^sup>\<star>
[PROOF STEP]
by (fact star_mon)
[PROOF STATE]
proof (state)
this:
x\<^sup>\<star> \<le> (y \<leftarrow> y)\<^sup>\<star>

goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
hence "x\<^sup>\<star> \<le> y \<leftarrow> y"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>\<star> \<le> (y \<leftarrow> y)\<^sup>\<star>

goal (1 subgoal):
 1. x\<^sup>\<star> \<le> y \<leftarrow> y
[PROOF STEP]
using local.order_trans residual_l_pure_induction
[PROOF STATE]
proof (prove)
using this:
x\<^sup>\<star> \<le> (y \<leftarrow> y)\<^sup>\<star>
\<lbrakk>?x \<le> ?y; ?y \<le> ?z\<rbrakk> \<Longrightarrow> ?x \<le> ?z
(?x \<leftarrow> ?x)\<^sup>\<star> \<le> ?x \<leftarrow> ?x

goal (1 subgoal):
 1. x\<^sup>\<star> \<le> y \<leftarrow> y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
x\<^sup>\<star> \<le> y \<leftarrow> y

goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
hence "x\<^sup>\<star> \<cdot> y \<le> y"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>\<star> \<le> y \<leftarrow> y

goal (1 subgoal):
 1. x\<^sup>\<star> \<cdot> y \<le> y
[PROOF STEP]
by (simp add: local.resl_galois)
[PROOF STATE]
proof (state)
this:
x\<^sup>\<star> \<cdot> y \<le> y

goal (1 subgoal):
 1. z + x \<cdot> y \<le> y \<Longrightarrow> x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
thus "x\<^sup>\<star> \<cdot> z \<le> y"
[PROOF STATE]
proof (prove)
using this:
x\<^sup>\<star> \<cdot> y \<le> y

goal (1 subgoal):
 1. x\<^sup>\<star> \<cdot> z \<le> y
[PROOF STEP]
by (meson hyp local.dual_order.trans local.join.le_supE local.mult_isol)
[PROOF STATE]
proof (state)
this:
x\<^sup>\<star> \<cdot> z \<le> y

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma roundup_help1_new: "\<lbrakk> 0 < l\<rbrakk> \<Longrightarrow> (roundup l 160 - 1) + 1 = (roundup l 160)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < l \<Longrightarrow> roundup l 160 - 1 + 1 = roundup l 160
[PROOF STEP]
apply (drule roundup_positiv [of l])
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < roundup l 160 \<Longrightarrow> roundup l 160 - 1 + 1 = roundup l 160
[PROOF STEP]
apply arith
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma fst_scaleC [simp]: "fst (scaleC r A) = scaleC r (fst A)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (r *\<^sub>C A) = r *\<^sub>C fst A
[PROOF STEP]
unfolding scaleC_prod_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. fst (r *\<^sub>C fst A, r *\<^sub>C snd A) = r *\<^sub>C fst A
[PROOF STEP]
by simp


[STATEMENT]
lemma distinct_of_odd_in_distinct_partitions:
  assumes "p \<in> {p. p partitions n \<and> (\<forall>i. p i \<noteq> 0 \<longrightarrow> odd i)}"
  shows "distinct_of_odd p \<in> {p. p partitions n \<and> (\<forall>i. p i \<le> 1)}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct_of_odd p \<in> {p. p partitions n \<and> (\<forall>i. p i \<le> 1)}
[PROOF STEP]
proof
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)
[PROOF STEP]
have "distinct_of_odd p partitions n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. distinct_of_odd p partitions n
[PROOF STEP]
proof (rule partitionsI)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. distinct_of_odd p i \<noteq> 0 \<Longrightarrow> 1 \<le> i \<and> i \<le> n
 2. (\<Sum>i\<le>n. distinct_of_odd p i * i) = n
[PROOF STEP]
fix i
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<And>i. distinct_of_odd p i \<noteq> 0 \<Longrightarrow> 1 \<le> i \<and> i \<le> n
 2. (\<Sum>i\<le>n. distinct_of_odd p i * i) = n
[PROOF STEP]
assume "distinct_of_odd p i \<noteq> 0"
[PROOF STATE]
proof (state)
this:
distinct_of_odd p i \<noteq> 0

goal (2 subgoals):
 1. \<And>i. distinct_of_odd p i \<noteq> 0 \<Longrightarrow> 1 \<le> i \<and> i \<le> n
 2. (\<Sum>i\<le>n. distinct_of_odd p i * i) = n
[PROOF STEP]
from this assms
[PROOF STATE]
proof (chain)
picking this:
distinct_of_odd p i \<noteq> 0
p \<in> {p. p partitions n \<and> (\<forall>i. p i \<noteq> 0 \<longrightarrow> odd i)}
[PROOF STEP]
show "1 \<le> i \<and> i \<le> n"
[PROOF STATE]
proof (prove)
using this:
distinct_of_odd p i \<noteq> 0
p \<in> {p. p partitions n \<and> (\<forall>i. p i \<noteq> 0 \<longrightarrow> odd i)}

goal (1 subgoal):
 1. 1 \<le> i \<and> i \<le> n
[PROOF STEP]
unfolding partitions_def
[PROOF STATE]
proof (prove)
using this:
distinct_of_odd p i \<noteq> 0
p \<in> {p. ((\<forall>i. p i \<noteq> 0 \<longrightarrow> 1 \<le> i \<and> i \<le> n) \<and> (\<Sum>i\<le>n. p i * i) = n) \<and> (\<forall>i. p i \<noteq> 0 \<longrightarrow> odd i)}

goal (1 subgoal):
 1. 1 \<le> i \<and> i \<le> n
[PROOF STEP]
by (rule_tac distinct_of_odd) (auto simp add: leq_n)
[PROOF STATE]
proof (state)
this:
1 \<le> i \<and> i \<le> n

goal (1 subgoal):
 1. (\<Sum>i\<le>n. distinct_of_odd p i * i) = n
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. (\<Sum>i\<le>n. distinct_of_odd p i * i) = n
[PROOF STEP]
from assms
[PROOF STATE]
proof (chain)
picking this:
p \<in> {p. p partitions n \<and> (\<forall>i. p i \<noteq> 0 \<longrightarrow> odd i)}
[PROOF STEP]
show "(\<Sum>i\<le>n. distinct_of_odd p i * i) = n"
[PROOF STATE]
proof (prove)
using this:
p \<in> {p. p partitions n \<and> (\<forall>i. p i \<noteq> 0 \<longrightarrow> odd i)}

goal (1 subgoal):
 1. (\<Sum>i\<le>n. distinct_of_odd p i * i) = n
[PROOF STEP]
by (subst  sum_distinct_of_odd) (auto simp add: distinct_distinct_of_odd leq_n elim: partitionsE)
[PROOF STATE]
proof (state)
this:
(\<Sum>i\<le>n. distinct_of_odd p i * i) = n

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
distinct_of_odd p partitions n

goal (1 subgoal):
 1. distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
distinct_of_odd p partitions n

goal (1 subgoal):
 1. distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)
[PROOF STEP]
have "\<forall>i. distinct_of_odd p i \<le> 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>i. distinct_of_odd p i \<le> 1
[PROOF STEP]
by (intro allI distinct_distinct_of_odd)
[PROOF STATE]
proof (state)
this:
\<forall>i. distinct_of_odd p i \<le> 1

goal (1 subgoal):
 1. distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
distinct_of_odd p partitions n
\<forall>i. distinct_of_odd p i \<le> 1
[PROOF STEP]
show "distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)"
[PROOF STATE]
proof (prove)
using this:
distinct_of_odd p partitions n
\<forall>i. distinct_of_odd p i \<le> 1

goal (1 subgoal):
 1. distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
distinct_of_odd p partitions n \<and> (\<forall>i. distinct_of_odd p i \<le> 1)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
theorem lucas:
  assumes n2: "n \<ge> 2" and an1: "[a^(n - 1) = 1] (mod n)"
    and pn: "\<forall>p. prime p \<and> p dvd n - 1 \<longrightarrow> [a^((n - 1) div p) \<noteq> 1] (mod n)"
  shows "prime n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. prime n
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. prime n
[PROOF STEP]
from n2
[PROOF STATE]
proof (chain)
picking this:
2 \<le> n
[PROOF STEP]
have n01: "n \<noteq> 0" "n \<noteq> 1" "n - 1 \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
2 \<le> n

goal (1 subgoal):
 1. n \<noteq> 0 &&& n \<noteq> 1 &&& n - 1 \<noteq> 0
[PROOF STEP]
by arith+
[PROOF STATE]
proof (state)
this:
n \<noteq> 0
n \<noteq> 1
n - 1 \<noteq> 0

goal (1 subgoal):
 1. prime n
[PROOF STEP]
from mod_less_divisor[of n 1] n01
[PROOF STATE]
proof (chain)
picking this:
0 < n \<Longrightarrow> 1 mod n < n
n \<noteq> 0
n \<noteq> 1
n - 1 \<noteq> 0
[PROOF STEP]
have onen: "1 mod n = 1"
[PROOF STATE]
proof (prove)
using this:
0 < n \<Longrightarrow> 1 mod n < n
n \<noteq> 0
n \<noteq> 1
n - 1 \<noteq> 0

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

goal (1 subgoal):
 1. prime n
[PROOF STEP]
from lucas_coprime_lemma[OF n01(3) an1] cong_imp_coprime an1
[PROOF STATE]
proof (chain)
picking this:
coprime a n
\<lbrakk>[?a = ?b] (mod ?m); coprime ?a ?m\<rbrakk> \<Longrightarrow> coprime ?b ?m
[a ^ (n - 1) = 1] (mod n)
[PROOF STEP]
have an: "coprime a n" "coprime (a ^ (n - 1)) n"
[PROOF STATE]
proof (prove)
using this:
coprime a n
\<lbrakk>[?a = ?b] (mod ?m); coprime ?a ?m\<rbrakk> \<Longrightarrow> coprime ?b ?m
[a ^ (n - 1) = 1] (mod n)

goal (1 subgoal):
 1. coprime a n &&& coprime (a ^ (n - 1)) n
[PROOF STEP]
using \<open>n \<ge> 2\<close>
[PROOF STATE]
proof (prove)
using this:
coprime a n
\<lbrakk>[?a = ?b] (mod ?m); coprime ?a ?m\<rbrakk> \<Longrightarrow> coprime ?b ?m
[a ^ (n - 1) = 1] (mod n)
2 \<le> n

goal (1 subgoal):
 1. coprime a n &&& coprime (a ^ (n - 1)) n
[PROOF STEP]
by simp_all
[PROOF STATE]
proof (state)
this:
coprime a n
coprime (a ^ (n - 1)) n

goal (1 subgoal):
 1. prime n
[PROOF STEP]
have False if H0: "\<exists>m. 0 < m \<and> m < n - 1 \<and> [a ^ m = 1] (mod n)" (is "\<exists>m. ?P m")
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
from H0[unfolded nat_exists_least_iff[of ?P]]
[PROOF STATE]
proof (chain)
picking this:
\<exists>m. (0 < m \<and> m < n - 1 \<and> [a ^ m = 1] (mod n)) \<and> (\<forall>ma<m. \<not> (0 < ma \<and> ma < n - 1 \<and> [a ^ ma = 1] (mod n)))
[PROOF STEP]
obtain m where
      m: "0 < m" "m < n - 1" "[a ^ m = 1] (mod n)" "\<forall>k <m. \<not>?P k"
[PROOF STATE]
proof (prove)
using this:
\<exists>m. (0 < m \<and> m < n - 1 \<and> [a ^ m = 1] (mod n)) \<and> (\<forall>ma<m. \<not> (0 < ma \<and> ma < n - 1 \<and> [a ^ ma = 1] (mod n)))

goal (1 subgoal):
 1. (\<And>m. \<lbrakk>0 < m; m < n - 1; [a ^ m = 1] (mod n); \<forall>k<m. \<not> (0 < k \<and> k < n - 1 \<and> [a ^ k = 1] (mod n))\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
0 < m
m < n - 1
[a ^ m = 1] (mod n)
\<forall>k<m. \<not> (0 < k \<and> k < n - 1 \<and> [a ^ k = 1] (mod n))

goal (1 subgoal):
 1. False
[PROOF STEP]
have False if nm1: "(n - 1) mod m > 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. False
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
from mod_less_divisor[OF m(1)]
[PROOF STATE]
proof (chain)
picking this:
?m mod m < m
[PROOF STEP]
have th0:"(n - 1) mod m < m"
[PROOF STATE]
proof (prove)
using this:
?m mod m < m

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

goal (1 subgoal):
 1. False
[PROOF STEP]
let ?y = "a^ ((n - 1) div m * m)"
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. False
[PROOF STEP]
note mdeq = div_mult_mod_eq[of "(n - 1)" m]
[PROOF STATE]
proof (state)
this:
(n - 1) div m * m + (n - 1) mod m = n - 1

goal (1 subgoal):
 1. False
[PROOF STEP]
have yn: "coprime ?y n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. coprime (a ^ ((n - 1) div m * m)) n
[PROOF STEP]
using an(1)
[PROOF STATE]
proof (prove)
using this:
coprime a n

goal (1 subgoal):
 1. coprime (a ^ ((n - 1) div m * m)) n
[PROOF STEP]
by (cases "(n - Suc 0) div m * m = 0") auto
[PROOF STATE]
proof (state)
this:
coprime (a ^ ((n - 1) div m * m)) n

goal (1 subgoal):
 1. False
[PROOF STEP]
have "?y mod n = (a^m)^((n - 1) div m) mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ ((n - 1) div m * m) mod n = (a ^ m) ^ ((n - 1) div m) mod n
[PROOF STEP]
by (simp add: algebra_simps power_mult)
[PROOF STATE]
proof (state)
this:
a ^ ((n - 1) div m * m) mod n = (a ^ m) ^ ((n - 1) div m) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a ^ ((n - 1) div m * m) mod n = (a ^ m) ^ ((n - 1) div m) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
have "\<dots> = (a^m mod n)^((n - 1) div m) mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a ^ m) ^ ((n - 1) div m) mod n = (a ^ m mod n) ^ ((n - 1) div m) mod n
[PROOF STEP]
using power_mod[of "a^m" n "(n - 1) div m"]
[PROOF STATE]
proof (prove)
using this:
(a ^ m mod n) ^ ((n - 1) div m) mod n = (a ^ m) ^ ((n - 1) div m) mod n

goal (1 subgoal):
 1. (a ^ m) ^ ((n - 1) div m) mod n = (a ^ m mod n) ^ ((n - 1) div m) mod n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
(a ^ m) ^ ((n - 1) div m) mod n = (a ^ m mod n) ^ ((n - 1) div m) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a ^ m) ^ ((n - 1) div m) mod n = (a ^ m mod n) ^ ((n - 1) div m) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
have "\<dots> = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a ^ m mod n) ^ ((n - 1) div m) mod n = 1
[PROOF STEP]
using m(3)[unfolded cong_def onen] onen
[PROOF STATE]
proof (prove)
using this:
a ^ m mod n = 1
1 mod n = 1

goal (1 subgoal):
 1. (a ^ m mod n) ^ ((n - 1) div m) mod n = 1
[PROOF STEP]
by (metis power_one)
[PROOF STATE]
proof (state)
this:
(a ^ m mod n) ^ ((n - 1) div m) mod n = 1

goal (1 subgoal):
 1. False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a ^ ((n - 1) div m * m) mod n = 1
[PROOF STEP]
have *: "?y mod n = 1"
[PROOF STATE]
proof (prove)
using this:
a ^ ((n - 1) div m * m) mod n = 1

goal (1 subgoal):
 1. a ^ ((n - 1) div m * m) mod n = 1
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
a ^ ((n - 1) div m * m) mod n = 1

goal (1 subgoal):
 1. False
[PROOF STEP]
have **: "[?y * a ^ ((n - 1) mod m) = ?y* 1] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [a ^ ((n - 1) div m * m) * a ^ ((n - 1) mod m) = a ^ ((n - 1) div m * m) * 1] (mod n)
[PROOF STEP]
using an1[unfolded cong_def onen] onen
          div_mult_mod_eq[of "(n - 1)" m, symmetric]
[PROOF STATE]
proof (prove)
using this:
a ^ (n - 1) mod n = 1
1 mod n = 1
n - 1 = (n - 1) div m * m + (n - 1) mod m

goal (1 subgoal):
 1. [a ^ ((n - 1) div m * m) * a ^ ((n - 1) mod m) = a ^ ((n - 1) div m * m) * 1] (mod n)
[PROOF STEP]
by (simp add:power_add[symmetric] cong_def * del: One_nat_def)
[PROOF STATE]
proof (state)
this:
[a ^ ((n - 1) div m * m) * a ^ ((n - 1) mod m) = a ^ ((n - 1) div m * m) * 1] (mod n)

goal (1 subgoal):
 1. False
[PROOF STEP]
have "[a ^ ((n - 1) mod m) = 1] (mod n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. [a ^ ((n - 1) mod m) = 1] (mod n)
[PROOF STEP]
by (metis cong_mult_rcancel_nat mult.commute ** yn)
[PROOF STATE]
proof (state)
this:
[a ^ ((n - 1) mod m) = 1] (mod n)

goal (1 subgoal):
 1. False
[PROOF STEP]
with m(4)[rule_format, OF th0] nm1
        less_trans[OF mod_less_divisor[OF m(1), of "n - 1"] m(2)]
[PROOF STATE]
proof (chain)
picking this:
\<not> (0 < (n - 1) mod m \<and> (n - 1) mod m < n - 1 \<and> [a ^ ((n - 1) mod m) = 1] (mod n))
0 < (n - 1) mod m
(n - 1) mod m < n - 1
[a ^ ((n - 1) mod m) = 1] (mod n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<not> (0 < (n - 1) mod m \<and> (n - 1) mod m < n - 1 \<and> [a ^ ((n - 1) mod m) = 1] (mod n))
0 < (n - 1) mod m
(n - 1) mod m < n - 1
[a ^ ((n - 1) mod m) = 1] (mod n)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
0 < (n - 1) mod m \<Longrightarrow> False

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < (n - 1) mod m \<Longrightarrow> False
[PROOF STEP]
have "(n - 1) mod m = 0"
[PROOF STATE]
proof (prove)
using this:
0 < (n - 1) mod m \<Longrightarrow> False

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

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
(n - 1) mod m = 0
[PROOF STEP]
have mn: "m dvd n - 1"
[PROOF STATE]
proof (prove)
using this:
(n - 1) mod m = 0

goal (1 subgoal):
 1. m dvd n - 1
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
m dvd n - 1

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
m dvd n - 1
[PROOF STEP]
obtain r where r: "n - 1 = m * r"
[PROOF STATE]
proof (prove)
using this:
m dvd n - 1

goal (1 subgoal):
 1. (\<And>r. n - 1 = m * r \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding dvd_def
[PROOF STATE]
proof (prove)
using this:
\<exists>k. n - 1 = m * k

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

goal (1 subgoal):
 1. False
[PROOF STEP]
from n01 r m(2)
[PROOF STATE]
proof (chain)
picking this:
n \<noteq> 0
n \<noteq> 1
n - 1 \<noteq> 0
n - 1 = m * r
m < n - 1
[PROOF STEP]
have r01: "r \<noteq> 0" "r \<noteq> 1"
[PROOF STATE]
proof (prove)
using this:
n \<noteq> 0
n \<noteq> 1
n - 1 \<noteq> 0
n - 1 = m * r
m < n - 1

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

goal (1 subgoal):
 1. False
[PROOF STEP]
obtain p where p: "prime p" "p dvd r"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>p. \<lbrakk>prime p; p dvd r\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by (metis prime_factor_nat r01(2))
[PROOF STATE]
proof (state)
this:
prime p
p dvd r

goal (1 subgoal):
 1. False
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
prime p
p dvd r
[PROOF STEP]
have th: "prime p \<and> p dvd n - 1"
[PROOF STATE]
proof (prove)
using this:
prime p
p dvd r

goal (1 subgoal):
 1. prime p \<and> p dvd n - 1
[PROOF STEP]
unfolding r
[PROOF STATE]
proof (prove)
using this:
prime p
p dvd r

goal (1 subgoal):
 1. prime p \<and> p dvd m * r
[PROOF STEP]
by (auto intro: dvd_mult)
[PROOF STATE]
proof (state)
this:
prime p \<and> p dvd n - 1

goal (1 subgoal):
 1. False
[PROOF STEP]
from r
[PROOF STATE]
proof (chain)
picking this:
n - 1 = m * r
[PROOF STEP]
have "(a ^ ((n - 1) div p)) mod n = (a^(m*r div p)) mod n"
[PROOF STATE]
proof (prove)
using this:
n - 1 = m * r

goal (1 subgoal):
 1. a ^ ((n - 1) div p) mod n = a ^ (m * r div p) mod n
[PROOF STEP]
by (simp add: power_mult)
[PROOF STATE]
proof (state)
this:
a ^ ((n - 1) div p) mod n = a ^ (m * r div p) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a ^ ((n - 1) div p) mod n = a ^ (m * r div p) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
have "\<dots> = (a^(m*(r div p))) mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ (m * r div p) mod n = a ^ (m * (r div p)) mod n
[PROOF STEP]
using div_mult1_eq[of m r p] p(2)[unfolded dvd_eq_mod_eq_0]
[PROOF STATE]
proof (prove)
using this:
m * r div p = m * (r div p) + m * (r mod p) div p
r mod p = 0

goal (1 subgoal):
 1. a ^ (m * r div p) mod n = a ^ (m * (r div p)) mod n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a ^ (m * r div p) mod n = a ^ (m * (r div p)) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a ^ (m * r div p) mod n = a ^ (m * (r div p)) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
have "\<dots> = ((a^m)^(r div p)) mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. a ^ (m * (r div p)) mod n = (a ^ m) ^ (r div p) mod n
[PROOF STEP]
by (simp add: power_mult)
[PROOF STATE]
proof (state)
this:
a ^ (m * (r div p)) mod n = (a ^ m) ^ (r div p) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
a ^ (m * (r div p)) mod n = (a ^ m) ^ (r div p) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
have "\<dots> = ((a^m mod n)^(r div p)) mod n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (a ^ m) ^ (r div p) mod n = (a ^ m mod n) ^ (r div p) mod n
[PROOF STEP]
using power_mod
[PROOF STATE]
proof (prove)
using this:
(?a mod ?b) ^ ?n mod ?b = ?a ^ ?n mod ?b

goal (1 subgoal):
 1. (a ^ m) ^ (r div p) mod n = (a ^ m mod n) ^ (r div p) mod n
[PROOF STEP]
..
[PROOF STATE]
proof (state)
this:
(a ^ m) ^ (r div p) mod n = (a ^ m mod n) ^ (r div p) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
(a ^ m) ^ (r div p) mod n = (a ^ m mod n) ^ (r div p) mod n

goal (1 subgoal):
 1. False
[PROOF STEP]
from m(3) onen
[PROOF STATE]
proof (chain)
picking this:
[a ^ m = 1] (mod n)
1 mod n = 1
[PROOF STEP]
have "\<dots> = 1"
[PROOF STATE]
proof (prove)
using this:
[a ^ m = 1] (mod n)
1 mod n = 1

goal (1 subgoal):
 1. (a ^ m mod n) ^ (r div p) mod n = 1
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
(a ^ m mod n) ^ (r div p) mod n = 1

goal (1 subgoal):
 1. False
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
a ^ ((n - 1) div p) mod n = 1
[PROOF STEP]
have "[(a ^ ((n - 1) div p))= 1] (mod n)"
[PROOF STATE]
proof (prove)
using this:
a ^ ((n - 1) div p) mod n = 1

goal (1 subgoal):
 1. [a ^ ((n - 1) div p) = 1] (mod n)
[PROOF STEP]
using onen
[PROOF STATE]
proof (prove)
using this:
a ^ ((n - 1) div p) mod n = 1
1 mod n = 1

goal (1 subgoal):
 1. [a ^ ((n - 1) div p) = 1] (mod n)
[PROOF STEP]
by (simp add: cong_def)
[PROOF STATE]
proof (state)
this:
[a ^ ((n - 1) div p) = 1] (mod n)

goal (1 subgoal):
 1. False
[PROOF STEP]
with pn th
[PROOF STATE]
proof (chain)
picking this:
\<forall>p. prime p \<and> p dvd n - 1 \<longrightarrow> [a ^ ((n - 1) div p) \<noteq> 1] (mod n)
prime p \<and> p dvd n - 1
[a ^ ((n - 1) div p) = 1] (mod n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>p. prime p \<and> p dvd n - 1 \<longrightarrow> [a ^ ((n - 1) div p) \<noteq> 1] (mod n)
prime p \<and> p dvd n - 1
[a ^ ((n - 1) div p) = 1] (mod n)

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

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>m>0. m < n - 1 \<and> [a ^ m = 1] (mod n) \<Longrightarrow> False

goal (1 subgoal):
 1. prime n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<exists>m>0. m < n - 1 \<and> [a ^ m = 1] (mod n) \<Longrightarrow> False
[PROOF STEP]
have "\<forall>m. 0 < m \<and> m < n - 1 \<longrightarrow> \<not> [a ^ m = 1] (mod n)"
[PROOF STATE]
proof (prove)
using this:
\<exists>m>0. m < n - 1 \<and> [a ^ m = 1] (mod n) \<Longrightarrow> False

goal (1 subgoal):
 1. \<forall>m. 0 < m \<and> m < n - 1 \<longrightarrow> [a ^ m \<noteq> 1] (mod n)
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>m. 0 < m \<and> m < n - 1 \<longrightarrow> [a ^ m \<noteq> 1] (mod n)

goal (1 subgoal):
 1. prime n
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>m. 0 < m \<and> m < n - 1 \<longrightarrow> [a ^ m \<noteq> 1] (mod n)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<forall>m. 0 < m \<and> m < n - 1 \<longrightarrow> [a ^ m \<noteq> 1] (mod n)

goal (1 subgoal):
 1. prime n
[PROOF STEP]
by (rule lucas_weak[OF n2 an1])
[PROOF STATE]
proof (state)
this:
prime n

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma det_state_cover_card[simp] :
  assumes "is_det_state_cover M V"
  and     "finite (nodes M)"
shows   "card (d_reachable M (initial M)) = card V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
obtain f where f_def : "is_det_state_cover_ass M f \<and> V = image f (d_reachable M (initial M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>f. is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
is_det_state_cover M V
finite (nodes M)

goal (1 subgoal):
 1. (\<And>f. is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
unfolding is_det_state_cover.simps
[PROOF STATE]
proof (prove)
using this:
\<exists>f. is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M)
finite (nodes M)

goal (1 subgoal):
 1. (\<And>f. is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M)

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M)
[PROOF STEP]
have card_f : "card V = card (image f (d_reachable M (initial M)))"
[PROOF STATE]
proof (prove)
using this:
is_det_state_cover_ass M f \<and> V = f ` d_reachable M (initial M)

goal (1 subgoal):
 1. card V = card (f ` d_reachable M (initial M))
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
card V = card (f ` d_reachable M (initial M))

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
have "d_reachable M (initial M) \<subseteq> nodes M"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. d_reachable M (initial M) \<subseteq> nodes M
[PROOF STEP]
unfolding d_reachable.simps d_reaches.simps
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. {q. \<exists>xs tr ys. d_reached_by M (initial M) xs q tr ys} \<subseteq> nodes M
[PROOF STEP]
using d_reachable_reachable
[PROOF STATE]
proof (prove)
using this:
d_reachable ?M ?p \<subseteq> reachable ?M ?p

goal (1 subgoal):
 1. {q. \<exists>xs tr ys. d_reached_by M (initial M) xs q tr ys} \<subseteq> nodes M
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
d_reachable M (initial M) \<subseteq> nodes M

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
d_reachable M (initial M) \<subseteq> nodes M
[PROOF STEP]
have dr_finite : "finite (d_reachable M (initial M))"
[PROOF STATE]
proof (prove)
using this:
d_reachable M (initial M) \<subseteq> nodes M

goal (1 subgoal):
 1. finite (d_reachable M (initial M))
[PROOF STEP]
using assms infinite_super
[PROOF STATE]
proof (prove)
using this:
d_reachable M (initial M) \<subseteq> nodes M
is_det_state_cover M V
finite (nodes M)
\<lbrakk>?S \<subseteq> ?T; infinite ?S\<rbrakk> \<Longrightarrow> infinite ?T

goal (1 subgoal):
 1. finite (d_reachable M (initial M))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
finite (d_reachable M (initial M))

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
finite (d_reachable M (initial M))
[PROOF STEP]
have card_le : "card (image f (d_reachable M (initial M))) \<le> card (d_reachable M (initial M))"
[PROOF STATE]
proof (prove)
using this:
finite (d_reachable M (initial M))

goal (1 subgoal):
 1. card (f ` d_reachable M (initial M)) \<le> card (d_reachable M (initial M))
[PROOF STEP]
using card_image_le
[PROOF STATE]
proof (prove)
using this:
finite (d_reachable M (initial M))
finite ?A \<Longrightarrow> card (?f ` ?A) \<le> card ?A

goal (1 subgoal):
 1. card (f ` d_reachable M (initial M)) \<le> card (d_reachable M (initial M))
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
card (f ` d_reachable M (initial M)) \<le> card (d_reachable M (initial M))

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
have "card (image f (d_reachable M (initial M))) = card (d_reachable M (initial M))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. card (f ` d_reachable M (initial M)) = card (d_reachable M (initial M))
[PROOF STEP]
by (meson card_image det_state_cover_ass_diff f_def inj_onI)
[PROOF STATE]
proof (state)
this:
card (f ` d_reachable M (initial M)) = card (d_reachable M (initial M))

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
card (f ` d_reachable M (initial M)) = card (d_reachable M (initial M))
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
card (f ` d_reachable M (initial M)) = card (d_reachable M (initial M))

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
using card_f
[PROOF STATE]
proof (prove)
using this:
card (f ` d_reachable M (initial M)) = card (d_reachable M (initial M))
card V = card (f ` d_reachable M (initial M))

goal (1 subgoal):
 1. card (d_reachable M (initial M)) = card V
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
card (d_reachable M (initial M)) = card V

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma esssup_AE_mono: "f \<in> borel_measurable M \<Longrightarrow> AE x in M. f x \<le> g x \<Longrightarrow> esssup M f \<le> esssup M g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>f \<in> borel_measurable M; AE x in M. f x \<le> g x\<rbrakk> \<Longrightarrow> esssup M f \<le> esssup M g
[PROOF STEP]
by (auto simp: esssup_def Limsup_mono)


[STATEMENT]
lemma DERIV_def: "DERIV f x :> D \<longleftrightarrow> (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0\<rightarrow> D"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (f has_field_derivative D) (at x) = (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0::'a\<rightarrow> D
[PROOF STEP]
unfolding field_has_derivative_at has_field_derivative_def has_field_derivative_iff
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0::'a\<rightarrow> D = (\<lambda>h. (f (x + h) - f x) / h) \<midarrow>0::'a\<rightarrow> D
[PROOF STEP]
..


[STATEMENT]
lemma le_ordinal_of_nat:
"(x \<le> ordinal_of_nat n) = (\<exists>m. x = ordinal_of_nat m \<and> m \<le> n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (x \<le> ordinal_of_nat n) = (\<exists>m. x = ordinal_of_nat m \<and> m \<le> n)
[PROOF STEP]
by (auto simp add: order_le_less less_ordinal_of_nat)


[STATEMENT]
lemma gcd_int_of_integer [code]:
  "gcd (int_of_integer x) (int_of_integer y) = int_of_integer (gcd x y)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. gcd (int_of_integer x) (int_of_integer y) = int_of_integer (gcd x y)
[PROOF STEP]
by transfer rule


[STATEMENT]
lemma csol_unique:
  assumes t1: "t1 \<in> existence_ivl t0 x0"
  assumes t2: "t2 \<in> existence_ivl t0 x0"
  assumes t: "t \<in> {t0 -- t1}" "t \<in> {t0 -- t2}"
  shows "csol t0 x0 t1 t = csol t0 x0 t2 t"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. csol t0 x0 t1 t = csol t0 x0 t2 t
[PROOF STEP]
using csols_unique[OF csol_mem_csols[OF t1] csol_mem_csols[OF t2]] t
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<in>{t0--t1} \<inter> {t0--t2}. csol t0 x0 t1 t = csol t0 x0 t2 t
t \<in> {t0--t1}
t \<in> {t0--t2}

goal (1 subgoal):
 1. csol t0 x0 t1 t = csol t0 x0 t2 t
[PROOF STEP]
by simp


[STATEMENT]
lemma step_n_pop_size_small [simp]: "\<lbrakk>
  invar (States dir big small);
  0 < size small;
  Small.pop small = (x, smallP);
  (step ^^ n) (States dir big smallP) = States dir' big' small'
\<rbrakk> \<Longrightarrow> Suc (size small') = size small"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>invar (States dir big small); 0 < size small; Small.pop small = (x, smallP); (step ^^ n) (States dir big smallP) = States dir' big' small'\<rbrakk> \<Longrightarrow> Suc (size small') = size small
[PROOF STEP]
using invar_pop_small size_pop step_n_size_small
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>invar (States ?dir ?big ?small); 0 < size ?small; Small.pop ?small = (?x, ?small')\<rbrakk> \<Longrightarrow> invar (States ?dir ?big ?small')
\<lbrakk>invar ?small; 0 < size ?small; Small.pop ?small = (?x, ?small')\<rbrakk> \<Longrightarrow> Suc (size ?small') = size ?small
\<lbrakk>invar (States ?dir ?big ?small); (step ^^ ?n) (States ?dir ?big ?small) = States ?dir' ?big' ?small'\<rbrakk> \<Longrightarrow> size ?small' = size ?small

goal (1 subgoal):
 1. \<lbrakk>invar (States dir big small); 0 < size small; Small.pop small = (x, smallP); (step ^^ n) (States dir big smallP) = States dir' big' small'\<rbrakk> \<Longrightarrow> Suc (size small') = size small
[PROOF STEP]
by (metis (no_types, opaque_lifting) invar_states.simps)


[STATEMENT]
lemma sum_sum_eq_sum_Un:
  fixes A :: "nat \<Rightarrow> nat set"
  assumes "\<forall>x \<in> {1..m}. \<forall>y \<in> {1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}"
      and "\<forall>x \<in> {1..m}. finite (A x)"
  shows "(\<Sum>x \<in> {1..m}. (\<Sum>y \<in> A x. t y)) = (\<Sum>x \<in> (\<Union>y \<in> {1..m}. A y). t x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m}))
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}
\<forall>x\<in>{1..m}. finite (A x)

goal (1 subgoal):
 1. (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m}))
[PROOF STEP]
proof (induction m)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
case (Suc m)
[PROOF STATE]
proof (state)
this:
\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m}))
\<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}
\<forall>x\<in>{1..Suc m}. finite (A x)

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
have FINITE: "finite (\<Union>x \<in> {1..m}. A x)" "finite (A (Suc m))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. finite (\<Union> (A ` {1..m})) &&& finite (A (Suc m))
[PROOF STEP]
using Suc.prems(2)
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{1..Suc m}. finite (A x)

goal (1 subgoal):
 1. finite (\<Union> (A ` {1..m})) &&& finite (A (Suc m))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
finite (\<Union> (A ` {1..m}))
finite (A (Suc m))

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
have "\<forall>x \<in> {1..m}. A x \<inter> A (Suc m) = {}"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x\<in>{1..m}. A x \<inter> A (Suc m) = {}
[PROOF STEP]
using Suc.prems(1)
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}

goal (1 subgoal):
 1. \<forall>x\<in>{1..m}. A x \<inter> A (Suc m) = {}
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>{1..m}. A x \<inter> A (Suc m) = {}

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>{1..m}. A x \<inter> A (Suc m) = {}
[PROOF STEP]
have DISJNT: "(\<Union>x \<in> {1..m}. A x) \<inter> (A (Suc m)) = {}"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{1..m}. A x \<inter> A (Suc m) = {}

goal (1 subgoal):
 1. \<Union> (A ` {1..m}) \<inter> A (Suc m) = {}
[PROOF STEP]
using Union_disjoint
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>{1..m}. A x \<inter> A (Suc m) = {}
(\<Union> ?C \<inter> ?A = {}) = (\<forall>B\<in>?C. B \<inter> ?A = {})

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

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
have "(\<Sum>x \<in> (\<Union>y \<in> {1..m}. A y). t x) + (\<Sum>x \<in> A (Suc m). t x)
      = (\<Sum>x \<in> ((\<Union>y \<in> {1..m}. A y) \<union> A (Suc m)). t x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..m}) \<union> A (Suc m))
[PROOF STEP]
using sum.union_disjoint[OF FINITE DISJNT, symmetric]
[PROOF STATE]
proof (prove)
using this:
sum ?g (\<Union> (A ` {1..m})) + sum ?g (A (Suc m)) = sum ?g (\<Union> (A ` {1..m}) \<union> A (Suc m))

goal (1 subgoal):
 1. sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..m}) \<union> A (Suc m))
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..m}) \<union> A (Suc m))

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..m}) \<union> A (Suc m))

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
have "... = (\<Sum>x \<in> (\<Union>y \<in> {1..Suc m}. A y). t x)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. sum t (\<Union> (A ` {1..m}) \<union> A (Suc m)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
by (metis UN_insert image_Suc_lessThan image_insert inf_sup_aci(5) lessThan_Suc)
[PROOF STATE]
proof (state)
this:
sum t (\<Union> (A ` {1..m}) \<union> A (Suc m)) = sum t (\<Union> (A ` {1..Suc m}))

goal (2 subgoals):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
 2. \<And>m. \<lbrakk>\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m})); \<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..Suc m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..Suc m}))

goal (1 subgoal):
 1. (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
using Suc
[PROOF STATE]
proof (prove)
using this:
sum t (\<Union> (A ` {1..m})) + sum t (A (Suc m)) = sum t (\<Union> (A ` {1..Suc m}))
\<lbrakk>\<forall>x\<in>{1..m}. \<forall>y\<in>{1..m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..m}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..m. sum t (A x)) = sum t (\<Union> (A ` {1..m}))
\<forall>x\<in>{1..Suc m}. \<forall>y\<in>{1..Suc m}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}
\<forall>x\<in>{1..Suc m}. finite (A x)

goal (1 subgoal):
 1. (\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(\<Sum>x = 1..Suc m. sum t (A x)) = sum t (\<Union> (A ` {1..Suc m}))

goal (1 subgoal):
 1. \<lbrakk>\<forall>x\<in>{1..0}. \<forall>y\<in>{1..0}. x \<noteq> y \<longrightarrow> A x \<inter> A y = {}; \<forall>x\<in>{1..0}. finite (A x)\<rbrakk> \<Longrightarrow> (\<Sum>x = 1..0. sum t (A x)) = sum t (\<Union> (A ` {1..0}))
[PROOF STEP]
qed simp


[STATEMENT]
lemma bool19: "(True = False) = False"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (True = False) = False
[PROOF STEP]
by blast


[STATEMENT]
lemma set_integrable_mult_divide_iff [simp]:
  fixes a :: "'a::{real_normed_field, second_countable_topology}"
  assumes "a \<noteq> 0"
  shows "set_integrable M A (\<lambda>t. f t / a) \<longleftrightarrow> set_integrable M A f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set_integrable M A (\<lambda>t. f t / a) = set_integrable M A f
[PROOF STEP]
by (simp add: divide_inverse assms)


[STATEMENT]
lemma deriv_exp [simp]: "deriv exp x = exp x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. deriv exp x = exp x
[PROOF STEP]
using DERIV_exp DERIV_imp_deriv
[PROOF STATE]
proof (prove)
using this:
(exp has_field_derivative exp ?x) (at ?x)
(?f has_field_derivative ?f') (at ?x) \<Longrightarrow> deriv ?f ?x = ?f'

goal (1 subgoal):
 1. deriv exp x = exp x
[PROOF STEP]
by blast


[STATEMENT]
lemma semialg_functions_memI:
  assumes "f \<in> carrier (Fun\<^bsub>n\<^esub> Q\<^sub>p)"
  assumes "is_semialg_function n f"
  shows "f \<in> semialg_functions n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f \<in> semialg_functions n
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier (function_ring (carrier (Q\<^sub>p\<^bsup>n\<^esup>)) Q\<^sub>p)
is_semialg_function n f

goal (1 subgoal):
 1. f \<in> semialg_functions n
[PROOF STEP]
unfolding semialg_functions_def
[PROOF STATE]
proof (prove)
using this:
f \<in> carrier (function_ring (carrier (Q\<^sub>p\<^bsup>n\<^esup>)) Q\<^sub>p)
is_semialg_function n f

goal (1 subgoal):
 1. f \<in> {f \<in> carrier (Q\<^sub>p\<^bsup>n\<^esup>) \<rightarrow> carrier Q\<^sub>p. is_semialg_function n f \<and> f = restrict f (carrier (Q\<^sub>p\<^bsup>n\<^esup>))}
[PROOF STEP]
by (metis (mono_tags, lifting) Qp_funs_car_memI function_ring_car_eqI
      is_semialg_function_closed mem_Collect_eq restrict_Pi_cancel restrict_apply)


[STATEMENT]
lemma (in Semilat) list_update_le_listI [rule_format]:
  "set xs \<subseteq> A \<longrightarrow> set ys \<subseteq> A \<longrightarrow> xs [\<sqsubseteq>\<^bsub>r\<^esub>] ys \<longrightarrow> p < size xs \<longrightarrow>
   x \<sqsubseteq>\<^bsub>r\<^esub> ys!p \<longrightarrow> x\<in>A \<longrightarrow> xs[p := x \<squnion>\<^bsub>f\<^esub> xs!p] [\<sqsubseteq>\<^bsub>r\<^esub>] ys"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set xs \<subseteq> A \<longrightarrow> set ys \<subseteq> A \<longrightarrow> xs [\<sqsubseteq>\<^bsub>r\<^esub>] ys \<longrightarrow> p < length xs \<longrightarrow> x \<sqsubseteq>\<^bsub>r\<^esub> ys ! p \<longrightarrow> x \<in> A \<longrightarrow> xs[p := x \<squnion>\<^bsub>f\<^esub> xs ! p] [\<sqsubseteq>\<^bsub>r\<^esub>] ys
[PROOF STEP]
(*<*)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set xs \<subseteq> A \<longrightarrow> set ys \<subseteq> A \<longrightarrow> xs [\<sqsubseteq>\<^bsub>r\<^esub>] ys \<longrightarrow> p < length xs \<longrightarrow> x \<sqsubseteq>\<^bsub>r\<^esub> ys ! p \<longrightarrow> x \<in> A \<longrightarrow> xs[p := x \<squnion>\<^bsub>f\<^esub> xs ! p] [\<sqsubseteq>\<^bsub>r\<^esub>] ys
[PROOF STEP]
apply(insert semilat)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. semilat (A, r, f) \<Longrightarrow> set xs \<subseteq> A \<longrightarrow> set ys \<subseteq> A \<longrightarrow> xs [\<sqsubseteq>\<^bsub>r\<^esub>] ys \<longrightarrow> p < length xs \<longrightarrow> x \<sqsubseteq>\<^bsub>r\<^esub> ys ! p \<longrightarrow> x \<in> A \<longrightarrow> xs[p := x \<squnion>\<^bsub>f\<^esub> xs ! p] [\<sqsubseteq>\<^bsub>r\<^esub>] ys
[PROOF STEP]
apply (simp only: Listn.le_def lesub_def semilat_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. case (A, r, f) of (A, r, f) \<Rightarrow> order r \<and> Semilat.closed A f \<and> (\<forall>x\<in>A. \<forall>y\<in>A. r x (x \<squnion>\<^bsub>f\<^esub> y)) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. r y (x \<squnion>\<^bsub>f\<^esub> y)) \<and> (\<forall>x\<in>A. \<forall>y\<in>A. \<forall>z\<in>A. r x z \<and> r y z \<longrightarrow> r (x \<squnion>\<^bsub>f\<^esub> y) z) \<Longrightarrow> set xs \<subseteq> A \<longrightarrow> set ys \<subseteq> A \<longrightarrow> list_all2 r xs ys \<longrightarrow> p < length xs \<longrightarrow> r x (ys ! p) \<longrightarrow> x \<in> A \<longrightarrow> list_all2 r (xs[p := x \<squnion>\<^bsub>f\<^esub> xs ! p]) ys
[PROOF STEP]
apply (simp add: list_all2_conv_all_nth nth_list_update)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done


[STATEMENT]
lemma diamond_right_dist_sup:
  "|x>(y \<squnion> z) = |x>y \<squnion> |x>z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. | x > (y \<squnion> z) = | x > y \<squnion> | x > z
[PROOF STEP]
by (simp add: d_dist_sup diamond_def mult_left_dist_sup)


[STATEMENT]
lemma (in CRR_market) delta_pf_updated:
  shows "cls_val_process Mkt (delta_pf N der matur) (Suc n) w =
    geom_proc (Suc n) w * delta_price N der matur n w"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cls_val_process Mkt (delta_pf N der matur) (Suc n) w = geom_proc (Suc n) w * delta_price N der matur n w
[PROOF STEP]
unfolding delta_pf_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. cls_val_process Mkt (qty_single stk (delta_predict N der matur)) (Suc n) w = geom_proc (Suc n) w * delta_price N der matur n w
[PROOF STEP]
using stk_price qty_single_updated[of Mkt]
[PROOF STATE]
proof (prove)
using this:
prices Mkt stk = geom_proc
cls_val_process Mkt (qty_single ?asset ?qty) (Suc ?n) ?w = prices Mkt ?asset (Suc ?n) ?w * ?qty (Suc ?n) ?w

goal (1 subgoal):
 1. cls_val_process Mkt (qty_single stk (delta_predict N der matur)) (Suc n) w = geom_proc (Suc n) w * delta_price N der matur n w
[PROOF STEP]
by simp


[STATEMENT]
lemma polyfun_extremal_lemma:
    fixes c :: "nat \<Rightarrow> 'a::real_normed_div_algebra"
  assumes "0 < e"
    shows "\<exists>M. \<forall>z. M \<le> norm(z) \<longrightarrow> norm (\<Sum>i\<le>n. c(i) * z^i) \<le> e * norm(z) ^ (Suc n)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n
[PROOF STEP]
proof (induct n)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>0. c i * z ^ i) \<le> e * norm z ^ Suc 0
 2. \<And>n. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n \<Longrightarrow> \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
case 0
[PROOF STATE]
proof (state)
this:

goal (2 subgoals):
 1. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>0. c i * z ^ i) \<le> e * norm z ^ Suc 0
 2. \<And>n. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n \<Longrightarrow> \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
with assms
[PROOF STATE]
proof (chain)
picking this:
0 < e
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
using this:
0 < e

goal (1 subgoal):
 1. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>0. c i * z ^ i) \<le> e * norm z ^ Suc 0
[PROOF STEP]
apply (rule_tac x="norm (c 0) / e" in exI)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < e \<Longrightarrow> \<forall>z. norm (c 0) / e \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>0. c i * z ^ i) \<le> e * norm z ^ Suc 0
[PROOF STEP]
apply (auto simp: field_simps)
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>0. c i * z ^ i) \<le> e * norm z ^ Suc 0

goal (1 subgoal):
 1. \<And>n. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n \<Longrightarrow> \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>n. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n \<Longrightarrow> \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
case (Suc n)
[PROOF STATE]
proof (state)
this:
\<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n

goal (1 subgoal):
 1. \<And>n. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n \<Longrightarrow> \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
obtain M where M: "\<And>z. M \<le> norm z \<Longrightarrow> norm (\<Sum>i\<le>n. c i * z^i) \<le> e * norm z ^ Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<And>M. (\<And>z. M \<le> norm z \<Longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using Suc assms
[PROOF STATE]
proof (prove)
using this:
\<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n
0 < e

goal (1 subgoal):
 1. (\<And>M. (\<And>z. M \<le> norm z \<Longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n) \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
M \<le> norm ?z \<Longrightarrow> norm (\<Sum>i\<le>n. c i * ?z ^ i) \<le> e * norm ?z ^ Suc n

goal (1 subgoal):
 1. \<And>n. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n \<Longrightarrow> \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
show ?case
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
proof (rule exI [where x= "max M (1 + norm(c(Suc n)) / e)"], clarsimp simp del: power_Suc)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
fix z::'a
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
assume z1: "M \<le> norm z" and "1 + norm (c (Suc n)) / e \<le> norm z"
[PROOF STATE]
proof (state)
this:
M \<le> norm z
1 + norm (c (Suc n)) / e \<le> norm z

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
M \<le> norm z
1 + norm (c (Suc n)) / e \<le> norm z
[PROOF STEP]
have z2: "e + norm (c (Suc n)) \<le> e * norm z"
[PROOF STATE]
proof (prove)
using this:
M \<le> norm z
1 + norm (c (Suc n)) / e \<le> norm z

goal (1 subgoal):
 1. e + norm (c (Suc n)) \<le> e * norm z
[PROOF STEP]
using assms
[PROOF STATE]
proof (prove)
using this:
M \<le> norm z
1 + norm (c (Suc n)) / e \<le> norm z
0 < e

goal (1 subgoal):
 1. e + norm (c (Suc n)) \<le> e * norm z
[PROOF STEP]
by (simp add: field_simps)
[PROOF STATE]
proof (state)
this:
e + norm (c (Suc n)) \<le> e * norm z

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
have "norm (\<Sum>i\<le>n. c i * z^i) \<le> e * norm z ^ Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n
[PROOF STEP]
using M [OF z1]
[PROOF STATE]
proof (prove)
using this:
norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n

goal (1 subgoal):
 1. norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n
[PROOF STEP]
have "norm (\<Sum>i\<le>n. c i * z^i) + norm (c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)"
[PROOF STATE]
proof (prove)
using this:
norm (\<Sum>i\<le>n. c i * z ^ i) \<le> e * norm z ^ Suc n

goal (1 subgoal):
 1. norm (\<Sum>i\<le>n. c i * z ^ i) + norm (c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm (\<Sum>i\<le>n. c i * z ^ i) + norm (c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
norm (\<Sum>i\<le>n. c i * z ^ i) + norm (c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)
[PROOF STEP]
have "norm ((\<Sum>i\<le>n. c i * z^i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)"
[PROOF STATE]
proof (prove)
using this:
norm (\<Sum>i\<le>n. c i * z ^ i) + norm (c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)

goal (1 subgoal):
 1. norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)
[PROOF STEP]
by (blast intro: norm_triangle_le elim: )
[PROOF STATE]
proof (state)
this:
norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n)

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
have "... \<le> (e + norm (c (Suc n))) * norm z ^ Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n) \<le> (e + norm (c (Suc n))) * norm z ^ Suc n
[PROOF STEP]
by (simp add: norm_power norm_mult algebra_simps)
[PROOF STATE]
proof (state)
this:
e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n) \<le> (e + norm (c (Suc n))) * norm z ^ Suc n

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
also
[PROOF STATE]
proof (state)
this:
e * norm z ^ Suc n + norm (c (Suc n) * z ^ Suc n) \<le> (e + norm (c (Suc n))) * norm z ^ Suc n

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
have "... \<le> (e * norm z) * norm z ^ Suc n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (e + norm (c (Suc n))) * norm z ^ Suc n \<le> e * norm z * norm z ^ Suc n
[PROOF STEP]
by (metis z2 mult.commute mult_left_mono norm_ge_zero norm_power)
[PROOF STATE]
proof (state)
this:
(e + norm (c (Suc n))) * norm z ^ Suc n \<le> e * norm z * norm z ^ Suc n

goal (1 subgoal):
 1. \<And>z. \<lbrakk>M \<le> norm z; 1 + norm (c (Suc n)) / e \<le> norm z\<rbrakk> \<Longrightarrow> norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
finally
[PROOF STATE]
proof (chain)
picking this:
norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z * norm z ^ Suc n
[PROOF STEP]
show "norm ((\<Sum>i\<le>n. c i * z^i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)"
[PROOF STATE]
proof (prove)
using this:
norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z * norm z ^ Suc n

goal (1 subgoal):
 1. norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
norm ((\<Sum>i\<le>n. c i * z ^ i) + c (Suc n) * z ^ Suc n) \<le> e * norm z ^ Suc (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
\<exists>M. \<forall>z. M \<le> norm z \<longrightarrow> norm (\<Sum>i\<le>Suc n. c i * z ^ i) \<le> e * norm z ^ Suc (Suc n)

goal:
No subgoals!
[PROOF STEP]
qed