[STATEMENT]
lemma Z:
  assumes "l<n"
  shows "Zeq l t = (if Req l t > 0 then Suc 0 else 0)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have cond: "2^c * (z l) = (r l + d) && f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ c * z l = r l + d && f
[PROOF STEP]
using m_eq mask_equations_def assms
[PROOF STATE]
proof (prove)
using this:
mask_equations n r z c d e f
mask_equations ?n ?r ?z ?c ?d ?e ?f = ((\<forall>l<?n. ?r l \<preceq> ?d) \<and> (\<forall>l<?n. ?z l \<preceq> ?e) \<and> (\<forall>l<?n. 2 ^ ?c * ?z l = ?r l + ?d && ?f))
l < n

goal (1 subgoal):
 1. 2 ^ c * z l = r l + d && f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
2 ^ c * z l = r l + d && f

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have d_block: "\<forall>t\<le>q. nth_digit d t b = 2^c - 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
[PROOF STEP]
using d_def b_def
      less_imp_diff_less nth_digit_gen_power_series[of "\<lambda>_. 2^c-1" "c"] c_gt0
[PROOF STATE]
proof (prove)
using this:
d = (\<Sum>t = 0..q. (2 ^ c - 1) * b ^ t)
b = 2 ^ Suc c
?j < ?k \<Longrightarrow> ?j - ?n < ?k
\<forall>k. 2 ^ c - 1 < 2 ^ Suc c \<Longrightarrow> nth_digit (\<Sum>k = 0..?q. (2 ^ c - 1) * (2 ^ Suc c) ^ k) ?t (2 ^ Suc c) = (if ?t \<le> ?q then 2 ^ c - 1 else 0)
0 < c

goal (1 subgoal):
 1. \<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have rl_bound: "t\<le>q \<longrightarrow> nth_digit (r l) t b \<exclamdown> c= 0" for t
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. t \<le> q \<longrightarrow> nth_digit (r l) t b \<exclamdown> c = 0
[PROOF STEP]
by (simp add: assms rl_fst_digit_zero)
[PROOF STATE]
proof (state)
this:
?t \<le> q \<longrightarrow> nth_digit (r l) ?t b \<exclamdown> c = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have f_block: "\<forall>t\<le>q. nth_digit f t b = 2^c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>t\<le>q. nth_digit f t b = 2 ^ c
[PROOF STEP]
using f_def b_def less_imp_diff_less nth_digit_gen_power_series[of "\<lambda>_. 2^c" c] c_gt0
[PROOF STATE]
proof (prove)
using this:
f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)
b = 2 ^ Suc c
?j < ?k \<Longrightarrow> ?j - ?n < ?k
\<forall>k. 2 ^ c < 2 ^ Suc c \<Longrightarrow> nth_digit (\<Sum>k = 0..?q. 2 ^ c * (2 ^ Suc c) ^ k) ?t (2 ^ Suc c) = (if ?t \<le> ?q then 2 ^ c else 0)
0 < c

goal (1 subgoal):
 1. \<forall>t\<le>q. nth_digit f t b = 2 ^ c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. nth_digit f t b = 2 ^ c

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<le>q. nth_digit f t b = 2 ^ c
[PROOF STEP]
have "\<forall>t\<le>q.\<forall>k<c. nth_digit f t b \<exclamdown> k = 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. nth_digit f t b = 2 ^ c

goal (1 subgoal):
 1. \<forall>t\<le>q. \<forall>k<c. nth_digit f t b \<exclamdown> k = 0
[PROOF STEP]
by (simp add: aux_powertwo_digits)
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. \<forall>k<c. nth_digit f t b \<exclamdown> k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. \<forall>k<c. nth_digit f t b \<exclamdown> k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have AND_gen: "\<forall>t\<le>q.\<forall>k\<le>c. nth_digit ((r l + d) && f) t b \<exclamdown> k = (nth_digit (r l + d) t b \<exclamdown> k) * nth_digit f t b \<exclamdown> k"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
[PROOF STEP]
using b_def digit_gen_pow2_reduct bitAND_digit_mult digit_gen_pow2_reduct le_imp_less_Suc
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c
?k < ?c \<Longrightarrow> nth_digit ?a ?t (2 ^ ?c) \<exclamdown> ?k = ?a \<exclamdown> (?c * ?t + ?k)
(?a && ?b) \<exclamdown> ?k = ?a \<exclamdown> ?k * ?b \<exclamdown> ?k
?k < ?c \<Longrightarrow> nth_digit ?a ?t (2 ^ ?c) \<exclamdown> ?k = ?a \<exclamdown> (?c * ?t + ?k)
?m \<le> ?n \<Longrightarrow> ?m < Suc ?n

goal (1 subgoal):
 1. \<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
[PROOF STEP]
by presburger
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<le>q. \<forall>k<c. nth_digit f t b \<exclamdown> k = 0
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
[PROOF STEP]
have "\<forall>t\<le>q.\<forall>k<c. nth_digit ((r l + d) && f) t b \<exclamdown> k = 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. \<forall>k<c. nth_digit f t b \<exclamdown> k = 0
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k

goal (1 subgoal):
 1. \<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
using f_def
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. \<forall>k<c. nth_digit f t b \<exclamdown> k = 0
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)

goal (1 subgoal):
 1. \<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "(r l + d) && f < b ^ Suc q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r l + d && f < b ^ Suc q
[PROOF STEP]
using lm0245[of "r l + d" f] masks_leq[of "(r l + d) && f" f] f_def
[PROOF STATE]
proof (prove)
using this:
r l + d && f \<preceq> f
r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f
f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)

goal (1 subgoal):
 1. r l + d && f < b ^ Suc q
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
have "2 < b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 < b
[PROOF STEP]
using b_def c_gt0 gr0_conv_Suc not_less_iff_gr_or_eq
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c
0 < c
(0 < ?n) = (\<exists>m. ?n = Suc m)
(\<not> ?x < ?y) = (?y < ?x \<or> ?x = ?y)

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

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
2 < b
[PROOF STEP]
have "b^u + b^u < b* b^ u" for u
[PROOF STATE]
proof (prove)
using this:
2 < b

goal (1 subgoal):
 1. b ^ u + b ^ u < b * b ^ u
[PROOF STEP]
using zero_less_power[of b u] mult_less_mono1[of 2 b "b^u"]
[PROOF STATE]
proof (prove)
using this:
2 < b
0 < b \<Longrightarrow> 0 < b ^ u
\<lbrakk>2 < b; 0 < b ^ u\<rbrakk> \<Longrightarrow> 2 * b ^ u < b * b ^ u

goal (1 subgoal):
 1. b ^ u + b ^ u < b * b ^ u
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
b ^ ?u + b ^ ?u < b * b ^ ?u

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
b ^ ?u + b ^ ?u < b * b ^ ?u
[PROOF STEP]
have "(\<Sum>t\<in>{..<q}. b ^ t) <  b ^ q"
[PROOF STATE]
proof (prove)
using this:
b ^ ?u + b ^ ?u < b * b ^ ?u

goal (1 subgoal):
 1. sum ((^) b) {..<q} < b ^ q
[PROOF STEP]
apply(induct q, auto)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>q. \<lbrakk>sum ((^) b) {..<q} < b ^ q; \<And>u. b ^ u + b ^ u < b * b ^ u\<rbrakk> \<Longrightarrow> sum ((^) b) {..<q} + b ^ q < b * b ^ q
[PROOF STEP]
subgoal for q
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>sum ((^) b) {..<q} < b ^ q; \<And>u. b ^ u + b ^ u < b * b ^ u\<rbrakk> \<Longrightarrow> sum ((^) b) {..<q} + b ^ q < b * b ^ q
[PROOF STEP]
using add_strict_right_mono[of " sum ((^) b) {..<q}" "b^q" "b^q"] less_trans
[PROOF STATE]
proof (prove)
using this:
sum ((^) b) {..<q} < b ^ q \<Longrightarrow> sum ((^) b) {..<q} + b ^ q < b ^ q + b ^ q
\<lbrakk>?x < ?y; ?y < ?z\<rbrakk> \<Longrightarrow> ?x < ?z

goal (1 subgoal):
 1. \<lbrakk>sum ((^) b) {..<q} < b ^ q; \<And>u. b ^ u + b ^ u < b * b ^ u\<rbrakk> \<Longrightarrow> sum ((^) b) {..<q} + b ^ q < b * b ^ q
[PROOF STEP]
by blast
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
sum ((^) b) {..<q} < b ^ q

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
sum ((^) b) {..<q} < b ^ q
[PROOF STEP]
have "(\<Sum>t\<in>{..<q}.2^c* b ^ t) < 2^c * b^ q"
[PROOF STATE]
proof (prove)
using this:
sum ((^) b) {..<q} < b ^ q

goal (1 subgoal):
 1. (\<Sum>t<q. 2 ^ c * b ^ t) < 2 ^ c * b ^ q
[PROOF STEP]
using sum_distrib_left[of "2^c" "\<lambda>q. b^q" "{..<q}"]
     zero_less_power[of 2 c] mult_less_mono1[of "sum ((^) b) {..<q}" "b ^ q" "2^c"]
[PROOF STATE]
proof (prove)
using this:
sum ((^) b) {..<q} < b ^ q
2 ^ c * sum ((^) b) {..<q} = (\<Sum>n<q. 2 ^ c * b ^ n)
(0::?'a1) < (2::?'a1) \<Longrightarrow> (0::?'a1) < (2::?'a1) ^ c
\<lbrakk>sum ((^) b) {..<q} < b ^ q; 0 < 2 ^ c\<rbrakk> \<Longrightarrow> sum ((^) b) {..<q} * 2 ^ c < b ^ q * 2 ^ c

goal (1 subgoal):
 1. (\<Sum>t<q. 2 ^ c * b ^ t) < 2 ^ c * b ^ q
[PROOF STEP]
by (simp add: mult.commute)
[PROOF STATE]
proof (state)
this:
(\<Sum>t<q. 2 ^ c * b ^ t) < 2 ^ c * b ^ q

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
(\<Sum>t<q. 2 ^ c * b ^ t) < 2 ^ c * b ^ q

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
have "2 ^ c * b ^ q = b ^ Suc q div 2"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 2 ^ c * b ^ q = b ^ Suc q div 2
[PROOF STEP]
using b_def
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c

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

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
2 ^ c * b ^ q = b ^ Suc q div 2

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
have "f= (\<Sum>t\<in>{..<q}.2^c* b ^ t) + 2^c*b^q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f = (\<Sum>t<q. 2 ^ c * b ^ t) + 2 ^ c * b ^ q
[PROOF STEP]
using f_def atLeastLessThanSuc_atLeastAtMost c_eq rm_constants_def gr0_conv_Suc lessThan_atLeast0
[PROOF STATE]
proof (prove)
using this:
f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)
{?l..<Suc ?u} = {?l..?u}
rm_constants q c b d e f a
rm_constants ?q ?c ?b ?d ?e ?f ?a = (?b = B ?c \<and> ?d = D ?q ?c ?b \<and> ?e = E ?q ?b \<and> ?f = F ?q ?c ?b \<and> 0 < ?c \<and> ?a < 2 ^ ?c \<and> 0 < ?q)
(0 < ?n) = (\<exists>m. ?n = Suc m)
{..<?n} = {0..<?n}

goal (1 subgoal):
 1. f = (\<Sum>t<q. 2 ^ c * b ^ t) + 2 ^ c * b ^ q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f = (\<Sum>t<q. 2 ^ c * b ^ t) + 2 ^ c * b ^ q

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
(\<Sum>t<q. 2 ^ c * b ^ t) < 2 ^ c * b ^ q
2 ^ c * b ^ q = b ^ Suc q div 2
f = (\<Sum>t<q. 2 ^ c * b ^ t) + 2 ^ c * b ^ q
[PROOF STEP]
have "f < b ^ Suc q"
[PROOF STATE]
proof (prove)
using this:
(\<Sum>t<q. 2 ^ c * b ^ t) < 2 ^ c * b ^ q
2 ^ c * b ^ q = b ^ Suc q div 2
f = (\<Sum>t<q. 2 ^ c * b ^ t) + 2 ^ c * b ^ q

goal (1 subgoal):
 1. f < b ^ Suc q
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
f < b ^ Suc q

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
f < b ^ Suc q

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
have "(r l + d) && f \<le> f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r l + d && f \<le> f
[PROOF STEP]
using lm0245[of "r l + d" f] masks_leq[of "(r l + d) && f" f]
[PROOF STATE]
proof (prove)
using this:
r l + d && f \<preceq> f
r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f

goal (1 subgoal):
 1. r l + d && f \<le> f
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r l + d && f \<le> f

goal (1 subgoal):
 1. \<lbrakk>r l + d && f \<preceq> f; r l + d && f \<preceq> f \<longrightarrow> r l + d && f \<le> f; f = (\<Sum>t = 0..q. 2 ^ c * b ^ t)\<rbrakk> \<Longrightarrow> r l + d && f < b ^ Suc q
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
f < b ^ Suc q
r l + d && f \<le> f
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
f < b ^ Suc q
r l + d && f \<le> f

goal (1 subgoal):
 1. r l + d && f < b ^ Suc q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r l + d && f < b ^ Suc q

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
r l + d && f < b ^ Suc q

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r l + d && f < b ^ Suc q
[PROOF STEP]
have rldf0: "t>q \<longrightarrow> nth_digit ((r l + d) && f) t b = 0" for t
[PROOF STATE]
proof (prove)
using this:
r l + d && f < b ^ Suc q

goal (1 subgoal):
 1. q < t \<longrightarrow> nth_digit (r l + d && f) t b = 0
[PROOF STEP]
using nth_digit_def[of "r l + d && f" t b]
    div_less[of "r l + d && f" "b^t"] b_def power_increasing[of "Suc q" t b]
[PROOF STATE]
proof (prove)
using this:
r l + d && f < b ^ Suc q
nth_digit (r l + d && f) t b = (r l + d && f) div b ^ t mod b
r l + d && f < b ^ t \<Longrightarrow> (r l + d && f) div b ^ t = 0
b = 2 ^ Suc c
\<lbrakk>Suc q \<le> t; 1 \<le> b\<rbrakk> \<Longrightarrow> b ^ Suc q \<le> b ^ t

goal (1 subgoal):
 1. q < t \<longrightarrow> nth_digit (r l + d && f) t b = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "\<forall>t>q.\<forall>k<c. nth_digit ((r l + d) && f) t b \<exclamdown> k = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>t>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
using aux_lt_implies_mask rldf0
[PROOF STATE]
proof (prove)
using this:
?a < 2 ^ ?k \<Longrightarrow> \<forall>r\<ge>?k. ?a \<exclamdown> r = 0
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0

goal (1 subgoal):
 1. \<forall>t>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
\<forall>t>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0
\<forall>t>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
have AND_zero: "\<forall>t.\<forall>k<c. nth_digit ((r l + d) && f) t b \<exclamdown> k = 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0
\<forall>t>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. \<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
using leI
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0
\<forall>t>q. \<forall>k<c. nth_digit (r l + d && f) t b \<exclamdown> k = 0
\<not> ?x < ?y \<Longrightarrow> ?y \<le> ?x

goal (1 subgoal):
 1. \<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
\<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "0<k \<Longrightarrow> k< Suc c \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = nth_digit ((r l + d) && f) (Suc t) b \<exclamdown> (k - 1)"
    for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (k - 1)
[PROOF STEP]
using b_def nth_digit_bound digit_gen_pow2_reduct[of k "Suc c" "z l" t] aux_digit_shift[of "z l" c "t + c * t + k"]
    digit_gen_pow2_reduct[of "k-1" "Suc c" "z l * 2^c" "Suc t"] cond
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c
nth_digit ?x ?t (2 ^ Suc ?c) < 2 ^ Suc ?c
k < Suc c \<Longrightarrow> nth_digit (z l) t (2 ^ Suc c) \<exclamdown> k = z l \<exclamdown> (Suc c * t + k)
(z l * 2 ^ c) \<exclamdown> (t + c * t + k + c) = z l \<exclamdown> (t + c * t + k)
k - 1 < Suc c \<Longrightarrow> nth_digit (z l * 2 ^ c) (Suc t) (2 ^ Suc c) \<exclamdown> (k - 1) = (z l * 2 ^ c) \<exclamdown> (Suc c * Suc t + (k - 1))
2 ^ c * z l = r l + d && f

goal (1 subgoal):
 1. \<lbrakk>0 < k; k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (k - 1)
[PROOF STEP]
by (simp add: add.commute add.left_commute mult.commute)
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)
[PROOF STEP]
have aux: "0<k \<Longrightarrow> k< Suc c \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = 0" for k
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)

goal (1 subgoal):
 1. \<lbrakk>0 < k; k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = 0
[PROOF STEP]
using AND_zero
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)
\<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. \<lbrakk>0 < k; k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have zl_formula: "nth_digit (z l) t b =  nth_digit (z l) t b \<exclamdown> 0 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
using b_def digit_sum_repr[of "nth_digit (z l) t b" "Suc c"]
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>b = 2 ^ Suc c; nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)\<rbrakk> \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
have "nth_digit (z l) t b < 2 ^ Suc c
          \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k\<in>{0..<Suc c}. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k = 0..<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)
[PROOF STEP]
using b_def digit_sum_repr[of "nth_digit (z l) t b" "Suc c"]
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k = 0..<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)
[PROOF STEP]
by (simp add: atLeast0LessThan)
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k = 0..<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. \<lbrakk>b = 2 ^ Suc c; nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)\<rbrakk> \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
hence "nth_digit (z l) t b < 2 ^ Suc c
          \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
                                            + (\<Sum>k\<in>{0<..<Suc c}. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)"
[PROOF STATE]
proof (prove)
using this:
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k = 0..<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0 + (\<Sum>k\<in>{0<..<Suc c}. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)
[PROOF STEP]
by (metis One_nat_def atLeastSucLessThan_greaterThanLessThan mult_numeral_1_right
                numeral_1_eq_Suc_0 power_0 sum.atLeast_Suc_lessThan zero_less_Suc)
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0 + (\<Sum>k\<in>{0<..<Suc c}. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. \<lbrakk>b = 2 ^ Suc c; nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = (\<Sum>k<Suc c. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)\<rbrakk> \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0 + (\<Sum>k\<in>{0<..<Suc c}. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
using aux nth_digit_bound b_def
[PROOF STATE]
proof (prove)
using this:
nth_digit (z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0 + (\<Sum>k\<in>{0<..<Suc c}. nth_digit (z l) t b \<exclamdown> k * 2 ^ k)
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = 0
nth_digit ?x ?t (2 ^ Suc ?c) < 2 ^ Suc ?c
b = 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
consider (tleq) "t\<le>q" |(tgq) "t>q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>t \<le> q \<Longrightarrow> thesis; q < t \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by linarith
[PROOF STATE]
proof (state)
this:
\<lbrakk>t \<le> q \<Longrightarrow> ?thesis; q < t \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>t \<le> q \<Longrightarrow> ?thesis; q < t \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>t \<le> q \<Longrightarrow> ?thesis; q < t \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
case tleq
[PROOF STATE]
proof (state)
this:
t \<le> q

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
t \<le> q
[PROOF STEP]
have t_bound: "t \<le> q"
[PROOF STATE]
proof (prove)
using this:
t \<le> q

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

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "nth_digit ((r l + d) && f) t b \<exclamdown> c =  (nth_digit (r l + d) t b \<exclamdown> c)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c
[PROOF STEP]
using f_block bitAND_single_digit AND_gen t_bound
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. nth_digit f t b = 2 ^ c
\<lbrakk>2 ^ ?c \<le> ?x; ?x < 2 ^ Suc ?c\<rbrakk> \<Longrightarrow> ?x \<exclamdown> ?c = 1
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
t \<le> q

goal (1 subgoal):
 1. nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "nth_digit (r l + d && f) t b < 2 ^ Suc c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (r l + d && f) t b < 2 ^ Suc c
[PROOF STEP]
using nth_digit_def b_def
[PROOF STATE]
proof (prove)
using this:
nth_digit ?num ?k ?base = ?num div ?base ^ ?k mod ?base
b = 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (r l + d && f) t b < 2 ^ Suc c
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nth_digit (r l + d && f) t b < 2 ^ Suc c

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c
nth_digit (r l + d && f) t b < 2 ^ Suc c
[PROOF STEP]
have AND_all:"nth_digit ((r l + d) && f) t b = (nth_digit (r l + d) t b \<exclamdown> c) * 2^c"
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c
nth_digit (r l + d && f) t b < 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c
[PROOF STEP]
using AND_gen AND_zero
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c
nth_digit (r l + d && f) t b < 2 ^ Suc c
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
\<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c
[PROOF STEP]
using digit_sum_repr[of "nth_digit ((r l + d) && f) t b" "Suc c"]
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d && f) t b \<exclamdown> c = nth_digit (r l + d) t b \<exclamdown> c
nth_digit (r l + d && f) t b < 2 ^ Suc c
\<forall>t\<le>q. \<forall>k\<le>c. nth_digit (r l + d && f) t b \<exclamdown> k = nth_digit (r l + d) t b \<exclamdown> k * nth_digit f t b \<exclamdown> k
\<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0
nth_digit (r l + d && f) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (r l + d && f) t b = (\<Sum>k<Suc c. nth_digit (r l + d && f) t b \<exclamdown> k * 2 ^ k)

goal (1 subgoal):
 1. nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c
[PROOF STEP]
have "\<forall>k<c. nth_digit (2^c * (z l)) t b \<exclamdown> k =  0"
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c

goal (1 subgoal):
 1. \<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
[PROOF STEP]
using cond AND_zero
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c
2 ^ c * z l = r l + d && f
\<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. \<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
[PROOF STEP]
by metis
[PROOF STATE]
proof (state)
this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "nth_digit (2^c * (z l)) t b \<exclamdown> c =  nth_digit (z l) t b \<exclamdown> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
using digit_gen_pow2_reduct[of c "Suc c" " (2^c * (z l))" t]
            digit_gen_pow2_reduct[of 0 "Suc c" "z l" t] b_def
[PROOF STATE]
proof (prove)
using this:
c < Suc c \<Longrightarrow> nth_digit (2 ^ c * z l) t (2 ^ Suc c) \<exclamdown> c = (2 ^ c * z l) \<exclamdown> (Suc c * t + c)
0 < Suc c \<Longrightarrow> nth_digit (z l) t (2 ^ Suc c) \<exclamdown> 0 = z l \<exclamdown> (Suc c * t + 0)
b = 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
by (simp add: aux_digit_shift mult.commute)
[PROOF STATE]
proof (state)
this:
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
have zl0: "nth_digit (2^c * (z l)) t b = 2^c * nth_digit (z l) t b \<exclamdown> 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
using digit_sum_repr[of "nth_digit (2^c * (z l)) t b" "Suc c"] nth_digit_bound b_def
[PROOF STATE]
proof (prove)
using this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
nth_digit (2 ^ c * z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (2 ^ c * z l) t b = (\<Sum>k<Suc c. nth_digit (2 ^ c * z l) t b \<exclamdown> k * 2 ^ k)
nth_digit ?x ?t (2 ^ Suc ?c) < 2 ^ Suc ?c
b = 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "nth_digit (2^c * (z l)) t b = 2^c * nth_digit (z l) t b"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b
[PROOF STEP]
using zl0 zl_formula
[PROOF STATE]
proof (prove)
using this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0
nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b
[PROOF STEP]
have zl_block: "nth_digit (z l) t b = nth_digit (r l + d) t b \<exclamdown> c"
[PROOF STATE]
proof (prove)
using this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b

goal (1 subgoal):
 1. nth_digit (z l) t b = nth_digit (r l + d) t b \<exclamdown> c
[PROOF STEP]
using AND_all cond
[PROOF STATE]
proof (prove)
using this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b
nth_digit (r l + d && f) t b = nth_digit (r l + d) t b \<exclamdown> c * 2 ^ c
2 ^ c * z l = r l + d && f

goal (1 subgoal):
 1. nth_digit (z l) t b = nth_digit (r l + d) t b \<exclamdown> c
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b = nth_digit (r l + d) t b \<exclamdown> c

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
consider (g0) "Req l t > 0" | (e0) "Req l t = 0 "
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < Req l t \<Longrightarrow> thesis; Req l t = 0 \<Longrightarrow> thesis\<rbrakk> \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < Req l t \<Longrightarrow> ?thesis; Req l t = 0 \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (2 subgoals):
 1. t \<le> q \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < Req l t \<Longrightarrow> ?thesis; Req l t = 0 \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < Req l t \<Longrightarrow> ?thesis; Req l t = 0 \<Longrightarrow> ?thesis\<rbrakk> \<Longrightarrow> ?thesis

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
proof cases
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < Req l t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. Req l t = 0 \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
case e0
[PROOF STATE]
proof (state)
this:
Req l t = 0

goal (2 subgoals):
 1. 0 < Req l t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
 2. Req l t = 0 \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
using e0
[PROOF STATE]
proof (prove)
using this:
Req l t = 0

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
apply(auto simp add: Req_def Zeq_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
assume asm: "nth_digit (r l) t b = 0"
[PROOF STATE]
proof (state)
this:
nth_digit (r l) t b = 0

goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
have add:"((nth_digit d t b) + (nth_digit (r l) t b)) \<exclamdown> c = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 0
[PROOF STEP]
by (simp add: asm d_block nth_bit_def t_bound)
[PROOF STATE]
proof (state)
this:
(nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 0

goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
from d_block t_bound
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
t \<le> q
[PROOF STEP]
have "nth_digit d (t-1) b \<exclamdown> c = 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
t \<le> q

goal (1 subgoal):
 1. nth_digit d (t - 1) b \<exclamdown> c = 0
[PROOF STEP]
using add asm
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
t \<le> q
(nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 0
nth_digit (r l) t b = 0

goal (1 subgoal):
 1. nth_digit d (t - 1) b \<exclamdown> c = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit d (t - 1) b \<exclamdown> c = 0

goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit d (t - 1) b \<exclamdown> c = 0
[PROOF STEP]
have "(nth_digit (r l + d) t b) \<exclamdown> c = 0"
[PROOF STATE]
proof (prove)
using this:
nth_digit d (t - 1) b \<exclamdown> c = 0

goal (1 subgoal):
 1. nth_digit (r l + d) t b \<exclamdown> c = 0
[PROOF STEP]
using add digit_wise_block_additivity[of "r l" "t" "c" "d" "c"] rl_bound[of "t-1"] b_def asm t_bound c_gt0
[PROOF STATE]
proof (prove)
using this:
nth_digit d (t - 1) b \<exclamdown> c = 0
(nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 0
\<lbrakk>nth_digit (r l) (t - 1) (2 ^ Suc c) \<exclamdown> c = 0; nth_digit d (t - 1) (2 ^ Suc c) \<exclamdown> c = 0; c \<le> c; 0 < c\<rbrakk> \<Longrightarrow> nth_digit (r l + d) t (2 ^ Suc c) \<exclamdown> c = (nth_digit (r l) t (2 ^ Suc c) + nth_digit d t (2 ^ Suc c)) \<exclamdown> c
t - 1 \<le> q \<longrightarrow> nth_digit (r l) (t - 1) b \<exclamdown> c = 0
b = 2 ^ Suc c
nth_digit (r l) t b = 0
t \<le> q
0 < c

goal (1 subgoal):
 1. nth_digit (r l + d) t b \<exclamdown> c = 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (r l + d) t b \<exclamdown> c = 0

goal (1 subgoal):
 1. nth_digit (r l) t b = 0 \<Longrightarrow> nth_digit (z l) t b = 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit (r l + d) t b \<exclamdown> c = 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d) t b \<exclamdown> c = 0

goal (1 subgoal):
 1. nth_digit (z l) t b = 0
[PROOF STEP]
using zl_block
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d) t b \<exclamdown> c = 0
nth_digit (z l) t b = nth_digit (r l + d) t b \<exclamdown> c

goal (1 subgoal):
 1. nth_digit (z l) t b = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b = 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
Zeq l t = (if 0 < Req l t then Suc 0 else 0)

goal (1 subgoal):
 1. 0 < Req l t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < Req l t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
case g0
[PROOF STATE]
proof (state)
this:
0 < Req l t

goal (1 subgoal):
 1. 0 < Req l t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
using g0
[PROOF STATE]
proof (prove)
using this:
0 < Req l t

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
apply(auto simp add: Req_def Zeq_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
subgoal
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
assume "0 < nth_digit (r l) t b"
[PROOF STATE]
proof (state)
this:
0 < nth_digit (r l) t b

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
0 < nth_digit (r l) t b
[PROOF STEP]
obtain k0 where k0_def: "nth_digit (r l) t b \<exclamdown> k0 = 1"
[PROOF STATE]
proof (prove)
using this:
0 < nth_digit (r l) t b

goal (1 subgoal):
 1. (\<And>k0. nth_digit (r l) t b \<exclamdown> k0 = 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
using aux0_digit_wise_equiv
[PROOF STATE]
proof (prove)
using this:
0 < nth_digit (r l) t b
0 < ?a \<Longrightarrow> \<exists>k. ?a \<exclamdown> k = 1

goal (1 subgoal):
 1. (\<And>k0. nth_digit (r l) t b \<exclamdown> k0 = 1 \<Longrightarrow> thesis) \<Longrightarrow> thesis
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (r l) t b \<exclamdown> k0 = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit (r l) t b \<exclamdown> k0 = 1
[PROOF STEP]
have "k0\<le>c"
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l) t b \<exclamdown> k0 = 1

goal (1 subgoal):
 1. k0 \<le> c
[PROOF STEP]
using nth_digit_bound[of "r l" t c] b_def aux_lt_implies_mask
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l) t b \<exclamdown> k0 = 1
nth_digit (r l) t (2 ^ Suc c) < 2 ^ Suc c
b = 2 ^ Suc c
?a < 2 ^ ?k \<Longrightarrow> \<forall>r\<ge>?k. ?a \<exclamdown> r = 0

goal (1 subgoal):
 1. k0 \<le> c
[PROOF STEP]
by (metis Suc_leI leI zero_neq_one)
[PROOF STATE]
proof (state)
this:
k0 \<le> c

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
k0 \<le> c
[PROOF STEP]
have k0bound: "k0<c"
[PROOF STATE]
proof (prove)
using this:
k0 \<le> c

goal (1 subgoal):
 1. k0 < c
[PROOF STEP]
using rl_fst_digit_zero
[PROOF STATE]
proof (prove)
using this:
k0 \<le> c
?l < n \<Longrightarrow> nth_digit (r ?l) ?t b \<exclamdown> c = 0

goal (1 subgoal):
 1. k0 < c
[PROOF STEP]
using k0_def le_less rl_bound t_bound
[PROOF STATE]
proof (prove)
using this:
k0 \<le> c
?l < n \<Longrightarrow> nth_digit (r ?l) ?t b \<exclamdown> c = 0
nth_digit (r l) t b \<exclamdown> k0 = 1
(?x \<le> ?y) = (?x < ?y \<or> ?x = ?y)
?t \<le> q \<longrightarrow> nth_digit (r l) ?t b \<exclamdown> c = 0
t \<le> q

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

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
k0 < c

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
have d_dig: "\<forall>k<c. nth_digit d t b \<exclamdown> k = 1"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>k<c. nth_digit d t b \<exclamdown> k = 1
[PROOF STEP]
using d_block t_bound nth_bit_def[of "nth_digit d t b"]
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
t \<le> q
nth_digit d t b \<exclamdown> ?k = nth_digit d t b div 2 ^ ?k mod 2

goal (1 subgoal):
 1. \<forall>k<c. nth_digit d t b \<exclamdown> k = 1
[PROOF STEP]
by (metis One_nat_def Suc_1 Suc_diff_Suc Suc_pred dmask_aux even_add even_power odd_iff_mod_2_eq_one
              one_mod_two_eq_one plus_1_eq_Suc zero_less_Suc zero_less_power)
[PROOF STATE]
proof (state)
this:
\<forall>k<c. nth_digit d t b \<exclamdown> k = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
k0 < c
\<forall>k<c. nth_digit d t b \<exclamdown> k = 1
[PROOF STEP]
have "nth_digit d t b \<exclamdown> k0 = 1"
[PROOF STATE]
proof (prove)
using this:
k0 < c
\<forall>k<c. nth_digit d t b \<exclamdown> k = 1

goal (1 subgoal):
 1. nth_digit d t b \<exclamdown> k0 = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nth_digit d t b \<exclamdown> k0 = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit d t b \<exclamdown> k0 = 1
[PROOF STEP]
have "bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1"
[PROOF STATE]
proof (prove)
using this:
nth_digit d t b \<exclamdown> k0 = 1

goal (1 subgoal):
 1. bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1
[PROOF STEP]
using
             k0_def sum_carry_formula carry_bounded less_eq_Suc_le
[PROOF STATE]
proof (prove)
using this:
nth_digit d t b \<exclamdown> k0 = 1
nth_digit (r l) t b \<exclamdown> k0 = 1
bin_carry ?a ?b (?k + 1) = (?a \<exclamdown> ?k + ?b \<exclamdown> ?k + bin_carry ?a ?b ?k) div 2
bin_carry ?a ?b ?k \<le> 1
(?n < ?m) = (Suc ?n \<le> ?m)

goal (1 subgoal):
 1. bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
have "\<And>n. Suc k0 \<le> n \<Longrightarrow> n < c \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) n =
             Suc 0 \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>n. \<lbrakk>Suc k0 \<le> n; n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0
[PROOF STEP]
subgoal for n
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>Suc k0 \<le> n; n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0
[PROOF STEP]
proof-
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<lbrakk>Suc k0 \<le> n; n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0
[PROOF STEP]
assume "n<c" "bin_carry (nth_digit d t b) (nth_digit (r l) t b) n =  Suc 0"
[PROOF STATE]
proof (state)
this:
n < c
bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0

goal (1 subgoal):
 1. \<lbrakk>Suc k0 \<le> n; n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
n < c
bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
n < c
bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0

goal (1 subgoal):
 1. bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0
[PROOF STEP]
using d_dig sum_carry_formula
              carry_bounded[of "(nth_digit d t b)" "(nth_digit (r l) t b)"  "Suc n" ]
[PROOF STATE]
proof (prove)
using this:
n < c
bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = Suc 0
\<forall>k<c. nth_digit d t b \<exclamdown> k = 1
bin_carry ?a ?b (?k + 1) = (?a \<exclamdown> ?k + ?b \<exclamdown> ?k + bin_carry ?a ?b ?k) div 2
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) \<le> 1

goal (1 subgoal):
 1. bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = Suc 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
\<lbrakk>Suc k0 \<le> ?n; ?n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) ?n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc ?n) = Suc 0

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1
\<lbrakk>Suc k0 \<le> ?n; ?n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) ?n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc ?n) = Suc 0
[PROOF STEP]
have "bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1" (is "?P c")
[PROOF STATE]
proof (prove)
using this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1
\<lbrakk>Suc k0 \<le> ?n; ?n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) ?n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc ?n) = Suc 0

goal (1 subgoal):
 1. bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1
[PROOF STEP]
using dec_induct[of "Suc k0" c ?P]
[PROOF STATE]
proof (prove)
using this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1
\<lbrakk>Suc k0 \<le> ?n; ?n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) ?n = Suc 0\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc ?n) = Suc 0
\<lbrakk>Suc k0 \<le> c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc k0) = 1; \<And>n. \<lbrakk>Suc k0 \<le> n; n < c; bin_carry (nth_digit d t b) (nth_digit (r l) t b) n = 1\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) (Suc n) = 1\<rbrakk> \<Longrightarrow> bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1

goal (1 subgoal):
 1. bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1
[PROOF STEP]
by (simp add: Suc_le_eq k0bound)
[PROOF STATE]
proof (state)
this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1
[PROOF STEP]
have add:"((nth_digit d t b) + (nth_digit (r l) t b)) \<exclamdown> c = 1"
[PROOF STATE]
proof (prove)
using this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1

goal (1 subgoal):
 1. (nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 1
[PROOF STEP]
using sum_digit_formula[of "nth_digit d t b" "nth_digit (r l) t b" c]
            d_block nth_bit_def t_bound assms rl_fst_digit_zero
[PROOF STATE]
proof (prove)
using this:
bin_carry (nth_digit d t b) (nth_digit (r l) t b) c = 1
(nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = (nth_digit d t b \<exclamdown> c + nth_digit (r l) t b \<exclamdown> c + bin_carry (nth_digit d t b) (nth_digit (r l) t b) c) mod 2
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
?num \<exclamdown> ?k = ?num div 2 ^ ?k mod 2
t \<le> q
l < n
?l < n \<Longrightarrow> nth_digit (r ?l) ?t b \<exclamdown> c = 0

goal (1 subgoal):
 1. (nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 1
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
(nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
from d_block t_bound
[PROOF STATE]
proof (chain)
picking this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
t \<le> q
[PROOF STEP]
have "nth_digit d (t-1) b \<exclamdown> c = 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1
t \<le> q

goal (1 subgoal):
 1. nth_digit d (t - 1) b \<exclamdown> c = 0
[PROOF STEP]
by (smt aux_lt_implies_mask diff_le_self diff_less le_eq_less_or_eq le_trans
                  zero_less_numeral zero_less_one zero_less_power)
[PROOF STATE]
proof (state)
this:
nth_digit d (t - 1) b \<exclamdown> c = 0

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit d (t - 1) b \<exclamdown> c = 0
[PROOF STEP]
have "(nth_digit (r l + d) t b) \<exclamdown> c = 1"
[PROOF STATE]
proof (prove)
using this:
nth_digit d (t - 1) b \<exclamdown> c = 0

goal (1 subgoal):
 1. nth_digit (r l + d) t b \<exclamdown> c = 1
[PROOF STEP]
using add b_def t_bound
            block_additivity assms rl_fst_digit_zero c_gt0 d_block
[PROOF STATE]
proof (prove)
using this:
nth_digit d (t - 1) b \<exclamdown> c = 0
(nth_digit d t b + nth_digit (r l) t b) \<exclamdown> c = 1
b = 2 ^ Suc c
t \<le> q
\<lbrakk>0 < ?c; nth_digit ?x (?t - 1) (2 ^ Suc ?c) \<exclamdown> ?c = 0; nth_digit ?y (?t - 1) (2 ^ Suc ?c) \<exclamdown> ?c = 0; nth_digit ?x ?t (2 ^ Suc ?c) \<exclamdown> ?c = 0; nth_digit ?y ?t (2 ^ Suc ?c) \<exclamdown> ?c = 0\<rbrakk> \<Longrightarrow> nth_digit (?x + ?y) ?t (2 ^ Suc ?c) = nth_digit ?x ?t (2 ^ Suc ?c) + nth_digit ?y ?t (2 ^ Suc ?c)
l < n
?l < n \<Longrightarrow> nth_digit (r ?l) ?t b \<exclamdown> c = 0
0 < c
\<forall>t\<le>q. nth_digit d t b = 2 ^ c - 1

goal (1 subgoal):
 1. nth_digit (r l + d) t b \<exclamdown> c = 1
[PROOF STEP]
by (simp add: add.commute)
[PROOF STATE]
proof (state)
this:
nth_digit (r l + d) t b \<exclamdown> c = 1

goal (1 subgoal):
 1. 0 < nth_digit (r l) t b \<Longrightarrow> nth_digit (z l) t b = Suc 0
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit (r l + d) t b \<exclamdown> c = 1
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d) t b \<exclamdown> c = 1

goal (1 subgoal):
 1. nth_digit (z l) t b = Suc 0
[PROOF STEP]
using zl_block
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l + d) t b \<exclamdown> c = 1
nth_digit (z l) t b = nth_digit (r l + d) t b \<exclamdown> c

goal (1 subgoal):
 1. nth_digit (z l) t b = Suc 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
nth_digit (z l) t b = Suc 0

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (prove)
goal:
No subgoals!
[PROOF STEP]
done
[PROOF STATE]
proof (state)
this:
Zeq l t = (if 0 < Req l t then Suc 0 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Zeq l t = (if 0 < Req l t then Suc 0 else 0)

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
case tgq
[PROOF STATE]
proof (state)
this:
q < t

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
q < t
[PROOF STEP]
have t_bound: "q<t"
[PROOF STATE]
proof (prove)
using this:
q < t

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

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
(* (r l) is 0 for all blocks *)
[PROOF STATE]
proof (state)
this:
q < t

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "r l < b ^ q"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. r l < b ^ q
[PROOF STEP]
using reg_equations_def assms r_eq
[PROOF STATE]
proof (prove)
using this:
reg_equations ?p ?r ?z ?s ?b ?a ?n ?q = ((\<forall>l>0. l < ?n \<longrightarrow> ?r l = ?b * ?r l + ?b * \<Sum>R+ ?p l ?s - ?b * \<Sum>R- ?p l (\<lambda>k. ?s k && ?z l) ) \<and> ?r 0 = ?a + ?b * ?r 0 + ?b * \<Sum>R+ ?p 0 ?s - ?b * \<Sum>R- ?p 0 (\<lambda>k. ?s k && ?z 0)  \<and> (\<forall>l<?n. ?r l < ?b ^ ?q))
l < n
reg_equations p r z s b a n q

goal (1 subgoal):
 1. r l < b ^ q
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
r l < b ^ q

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
r l < b ^ q
[PROOF STEP]
have rl0: "nth_digit (r l) t b = 0"
[PROOF STATE]
proof (prove)
using this:
r l < b ^ q

goal (1 subgoal):
 1. nth_digit (r l) t b = 0
[PROOF STEP]
using t_bound nth_digit_def[of "r l" t b] b_gt1
        power_strict_increasing[of q t b]
[PROOF STATE]
proof (prove)
using this:
r l < b ^ q
q < t
nth_digit (r l) t b = r l div b ^ t mod b
1 < b
\<lbrakk>q < t; 1 < b\<rbrakk> \<Longrightarrow> b ^ q < b ^ t

goal (1 subgoal):
 1. nth_digit (r l) t b = 0
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
nth_digit (r l) t b = 0

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
nth_digit (r l) t b = 0
[PROOF STEP]
have "\<forall>k<c. nth_digit (2^c * (z l)) t b \<exclamdown> k = 0"
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l) t b = 0

goal (1 subgoal):
 1. \<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
[PROOF STEP]
using cond AND_zero
[PROOF STATE]
proof (prove)
using this:
nth_digit (r l) t b = 0
2 ^ c * z l = r l + d && f
\<forall>t k. k < c \<longrightarrow> nth_digit (r l + d && f) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. \<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
(* the next two statements are already proven above but here they rely on rl0 *)
[PROOF STATE]
proof (state)
this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
moreover
[PROOF STATE]
proof (state)
this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "nth_digit (2^c * (z l)) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
using digit_gen_pow2_reduct[of c "Suc c" " (2^c * (z l))" t]
            digit_gen_pow2_reduct[of 0 "Suc c" "z l" t] b_def
[PROOF STATE]
proof (prove)
using this:
c < Suc c \<Longrightarrow> nth_digit (2 ^ c * z l) t (2 ^ Suc c) \<exclamdown> c = (2 ^ c * z l) \<exclamdown> (Suc c * t + c)
0 < Suc c \<Longrightarrow> nth_digit (z l) t (2 ^ Suc c) \<exclamdown> 0 = z l \<exclamdown> (Suc c * t + 0)
b = 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
by (simp add: aux_digit_shift mult.commute)
[PROOF STATE]
proof (state)
this:
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
ultimately
[PROOF STATE]
proof (chain)
picking this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
have zl0: "nth_digit (2^c * (z l)) t b = 2^c * nth_digit (z l) t b \<exclamdown> 0"
[PROOF STATE]
proof (prove)
using this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
using digit_sum_repr[of "nth_digit (2^c * (z l)) t b" "Suc c"] nth_digit_bound b_def
[PROOF STATE]
proof (prove)
using this:
\<forall>k<c. nth_digit (2 ^ c * z l) t b \<exclamdown> k = 0
nth_digit (2 ^ c * z l) t b \<exclamdown> c = nth_digit (z l) t b \<exclamdown> 0
nth_digit (2 ^ c * z l) t b < 2 ^ Suc c \<Longrightarrow> nth_digit (2 ^ c * z l) t b = (\<Sum>k<Suc c. nth_digit (2 ^ c * z l) t b \<exclamdown> k * 2 ^ k)
nth_digit ?x ?t (2 ^ Suc ?c) < 2 ^ Suc ?c
b = 2 ^ Suc c

goal (1 subgoal):
 1. nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
have "0<k \<Longrightarrow> k< Suc c \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = nth_digit ((r l + d) && f) (Suc t) b \<exclamdown> (k - 1)"
      for k
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>0 < k; k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (k - 1)
[PROOF STEP]
using b_def nth_digit_bound digit_gen_pow2_reduct[of k "Suc c" "z l" t] aux_digit_shift[of "z l" c "t + c * t + k"]
      digit_gen_pow2_reduct[of "k-1" "Suc c" "z l * 2^c" "Suc t"] cond
[PROOF STATE]
proof (prove)
using this:
b = 2 ^ Suc c
nth_digit ?x ?t (2 ^ Suc ?c) < 2 ^ Suc ?c
k < Suc c \<Longrightarrow> nth_digit (z l) t (2 ^ Suc c) \<exclamdown> k = z l \<exclamdown> (Suc c * t + k)
(z l * 2 ^ c) \<exclamdown> (t + c * t + k + c) = z l \<exclamdown> (t + c * t + k)
k - 1 < Suc c \<Longrightarrow> nth_digit (z l * 2 ^ c) (Suc t) (2 ^ Suc c) \<exclamdown> (k - 1) = (z l * 2 ^ c) \<exclamdown> (Suc c * Suc t + (k - 1))
2 ^ c * z l = r l + d && f

goal (1 subgoal):
 1. \<lbrakk>0 < k; k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (k - 1)
[PROOF STEP]
by (simp add: add.commute add.left_commute mult.commute)
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
(* Using some simplification lemmas, the result follows *)
[PROOF STATE]
proof (state)
this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)

goal (1 subgoal):
 1. q < t \<Longrightarrow> Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)
[PROOF STEP]
show ?thesis
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
using Zeq_def Req_def cond rl0 zl0 rldf0 zl_formula t_bound
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>0 < ?k; ?k < Suc c\<rbrakk> \<Longrightarrow> nth_digit (z l) t b \<exclamdown> ?k = nth_digit (r l + d && f) (Suc t) b \<exclamdown> (?k - 1)
Zeq = (\<lambda>l t. nth_digit (z l) t b)
Req = (\<lambda>l t. nth_digit (r l) t b)
2 ^ c * z l = r l + d && f
nth_digit (r l) t b = 0
nth_digit (2 ^ c * z l) t b = 2 ^ c * nth_digit (z l) t b \<exclamdown> 0
q < ?t \<longrightarrow> nth_digit (r l + d && f) ?t b = 0
nth_digit (z l) t b = nth_digit (z l) t b \<exclamdown> 0
q < t

goal (1 subgoal):
 1. Zeq l t = (if 0 < Req l t then Suc 0 else 0)
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
Zeq l t = (if 0 < Req l t then Suc 0 else 0)

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
Zeq l t = (if 0 < Req l t then Suc 0 else 0)

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma homeomorphic_rel_boundaries_same_dimension:
  fixes S :: "'a::euclidean_space set" and T :: "'b::euclidean_space set"
  assumes "S homeomorphic T" and aff: "aff_dim S = aff_dim T"
  shows "(S - rel_interior S) homeomorphic (T - rel_interior T)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. S - rel_interior S homeomorphic T - rel_interior T
[PROOF STEP]
using assms [unfolded homeomorphic_minimal]
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g
aff_dim S = aff_dim T

goal (1 subgoal):
 1. S - rel_interior S homeomorphic T - rel_interior T
[PROOF STEP]
unfolding homeomorphic_def
[PROOF STATE]
proof (prove)
using this:
\<exists>f g. (\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x) \<and> (\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y) \<and> continuous_on S f \<and> continuous_on T g
aff_dim S = aff_dim T

goal (1 subgoal):
 1. \<exists>f g. homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
proof (clarify elim!: ex_forward)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
fix f g
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
assume S: "\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x" and T: "\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y"
     and contf: "continuous_on S f" and contg: "continuous_on T g"
[PROOF STATE]
proof (state)
this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g
[PROOF STEP]
have fST: "f ` S = T" and gTS: "g ` T = S" and "inj_on f S" "inj_on g T"
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
continuous_on S f
continuous_on T g

goal (1 subgoal):
 1. f ` S = T &&& g ` T = S &&& inj_on f S &&& inj_on g T
[PROOF STEP]
by (auto simp: inj_on_def intro: rev_image_eqI) metis+
[PROOF STATE]
proof (state)
this:
f ` S = T
g ` T = S
inj_on f S
inj_on g T

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
have fim: "f ` rel_interior S \<subseteq> rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` rel_interior S \<subseteq> rel_interior T
[PROOF STEP]
by (metis \<open>inj_on f S\<close> aff contf continuous_image_subset_rel_interior fST order_refl)
[PROOF STATE]
proof (state)
this:
f ` rel_interior S \<subseteq> rel_interior T

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
have gim: "g ` rel_interior T \<subseteq> rel_interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ` rel_interior T \<subseteq> rel_interior S
[PROOF STEP]
by (metis \<open>inj_on g T\<close> aff contg continuous_image_subset_rel_interior gTS order_refl)
[PROOF STATE]
proof (state)
this:
g ` rel_interior T \<subseteq> rel_interior S

goal (1 subgoal):
 1. \<And>f g. \<lbrakk>aff_dim S = aff_dim T; \<forall>x\<in>S. f x \<in> T \<and> g (f x) = x; \<forall>y\<in>T. g y \<in> S \<and> f (g y) = y; continuous_on S f; continuous_on T g\<rbrakk> \<Longrightarrow> homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
show "homeomorphism (S - rel_interior S) (T - rel_interior T) f g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. homeomorphism (S - rel_interior S) (T - rel_interior T) f g
[PROOF STEP]
unfolding homeomorphism_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>S - rel_interior S. g (f x) = x) \<and> f ` (S - rel_interior S) = T - rel_interior T \<and> continuous_on (S - rel_interior S) f \<and> (\<forall>y\<in>T - rel_interior T. f (g y) = y) \<and> g ` (T - rel_interior T) = S - rel_interior S \<and> continuous_on (T - rel_interior T) g
[PROOF STEP]
proof (intro conjI ballI)
[PROOF STATE]
proof (state)
goal (6 subgoals):
 1. \<And>x. x \<in> S - rel_interior S \<Longrightarrow> g (f x) = x
 2. f ` (S - rel_interior S) = T - rel_interior T
 3. continuous_on (S - rel_interior S) f
 4. \<And>y. y \<in> T - rel_interior T \<Longrightarrow> f (g y) = y
 5. g ` (T - rel_interior T) = S - rel_interior S
 6. continuous_on (T - rel_interior T) g
[PROOF STEP]
show gf: "\<And>x. x \<in> S - rel_interior S \<Longrightarrow> g (f x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>x. x \<in> S - rel_interior S \<Longrightarrow> g (f x) = x
[PROOF STEP]
using S rel_interior_subset
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
rel_interior ?S \<subseteq> ?S

goal (1 subgoal):
 1. \<And>x. x \<in> S - rel_interior S \<Longrightarrow> g (f x) = x
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?x \<in> S - rel_interior S \<Longrightarrow> g (f ?x) = ?x

goal (5 subgoals):
 1. f ` (S - rel_interior S) = T - rel_interior T
 2. continuous_on (S - rel_interior S) f
 3. \<And>y. y \<in> T - rel_interior T \<Longrightarrow> f (g y) = y
 4. g ` (T - rel_interior T) = S - rel_interior S
 5. continuous_on (T - rel_interior T) g
[PROOF STEP]
show fg: "\<And>y. y \<in> T - rel_interior T \<Longrightarrow> f (g y) = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<And>y. y \<in> T - rel_interior T \<Longrightarrow> f (g y) = y
[PROOF STEP]
using T mem_rel_interior_ball
[PROOF STATE]
proof (prove)
using this:
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
(?x \<in> rel_interior ?S) = (?x \<in> ?S \<and> (\<exists>e>0. ball ?x e \<inter> affine hull ?S \<subseteq> ?S))

goal (1 subgoal):
 1. \<And>y. y \<in> T - rel_interior T \<Longrightarrow> f (g y) = y
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
?y \<in> T - rel_interior T \<Longrightarrow> f (g ?y) = ?y

goal (4 subgoals):
 1. f ` (S - rel_interior S) = T - rel_interior T
 2. continuous_on (S - rel_interior S) f
 3. g ` (T - rel_interior T) = S - rel_interior S
 4. continuous_on (T - rel_interior T) g
[PROOF STEP]
show "f ` (S - rel_interior S) = T - rel_interior T"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f ` (S - rel_interior S) = T - rel_interior T
[PROOF STEP]
using S fST fim gim
[PROOF STATE]
proof (prove)
using this:
\<forall>x\<in>S. f x \<in> T \<and> g (f x) = x
f ` S = T
f ` rel_interior S \<subseteq> rel_interior T
g ` rel_interior T \<subseteq> rel_interior S

goal (1 subgoal):
 1. f ` (S - rel_interior S) = T - rel_interior T
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
f ` (S - rel_interior S) = T - rel_interior T

goal (3 subgoals):
 1. continuous_on (S - rel_interior S) f
 2. g ` (T - rel_interior T) = S - rel_interior S
 3. continuous_on (T - rel_interior T) g
[PROOF STEP]
show "continuous_on (S - rel_interior S) f"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on (S - rel_interior S) f
[PROOF STEP]
using contf continuous_on_subset rel_interior_subset
[PROOF STATE]
proof (prove)
using this:
continuous_on S f
\<lbrakk>continuous_on ?s ?f; ?t \<subseteq> ?s\<rbrakk> \<Longrightarrow> continuous_on ?t ?f
rel_interior ?S \<subseteq> ?S

goal (1 subgoal):
 1. continuous_on (S - rel_interior S) f
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
continuous_on (S - rel_interior S) f

goal (2 subgoals):
 1. g ` (T - rel_interior T) = S - rel_interior S
 2. continuous_on (T - rel_interior T) g
[PROOF STEP]
show "g ` (T - rel_interior T) = S - rel_interior S"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. g ` (T - rel_interior T) = S - rel_interior S
[PROOF STEP]
using T gTS gim fim
[PROOF STATE]
proof (prove)
using this:
\<forall>y\<in>T. g y \<in> S \<and> f (g y) = y
g ` T = S
g ` rel_interior T \<subseteq> rel_interior S
f ` rel_interior S \<subseteq> rel_interior T

goal (1 subgoal):
 1. g ` (T - rel_interior T) = S - rel_interior S
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
g ` (T - rel_interior T) = S - rel_interior S

goal (1 subgoal):
 1. continuous_on (T - rel_interior T) g
[PROOF STEP]
show "continuous_on (T - rel_interior T) g"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. continuous_on (T - rel_interior T) g
[PROOF STEP]
using contg continuous_on_subset rel_interior_subset
[PROOF STATE]
proof (prove)
using this:
continuous_on T g
\<lbrakk>continuous_on ?s ?f; ?t \<subseteq> ?s\<rbrakk> \<Longrightarrow> continuous_on ?t ?f
rel_interior ?S \<subseteq> ?S

goal (1 subgoal):
 1. continuous_on (T - rel_interior T) g
[PROOF STEP]
by blast
[PROOF STATE]
proof (state)
this:
continuous_on (T - rel_interior T) g

goal:
No subgoals!
[PROOF STEP]
qed
[PROOF STATE]
proof (state)
this:
homeomorphism (S - rel_interior S) (T - rel_interior T) f g

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma expands_to_abs_pos:
  assumes "trimmed_pos F" "basis_wf basis" "(f expands_to F) basis"
  shows   "((\<lambda>x. abs (f x)) expands_to F) basis"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ((\<lambda>x. \<bar>f x\<bar>) expands_to F) basis
[PROOF STEP]
using assms(3)
[PROOF STATE]
proof (prove)
using this:
(f expands_to F) basis

goal (1 subgoal):
 1. ((\<lambda>x. \<bar>f x\<bar>) expands_to F) basis
[PROOF STEP]
proof (rule expands_to_cong)
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x = \<bar>f x\<bar>
[PROOF STEP]
from trimmed_imp_eventually_sgn[of basis F] assms
[PROOF STATE]
proof (chain)
picking this:
\<lbrakk>basis_wf basis; is_expansion F basis; trimmed F\<rbrakk> \<Longrightarrow> \<forall>\<^sub>F x in at_top. sgn (eval F x) = sgn (fst (dominant_term F))
trimmed_pos F
basis_wf basis
(f expands_to F) basis
[PROOF STEP]
have "eventually (\<lambda>x. sgn (eval F x) = 1) at_top"
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>basis_wf basis; is_expansion F basis; trimmed F\<rbrakk> \<Longrightarrow> \<forall>\<^sub>F x in at_top. sgn (eval F x) = sgn (fst (dominant_term F))
trimmed_pos F
basis_wf basis
(f expands_to F) basis

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. sgn (eval F x) = 1
[PROOF STEP]
by (simp add: expands_to.simps trimmed_pos_def)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. sgn (eval F x) = 1

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x = \<bar>f x\<bar>
[PROOF STEP]
with assms(3)
[PROOF STATE]
proof (chain)
picking this:
(f expands_to F) basis
\<forall>\<^sub>F x in at_top. sgn (eval F x) = 1
[PROOF STEP]
show "eventually (\<lambda>x. f x = abs (f x)) at_top"
[PROOF STATE]
proof (prove)
using this:
(f expands_to F) basis
\<forall>\<^sub>F x in at_top. sgn (eval F x) = 1

goal (1 subgoal):
 1. \<forall>\<^sub>F x in at_top. f x = \<bar>f x\<bar>
[PROOF STEP]
by (auto simp: expands_to.simps sgn_if split: if_splits elim: eventually_elim2)
[PROOF STATE]
proof (state)
this:
\<forall>\<^sub>F x in at_top. f x = \<bar>f x\<bar>

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma zcf_zero_degree_zero:
  assumes "f \<in> carrier P"
  assumes "degree f = 0"
  assumes "zcf f = \<zero>"
  shows "f = \<zero>\<^bsub>P\<^esub>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. f = \<zero>\<^bsub>P\<^esub>
[PROOF STEP]
using zcf_degree_zero[of f] assms ltrm_deg_0[of f]
[PROOF STATE]
proof (prove)
using this:
\<lbrakk>f \<in> carrier P; deg R f = 0\<rbrakk> \<Longrightarrow> f (deg R f) = zcf f
f \<in> carrier P
deg R f = 0
zcf f = \<zero>
\<lbrakk>f \<in> carrier P; deg R f = 0\<rbrakk> \<Longrightarrow> monom P (f (deg R f)) (deg R f) = f

goal (1 subgoal):
 1. f = \<zero>\<^bsub>P\<^esub>
[PROOF STEP]
by simp


[STATEMENT]
lemma ratrel_equivp:
  "part_equivp ratrel"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. part_equivp (\<approx>)
[PROOF STEP]
proof (auto intro!: part_equivpI reflpI sympI transpI exI[of _ "1 :: int"])
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
fix a b c d e f :: int
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
assume nz: "d \<noteq> 0" "b \<noteq> 0"
[PROOF STATE]
proof (state)
this:
d \<noteq> 0
b \<noteq> 0

goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
assume y: "a * d = c * b"
[PROOF STATE]
proof (state)
this:
a * d = c * b

goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
assume x: "c * f = e * d"
[PROOF STATE]
proof (state)
this:
c * f = e * d

goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c * f = e * d
[PROOF STEP]
have "c * b * f = e * d * b"
[PROOF STATE]
proof (prove)
using this:
c * f = e * d

goal (1 subgoal):
 1. c * b * f = e * d * b
[PROOF STEP]
using nz
[PROOF STATE]
proof (prove)
using this:
c * f = e * d
d \<noteq> 0
b \<noteq> 0

goal (1 subgoal):
 1. c * b * f = e * d * b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
c * b * f = e * d * b

goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
c * b * f = e * d * b
[PROOF STEP]
have "a * d * f = e * d * b"
[PROOF STATE]
proof (prove)
using this:
c * b * f = e * d * b

goal (1 subgoal):
 1. a * d * f = e * d * b
[PROOF STEP]
using y
[PROOF STATE]
proof (prove)
using this:
c * b * f = e * d * b
a * d = c * b

goal (1 subgoal):
 1. a * d * f = e * d * b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a * d * f = e * d * b

goal (1 subgoal):
 1. \<And>a b aa ba ab bb. \<lbrakk>b \<noteq> 0; bb \<noteq> 0; aa * bb = ab * ba; ba \<noteq> 0; a * ba = aa * b\<rbrakk> \<Longrightarrow> a * bb = ab * b
[PROOF STEP]
then
[PROOF STATE]
proof (chain)
picking this:
a * d * f = e * d * b
[PROOF STEP]
show "a * f = e * b"
[PROOF STATE]
proof (prove)
using this:
a * d * f = e * d * b

goal (1 subgoal):
 1. a * f = e * b
[PROOF STEP]
using nz
[PROOF STATE]
proof (prove)
using this:
a * d * f = e * d * b
d \<noteq> 0
b \<noteq> 0

goal (1 subgoal):
 1. a * f = e * b
[PROOF STEP]
by simp
[PROOF STATE]
proof (state)
this:
a * f = e * b

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma adj_relation_wf: "(u, v) \<in> adj_relation \<Longrightarrow> {u, v} \<subseteq> V"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u, v) \<in> adj_relation \<Longrightarrow> {u, v} \<subseteq> V
[PROOF STEP]
unfolding adj_relation_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (u, v) \<in> {(u, v) |u v. vert_adj u v} \<Longrightarrow> {u, v} \<subseteq> V
[PROOF STEP]
using vert_adj_imp_inV
[PROOF STATE]
proof (prove)
using this:
vert_adj ?v1.0 ?v2.0 \<Longrightarrow> ?v1.0 \<in> V \<and> ?v2.0 \<in> V

goal (1 subgoal):
 1. (u, v) \<in> {(u, v) |u v. vert_adj u v} \<Longrightarrow> {u, v} \<subseteq> V
[PROOF STEP]
by auto


[STATEMENT]
lemma Keys_to_list_eq_pps_to_list: "Keys_to_list ps = pps_to_list (Keys (set ps))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Keys_to_list ps = pps_to_list (Keys (set ps))
[PROOF STEP]
using _ Keys_to_list_sorted_wrt distinct_Keys_to_list pps_to_list_sorted_wrt distinct_pps_to_list
[PROOF STATE]
proof (prove)
using this:
PROP ?psi \<Longrightarrow> PROP ?psi
sorted_wrt (\<succ>\<^sub>t) (Keys_to_list ?ps)
distinct (Keys_to_list ?ps)
sorted_wrt (\<succ>\<^sub>t) (pps_to_list ?S)
distinct (pps_to_list ?S)

goal (1 subgoal):
 1. Keys_to_list ps = pps_to_list (Keys (set ps))
[PROOF STEP]
proof (rule sorted_wrt_distinct_set_unique)
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. antisymp (\<succ>\<^sub>t)
 2. set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))
[PROOF STEP]
show "antisymp (\<succ>\<^sub>t)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. antisymp (\<succ>\<^sub>t)
[PROOF STEP]
unfolding antisymp_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<forall>x y. x \<succ>\<^sub>t y \<longrightarrow> y \<succ>\<^sub>t x \<longrightarrow> x = y
[PROOF STEP]
by fastforce
[PROOF STATE]
proof (state)
this:
antisymp (\<succ>\<^sub>t)

goal (1 subgoal):
 1. set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))
[PROOF STEP]
next
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))
[PROOF STEP]
from finite_set
[PROOF STATE]
proof (chain)
picking this:
finite (set ?xs)
[PROOF STEP]
have fin: "finite (Keys (set ps))"
[PROOF STATE]
proof (prove)
using this:
finite (set ?xs)

goal (1 subgoal):
 1. finite (Keys (set ps))
[PROOF STEP]
by (rule finite_Keys)
[PROOF STATE]
proof (state)
this:
finite (Keys (set ps))

goal (1 subgoal):
 1. set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))
[PROOF STEP]
show "set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))
[PROOF STEP]
by (simp add: set_Keys_to_list set_pps_to_list[OF fin])
[PROOF STATE]
proof (state)
this:
set (Keys_to_list ps) = set (pps_to_list (Keys (set ps)))

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma H2N_inv:
  "H2N (Suc (Suc b)) (N2H (Suc (Suc b)) n) = n"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. H2N (Suc (Suc b)) (N2H (Suc (Suc b)) n) = n
[PROOF STEP]
using evalC_surjective[of "b" n]
[PROOF STATE]
proof (prove)
using this:
\<exists>n'\<in>hbase (Suc (Suc b)). evalC (Suc (Suc b)) n' = n

goal (1 subgoal):
 1. H2N (Suc (Suc b)) (N2H (Suc (Suc b)) n) = n
[PROOF STEP]
by (auto simp: N2H_def H2N_def[abs_def] intro: f_inv_into_f)


[STATEMENT]
lemma lemAxisIsLine:
    assumes "onAxisT x"
      and   "onAxisT y"
      and   "onAxisT z"
      and   "x \<noteq> y"
      and   "y \<noteq> z"
      and   "z \<noteq> x"
    shows   "collinear x y z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
define ratio where "ratio = -(tval y - tval x) / (tval z - tval y)"
[PROOF STATE]
proof (state)
this:
ratio = - (tval y - tval x) / (tval z - tval y)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have x_onAxis: "xval x = 0 \<and> yval x = 0 \<and> zval x = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xval x = (0::'a) \<and> yval x = (0::'a) \<and> zval x = (0::'a)
[PROOF STEP]
by (metis assms(1) onAxisT.simps)
[PROOF STATE]
proof (state)
this:
xval x = (0::'a) \<and> yval x = (0::'a) \<and> zval x = (0::'a)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have y_onAxis: "xval y = 0 \<and> yval y = 0 \<and> zval y = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xval y = (0::'a) \<and> yval y = (0::'a) \<and> zval y = (0::'a)
[PROOF STEP]
by (metis assms(2) onAxisT.simps)
[PROOF STATE]
proof (state)
this:
xval y = (0::'a) \<and> yval y = (0::'a) \<and> zval y = (0::'a)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have z_onAxis: "xval z = 0 \<and> yval z = 0 \<and> zval z = 0"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. xval z = (0::'a) \<and> yval z = (0::'a) \<and> zval z = (0::'a)
[PROOF STEP]
by (metis assms(3) onAxisT.simps)
[PROOF STATE]
proof (state)
this:
xval z = (0::'a) \<and> yval z = (0::'a) \<and> zval z = (0::'a)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have  "tval z - tval y = 0 \<longrightarrow> z = y"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tval z - tval y = (0::'a) \<longrightarrow> z = y
[PROOF STEP]
by (simp add: z_onAxis y_onAxis)
[PROOF STATE]
proof (state)
this:
tval z - tval y = (0::'a) \<longrightarrow> z = y

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
hence "tval z \<noteq> tval y"
[PROOF STATE]
proof (prove)
using this:
tval z - tval y = (0::'a) \<longrightarrow> z = y

goal (1 subgoal):
 1. tval z \<noteq> tval y
[PROOF STEP]
by (metis assms(5) eq_iff_diff_eq_0)
[PROOF STATE]
proof (state)
this:
tval z \<noteq> tval y

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
hence tvalyz_nonzero: "tval z - tval y \<noteq> 0"
[PROOF STATE]
proof (prove)
using this:
tval z \<noteq> tval y

goal (1 subgoal):
 1. tval z - tval y \<noteq> (0::'a)
[PROOF STEP]
by (metis eq_iff_diff_eq_0)
[PROOF STATE]
proof (state)
this:
tval z - tval y \<noteq> (0::'a)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have x_to_y: "from x to y = \<lparr> tdir = tval y - tval x, xdir = 0, ydir = 0, zdir = 0 \<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from x to y = \<lparr>tdir = tval y - tval x, xdir = 0::'a, ydir = 0::'a, zdir = 0::'a\<rparr>
[PROOF STEP]
by (simp add: x_onAxis y_onAxis)
[PROOF STATE]
proof (state)
this:
from x to y = \<lparr>tdir = tval y - tval x, xdir = 0::'a, ydir = 0::'a, zdir = 0::'a\<rparr>

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have y_to_z: "from y to z = \<lparr> tdir = tval z - tval y, xdir = 0, ydir = 0, zdir = 0 \<rparr>"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from y to z = \<lparr>tdir = tval z - tval y, xdir = 0::'a, ydir = 0::'a, zdir = 0::'a\<rparr>
[PROOF STEP]
by (simp add:y_onAxis z_onAxis)
[PROOF STATE]
proof (state)
this:
from y to z = \<lparr>tdir = tval z - tval y, xdir = 0::'a, ydir = 0::'a, zdir = 0::'a\<rparr>

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
have "from x to y = (-ratio)**(from y to z)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. from x to y = (- ratio) ** from y to z
[PROOF STEP]
apply (simp add: x_to_y y_to_z ratio_def)
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. tval y - tval x = - ((tval x - tval y) * (tval z - tval y) / (tval z - tval y)) \<and> xval y - xval x = - ((tval x - tval y) * (xval z - xval y) / (tval z - tval y)) \<and> yval y - yval x = - ((tval x - tval y) * (yval z - yval y) / (tval z - tval y)) \<and> zval y - zval x = - ((tval x - tval y) * (zval z - zval y) / (tval z - tval y))
[PROOF STEP]
by (metis diff_self eq_divide_imp minus_diff_eq mult_eq_0_iff
                tvalyz_nonzero x_onAxis y_onAxis z_onAxis)
[PROOF STATE]
proof (state)
this:
from x to y = (- ratio) ** from y to z

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
hence "collinear x y (y \<leadsto> (from y to z))"
[PROOF STATE]
proof (prove)
using this:
from x to y = (- ratio) ** from y to z

goal (1 subgoal):
 1. collinear x y (y \<leadsto> from y to z)
[PROOF STEP]
by (metis lemDirectionCollinear)
[PROOF STATE]
proof (state)
this:
collinear x y (y \<leadsto> from y to z)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
collinear x y (y \<leadsto> from y to z)

goal (1 subgoal):
 1. collinear x y z
[PROOF STEP]
by (metis lemLineEndpoint)
[PROOF STATE]
proof (state)
this:
collinear x y z

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma exists_index_imp_Sup_llist: "enat i < llength Xs \<Longrightarrow> x \<in> lnth Xs i \<Longrightarrow> x \<in> Sup_llist Xs"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>enat i < llength Xs; x \<in> lnth Xs i\<rbrakk> \<Longrightarrow> x \<in> Sup_llist Xs
[PROOF STEP]
unfolding Sup_llist_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>enat i < llength Xs; x \<in> lnth Xs i\<rbrakk> \<Longrightarrow> x \<in> \<Union> (lnth Xs ` {i. enat i < llength Xs})
[PROOF STEP]
by auto


[STATEMENT]
lemma l11_44_1_b:
  assumes "\<not> Col A B C" and
    "B A C CongA B C A"
  shows "Cong B A B C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. Cong B A B C
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (1 subgoal):
 1. Cong B A B C
[PROOF STEP]
have "B A Lt B C \<or> B A Gt B C \<or> Cong B A B C"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. B A Lt B C \<or> B A Gt B C \<or> Cong B A B C
[PROOF STEP]
by (simp add: or_lt_cong_gt)
[PROOF STATE]
proof (state)
this:
B A Lt B C \<or> B A Gt B C \<or> Cong B A B C

goal (1 subgoal):
 1. Cong B A B C
[PROOF STEP]
thus ?thesis
[PROOF STATE]
proof (prove)
using this:
B A Lt B C \<or> B A Gt B C \<or> Cong B A B C

goal (1 subgoal):
 1. Cong B A B C
[PROOF STEP]
by (meson Gt_def assms(1) assms(2) conga_sym l11_44_2_a not_col_permutation_3 not_lta_and_conga)
[PROOF STATE]
proof (state)
this:
Cong B A B C

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma periodic_orbit_period:
  assumes "periodic_orbit x"
  shows "period x > 0" "flow0 x (period x) = x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < period x &&& flow0 x (period x) = x
[PROOF STEP]
proof -
[PROOF STATE]
proof (state)
goal (2 subgoals):
 1. 0 < period x
 2. flow0 x (period x) = x
[PROOF STEP]
from periodic_orbit_recurrence_times_closed[OF assms(1)]
[PROOF STATE]
proof (chain)
picking this:
closed {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}
[PROOF STEP]
have cl: "closed {T \<in> existence_ivl0 x. T > 0 \<and> flow0 x T = x}"
[PROOF STATE]
proof (prove)
using this:
closed {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}

goal (1 subgoal):
 1. closed {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
closed {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}

goal (2 subgoals):
 1. 0 < period x
 2. flow0 x (period x) = x
[PROOF STEP]
have "closed_orbit x"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. closed_orbit x
[PROOF STEP]
using assms(1)
[PROOF STATE]
proof (prove)
using this:
periodic_orbit x

goal (1 subgoal):
 1. closed_orbit x
[PROOF STEP]
unfolding periodic_orbit_def
[PROOF STATE]
proof (prove)
using this:
closed_orbit x \<and> 0 < period x

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

goal (2 subgoals):
 1. 0 < period x
 2. flow0 x (period x) = x
[PROOF STEP]
from closed_contains_Inf[OF closed_orbit_recurrence_times_nonempty[OF this]
      closed_orbit_recurrence_times_bdd_below cl]
[PROOF STATE]
proof (chain)
picking this:
Inf {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x} \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}
[PROOF STEP]
have "period x \<in>  {T \<in> existence_ivl0 x. T > 0 \<and> flow0 x T = x}"
[PROOF STATE]
proof (prove)
using this:
Inf {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x} \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}

goal (1 subgoal):
 1. period x \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}
[PROOF STEP]
unfolding period_def
[PROOF STATE]
proof (prove)
using this:
Inf {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x} \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}

goal (1 subgoal):
 1. Inf {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x} \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}
[PROOF STEP]
.
[PROOF STATE]
proof (state)
this:
period x \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}

goal (2 subgoals):
 1. 0 < period x
 2. flow0 x (period x) = x
[PROOF STEP]
thus "period x > 0" "flow0 x (period x) = x"
[PROOF STATE]
proof (prove)
using this:
period x \<in> {T \<in> existence_ivl0 x. 0 < T \<and> flow0 x T = x}

goal (1 subgoal):
 1. 0 < period x &&& flow0 x (period x) = x
[PROOF STEP]
by auto
[PROOF STATE]
proof (state)
this:
0 < period x
flow0 x (period x) = x

goal:
No subgoals!
[PROOF STEP]
qed


[STATEMENT]
lemma p_j_pos: "0 < p_j"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < p_j
[PROOF STEP]
unfolding p_j_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. 0 < 1 / real (card J)
[PROOF STEP]
using J_not_empty
[PROOF STATE]
proof (prove)
using this:
J \<noteq> {}

goal (1 subgoal):
 1. 0 < 1 / real (card J)
[PROOF STEP]
by auto


[STATEMENT]
lemma sort_eqv_trans: "sort_eqv cs x y \<Longrightarrow> sort_eqv cs y z \<Longrightarrow> sort_eqv cs x z"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. \<lbrakk>sort_eqv cs x y; sort_eqv cs y z\<rbrakk> \<Longrightarrow> sort_eqv cs x z
[PROOF STEP]
using sort_eqv_def sort_leq_trans
[PROOF STATE]
proof (prove)
using this:
sort_eqv ?cs ?s1.0 ?s2.0 = (sort_leq ?cs ?s1.0 ?s2.0 \<and> sort_leq ?cs ?s2.0 ?s1.0)
\<lbrakk>sort_leq cs ?x ?y; sort_leq cs ?y ?z\<rbrakk> \<Longrightarrow> sort_leq cs ?x ?z

goal (1 subgoal):
 1. \<lbrakk>sort_eqv cs x y; sort_eqv cs y z\<rbrakk> \<Longrightarrow> sort_eqv cs x z
[PROOF STEP]
by blast


[STATEMENT]
lemma ivl_integral_const [simp]:
  shows "ivl_integral a b (\<lambda>x. c) = (b - a) *\<^sub>R c"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ivl_integral a b (\<lambda>x. c) = (b - a) *\<^sub>R c
[PROOF STEP]
by (auto simp: ivl_integral_def algebra_simps)


[STATEMENT]
lemma ccLinear_lub[simp]:
  "ccLinear S (lub X) = (\<forall> G\<in>X. ccLinear S G)"
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. ccLinear S (lub X) = (\<forall>G\<in>X. ccLinear S G)
[PROOF STEP]
unfolding ccLinear_def
[PROOF STATE]
proof (prove)
goal (1 subgoal):
 1. (\<forall>x\<in>S. \<forall>y\<in>S. x--y\<notin>lub X) = (\<forall>G\<in>X. \<forall>x\<in>S. \<forall>y\<in>S. x--y\<notin>G)
[PROOF STEP]
by auto