session
stringclasses 1
value | dependency
sequencelengths 0
0
| context
stringlengths 31
38.1k
| proof
stringlengths 31
38.1k
| proof_state
stringlengths 38
24.6M
| statement
stringlengths 22
5.17k
| name
stringlengths 13
17
| theory_name
stringclasses 518
values | num_steps
int64 1
963
|
|---|---|---|---|---|---|---|---|---|
[] |
lemma n_less_equal_power_2:
"n < 2 ^ n" by (fact less_exp)
|
lemma n_less_equal_power_2:
"n < 2 ^ n" by (fact less_exp)
|
proof (prove)
goal (1 subgoal):
1. n < 2 ^ n
|
lemma n_less_equal_power_2:
"n < 2 ^ n"
|
unnamed_thy_1
|
More_Arithmetic
| 1
|
|
[] |
lemma min_pm [simp]: "min a b + (a - b) = a"
for a b :: nat by arith
|
lemma min_pm [simp]: "min a b + (a - b) = a"
for a b :: nat by arith
|
proof (prove)
goal (1 subgoal):
1. min a b + (a - b) = a
|
lemma min_pm [simp]: "min a b + (a - b) = a"
for a b :: nat
|
unnamed_thy_2
|
More_Arithmetic
| 1
|
|
[] |
lemma min_pm1 [simp]: "a - b + min a b = a"
for a b :: nat by arith
|
lemma min_pm1 [simp]: "a - b + min a b = a"
for a b :: nat by arith
|
proof (prove)
goal (1 subgoal):
1. a - b + min a b = a
|
lemma min_pm1 [simp]: "a - b + min a b = a"
for a b :: nat
|
unnamed_thy_3
|
More_Arithmetic
| 1
|
|
[] |
lemma rev_min_pm [simp]: "min b a + (a - b) = a"
for a b :: nat by arith
|
lemma rev_min_pm [simp]: "min b a + (a - b) = a"
for a b :: nat by arith
|
proof (prove)
goal (1 subgoal):
1. min b a + (a - b) = a
|
lemma rev_min_pm [simp]: "min b a + (a - b) = a"
for a b :: nat
|
unnamed_thy_4
|
More_Arithmetic
| 1
|
|
[] |
lemma rev_min_pm1 [simp]: "a - b + min b a = a"
for a b :: nat by arith
|
lemma rev_min_pm1 [simp]: "a - b + min b a = a"
for a b :: nat by arith
|
proof (prove)
goal (1 subgoal):
1. a - b + min b a = a
|
lemma rev_min_pm1 [simp]: "a - b + min b a = a"
for a b :: nat
|
unnamed_thy_5
|
More_Arithmetic
| 1
|
|
[] |
lemma min_minus' [simp]: "min (m - k) m = m - k"
for m k :: nat by arith
|
lemma min_minus' [simp]: "min (m - k) m = m - k"
for m k :: nat by arith
|
proof (prove)
goal (1 subgoal):
1. min (m - k) m = m - k
|
lemma min_minus' [simp]: "min (m - k) m = m - k"
for m k :: nat
|
unnamed_thy_7
|
More_Arithmetic
| 1
|
|
[] |
lemma nat_less_power_trans:
fixes n :: nat
assumes nv: "n < 2 ^ (m - k)"
and kv: "k \<le> m"
shows "2 ^ k * n < 2 ^ m" proof (rule order_less_le_trans) show "2 ^ k * n < 2 ^ k * 2 ^ (m - k)" by (rule mult_less_mono2 [OF nv zero_less_power]) simp show "(2::nat) ^ k * 2 ^ (m - k) \<le> 2 ^ m" using nv kv by (subst power_add [symmetric]) simp qed
|
lemma nat_less_power_trans:
fixes n :: nat
assumes nv: "n < 2 ^ (m - k)"
and kv: "k \<le> m"
shows "2 ^ k * n < 2 ^ m" proof (rule order_less_le_trans) show "2 ^ k * n < 2 ^ k * 2 ^ (m - k)" by (rule mult_less_mono2 [OF nv zero_less_power]) simp show "(2::nat) ^ k * 2 ^ (m - k) \<le> 2 ^ m" using nv kv by (subst power_add [symmetric]) simp qed
|
proof (prove)
goal (1 subgoal):
1. 2 ^ k * n < 2 ^ m proof (state)
goal (2 subgoals):
1. 2 ^ k * n < ?y
2. ?y \<le> 2 ^ m proof (prove)
goal (1 subgoal):
1. 2 ^ k * n < 2 ^ k * 2 ^ (m - k) proof (state)
this:
2 ^ k * n < 2 ^ k * 2 ^ (m - k)
goal (1 subgoal):
1. 2 ^ k * 2 ^ (m - k) \<le> 2 ^ m proof (prove)
goal (1 subgoal):
1. 2 ^ k * 2 ^ (m - k) \<le> 2 ^ m proof (prove)
using this:
n < 2 ^ (m - k)
k \<le> m
goal (1 subgoal):
1. 2 ^ k * 2 ^ (m - k) \<le> 2 ^ m proof (state)
this:
2 ^ k * 2 ^ (m - k) \<le> 2 ^ m
goal:
No subgoals!
|
lemma nat_less_power_trans:
fixes n :: nat
assumes nv: "n < 2 ^ (m - k)"
and kv: "k \<le> m"
shows "2 ^ k * n < 2 ^ m"
|
unnamed_thy_8
|
More_Arithmetic
| 7
|
|
[] |
lemma nat_le_power_trans:
fixes n :: nat
shows "\<lbrakk>n \<le> 2 ^ (m - k); k \<le> m\<rbrakk> \<Longrightarrow> 2 ^ k * n \<le> 2 ^ m" by (metis le_add_diff_inverse mult_le_mono2 semiring_normalization_rules(26))
|
lemma nat_le_power_trans:
fixes n :: nat
shows "\<lbrakk>n \<le> 2 ^ (m - k); k \<le> m\<rbrakk> \<Longrightarrow> 2 ^ k * n \<le> 2 ^ m" by (metis le_add_diff_inverse mult_le_mono2 semiring_normalization_rules(26))
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>n \<le> 2 ^ (m - k); k \<le> m\<rbrakk> \<Longrightarrow> 2 ^ k * n \<le> 2 ^ m
|
lemma nat_le_power_trans:
fixes n :: nat
shows "\<lbrakk>n \<le> 2 ^ (m - k); k \<le> m\<rbrakk> \<Longrightarrow> 2 ^ k * n \<le> 2 ^ m"
|
unnamed_thy_9
|
More_Arithmetic
| 1
|
|
[] |
lemma nat_add_offset_less:
fixes x :: nat
assumes yv: "y < 2 ^ n"
and xv: "x < 2 ^ m"
and mn: "sz = m + n"
shows "x * 2 ^ n + y < 2 ^ sz" proof (subst mn) from yv obtain qy where "y + qy = 2 ^ n" and "0 < qy" by (auto dest: less_imp_add_positive) have "x * 2 ^ n + y < x * 2 ^ n + 2 ^ n" by simp fact+ also have "\<dots> = (x + 1) * 2 ^ n" by simp also have "\<dots> \<le> 2 ^ (m + n)" using xv by (subst power_add) (rule mult_le_mono1, simp) finally show "x * 2 ^ n + y < 2 ^ (m + n)" . qed
|
lemma nat_add_offset_less:
fixes x :: nat
assumes yv: "y < 2 ^ n"
and xv: "x < 2 ^ m"
and mn: "sz = m + n"
shows "x * 2 ^ n + y < 2 ^ sz" proof (subst mn) from yv obtain qy where "y + qy = 2 ^ n" and "0 < qy" by (auto dest: less_imp_add_positive) have "x * 2 ^ n + y < x * 2 ^ n + 2 ^ n" by simp fact+ also have "\<dots> = (x + 1) * 2 ^ n" by simp also have "\<dots> \<le> 2 ^ (m + n)" using xv by (subst power_add) (rule mult_le_mono1, simp) finally show "x * 2 ^ n + y < 2 ^ (m + n)" . qed
|
proof (prove)
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ sz proof (state)
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (chain)
picking this:
y < 2 ^ n proof (prove)
using this:
y < 2 ^ n
goal (1 subgoal):
1. (\<And>qy. \<lbrakk>y + qy = 2 ^ n; 0 < qy\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis proof (state)
this:
y + qy = 2 ^ n
0 < qy
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (prove)
goal (1 subgoal):
1. x * 2 ^ n + y < x * 2 ^ n + 2 ^ n proof (state)
this:
x * 2 ^ n + y < x * 2 ^ n + 2 ^ n
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (state)
this:
x * 2 ^ n + y < x * 2 ^ n + 2 ^ n
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (prove)
goal (1 subgoal):
1. x * 2 ^ n + 2 ^ n = (x + 1) * 2 ^ n proof (state)
this:
x * 2 ^ n + 2 ^ n = (x + 1) * 2 ^ n
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (state)
this:
x * 2 ^ n + 2 ^ n = (x + 1) * 2 ^ n
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (prove)
goal (1 subgoal):
1. (x + 1) * 2 ^ n \<le> 2 ^ (m + n) proof (prove)
using this:
x < 2 ^ m
goal (1 subgoal):
1. (x + 1) * 2 ^ n \<le> 2 ^ (m + n) proof (state)
this:
(x + 1) * 2 ^ n \<le> 2 ^ (m + n)
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (chain)
picking this:
x * 2 ^ n + y < 2 ^ (m + n) proof (prove)
using this:
x * 2 ^ n + y < 2 ^ (m + n)
goal (1 subgoal):
1. x * 2 ^ n + y < 2 ^ (m + n) proof (state)
this:
x * 2 ^ n + y < 2 ^ (m + n)
goal:
No subgoals!
|
lemma nat_add_offset_less:
fixes x :: nat
assumes yv: "y < 2 ^ n"
and xv: "x < 2 ^ m"
and mn: "sz = m + n"
shows "x * 2 ^ n + y < 2 ^ sz"
|
unnamed_thy_10
|
More_Arithmetic
| 17
|
|
[] |
lemma nat_power_less_diff:
assumes lt: "(2::nat) ^ n * q < 2 ^ m"
shows "q < 2 ^ (m - n)" using lt proof (induct n arbitrary: m) case 0 then show ?case by simp next case (Suc n) have ih: "\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n)"
and prem: "2 ^ Suc n * q < 2 ^ m" by fact+ show ?case proof (cases m) case 0 then show ?thesis using Suc by simp next case (Suc m') then show ?thesis using prem by (simp add: ac_simps ih) qed qed
|
lemma nat_power_less_diff:
assumes lt: "(2::nat) ^ n * q < 2 ^ m"
shows "q < 2 ^ (m - n)" using lt proof (induct n arbitrary: m) case 0 then show ?case by simp next case (Suc n) have ih: "\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n)"
and prem: "2 ^ Suc n * q < 2 ^ m" by fact+ show ?case proof (cases m) case 0 then show ?thesis using Suc by simp next case (Suc m') then show ?thesis using prem by (simp add: ac_simps ih) qed qed
|
proof (prove)
goal (1 subgoal):
1. q < 2 ^ (m - n) proof (prove)
using this:
2 ^ n * q < 2 ^ m
goal (1 subgoal):
1. q < 2 ^ (m - n) proof (state)
goal (2 subgoals):
1. \<And>m. 2 ^ 0 * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - 0)
2. \<And>n m. \<lbrakk>\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n); 2 ^ Suc n * q < 2 ^ m\<rbrakk> \<Longrightarrow> q < 2 ^ (m - Suc n) proof (state)
this:
2 ^ 0 * q < 2 ^ m
goal (2 subgoals):
1. \<And>m. 2 ^ 0 * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - 0)
2. \<And>n m. \<lbrakk>\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n); 2 ^ Suc n * q < 2 ^ m\<rbrakk> \<Longrightarrow> q < 2 ^ (m - Suc n) proof (chain)
picking this:
2 ^ 0 * q < 2 ^ m proof (prove)
using this:
2 ^ 0 * q < 2 ^ m
goal (1 subgoal):
1. q < 2 ^ (m - 0) proof (state)
this:
q < 2 ^ (m - 0)
goal (1 subgoal):
1. \<And>n m. \<lbrakk>\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n); 2 ^ Suc n * q < 2 ^ m\<rbrakk> \<Longrightarrow> q < 2 ^ (m - Suc n) proof (state)
goal (1 subgoal):
1. \<And>n m. \<lbrakk>\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n); 2 ^ Suc n * q < 2 ^ m\<rbrakk> \<Longrightarrow> q < 2 ^ (m - Suc n) proof (state)
this:
2 ^ n * q < 2 ^ ?m \<Longrightarrow> q < 2 ^ (?m - n)
2 ^ Suc n * q < 2 ^ m
goal (1 subgoal):
1. \<And>n m. \<lbrakk>\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n); 2 ^ Suc n * q < 2 ^ m\<rbrakk> \<Longrightarrow> q < 2 ^ (m - Suc n) proof (prove)
goal (1 subgoal):
1. (\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n)) &&& 2 ^ Suc n * q < 2 ^ m proof (state)
this:
2 ^ n * q < 2 ^ ?m \<Longrightarrow> q < 2 ^ (?m - n)
2 ^ Suc n * q < 2 ^ m
goal (1 subgoal):
1. \<And>n m. \<lbrakk>\<And>m. 2 ^ n * q < 2 ^ m \<Longrightarrow> q < 2 ^ (m - n); 2 ^ Suc n * q < 2 ^ m\<rbrakk> \<Longrightarrow> q < 2 ^ (m - Suc n) proof (prove)
goal (1 subgoal):
1. q < 2 ^ (m - Suc n) proof (state)
goal (2 subgoals):
1. m = 0 \<Longrightarrow> q < 2 ^ (m - Suc n)
2. \<And>nat. m = Suc nat \<Longrightarrow> q < 2 ^ (m - Suc n) proof (state)
this:
m = 0
goal (2 subgoals):
1. m = 0 \<Longrightarrow> q < 2 ^ (m - Suc n)
2. \<And>nat. m = Suc nat \<Longrightarrow> q < 2 ^ (m - Suc n) proof (chain)
picking this:
m = 0 proof (prove)
using this:
m = 0
goal (1 subgoal):
1. q < 2 ^ (m - Suc n) proof (prove)
using this:
m = 0
2 ^ n * q < 2 ^ ?m \<Longrightarrow> q < 2 ^ (?m - n)
2 ^ Suc n * q < 2 ^ m
goal (1 subgoal):
1. q < 2 ^ (m - Suc n) proof (state)
this:
q < 2 ^ (m - Suc n)
goal (1 subgoal):
1. \<And>nat. m = Suc nat \<Longrightarrow> q < 2 ^ (m - Suc n) proof (state)
goal (1 subgoal):
1. \<And>nat. m = Suc nat \<Longrightarrow> q < 2 ^ (m - Suc n) proof (state)
this:
m = Suc m'
goal (1 subgoal):
1. \<And>nat. m = Suc nat \<Longrightarrow> q < 2 ^ (m - Suc n) proof (chain)
picking this:
m = Suc m' proof (prove)
using this:
m = Suc m'
goal (1 subgoal):
1. q < 2 ^ (m - Suc n) proof (prove)
using this:
m = Suc m'
2 ^ Suc n * q < 2 ^ m
goal (1 subgoal):
1. q < 2 ^ (m - Suc n) proof (state)
this:
q < 2 ^ (m - Suc n)
goal:
No subgoals! proof (state)
this:
q < 2 ^ (m - Suc n)
goal:
No subgoals!
|
lemma nat_power_less_diff:
assumes lt: "(2::nat) ^ n * q < 2 ^ m"
shows "q < 2 ^ (m - n)"
|
unnamed_thy_11
|
More_Arithmetic
| 25
|
|
[] |
lemma power_2_mult_step_le:
"\<lbrakk>n' \<le> n; 2 ^ n' * k' < 2 ^ n * k\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * (k::nat)" apply (cases "n'=n", simp) apply (metis Suc_leI le_refl mult_Suc_right mult_le_mono semiring_normalization_rules(7)) apply (drule (1) le_neq_trans) apply clarsimp apply (subgoal_tac "\<exists>m. n = n' + m") prefer 2 apply (simp add: le_Suc_ex) apply (clarsimp simp: power_add) apply (metis Suc_leI mult.assoc mult_Suc_right nat_mult_le_cancel_disj) done
|
lemma power_2_mult_step_le:
"\<lbrakk>n' \<le> n; 2 ^ n' * k' < 2 ^ n * k\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * (k::nat)" apply (cases "n'=n", simp) apply (metis Suc_leI le_refl mult_Suc_right mult_le_mono semiring_normalization_rules(7)) apply (drule (1) le_neq_trans) apply clarsimp apply (subgoal_tac "\<exists>m. n = n' + m") prefer 2 apply (simp add: le_Suc_ex) apply (clarsimp simp: power_add) apply (metis Suc_leI mult.assoc mult_Suc_right nat_mult_le_cancel_disj) done
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>n' \<le> n; 2 ^ n' * k' < 2 ^ n * k\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * k proof (prove)
goal (2 subgoals):
1. \<lbrakk>k' < k; n' = n\<rbrakk> \<Longrightarrow> 2 ^ n + 2 ^ n * k' \<le> 2 ^ n * k
2. \<lbrakk>n' \<le> n; 2 ^ n' * k' < 2 ^ n * k; n' \<noteq> n\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * k proof (prove)
goal (1 subgoal):
1. \<lbrakk>n' \<le> n; 2 ^ n' * k' < 2 ^ n * k; n' \<noteq> n\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * k proof (prove)
goal (1 subgoal):
1. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' \<noteq> n; n' < n\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * k proof (prove)
goal (1 subgoal):
1. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' < n\<rbrakk> \<Longrightarrow> 2 ^ n' + 2 ^ n' * k' \<le> 2 ^ n * k proof (prove)
goal (2 subgoals):
1. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' < n; \<exists>m. n = n' + m\<rbrakk> \<Longrightarrow> 2 ^ n' + 2 ^ n' * k' \<le> 2 ^ n * k
2. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' < n\<rbrakk> \<Longrightarrow> \<exists>m. n = n' + m proof (prove)
goal (2 subgoals):
1. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' < n\<rbrakk> \<Longrightarrow> \<exists>m. n = n' + m
2. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' < n; \<exists>m. n = n' + m\<rbrakk> \<Longrightarrow> 2 ^ n' + 2 ^ n' * k' \<le> 2 ^ n * k proof (prove)
goal (1 subgoal):
1. \<lbrakk>2 ^ n' * k' < 2 ^ n * k; n' < n; \<exists>m. n = n' + m\<rbrakk> \<Longrightarrow> 2 ^ n' + 2 ^ n' * k' \<le> 2 ^ n * k proof (prove)
goal (1 subgoal):
1. \<And>m. \<lbrakk>k' < 2 ^ m * k; 0 < m; n = n' + m\<rbrakk> \<Longrightarrow> 2 ^ n' + 2 ^ n' * k' \<le> 2 ^ n' * 2 ^ m * k proof (prove)
goal:
No subgoals!
|
lemma power_2_mult_step_le:
"\<lbrakk>n' \<le> n; 2 ^ n' * k' < 2 ^ n * k\<rbrakk> \<Longrightarrow> 2 ^ n' * (k' + 1) \<le> 2 ^ n * (k::nat)"
|
unnamed_thy_12
|
More_Arithmetic
| 10
|
|
[] |
lemma nat_mult_power_less_eq:
"b > 0 \<Longrightarrow> (a * b ^ n < (b :: nat) ^ m) = (a < b ^ (m - n))" using mult_less_cancel2[where m = a and k = "b ^ n" and n="b ^ (m - n)"]
mult_less_cancel2[where m="a * b ^ (n - m)" and k="b ^ m" and n=1] apply (simp only: power_add[symmetric] nat_minus_add_max) apply (simp only: power_add[symmetric] nat_minus_add_max ac_simps) apply (simp add: max_def split: if_split_asm) done
|
lemma nat_mult_power_less_eq:
"b > 0 \<Longrightarrow> (a * b ^ n < (b :: nat) ^ m) = (a < b ^ (m - n))" using mult_less_cancel2[where m = a and k = "b ^ n" and n="b ^ (m - n)"]
mult_less_cancel2[where m="a * b ^ (n - m)" and k="b ^ m" and n=1] apply (simp only: power_add[symmetric] nat_minus_add_max) apply (simp only: power_add[symmetric] nat_minus_add_max ac_simps) apply (simp add: max_def split: if_split_asm) done
|
proof (prove)
goal (1 subgoal):
1. 0 < b \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n)) proof (prove)
using this:
(a * b ^ n < b ^ (m - n) * b ^ n) = (0 < b ^ n \<and> a < b ^ (m - n))
(a * b ^ (n - m) * b ^ m < 1 * b ^ m) = (0 < b ^ m \<and> a * b ^ (n - m) < 1)
goal (1 subgoal):
1. 0 < b \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n)) proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 < b; (a * b ^ n < b ^ max m n) = (0 < b ^ n \<and> a < b ^ (m - n)); (a * b ^ (n - m) * b ^ m < 1 * b ^ m) = (0 < b ^ m \<and> a * b ^ (n - m) < 1)\<rbrakk> \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n)) proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 < b; (a * b ^ n < b ^ max m n) = (0 < b ^ n \<and> a < b ^ (m - n)); (a * b ^ (m + (n - m)) < 1 * b ^ m) = (0 < b ^ m \<and> a * b ^ (n - m) < 1)\<rbrakk> \<Longrightarrow> (a * b ^ n < b ^ m) = (a < b ^ (m - n)) proof (prove)
goal:
No subgoals!
|
lemma nat_mult_power_less_eq:
"b > 0 \<Longrightarrow> (a * b ^ n < (b :: nat) ^ m) = (a < b ^ (m - n))"
|
unnamed_thy_13
|
More_Arithmetic
| 5
|
|
[] |
lemma diff_diff_less:
"(i < m - (m - (n :: nat))) = (i < m \<and> i < n)" by auto
|
lemma diff_diff_less:
"(i < m - (m - (n :: nat))) = (i < m \<and> i < n)" by auto
|
proof (prove)
goal (1 subgoal):
1. (i < m - (m - n)) = (i < m \<and> i < n)
|
lemma diff_diff_less:
"(i < m - (m - (n :: nat))) = (i < m \<and> i < n)"
|
unnamed_thy_14
|
More_Arithmetic
| 1
|
|
[] |
lemma small_powers_of_2:
\<open>x < 2 ^ (x - 1)\<close> if \<open>x \<ge> 3\<close> for x :: nat proof - define m where \<open>m = x - 3\<close> with that have \<open>x = m + 3\<close> by simp moreover have \<open>m + 3 < 4 * 2 ^ m\<close> by (induction m) simp_all ultimately show ?thesis by simp qed
|
lemma small_powers_of_2:
\<open>x < 2 ^ (x - 1)\<close> if \<open>x \<ge> 3\<close> for x :: nat proof - define m where \<open>m = x - 3\<close> with that have \<open>x = m + 3\<close> by simp moreover have \<open>m + 3 < 4 * 2 ^ m\<close> by (induction m) simp_all ultimately show ?thesis by simp qed
|
proof (prove)
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (state)
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (state)
this:
m = x - 3
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (chain)
picking this:
3 \<le> x
m = x - 3 proof (prove)
using this:
3 \<le> x
m = x - 3
goal (1 subgoal):
1. x = m + 3 proof (state)
this:
x = m + 3
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (state)
this:
x = m + 3
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (prove)
goal (1 subgoal):
1. m + 3 < 4 * 2 ^ m proof (state)
this:
m + 3 < 4 * 2 ^ m
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (chain)
picking this:
x = m + 3
m + 3 < 4 * 2 ^ m proof (prove)
using this:
x = m + 3
m + 3 < 4 * 2 ^ m
goal (1 subgoal):
1. x < 2 ^ (x - 1) proof (state)
this:
x < 2 ^ (x - 1)
goal:
No subgoals!
|
lemma small_powers_of_2:
\<open>x < 2 ^ (x - 1)\<close> if \<open>x \<ge> 3\<close> for x :: nat
|
unnamed_thy_15
|
More_Arithmetic
| 12
|
|
[] |
lemma msrevs:
"0 < n \<Longrightarrow> (k * n + m) div n = m div n + k"
"(k * n + m) mod n = m mod n"
for n :: nat by simp_all
|
lemma msrevs:
"0 < n \<Longrightarrow> (k * n + m) div n = m div n + k"
"(k * n + m) mod n = m mod n"
for n :: nat by simp_all
|
proof (prove)
goal (1 subgoal):
1. (0 < n \<Longrightarrow> (k * n + m) div n = m div n + k) &&& (k * n + m) mod n = m mod n
|
lemma msrevs:
"0 < n \<Longrightarrow> (k * n + m) div n = m div n + k"
"(k * n + m) mod n = m mod n"
for n :: nat
|
unnamed_thy_16
|
More_Arithmetic
| 1
|
|
[] |
lemma int_div_same_is_1 [simp]:
\<open>a div b = a \<longleftrightarrow> b = 1\<close> if \<open>0 < a\<close> for a b :: int using that by (metis div_by_1 abs_ge_zero abs_of_pos int_div_less_self neq_iff
nonneg1_imp_zdiv_pos_iff zabs_less_one_iff)
|
lemma int_div_same_is_1 [simp]:
\<open>a div b = a \<longleftrightarrow> b = 1\<close> if \<open>0 < a\<close> for a b :: int using that by (metis div_by_1 abs_ge_zero abs_of_pos int_div_less_self neq_iff
nonneg1_imp_zdiv_pos_iff zabs_less_one_iff)
|
proof (prove)
goal (1 subgoal):
1. (a div b = a) = (b = 1) proof (prove)
using this:
0 < a
goal (1 subgoal):
1. (a div b = a) = (b = 1)
|
lemma int_div_same_is_1 [simp]:
\<open>a div b = a \<longleftrightarrow> b = 1\<close> if \<open>0 < a\<close> for a b :: int
|
unnamed_thy_17
|
More_Divides
| 2
|
|
[] |
lemma int_div_minus_is_minus1 [simp]:
\<open>a div b = - a \<longleftrightarrow> b = - 1\<close> if \<open>0 > a\<close> for a b :: int using that by (metis div_minus_right equation_minus_iff int_div_same_is_1 neg_0_less_iff_less)
|
lemma int_div_minus_is_minus1 [simp]:
\<open>a div b = - a \<longleftrightarrow> b = - 1\<close> if \<open>0 > a\<close> for a b :: int using that by (metis div_minus_right equation_minus_iff int_div_same_is_1 neg_0_less_iff_less)
|
proof (prove)
goal (1 subgoal):
1. (a div b = - a) = (b = - 1) proof (prove)
using this:
a < 0
goal (1 subgoal):
1. (a div b = - a) = (b = - 1)
|
lemma int_div_minus_is_minus1 [simp]:
\<open>a div b = - a \<longleftrightarrow> b = - 1\<close> if \<open>0 > a\<close> for a b :: int
|
unnamed_thy_18
|
More_Divides
| 2
|
|
[] |
lemma nat_div_eq_Suc_0_iff: "n div m = Suc 0 \<longleftrightarrow> m \<le> n \<and> n < 2 * m" apply auto using div_greater_zero_iff apply fastforce apply (metis One_nat_def div_greater_zero_iff dividend_less_div_times mult.right_neutral mult_Suc mult_numeral_1 numeral_2_eq_2 zero_less_numeral) apply (simp add: div_nat_eqI) done
|
lemma nat_div_eq_Suc_0_iff: "n div m = Suc 0 \<longleftrightarrow> m \<le> n \<and> n < 2 * m" apply auto using div_greater_zero_iff apply fastforce apply (metis One_nat_def div_greater_zero_iff dividend_less_div_times mult.right_neutral mult_Suc mult_numeral_1 numeral_2_eq_2 zero_less_numeral) apply (simp add: div_nat_eqI) done
|
proof (prove)
goal (1 subgoal):
1. (n div m = Suc 0) = (m \<le> n \<and> n < 2 * m) proof (prove)
goal (3 subgoals):
1. n div m = Suc 0 \<Longrightarrow> m \<le> n
2. n div m = Suc 0 \<Longrightarrow> n < 2 * m
3. \<lbrakk>m \<le> n; n < 2 * m\<rbrakk> \<Longrightarrow> n div m = Suc 0 proof (prove)
using this:
(0 < ?m div ?n) = (?n \<le> ?m \<and> 0 < ?n)
goal (3 subgoals):
1. n div m = Suc 0 \<Longrightarrow> m \<le> n
2. n div m = Suc 0 \<Longrightarrow> n < 2 * m
3. \<lbrakk>m \<le> n; n < 2 * m\<rbrakk> \<Longrightarrow> n div m = Suc 0 proof (prove)
goal (2 subgoals):
1. n div m = Suc 0 \<Longrightarrow> n < 2 * m
2. \<lbrakk>m \<le> n; n < 2 * m\<rbrakk> \<Longrightarrow> n div m = Suc 0 proof (prove)
goal (1 subgoal):
1. \<lbrakk>m \<le> n; n < 2 * m\<rbrakk> \<Longrightarrow> n div m = Suc 0 proof (prove)
goal:
No subgoals!
|
lemma nat_div_eq_Suc_0_iff: "n div m = Suc 0 \<longleftrightarrow> m \<le> n \<and> n < 2 * m"
|
unnamed_thy_19
|
More_Divides
| 6
|
|
[] |
lemma diff_mod_le:
\<open>a - a mod b \<le> d - b\<close> if \<open>a < d\<close> \<open>b dvd d\<close> for a b d :: nat using that apply(subst minus_mod_eq_mult_div) apply(clarsimp simp: dvd_def) apply(cases \<open>b = 0\<close>) apply simp apply(subgoal_tac "a div b \<le> k - 1") prefer 2 apply(subgoal_tac "a div b < k") apply(simp add: less_Suc_eq_le [symmetric]) apply(subgoal_tac "b * (a div b) < b * ((b * k) div b)") apply clarsimp apply(subst div_mult_self1_is_m) apply arith apply(rule le_less_trans) apply simp apply(subst mult.commute) apply(rule div_times_less_eq_dividend) apply assumption apply clarsimp apply(subgoal_tac "b * (a div b) \<le> b * (k - 1)") apply(erule le_trans) apply(simp add: diff_mult_distrib2) apply simp done
|
lemma diff_mod_le:
\<open>a - a mod b \<le> d - b\<close> if \<open>a < d\<close> \<open>b dvd d\<close> for a b d :: nat using that apply(subst minus_mod_eq_mult_div) apply(clarsimp simp: dvd_def) apply(cases \<open>b = 0\<close>) apply simp apply(subgoal_tac "a div b \<le> k - 1") prefer 2 apply(subgoal_tac "a div b < k") apply(simp add: less_Suc_eq_le [symmetric]) apply(subgoal_tac "b * (a div b) < b * ((b * k) div b)") apply clarsimp apply(subst div_mult_self1_is_m) apply arith apply(rule le_less_trans) apply simp apply(subst mult.commute) apply(rule div_times_less_eq_dividend) apply assumption apply clarsimp apply(subgoal_tac "b * (a div b) \<le> b * (k - 1)") apply(erule le_trans) apply(simp add: diff_mult_distrib2) apply simp done
|
proof (prove)
goal (1 subgoal):
1. a - a mod b \<le> d - b proof (prove)
using this:
a < d
b dvd d
goal (1 subgoal):
1. a - a mod b \<le> d - b proof (prove)
goal (1 subgoal):
1. \<lbrakk>a < d; b dvd d\<rbrakk> \<Longrightarrow> b * (a div b) \<le> d - b proof (prove)
goal (1 subgoal):
1. \<And>k. \<lbrakk>a < b * k; d = b * k\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b = 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (1 subgoal):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> a div b \<le> k - 1 proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> a div b \<le> k - 1
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (3 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b < k\<rbrakk> \<Longrightarrow> a div b \<le> k - 1
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> a div b < k
3. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> a div b < k
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (3 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; b * (a div b) < b * (b * k div b)\<rbrakk> \<Longrightarrow> a div b < k
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) < b * (b * k div b)
3. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) < b * (b * k div b)
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (3 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> 0 < b
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) < b * k
3. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) < b * k
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (3 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> ?y17 k
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> ?y17 k < b * k
3. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (3 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b\<rbrakk> \<Longrightarrow> b * (a div b) \<le> ?y17 k
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> ?y17 k < b * k
3. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (3 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b\<rbrakk> \<Longrightarrow> a div b * b \<le> ?y21 k (?k21 k)
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> ?y21 k (?k21 k) < b * k
3. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0\<rbrakk> \<Longrightarrow> a < b * k
2. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (1 subgoal):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; b \<noteq> 0; a div b \<le> k - 1\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (1 subgoal):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b; a div b \<le> k - Suc 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b; a div b \<le> k - Suc 0; b * (a div b) \<le> b * (k - 1)\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * k - b
2. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b; a div b \<le> k - Suc 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * (k - 1) proof (prove)
goal (2 subgoals):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b; a div b \<le> k - Suc 0\<rbrakk> \<Longrightarrow> b * (k - 1) \<le> b * k - b
2. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b; a div b \<le> k - Suc 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * (k - 1) proof (prove)
goal (1 subgoal):
1. \<And>k. \<lbrakk>a < b * k; d = b * k; 0 < b; a div b \<le> k - Suc 0\<rbrakk> \<Longrightarrow> b * (a div b) \<le> b * (k - 1) proof (prove)
goal:
No subgoals!
|
lemma diff_mod_le:
\<open>a - a mod b \<le> d - b\<close> if \<open>a < d\<close> \<open>b dvd d\<close> for a b d :: nat
|
unnamed_thy_20
|
More_Divides
| 24
|
|
[] |
lemma one_mod_exp_eq_one [simp]:
"1 mod (2 * 2 ^ n) = (1::int)" using power_gt1 [of 2 n] by (auto intro: mod_pos_pos_trivial)
|
lemma one_mod_exp_eq_one [simp]:
"1 mod (2 * 2 ^ n) = (1::int)" using power_gt1 [of 2 n] by (auto intro: mod_pos_pos_trivial)
|
proof (prove)
goal (1 subgoal):
1. 1 mod (2 * 2 ^ n) = 1 proof (prove)
using this:
(1::?'a1) < (2::?'a1) \<Longrightarrow> (1::?'a1) < (2::?'a1) ^ Suc n
goal (1 subgoal):
1. 1 mod (2 * 2 ^ n) = 1
|
lemma one_mod_exp_eq_one [simp]:
"1 mod (2 * 2 ^ n) = (1::int)"
|
unnamed_thy_21
|
More_Divides
| 2
|
|
[] |
lemma int_mod_lem: "0 < n \<Longrightarrow> 0 \<le> b \<and> b < n \<longleftrightarrow> b mod n = b"
for b n :: int apply safe apply (erule (1) mod_pos_pos_trivial) apply (erule_tac [!] subst) apply auto done
|
lemma int_mod_lem: "0 < n \<Longrightarrow> 0 \<le> b \<and> b < n \<longleftrightarrow> b mod n = b"
for b n :: int apply safe apply (erule (1) mod_pos_pos_trivial) apply (erule_tac [!] subst) apply auto done
|
proof (prove)
goal (1 subgoal):
1. 0 < n \<Longrightarrow> (0 \<le> b \<and> b < n) = (b mod n = b) proof (prove)
goal (3 subgoals):
1. \<lbrakk>0 < n; 0 \<le> b; b < n\<rbrakk> \<Longrightarrow> b mod n = b
2. \<lbrakk>0 < n; b mod n = b\<rbrakk> \<Longrightarrow> 0 \<le> b
3. \<lbrakk>0 < n; b mod n = b\<rbrakk> \<Longrightarrow> b < n proof (prove)
goal (2 subgoals):
1. \<lbrakk>0 < n; b mod n = b\<rbrakk> \<Longrightarrow> 0 \<le> b
2. \<lbrakk>0 < n; b mod n = b\<rbrakk> \<Longrightarrow> b < n proof (prove)
goal (2 subgoals):
1. 0 < n \<Longrightarrow> 0 \<le> b mod n
2. 0 < n \<Longrightarrow> b mod n < n proof (prove)
goal:
No subgoals!
|
lemma int_mod_lem: "0 < n \<Longrightarrow> 0 \<le> b \<and> b < n \<longleftrightarrow> b mod n = b"
for b n :: int
|
unnamed_thy_22
|
More_Divides
| 5
|
|
[] |
lemma int_mod_ge': "b < 0 \<Longrightarrow> 0 < n \<Longrightarrow> b + n \<le> b mod n"
for b n :: int by (metis add_less_same_cancel2 int_mod_ge mod_add_self2)
|
lemma int_mod_ge': "b < 0 \<Longrightarrow> 0 < n \<Longrightarrow> b + n \<le> b mod n"
for b n :: int by (metis add_less_same_cancel2 int_mod_ge mod_add_self2)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>b < 0; 0 < n\<rbrakk> \<Longrightarrow> b + n \<le> b mod n
|
lemma int_mod_ge': "b < 0 \<Longrightarrow> 0 < n \<Longrightarrow> b + n \<le> b mod n"
for b n :: int
|
unnamed_thy_23
|
More_Divides
| 1
|
|
[] |
lemma int_mod_le': "0 \<le> b - n \<Longrightarrow> b mod n \<le> b - n"
for b n :: int by (metis minus_mod_self2 zmod_le_nonneg_dividend)
|
lemma int_mod_le': "0 \<le> b - n \<Longrightarrow> b mod n \<le> b - n"
for b n :: int by (metis minus_mod_self2 zmod_le_nonneg_dividend)
|
proof (prove)
goal (1 subgoal):
1. 0 \<le> b - n \<Longrightarrow> b mod n \<le> b - n
|
lemma int_mod_le': "0 \<le> b - n \<Longrightarrow> b mod n \<le> b - n"
for b n :: int
|
unnamed_thy_24
|
More_Divides
| 1
|
|
[] |
lemma emep1: "even n \<Longrightarrow> even d \<Longrightarrow> 0 \<le> d \<Longrightarrow> (n + 1) mod d = (n mod d) + 1"
for n d :: int by (auto simp add: pos_zmod_mult_2 add.commute dvd_def)
|
lemma emep1: "even n \<Longrightarrow> even d \<Longrightarrow> 0 \<le> d \<Longrightarrow> (n + 1) mod d = (n mod d) + 1"
for n d :: int by (auto simp add: pos_zmod_mult_2 add.commute dvd_def)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>even n; even d; 0 \<le> d\<rbrakk> \<Longrightarrow> (n + 1) mod d = n mod d + 1
|
lemma emep1: "even n \<Longrightarrow> even d \<Longrightarrow> 0 \<le> d \<Longrightarrow> (n + 1) mod d = (n mod d) + 1"
for n d :: int
|
unnamed_thy_25
|
More_Divides
| 1
|
|
[] |
lemma m1mod2k: "- 1 mod 2 ^ n = (2 ^ n - 1 :: int)" by (rule zmod_minus1) simp
|
lemma m1mod2k: "- 1 mod 2 ^ n = (2 ^ n - 1 :: int)" by (rule zmod_minus1) simp
|
proof (prove)
goal (1 subgoal):
1. - 1 mod 2 ^ n = 2 ^ n - 1
|
lemma m1mod2k: "- 1 mod 2 ^ n = (2 ^ n - 1 :: int)"
|
unnamed_thy_26
|
More_Divides
| 1
|
|
[] |
lemma sb_inc_lem: "a + 2^k < 0 \<Longrightarrow> a + 2^k + 2^(Suc k) \<le> (a + 2^k) mod 2^(Suc k)"
for a :: int using int_mod_ge' [where n = "2 ^ (Suc k)" and b = "a + 2 ^ k"] by simp
|
lemma sb_inc_lem: "a + 2^k < 0 \<Longrightarrow> a + 2^k + 2^(Suc k) \<le> (a + 2^k) mod 2^(Suc k)"
for a :: int using int_mod_ge' [where n = "2 ^ (Suc k)" and b = "a + 2 ^ k"] by simp
|
proof (prove)
goal (1 subgoal):
1. a + 2 ^ k < 0 \<Longrightarrow> a + 2 ^ k + 2 ^ Suc k \<le> (a + 2 ^ k) mod 2 ^ Suc k proof (prove)
using this:
\<lbrakk>a + 2 ^ k < 0; 0 < 2 ^ Suc k\<rbrakk> \<Longrightarrow> a + 2 ^ k + 2 ^ Suc k \<le> (a + 2 ^ k) mod 2 ^ Suc k
goal (1 subgoal):
1. a + 2 ^ k < 0 \<Longrightarrow> a + 2 ^ k + 2 ^ Suc k \<le> (a + 2 ^ k) mod 2 ^ Suc k
|
lemma sb_inc_lem: "a + 2^k < 0 \<Longrightarrow> a + 2^k + 2^(Suc k) \<le> (a + 2^k) mod 2^(Suc k)"
for a :: int
|
unnamed_thy_27
|
More_Divides
| 2
|
|
[] |
lemma sb_inc_lem': "a < - (2^k) \<Longrightarrow> a + 2^k + 2^(Suc k) \<le> (a + 2^k) mod 2^(Suc k)"
for a :: int by (rule sb_inc_lem) simp
|
lemma sb_inc_lem': "a < - (2^k) \<Longrightarrow> a + 2^k + 2^(Suc k) \<le> (a + 2^k) mod 2^(Suc k)"
for a :: int by (rule sb_inc_lem) simp
|
proof (prove)
goal (1 subgoal):
1. a < - (2 ^ k) \<Longrightarrow> a + 2 ^ k + 2 ^ Suc k \<le> (a + 2 ^ k) mod 2 ^ Suc k
|
lemma sb_inc_lem': "a < - (2^k) \<Longrightarrow> a + 2^k + 2^(Suc k) \<le> (a + 2^k) mod 2^(Suc k)"
for a :: int
|
unnamed_thy_28
|
More_Divides
| 1
|
|
[] |
lemma sb_dec_lem: "0 \<le> - (2 ^ k) + a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a"
for a :: int using int_mod_le'[where n = "2 ^ (Suc k)" and b = "a + 2 ^ k"] by simp
|
lemma sb_dec_lem: "0 \<le> - (2 ^ k) + a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a"
for a :: int using int_mod_le'[where n = "2 ^ (Suc k)" and b = "a + 2 ^ k"] by simp
|
proof (prove)
goal (1 subgoal):
1. 0 \<le> - (2 ^ k) + a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a proof (prove)
using this:
0 \<le> a + 2 ^ k - 2 ^ Suc k \<Longrightarrow> (a + 2 ^ k) mod 2 ^ Suc k \<le> a + 2 ^ k - 2 ^ Suc k
goal (1 subgoal):
1. 0 \<le> - (2 ^ k) + a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a
|
lemma sb_dec_lem: "0 \<le> - (2 ^ k) + a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a"
for a :: int
|
unnamed_thy_29
|
More_Divides
| 2
|
|
[] |
lemma sb_dec_lem': "2 ^ k \<le> a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a"
for a :: int by (rule sb_dec_lem) simp
|
lemma sb_dec_lem': "2 ^ k \<le> a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a"
for a :: int by (rule sb_dec_lem) simp
|
proof (prove)
goal (1 subgoal):
1. 2 ^ k \<le> a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a
|
lemma sb_dec_lem': "2 ^ k \<le> a \<Longrightarrow> (a + 2 ^ k) mod (2 * 2 ^ k) \<le> - (2 ^ k) + a"
for a :: int
|
unnamed_thy_30
|
More_Divides
| 1
|
|
[] |
lemma mod_2_neq_1_eq_eq_0: "k mod 2 \<noteq> 1 \<longleftrightarrow> k mod 2 = 0"
for k :: int by (fact not_mod_2_eq_1_eq_0)
|
lemma mod_2_neq_1_eq_eq_0: "k mod 2 \<noteq> 1 \<longleftrightarrow> k mod 2 = 0"
for k :: int by (fact not_mod_2_eq_1_eq_0)
|
proof (prove)
goal (1 subgoal):
1. (k mod 2 \<noteq> 1) = (k mod 2 = 0)
|
lemma mod_2_neq_1_eq_eq_0: "k mod 2 \<noteq> 1 \<longleftrightarrow> k mod 2 = 0"
for k :: int
|
unnamed_thy_31
|
More_Divides
| 1
|
|
[] |
lemma z1pmod2: "(2 * b + 1) mod 2 = (1::int)"
for b :: int by arith
|
lemma z1pmod2: "(2 * b + 1) mod 2 = (1::int)"
for b :: int by arith
|
proof (prove)
goal (1 subgoal):
1. (2 * b + 1) mod 2 = 1
|
lemma z1pmod2: "(2 * b + 1) mod 2 = (1::int)"
for b :: int
|
unnamed_thy_32
|
More_Divides
| 1
|
|
[] |
lemma p1mod22k': "(1 + 2 * b) mod (2 * 2 ^ n) = 1 + 2 * (b mod 2 ^ n)"
for b :: int by (rule pos_zmod_mult_2) simp
|
lemma p1mod22k': "(1 + 2 * b) mod (2 * 2 ^ n) = 1 + 2 * (b mod 2 ^ n)"
for b :: int by (rule pos_zmod_mult_2) simp
|
proof (prove)
goal (1 subgoal):
1. (1 + 2 * b) mod (2 * 2 ^ n) = 1 + 2 * (b mod 2 ^ n)
|
lemma p1mod22k': "(1 + 2 * b) mod (2 * 2 ^ n) = 1 + 2 * (b mod 2 ^ n)"
for b :: int
|
unnamed_thy_33
|
More_Divides
| 1
|
|
[] |
lemma p1mod22k: "(2 * b + 1) mod (2 * 2 ^ n) = 2 * (b mod 2 ^ n) + 1"
for b :: int by (simp add: p1mod22k' add.commute)
|
lemma p1mod22k: "(2 * b + 1) mod (2 * 2 ^ n) = 2 * (b mod 2 ^ n) + 1"
for b :: int by (simp add: p1mod22k' add.commute)
|
proof (prove)
goal (1 subgoal):
1. (2 * b + 1) mod (2 * 2 ^ n) = 2 * (b mod 2 ^ n) + 1
|
lemma p1mod22k: "(2 * b + 1) mod (2 * 2 ^ n) = 2 * (b mod 2 ^ n) + 1"
for b :: int
|
unnamed_thy_34
|
More_Divides
| 1
|
|
[] |
lemma pos_mod_sign2:
\<open>0 \<le> a mod 2\<close> for a :: int by simp
|
lemma pos_mod_sign2:
\<open>0 \<le> a mod 2\<close> for a :: int by simp
|
proof (prove)
goal (1 subgoal):
1. 0 \<le> a mod 2
|
lemma pos_mod_sign2:
\<open>0 \<le> a mod 2\<close> for a :: int
|
unnamed_thy_35
|
More_Divides
| 1
|
|
[] |
lemma pos_mod_bound2:
\<open>a mod 2 < 2\<close> for a :: int by simp
|
lemma pos_mod_bound2:
\<open>a mod 2 < 2\<close> for a :: int by simp
|
proof (prove)
goal (1 subgoal):
1. a mod 2 < 2
|
lemma pos_mod_bound2:
\<open>a mod 2 < 2\<close> for a :: int
|
unnamed_thy_36
|
More_Divides
| 1
|
|
[] |
lemma nmod2: "n mod 2 = 0 \<or> n mod 2 = 1"
for n :: int by arith
|
lemma nmod2: "n mod 2 = 0 \<or> n mod 2 = 1"
for n :: int by arith
|
proof (prove)
goal (1 subgoal):
1. n mod 2 = 0 \<or> n mod 2 = 1
|
lemma nmod2: "n mod 2 = 0 \<or> n mod 2 = 1"
for n :: int
|
unnamed_thy_37
|
More_Divides
| 1
|
|
[] |
lemma eme1p:
"even n \<Longrightarrow> even d \<Longrightarrow> 0 \<le> d \<Longrightarrow> (1 + n) mod d = 1 + n mod d" for n d :: int using emep1 [of n d] by (simp add: ac_simps)
|
lemma eme1p:
"even n \<Longrightarrow> even d \<Longrightarrow> 0 \<le> d \<Longrightarrow> (1 + n) mod d = 1 + n mod d" for n d :: int using emep1 [of n d] by (simp add: ac_simps)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>even n; even d; 0 \<le> d\<rbrakk> \<Longrightarrow> (1 + n) mod d = 1 + n mod d proof (prove)
using this:
\<lbrakk>even n; even d; 0 \<le> d\<rbrakk> \<Longrightarrow> (n + 1) mod d = n mod d + 1
goal (1 subgoal):
1. \<lbrakk>even n; even d; 0 \<le> d\<rbrakk> \<Longrightarrow> (1 + n) mod d = 1 + n mod d
|
lemma eme1p:
"even n \<Longrightarrow> even d \<Longrightarrow> 0 \<le> d \<Longrightarrow> (1 + n) mod d = 1 + n mod d" for n d :: int
|
unnamed_thy_38
|
More_Divides
| 2
|
|
[] |
lemma m1mod22k:
\<open>- 1 mod (2 * 2 ^ n) = 2 * 2 ^ n - (1::int)\<close> by (simp add: zmod_minus1)
|
lemma m1mod22k:
\<open>- 1 mod (2 * 2 ^ n) = 2 * 2 ^ n - (1::int)\<close> by (simp add: zmod_minus1)
|
proof (prove)
goal (1 subgoal):
1. - 1 mod (2 * 2 ^ n) = 2 * 2 ^ n - 1
|
lemma m1mod22k:
\<open>- 1 mod (2 * 2 ^ n) = 2 * 2 ^ n - (1::int)\<close>
|
unnamed_thy_39
|
More_Divides
| 1
|
|
[] |
lemma z1pdiv2: "(2 * b + 1) div 2 = b"
for b :: int by arith
|
lemma z1pdiv2: "(2 * b + 1) div 2 = b"
for b :: int by arith
|
proof (prove)
goal (1 subgoal):
1. (2 * b + 1) div 2 = b
|
lemma z1pdiv2: "(2 * b + 1) div 2 = b"
for b :: int
|
unnamed_thy_40
|
More_Divides
| 1
|
|
[] |
lemma zdiv_le_dividend:
\<open>0 \<le> a \<Longrightarrow> 0 < b \<Longrightarrow> a div b \<le> a\<close> for a b :: int by (metis div_by_1 int_one_le_iff_zero_less zdiv_mono2 zero_less_one)
|
lemma zdiv_le_dividend:
\<open>0 \<le> a \<Longrightarrow> 0 < b \<Longrightarrow> a div b \<le> a\<close> for a b :: int by (metis div_by_1 int_one_le_iff_zero_less zdiv_mono2 zero_less_one)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 \<le> a; 0 < b\<rbrakk> \<Longrightarrow> a div b \<le> a
|
lemma zdiv_le_dividend:
\<open>0 \<le> a \<Longrightarrow> 0 < b \<Longrightarrow> a div b \<le> a\<close> for a b :: int
|
unnamed_thy_41
|
More_Divides
| 1
|
|
[] |
lemma axxmod2: "(1 + x + x) mod 2 = 1 \<and> (0 + x + x) mod 2 = 0"
for x :: int by arith
|
lemma axxmod2: "(1 + x + x) mod 2 = 1 \<and> (0 + x + x) mod 2 = 0"
for x :: int by arith
|
proof (prove)
goal (1 subgoal):
1. (1 + x + x) mod 2 = 1 \<and> (0 + x + x) mod 2 = 0
|
lemma axxmod2: "(1 + x + x) mod 2 = 1 \<and> (0 + x + x) mod 2 = 0"
for x :: int
|
unnamed_thy_42
|
More_Divides
| 1
|
|
[] |
lemma axxdiv2: "(1 + x + x) div 2 = x \<and> (0 + x + x) div 2 = x"
for x :: int by arith
|
lemma axxdiv2: "(1 + x + x) div 2 = x \<and> (0 + x + x) div 2 = x"
for x :: int by arith
|
proof (prove)
goal (1 subgoal):
1. (1 + x + x) div 2 = x \<and> (0 + x + x) div 2 = x
|
lemma axxdiv2: "(1 + x + x) div 2 = x \<and> (0 + x + x) div 2 = x"
for x :: int
|
unnamed_thy_43
|
More_Divides
| 1
|
|
[] |
lemma mod_plus_right: "(a + x) mod m = (b + x) mod m \<longleftrightarrow> a mod m = b mod m"
for a b m x :: nat by (induct x) (simp_all add: mod_Suc, arith)
|
lemma mod_plus_right: "(a + x) mod m = (b + x) mod m \<longleftrightarrow> a mod m = b mod m"
for a b m x :: nat by (induct x) (simp_all add: mod_Suc, arith)
|
proof (prove)
goal (1 subgoal):
1. ((a + x) mod m = (b + x) mod m) = (a mod m = b mod m)
|
lemma mod_plus_right: "(a + x) mod m = (b + x) mod m \<longleftrightarrow> a mod m = b mod m"
for a b m x :: nat
|
unnamed_thy_44
|
More_Divides
| 1
|
|
[] |
lemma nat_minus_mod: "(n - n mod m) mod m = 0"
for m n :: nat by (induct n) (simp_all add: mod_Suc)
|
lemma nat_minus_mod: "(n - n mod m) mod m = 0"
for m n :: nat by (induct n) (simp_all add: mod_Suc)
|
proof (prove)
goal (1 subgoal):
1. (n - n mod m) mod m = 0
|
lemma nat_minus_mod: "(n - n mod m) mod m = 0"
for m n :: nat
|
unnamed_thy_45
|
More_Divides
| 1
|
|
[] |
lemma nat_mod_eq: "b < n \<Longrightarrow> a mod n = b mod n \<Longrightarrow> a mod n = b"
for a b n :: nat by (induct a) auto
|
lemma nat_mod_eq: "b < n \<Longrightarrow> a mod n = b mod n \<Longrightarrow> a mod n = b"
for a b n :: nat by (induct a) auto
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>b < n; a mod n = b mod n\<rbrakk> \<Longrightarrow> a mod n = b
|
lemma nat_mod_eq: "b < n \<Longrightarrow> a mod n = b mod n \<Longrightarrow> a mod n = b"
for a b n :: nat
|
unnamed_thy_46
|
More_Divides
| 1
|
|
[] |
lemma mod_nat_add: "x < z \<Longrightarrow> y < z \<Longrightarrow> (x + y) mod z = (if x + y < z then x + y else x + y - z)"
for x y z :: nat apply (rule nat_mod_eq) apply auto apply (rule trans) apply (rule le_mod_geq) apply simp apply (rule nat_mod_eq') apply arith done
|
lemma mod_nat_add: "x < z \<Longrightarrow> y < z \<Longrightarrow> (x + y) mod z = (if x + y < z then x + y else x + y - z)"
for x y z :: nat apply (rule nat_mod_eq) apply auto apply (rule trans) apply (rule le_mod_geq) apply simp apply (rule nat_mod_eq') apply arith done
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>x < z; y < z\<rbrakk> \<Longrightarrow> (x + y) mod z = (if x + y < z then x + y else x + y - z) proof (prove)
goal (2 subgoals):
1. \<lbrakk>x < z; y < z\<rbrakk> \<Longrightarrow> (if x + y < z then x + y else x + y - z) < z
2. \<lbrakk>x < z; y < z\<rbrakk> \<Longrightarrow> (x + y) mod z = (if x + y < z then x + y else x + y - z) mod z proof (prove)
goal (1 subgoal):
1. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> (x + y) mod z = x + y - z proof (prove)
goal (2 subgoals):
1. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> (x + y) mod z = ?s56
2. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> ?s56 = x + y - z proof (prove)
goal (2 subgoals):
1. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> z \<le> x + y
2. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> (x + y - z) mod z = x + y - z proof (prove)
goal (1 subgoal):
1. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> (x + y - z) mod z = x + y - z proof (prove)
goal (1 subgoal):
1. \<lbrakk>x < z; y < z; \<not> x + y < z\<rbrakk> \<Longrightarrow> x + y - z < z proof (prove)
goal:
No subgoals!
|
lemma mod_nat_add: "x < z \<Longrightarrow> y < z \<Longrightarrow> (x + y) mod z = (if x + y < z then x + y else x + y - z)"
for x y z :: nat
|
unnamed_thy_48
|
More_Divides
| 8
|
|
[] |
lemma mod_nat_sub: "x < z \<Longrightarrow> (x - y) mod z = x - y"
for x y :: nat by (rule nat_mod_eq') arith
|
lemma mod_nat_sub: "x < z \<Longrightarrow> (x - y) mod z = x - y"
for x y :: nat by (rule nat_mod_eq') arith
|
proof (prove)
goal (1 subgoal):
1. x < z \<Longrightarrow> (x - y) mod z = x - y
|
lemma mod_nat_sub: "x < z \<Longrightarrow> (x - y) mod z = x - y"
for x y :: nat
|
unnamed_thy_49
|
More_Divides
| 1
|
|
[] |
lemma int_mod_eq: "0 \<le> b \<Longrightarrow> b < n \<Longrightarrow> a mod n = b mod n \<Longrightarrow> a mod n = b"
for a b n :: int by (metis mod_pos_pos_trivial)
|
lemma int_mod_eq: "0 \<le> b \<Longrightarrow> b < n \<Longrightarrow> a mod n = b mod n \<Longrightarrow> a mod n = b"
for a b n :: int by (metis mod_pos_pos_trivial)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 \<le> b; b < n; a mod n = b mod n\<rbrakk> \<Longrightarrow> a mod n = b
|
lemma int_mod_eq: "0 \<le> b \<Longrightarrow> b < n \<Longrightarrow> a mod n = b mod n \<Longrightarrow> a mod n = b"
for a b n :: int
|
unnamed_thy_50
|
More_Divides
| 1
|
|
[] |
lemma zmde:
\<open>b * (a div b) = a - a mod b\<close> for a b :: \<open>'a::{group_add,semiring_modulo}\<close> using mult_div_mod_eq [of b a] by (simp add: eq_diff_eq)
|
lemma zmde:
\<open>b * (a div b) = a - a mod b\<close> for a b :: \<open>'a::{group_add,semiring_modulo}\<close> using mult_div_mod_eq [of b a] by (simp add: eq_diff_eq)
|
proof (prove)
goal (1 subgoal):
1. b * (a div b) = a - a mod b proof (prove)
using this:
b * (a div b) + a mod b = a
goal (1 subgoal):
1. b * (a div b) = a - a mod b
|
lemma zmde:
\<open>b * (a div b) = a - a mod b\<close> for a b :: \<open>'a::{group_add,semiring_modulo}\<close>
|
unnamed_thy_51
|
More_Divides
| 2
|
|
[] |
lemma zdiv_mult_self: "m \<noteq> 0 \<Longrightarrow> (a + m * n) div m = a div m + n"
for a m n :: int by simp
|
lemma zdiv_mult_self: "m \<noteq> 0 \<Longrightarrow> (a + m * n) div m = a div m + n"
for a m n :: int by simp
|
proof (prove)
goal (1 subgoal):
1. m \<noteq> 0 \<Longrightarrow> (a + m * n) div m = a div m + n
|
lemma zdiv_mult_self: "m \<noteq> 0 \<Longrightarrow> (a + m * n) div m = a div m + n"
for a m n :: int
|
unnamed_thy_52
|
More_Divides
| 1
|
|
[] |
lemma mod_power_lem: "a > 1 \<Longrightarrow> a ^ n mod a ^ m = (if m \<le> n then 0 else a ^ n)"
for a :: int by (simp add: mod_eq_0_iff_dvd le_imp_power_dvd)
|
lemma mod_power_lem: "a > 1 \<Longrightarrow> a ^ n mod a ^ m = (if m \<le> n then 0 else a ^ n)"
for a :: int by (simp add: mod_eq_0_iff_dvd le_imp_power_dvd)
|
proof (prove)
goal (1 subgoal):
1. 1 < a \<Longrightarrow> a ^ n mod a ^ m = (if m \<le> n then 0 else a ^ n)
|
lemma mod_power_lem: "a > 1 \<Longrightarrow> a ^ n mod a ^ m = (if m \<le> n then 0 else a ^ n)"
for a :: int
|
unnamed_thy_53
|
More_Divides
| 1
|
|
[] |
lemma nonneg_mod_div: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> (a mod b) \<and> 0 \<le> a div b"
for a b :: int by (cases "b = 0") (auto intro: pos_imp_zdiv_nonneg_iff [THEN iffD2])
|
lemma nonneg_mod_div: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> (a mod b) \<and> 0 \<le> a div b"
for a b :: int by (cases "b = 0") (auto intro: pos_imp_zdiv_nonneg_iff [THEN iffD2])
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 \<le> a; 0 \<le> b\<rbrakk> \<Longrightarrow> 0 \<le> a mod b \<and> 0 \<le> a div b
|
lemma nonneg_mod_div: "0 \<le> a \<Longrightarrow> 0 \<le> b \<Longrightarrow> 0 \<le> (a mod b) \<and> 0 \<le> a div b"
for a b :: int
|
unnamed_thy_54
|
More_Divides
| 1
|
|
[] |
lemma mod_exp_less_eq_exp:
\<open>a mod 2 ^ n < 2 ^ n\<close> for a :: int by (rule pos_mod_bound) simp
|
lemma mod_exp_less_eq_exp:
\<open>a mod 2 ^ n < 2 ^ n\<close> for a :: int by (rule pos_mod_bound) simp
|
proof (prove)
goal (1 subgoal):
1. a mod 2 ^ n < 2 ^ n
|
lemma mod_exp_less_eq_exp:
\<open>a mod 2 ^ n < 2 ^ n\<close> for a :: int
|
unnamed_thy_55
|
More_Divides
| 1
|
|
[] |
lemma div_mult_le:
\<open>a div b * b \<le> a\<close> for a b :: nat by (fact div_times_less_eq_dividend)
|
lemma div_mult_le:
\<open>a div b * b \<le> a\<close> for a b :: nat by (fact div_times_less_eq_dividend)
|
proof (prove)
goal (1 subgoal):
1. a div b * b \<le> a
|
lemma div_mult_le:
\<open>a div b * b \<le> a\<close> for a b :: nat
|
unnamed_thy_56
|
More_Divides
| 1
|
|
[] |
lemma power_sub:
fixes a :: nat
assumes lt: "n \<le> m"
and av: "0 < a"
shows "a ^ (m - n) = a ^ m div a ^ n" proof (subst nat_mult_eq_cancel1 [symmetric]) show "(0::nat) < a ^ n" using av by simp next from lt obtain q where mv: "n + q = m" by (auto simp: le_iff_add) have "a ^ n * (a ^ m div a ^ n) = a ^ m" proof (subst mult.commute) have "a ^ m = (a ^ m div a ^ n) * a ^ n + a ^ m mod a ^ n" by (rule div_mult_mod_eq [symmetric]) moreover have "a ^ m mod a ^ n = 0" by (subst mod_eq_0_iff_dvd, subst dvd_def, rule exI [where x = "a ^ q"],
(subst power_add [symmetric] mv)+, rule refl) ultimately show "(a ^ m div a ^ n) * a ^ n = a ^ m" by simp qed then show "a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)" using lt by (simp add: power_add [symmetric]) qed
|
lemma power_sub:
fixes a :: nat
assumes lt: "n \<le> m"
and av: "0 < a"
shows "a ^ (m - n) = a ^ m div a ^ n" proof (subst nat_mult_eq_cancel1 [symmetric]) show "(0::nat) < a ^ n" using av by simp next from lt obtain q where mv: "n + q = m" by (auto simp: le_iff_add) have "a ^ n * (a ^ m div a ^ n) = a ^ m" proof (subst mult.commute) have "a ^ m = (a ^ m div a ^ n) * a ^ n + a ^ m mod a ^ n" by (rule div_mult_mod_eq [symmetric]) moreover have "a ^ m mod a ^ n = 0" by (subst mod_eq_0_iff_dvd, subst dvd_def, rule exI [where x = "a ^ q"],
(subst power_add [symmetric] mv)+, rule refl) ultimately show "(a ^ m div a ^ n) * a ^ n = a ^ m" by simp qed then show "a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)" using lt by (simp add: power_add [symmetric]) qed
|
proof (prove)
goal (1 subgoal):
1. a ^ (m - n) = a ^ m div a ^ n proof (state)
goal (2 subgoals):
1. 0 < ?k
2. ?k * a ^ (m - n) = ?k * (a ^ m div a ^ n) proof (prove)
goal (1 subgoal):
1. 0 < a ^ n proof (prove)
using this:
0 < a
goal (1 subgoal):
1. 0 < a ^ n proof (state)
this:
0 < a ^ n
goal (1 subgoal):
1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n) proof (state)
goal (1 subgoal):
1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n) proof (chain)
picking this:
n \<le> m proof (prove)
using this:
n \<le> m
goal (1 subgoal):
1. (\<And>q. n + q = m \<Longrightarrow> thesis) \<Longrightarrow> thesis proof (state)
this:
n + q = m
goal (1 subgoal):
1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n) proof (prove)
goal (1 subgoal):
1. a ^ n * (a ^ m div a ^ n) = a ^ m proof (state)
goal (1 subgoal):
1. a ^ m div a ^ n * a ^ n = a ^ m proof (prove)
goal (1 subgoal):
1. a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n proof (state)
this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
goal (1 subgoal):
1. a ^ m div a ^ n * a ^ n = a ^ m proof (state)
this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
goal (1 subgoal):
1. a ^ m div a ^ n * a ^ n = a ^ m proof (prove)
goal (1 subgoal):
1. a ^ m mod a ^ n = 0 proof (state)
this:
a ^ m mod a ^ n = 0
goal (1 subgoal):
1. a ^ m div a ^ n * a ^ n = a ^ m proof (chain)
picking this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
a ^ m mod a ^ n = 0 proof (prove)
using this:
a ^ m = a ^ m div a ^ n * a ^ n + a ^ m mod a ^ n
a ^ m mod a ^ n = 0
goal (1 subgoal):
1. a ^ m div a ^ n * a ^ n = a ^ m proof (state)
this:
a ^ m div a ^ n * a ^ n = a ^ m
goal:
No subgoals! proof (state)
this:
a ^ n * (a ^ m div a ^ n) = a ^ m
goal (1 subgoal):
1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n) proof (chain)
picking this:
a ^ n * (a ^ m div a ^ n) = a ^ m proof (prove)
using this:
a ^ n * (a ^ m div a ^ n) = a ^ m
goal (1 subgoal):
1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n) proof (prove)
using this:
a ^ n * (a ^ m div a ^ n) = a ^ m
n \<le> m
goal (1 subgoal):
1. a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n) proof (state)
this:
a ^ n * a ^ (m - n) = a ^ n * (a ^ m div a ^ n)
goal:
No subgoals!
|
lemma power_sub:
fixes a :: nat
assumes lt: "n \<le> m"
and av: "0 < a"
shows "a ^ (m - n) = a ^ m div a ^ n"
|
unnamed_thy_57
|
More_Divides
| 24
|
|
[] |
lemma mod_lemma: "[| (0::nat) < c; r < b |] ==> b * (q mod c) + r < b * c" apply (cut_tac m = q and n = c in mod_less_divisor) apply (drule_tac [2] m = "q mod c" in less_imp_Suc_add, auto) apply (erule_tac P = "%x. lhs < rhs x" for lhs rhs in ssubst) apply (simp add: add_mult_distrib2) done
|
lemma mod_lemma: "[| (0::nat) < c; r < b |] ==> b * (q mod c) + r < b * c" apply (cut_tac m = q and n = c in mod_less_divisor) apply (drule_tac [2] m = "q mod c" in less_imp_Suc_add, auto) apply (erule_tac P = "%x. lhs < rhs x" for lhs rhs in ssubst) apply (simp add: add_mult_distrib2) done
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>0 < c; r < b\<rbrakk> \<Longrightarrow> b * (q mod c) + r < b * c proof (prove)
goal (2 subgoals):
1. \<lbrakk>0 < c; r < b\<rbrakk> \<Longrightarrow> 0 < c
2. \<lbrakk>0 < c; r < b; q mod c < c\<rbrakk> \<Longrightarrow> b * (q mod c) + r < b * c proof (prove)
goal (1 subgoal):
1. \<And>k. \<lbrakk>r < b; c = Suc (q mod c + k)\<rbrakk> \<Longrightarrow> b * (q mod c) + r < b * c proof (prove)
goal (1 subgoal):
1. \<And>k. r < b \<Longrightarrow> b * (q mod c) + r < b * Suc (q mod c + k) proof (prove)
goal:
No subgoals!
|
lemma mod_lemma: "[| (0::nat) < c; r < b |] ==> b * (q mod c) + r < b * c"
|
unnamed_thy_58
|
More_Divides
| 5
|
|
[] |
lemma less_two_pow_divD:
"\<lbrakk> (x :: nat) < 2 ^ n div 2 ^ m \<rbrakk>
\<Longrightarrow> n \<ge> m \<and> (x < 2 ^ (n - m))" apply (rule context_conjI) apply (rule ccontr) apply (simp add: power_strict_increasing) apply (simp add: power_sub) done
|
lemma less_two_pow_divD:
"\<lbrakk> (x :: nat) < 2 ^ n div 2 ^ m \<rbrakk>
\<Longrightarrow> n \<ge> m \<and> (x < 2 ^ (n - m))" apply (rule context_conjI) apply (rule ccontr) apply (simp add: power_strict_increasing) apply (simp add: power_sub) done
|
proof (prove)
goal (1 subgoal):
1. x < 2 ^ n div 2 ^ m \<Longrightarrow> m \<le> n \<and> x < 2 ^ (n - m) proof (prove)
goal (2 subgoals):
1. x < 2 ^ n div 2 ^ m \<Longrightarrow> m \<le> n
2. \<lbrakk>x < 2 ^ n div 2 ^ m; m \<le> n\<rbrakk> \<Longrightarrow> x < 2 ^ (n - m) proof (prove)
goal (2 subgoals):
1. \<lbrakk>x < 2 ^ n div 2 ^ m; \<not> m \<le> n\<rbrakk> \<Longrightarrow> False
2. \<lbrakk>x < 2 ^ n div 2 ^ m; m \<le> n\<rbrakk> \<Longrightarrow> x < 2 ^ (n - m) proof (prove)
goal (1 subgoal):
1. \<lbrakk>x < 2 ^ n div 2 ^ m; m \<le> n\<rbrakk> \<Longrightarrow> x < 2 ^ (n - m) proof (prove)
goal:
No subgoals!
|
lemma less_two_pow_divD:
"\<lbrakk> (x :: nat) < 2 ^ n div 2 ^ m \<rbrakk>
\<Longrightarrow> n \<ge> m \<and> (x < 2 ^ (n - m))"
|
unnamed_thy_59
|
More_Divides
| 5
|
|
[] |
lemma less_two_pow_divI:
"\<lbrakk> (x :: nat) < 2 ^ (n - m); m \<le> n \<rbrakk> \<Longrightarrow> x < 2 ^ n div 2 ^ m" by (simp add: power_sub)
|
lemma less_two_pow_divI:
"\<lbrakk> (x :: nat) < 2 ^ (n - m); m \<le> n \<rbrakk> \<Longrightarrow> x < 2 ^ n div 2 ^ m" by (simp add: power_sub)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>x < 2 ^ (n - m); m \<le> n\<rbrakk> \<Longrightarrow> x < 2 ^ n div 2 ^ m
|
lemma less_two_pow_divI:
"\<lbrakk> (x :: nat) < 2 ^ (n - m); m \<le> n \<rbrakk> \<Longrightarrow> x < 2 ^ n div 2 ^ m"
|
unnamed_thy_60
|
More_Divides
| 1
|
|
[] |
lemma power_mod_div:
fixes x :: "nat"
shows "x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)" (is "?LHS = ?RHS") proof (cases "n \<le> m") case True then have "?LHS = 0" apply - apply (rule div_less) apply (rule order_less_le_trans [OF mod_less_divisor]; simp) done also have "\<dots> = ?RHS" using True by simp finally show ?thesis . next case False then have lt: "m < n" by simp then obtain q where nv: "n = m + q" and "0 < q" by (auto dest: less_imp_Suc_add) then have "x mod 2 ^ n = 2 ^ m * (x div 2 ^ m mod 2 ^ q) + x mod 2 ^ m" by (simp add: power_add mod_mult2_eq) then have "?LHS = x div 2 ^ m mod 2 ^ q" by (simp add: div_add1_eq) also have "\<dots> = ?RHS" using nv by simp finally show ?thesis . qed
|
lemma power_mod_div:
fixes x :: "nat"
shows "x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)" (is "?LHS = ?RHS") proof (cases "n \<le> m") case True then have "?LHS = 0" apply - apply (rule div_less) apply (rule order_less_le_trans [OF mod_less_divisor]; simp) done also have "\<dots> = ?RHS" using True by simp finally show ?thesis . next case False then have lt: "m < n" by simp then obtain q where nv: "n = m + q" and "0 < q" by (auto dest: less_imp_Suc_add) then have "x mod 2 ^ n = 2 ^ m * (x div 2 ^ m mod 2 ^ q) + x mod 2 ^ m" by (simp add: power_add mod_mult2_eq) then have "?LHS = x div 2 ^ m mod 2 ^ q" by (simp add: div_add1_eq) also have "\<dots> = ?RHS" using nv by simp finally show ?thesis . qed
|
proof (prove)
goal (1 subgoal):
1. x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
goal (2 subgoals):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
2. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
n \<le> m
goal (2 subgoals):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
2. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
n \<le> m proof (prove)
using this:
n \<le> m
goal (1 subgoal):
1. x mod 2 ^ n div 2 ^ m = 0 proof (prove)
goal (1 subgoal):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = 0 proof (prove)
goal (1 subgoal):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n < 2 ^ m proof (prove)
goal:
No subgoals! proof (state)
this:
x mod 2 ^ n div 2 ^ m = 0
goal (2 subgoals):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
2. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
x mod 2 ^ n div 2 ^ m = 0
goal (2 subgoals):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
2. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (prove)
goal (1 subgoal):
1. 0 = x div 2 ^ m mod 2 ^ (n - m) proof (prove)
using this:
n \<le> m
goal (1 subgoal):
1. 0 = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
0 = x div 2 ^ m mod 2 ^ (n - m)
goal (2 subgoals):
1. n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
2. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (prove)
using this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
goal (1 subgoal):
1. x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
\<not> n \<le> m
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
\<not> n \<le> m proof (prove)
using this:
\<not> n \<le> m
goal (1 subgoal):
1. m < n proof (state)
this:
m < n
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
m < n proof (prove)
using this:
m < n
goal (1 subgoal):
1. (\<And>q. \<lbrakk>n = m + q; 0 < q\<rbrakk> \<Longrightarrow> thesis) \<Longrightarrow> thesis proof (state)
this:
n = m + q
0 < q
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
n = m + q
0 < q proof (prove)
using this:
n = m + q
0 < q
goal (1 subgoal):
1. x mod 2 ^ n = 2 ^ m * (x div 2 ^ m mod 2 ^ q) + x mod 2 ^ m proof (state)
this:
x mod 2 ^ n = 2 ^ m * (x div 2 ^ m mod 2 ^ q) + x mod 2 ^ m
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
x mod 2 ^ n = 2 ^ m * (x div 2 ^ m mod 2 ^ q) + x mod 2 ^ m proof (prove)
using this:
x mod 2 ^ n = 2 ^ m * (x div 2 ^ m mod 2 ^ q) + x mod 2 ^ m
goal (1 subgoal):
1. x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ q proof (state)
this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ q
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ q
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (prove)
goal (1 subgoal):
1. x div 2 ^ m mod 2 ^ q = x div 2 ^ m mod 2 ^ (n - m) proof (prove)
using this:
n = m + q
goal (1 subgoal):
1. x div 2 ^ m mod 2 ^ q = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
x div 2 ^ m mod 2 ^ q = x div 2 ^ m mod 2 ^ (n - m)
goal (1 subgoal):
1. \<not> n \<le> m \<Longrightarrow> x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (chain)
picking this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (prove)
using this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
goal (1 subgoal):
1. x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m) proof (state)
this:
x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)
goal:
No subgoals!
|
lemma power_mod_div:
fixes x :: "nat"
shows "x mod 2 ^ n div 2 ^ m = x div 2 ^ m mod 2 ^ (n - m)" (is "?LHS = ?RHS")
|
unnamed_thy_61
|
More_Divides
| 37
|
|
[] |
lemma mod_mod_power:
fixes k :: nat
shows "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ (min m n)" proof (cases "m \<le> n") case True then have "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m" apply - apply (subst mod_less [where n = "2 ^ n"]) apply (rule order_less_le_trans [OF mod_less_divisor]) apply simp+ done also have "\<dots> = k mod 2 ^ (min m n)" using True by simp finally show ?thesis . next case False then have "n < m" by simp then obtain d where md: "m = n + d" by (auto dest: less_imp_add_positive) then have "k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n" by (simp add: mod_mult2_eq power_add) then have "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n" by (simp add: mod_add_left_eq) then show ?thesis using False by simp qed
|
lemma mod_mod_power:
fixes k :: nat
shows "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ (min m n)" proof (cases "m \<le> n") case True then have "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m" apply - apply (subst mod_less [where n = "2 ^ n"]) apply (rule order_less_le_trans [OF mod_less_divisor]) apply simp+ done also have "\<dots> = k mod 2 ^ (min m n)" using True by simp finally show ?thesis . next case False then have "n < m" by simp then obtain d where md: "m = n + d" by (auto dest: less_imp_add_positive) then have "k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n" by (simp add: mod_mult2_eq power_add) then have "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n" by (simp add: mod_add_left_eq) then show ?thesis using False by simp qed
|
proof (prove)
goal (1 subgoal):
1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
goal (2 subgoals):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
this:
m \<le> n
goal (2 subgoals):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
m \<le> n proof (prove)
using this:
m \<le> n
goal (1 subgoal):
1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m proof (prove)
goal (1 subgoal):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m proof (prove)
goal (2 subgoals):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m < 2 ^ n
2. m \<le> n \<Longrightarrow> k mod 2 ^ m = k mod 2 ^ m proof (prove)
goal (3 subgoals):
1. m \<le> n \<Longrightarrow> 0 < 2 ^ m
2. m \<le> n \<Longrightarrow> 2 ^ m \<le> 2 ^ n
3. m \<le> n \<Longrightarrow> k mod 2 ^ m = k mod 2 ^ m proof (prove)
goal:
No subgoals! proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m
goal (2 subgoals):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ m
goal (2 subgoals):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (prove)
goal (1 subgoal):
1. k mod 2 ^ m = k mod 2 ^ min m n proof (prove)
using this:
m \<le> n
goal (1 subgoal):
1. k mod 2 ^ m = k mod 2 ^ min m n proof (state)
this:
k mod 2 ^ m = k mod 2 ^ min m n
goal (2 subgoals):
1. m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
2. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (prove)
using this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
goal (1 subgoal):
1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
this:
\<not> m \<le> n
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
\<not> m \<le> n proof (prove)
using this:
\<not> m \<le> n
goal (1 subgoal):
1. n < m proof (state)
this:
n < m
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
n < m proof (prove)
using this:
n < m
goal (1 subgoal):
1. (\<And>d. m = n + d \<Longrightarrow> thesis) \<Longrightarrow> thesis proof (state)
this:
m = n + d
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
m = n + d proof (prove)
using this:
m = n + d
goal (1 subgoal):
1. k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n proof (state)
this:
k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n proof (prove)
using this:
k mod 2 ^ m = 2 ^ n * (k div 2 ^ n mod 2 ^ d) + k mod 2 ^ n
goal (1 subgoal):
1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n
goal (1 subgoal):
1. \<not> m \<le> n \<Longrightarrow> k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (chain)
picking this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n proof (prove)
using this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n
goal (1 subgoal):
1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (prove)
using this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ n
\<not> m \<le> n
goal (1 subgoal):
1. k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n proof (state)
this:
k mod 2 ^ m mod 2 ^ n = k mod 2 ^ min m n
goal:
No subgoals!
|
lemma mod_mod_power:
fixes k :: nat
shows "k mod 2 ^ m mod 2 ^ n = k mod 2 ^ (min m n)"
|
unnamed_thy_62
|
More_Divides
| 35
|
|
[] |
lemma mod_div_equality_div_eq:
"a div b * b = (a - (a mod b) :: int)" by (simp add: field_simps)
|
lemma mod_div_equality_div_eq:
"a div b * b = (a - (a mod b) :: int)" by (simp add: field_simps)
|
proof (prove)
goal (1 subgoal):
1. a div b * b = a - a mod b
|
lemma mod_div_equality_div_eq:
"a div b * b = (a - (a mod b) :: int)"
|
unnamed_thy_63
|
More_Divides
| 1
|
|
[] |
lemma zmod_helper:
"n mod m = k \<Longrightarrow> ((n :: int) + a) mod m = (k + a) mod m" by (metis add.commute mod_add_right_eq)
|
lemma zmod_helper:
"n mod m = k \<Longrightarrow> ((n :: int) + a) mod m = (k + a) mod m" by (metis add.commute mod_add_right_eq)
|
proof (prove)
goal (1 subgoal):
1. n mod m = k \<Longrightarrow> (n + a) mod m = (k + a) mod m
|
lemma zmod_helper:
"n mod m = k \<Longrightarrow> ((n :: int) + a) mod m = (k + a) mod m"
|
unnamed_thy_64
|
More_Divides
| 1
|
|
[] |
lemma int_div_sub_1:
"\<lbrakk> m \<ge> 1 \<rbrakk> \<Longrightarrow> (n - (1 :: int)) div m = (if m dvd n then (n div m) - 1 else n div m)" apply (subgoal_tac "m = 0 \<or> (n - (1 :: int)) div m = (if m dvd n then (n div m) - 1 else n div m)") apply fastforce apply (subst mult_cancel_right[symmetric]) apply (simp only: left_diff_distrib split: if_split) apply (simp only: mod_div_equality_div_eq) apply (clarsimp simp: field_simps) apply (clarsimp simp: dvd_eq_mod_eq_0) apply (cases "m = 1") apply simp apply (subst mod_diff_eq[symmetric], simp add: zmod_minus1) apply clarsimp apply (subst diff_add_cancel[where b=1, symmetric]) apply (subst mod_add_eq[symmetric]) apply (simp add: field_simps) apply (rule mod_pos_pos_trivial) apply (subst add_0_right[where a=0, symmetric]) apply (rule add_mono) apply simp apply simp apply (cases "(n - 1) mod m = m - 1") apply (drule zmod_helper[where a=1]) apply simp apply (subgoal_tac "1 + (n - 1) mod m \<le> m") apply simp apply (subst field_simps, rule zless_imp_add1_zle) apply simp done
|
lemma int_div_sub_1:
"\<lbrakk> m \<ge> 1 \<rbrakk> \<Longrightarrow> (n - (1 :: int)) div m = (if m dvd n then (n div m) - 1 else n div m)" apply (subgoal_tac "m = 0 \<or> (n - (1 :: int)) div m = (if m dvd n then (n div m) - 1 else n div m)") apply fastforce apply (subst mult_cancel_right[symmetric]) apply (simp only: left_diff_distrib split: if_split) apply (simp only: mod_div_equality_div_eq) apply (clarsimp simp: field_simps) apply (clarsimp simp: dvd_eq_mod_eq_0) apply (cases "m = 1") apply simp apply (subst mod_diff_eq[symmetric], simp add: zmod_minus1) apply clarsimp apply (subst diff_add_cancel[where b=1, symmetric]) apply (subst mod_add_eq[symmetric]) apply (simp add: field_simps) apply (rule mod_pos_pos_trivial) apply (subst add_0_right[where a=0, symmetric]) apply (rule add_mono) apply simp apply simp apply (cases "(n - 1) mod m = m - 1") apply (drule zmod_helper[where a=1]) apply simp apply (subgoal_tac "1 + (n - 1) mod m \<le> m") apply simp apply (subst field_simps, rule zless_imp_add1_zle) apply simp done
|
proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> (n - 1) div m = (if m dvd n then n div m - 1 else n div m) proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m = 0 \<or> (n - 1) div m = (if m dvd n then n div m - 1 else n div m)\<rbrakk> \<Longrightarrow> (n - 1) div m = (if m dvd n then n div m - 1 else n div m)
2. 1 \<le> m \<Longrightarrow> m = 0 \<or> (n - 1) div m = (if m dvd n then n div m - 1 else n div m) proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> m = 0 \<or> (n - 1) div m = (if m dvd n then n div m - 1 else n div m) proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> (n - 1) div m * m = (if m dvd n then n div m - 1 else n div m) * m proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> (m dvd n \<longrightarrow> (n - 1) div m * m = n div m * m - 1 * m) \<and> (\<not> m dvd n \<longrightarrow> (n - 1) div m * m = n div m * m) proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> (m dvd n \<longrightarrow> n - 1 - (n - 1) mod m = n - n mod m - 1 * m) \<and> (\<not> m dvd n \<longrightarrow> n - 1 - (n - 1) mod m = n - n mod m) proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> (m dvd n \<longrightarrow> m = 1 + (n - 1) mod m) \<and> (\<not> m dvd n \<longrightarrow> n mod m = 1 + (n - 1) mod m) proof (prove)
goal (1 subgoal):
1. 1 \<le> m \<Longrightarrow> (n mod m = 0 \<longrightarrow> m = 1 + (n - 1) mod m) \<and> (n mod m \<noteq> 0 \<longrightarrow> n mod m = 1 + (n - 1) mod m) proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m = 1\<rbrakk> \<Longrightarrow> (n mod m = 0 \<longrightarrow> m = 1 + (n - 1) mod m) \<and> (n mod m \<noteq> 0 \<longrightarrow> n mod m = 1 + (n - 1) mod m)
2. \<lbrakk>1 \<le> m; m \<noteq> 1\<rbrakk> \<Longrightarrow> (n mod m = 0 \<longrightarrow> m = 1 + (n - 1) mod m) \<and> (n mod m \<noteq> 0 \<longrightarrow> n mod m = 1 + (n - 1) mod m) proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1\<rbrakk> \<Longrightarrow> (n mod m = 0 \<longrightarrow> m = 1 + (n - 1) mod m) \<and> (n mod m \<noteq> 0 \<longrightarrow> n mod m = 1 + (n - 1) mod m) proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1\<rbrakk> \<Longrightarrow> n mod m \<noteq> 0 \<longrightarrow> n mod m = 1 + (n - 1) mod m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> n mod m = 1 + (n - 1) mod m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> (n - 1 + 1) mod m = 1 + (n - 1) mod m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> ((n - 1) mod m + 1 mod m) mod m = 1 + (n - 1) mod m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> (1 + (n - 1) mod m) mod m = 1 + (n - 1) mod m proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 0 \<le> 1 + (n - 1) mod m
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 0 + 0 \<le> 1 + (n - 1) mod m
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (3 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 0 \<le> 1
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 0 \<le> (n - 1) mod m
3. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 0 \<le> (n - 1) mod m
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m = m - 1\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1 + 1) mod m = (m - 1 + 1) mod m\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m proof (prove)
goal (2 subgoals):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1; 1 + (n - 1) mod m \<le> m\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m < m
2. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m \<le> m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1\<rbrakk> \<Longrightarrow> 1 + (n - 1) mod m \<le> m proof (prove)
goal (1 subgoal):
1. \<lbrakk>1 \<le> m; m \<noteq> 1; n mod m \<noteq> 0; (n - 1) mod m \<noteq> m - 1\<rbrakk> \<Longrightarrow> (n - 1) mod m < m proof (prove)
goal:
No subgoals!
|
lemma int_div_sub_1:
"\<lbrakk> m \<ge> 1 \<rbrakk> \<Longrightarrow> (n - (1 :: int)) div m = (if m dvd n then (n div m) - 1 else n div m)"
|
unnamed_thy_65
|
More_Divides
| 27
|
|
[] |
lemma power_minus_is_div:
"b \<le> a \<Longrightarrow> (2 :: nat) ^ (a - b) = 2 ^ a div 2 ^ b" apply (induct a arbitrary: b) apply simp apply (erule le_SucE) apply (clarsimp simp:Suc_diff_le le_iff_add power_add) apply simp done
|
lemma power_minus_is_div:
"b \<le> a \<Longrightarrow> (2 :: nat) ^ (a - b) = 2 ^ a div 2 ^ b" apply (induct a arbitrary: b) apply simp apply (erule le_SucE) apply (clarsimp simp:Suc_diff_le le_iff_add power_add) apply simp done
|
proof (prove)
goal (1 subgoal):
1. b \<le> a \<Longrightarrow> 2 ^ (a - b) = 2 ^ a div 2 ^ b proof (prove)
goal (2 subgoals):
1. \<And>b. b \<le> 0 \<Longrightarrow> 2 ^ (0 - b) = 2 ^ 0 div 2 ^ b
2. \<And>a b. \<lbrakk>\<And>b. b \<le> a \<Longrightarrow> 2 ^ (a - b) = 2 ^ a div 2 ^ b; b \<le> Suc a\<rbrakk> \<Longrightarrow> 2 ^ (Suc a - b) = 2 ^ Suc a div 2 ^ b proof (prove)
goal (1 subgoal):
1. \<And>a b. \<lbrakk>\<And>b. b \<le> a \<Longrightarrow> 2 ^ (a - b) = 2 ^ a div 2 ^ b; b \<le> Suc a\<rbrakk> \<Longrightarrow> 2 ^ (Suc a - b) = 2 ^ Suc a div 2 ^ b proof (prove)
goal (2 subgoals):
1. \<And>a b. \<lbrakk>\<And>b. b \<le> a \<Longrightarrow> 2 ^ (a - b) = 2 ^ a div 2 ^ b; b \<le> a\<rbrakk> \<Longrightarrow> 2 ^ (Suc a - b) = 2 ^ Suc a div 2 ^ b
2. \<And>a b. \<lbrakk>\<And>b. b \<le> a \<Longrightarrow> 2 ^ (a - b) = 2 ^ a div 2 ^ b; b = Suc a\<rbrakk> \<Longrightarrow> 2 ^ (Suc a - b) = 2 ^ Suc a div 2 ^ b proof (prove)
goal (1 subgoal):
1. \<And>a b. \<lbrakk>\<And>b. b \<le> a \<Longrightarrow> 2 ^ (a - b) = 2 ^ a div 2 ^ b; b = Suc a\<rbrakk> \<Longrightarrow> 2 ^ (Suc a - b) = 2 ^ Suc a div 2 ^ b proof (prove)
goal:
No subgoals!
|
lemma power_minus_is_div:
"b \<le> a \<Longrightarrow> (2 :: nat) ^ (a - b) = 2 ^ a div 2 ^ b"
|
unnamed_thy_66
|
More_Divides
| 6
|
|
[] |
lemma two_pow_div_gt_le:
"v < 2 ^ n div (2 ^ m :: nat) \<Longrightarrow> m \<le> n" by (clarsimp dest!: less_two_pow_divD)
|
lemma two_pow_div_gt_le:
"v < 2 ^ n div (2 ^ m :: nat) \<Longrightarrow> m \<le> n" by (clarsimp dest!: less_two_pow_divD)
|
proof (prove)
goal (1 subgoal):
1. v < 2 ^ n div 2 ^ m \<Longrightarrow> m \<le> n
|
lemma two_pow_div_gt_le:
"v < 2 ^ n div (2 ^ m :: nat) \<Longrightarrow> m \<le> n"
|
unnamed_thy_67
|
More_Divides
| 1
|
|
[] |
lemma td_gal_lt:
\<open>0 < c \<Longrightarrow> a < b * c \<longleftrightarrow> a div c < b\<close>
for a b c :: nat by (simp add: div_less_iff_less_mult)
|
lemma td_gal_lt:
\<open>0 < c \<Longrightarrow> a < b * c \<longleftrightarrow> a div c < b\<close>
for a b c :: nat by (simp add: div_less_iff_less_mult)
|
proof (prove)
goal (1 subgoal):
1. 0 < c \<Longrightarrow> (a < b * c) = (a div c < b)
|
lemma td_gal_lt:
\<open>0 < c \<Longrightarrow> a < b * c \<longleftrightarrow> a div c < b\<close>
for a b c :: nat
|
unnamed_thy_68
|
More_Divides
| 1
|
|
[] |
lemma td_gal:
\<open>0 < c \<Longrightarrow> b * c \<le> a \<longleftrightarrow> b \<le> a div c\<close>
for a b c :: nat by (simp add: less_eq_div_iff_mult_less_eq)
|
lemma td_gal:
\<open>0 < c \<Longrightarrow> b * c \<le> a \<longleftrightarrow> b \<le> a div c\<close>
for a b c :: nat by (simp add: less_eq_div_iff_mult_less_eq)
|
proof (prove)
goal (1 subgoal):
1. 0 < c \<Longrightarrow> (b * c \<le> a) = (b \<le> a div c)
|
lemma td_gal:
\<open>0 < c \<Longrightarrow> b * c \<le> a \<longleftrightarrow> b \<le> a div c\<close>
for a b c :: nat
|
unnamed_thy_69
|
More_Divides
| 1
|
|
[] |
lemma disjunctive_add2:
"(x AND y) = 0 \<Longrightarrow> x + y = x OR y" by (metis disjunctive_add bit_0_eq bit_and_iff bot_apply bot_bool_def)
|
lemma disjunctive_add2:
"(x AND y) = 0 \<Longrightarrow> x + y = x OR y" by (metis disjunctive_add bit_0_eq bit_and_iff bot_apply bot_bool_def)
|
proof (prove)
goal (1 subgoal):
1. x AND y = (0::'a) \<Longrightarrow> x + y = x OR y
|
lemma disjunctive_add2:
"(x AND y) = 0 \<Longrightarrow> x + y = x OR y"
|
unnamed_thy_70
|
More_Bit_Ring
| 1
|
|
[] |
lemma not_xor_is_eqv:
"NOT (x XOR y) = (x AND y) OR (NOT x AND NOT y)" by (simp add: bit.xor_def bit.disj_conj_distrib or.commute)
|
lemma not_xor_is_eqv:
"NOT (x XOR y) = (x AND y) OR (NOT x AND NOT y)" by (simp add: bit.xor_def bit.disj_conj_distrib or.commute)
|
proof (prove)
goal (1 subgoal):
1. NOT (x XOR y) = x AND y OR NOT x AND NOT y
|
lemma not_xor_is_eqv:
"NOT (x XOR y) = (x AND y) OR (NOT x AND NOT y)"
|
unnamed_thy_71
|
More_Bit_Ring
| 1
|
|
[] |
lemma not_xor_eq_xor_not:
"(NOT x) XOR y = x XOR (NOT y)" by simp
|
lemma not_xor_eq_xor_not:
"(NOT x) XOR y = x XOR (NOT y)" by simp
|
proof (prove)
goal (1 subgoal):
1. NOT x XOR y = x XOR NOT y
|
lemma not_xor_eq_xor_not:
"(NOT x) XOR y = x XOR (NOT y)"
|
unnamed_thy_72
|
More_Bit_Ring
| 1
|
|
[] |
lemma minus_not_eq_plus_1:
"- NOT x = x + 1" by (simp add: minus_eq_not_plus_1)
|
lemma minus_not_eq_plus_1:
"- NOT x = x + 1" by (simp add: minus_eq_not_plus_1)
|
proof (prove)
goal (1 subgoal):
1. - NOT x = x + (1::'a)
|
lemma minus_not_eq_plus_1:
"- NOT x = x + 1"
|
unnamed_thy_74
|
More_Bit_Ring
| 1
|
|
[] |
lemma not_minus_eq_minus_1:
"NOT (- x) = x - 1" by (simp add: not_eq_complement)
|
lemma not_minus_eq_minus_1:
"NOT (- x) = x - 1" by (simp add: not_eq_complement)
|
proof (prove)
goal (1 subgoal):
1. NOT (- x) = x - (1::'a)
|
lemma not_minus_eq_minus_1:
"NOT (- x) = x - 1"
|
unnamed_thy_75
|
More_Bit_Ring
| 1
|
|
[] |
lemma and_plus_not_and:
"(x AND y) + (x AND NOT y) = x" by (metis and.left_commute and.right_neutral bit.conj_cancel_right bit.conj_disj_distrib
bit.conj_zero_right bit.disj_cancel_right disjunctive_add2)
|
lemma and_plus_not_and:
"(x AND y) + (x AND NOT y) = x" by (metis and.left_commute and.right_neutral bit.conj_cancel_right bit.conj_disj_distrib
bit.conj_zero_right bit.disj_cancel_right disjunctive_add2)
|
proof (prove)
goal (1 subgoal):
1. (x AND y) + (x AND NOT y) = x
|
lemma and_plus_not_and:
"(x AND y) + (x AND NOT y) = x"
|
unnamed_thy_76
|
More_Bit_Ring
| 1
|
|
[] |
lemma and_eq_not_or_minus:
"x AND y = (NOT x OR y) - NOT x" by (metis and.idem and_eq_not_not_or eq_diff_eq or.commute or.idem or_eq_and_not_plus)
|
lemma and_eq_not_or_minus:
"x AND y = (NOT x OR y) - NOT x" by (metis and.idem and_eq_not_not_or eq_diff_eq or.commute or.idem or_eq_and_not_plus)
|
proof (prove)
goal (1 subgoal):
1. x AND y = (NOT x OR y) - NOT x
|
lemma and_eq_not_or_minus:
"x AND y = (NOT x OR y) - NOT x"
|
unnamed_thy_78
|
More_Bit_Ring
| 1
|
|
[] |
lemma and_not_eq_or_minus:
"x AND NOT y = (x OR y) - y" by (simp add: or_eq_and_not_plus)
|
lemma and_not_eq_or_minus:
"x AND NOT y = (x OR y) - y" by (simp add: or_eq_and_not_plus)
|
proof (prove)
goal (1 subgoal):
1. x AND NOT y = (x OR y) - y
|
lemma and_not_eq_or_minus:
"x AND NOT y = (x OR y) - y"
|
unnamed_thy_79
|
More_Bit_Ring
| 1
|
|
[] |
lemma and_not_eq_minus_and:
"x AND NOT y = x - (x AND y)" by (simp add: add.commute eq_diff_eq and_plus_not_and)
|
lemma and_not_eq_minus_and:
"x AND NOT y = x - (x AND y)" by (simp add: add.commute eq_diff_eq and_plus_not_and)
|
proof (prove)
goal (1 subgoal):
1. x AND NOT y = x - (x AND y)
|
lemma and_not_eq_minus_and:
"x AND NOT y = x - (x AND y)"
|
unnamed_thy_80
|
More_Bit_Ring
| 1
|
|
[] |
lemma or_minus_eq_minus_and:
"(x OR y) - y = x - (x AND y)" by (metis and_not_eq_minus_and and_not_eq_or_minus)
|
lemma or_minus_eq_minus_and:
"(x OR y) - y = x - (x AND y)" by (metis and_not_eq_minus_and and_not_eq_or_minus)
|
proof (prove)
goal (1 subgoal):
1. (x OR y) - y = x - (x AND y)
|
lemma or_minus_eq_minus_and:
"(x OR y) - y = x - (x AND y)"
|
unnamed_thy_81
|
More_Bit_Ring
| 1
|
|
[] |
lemma plus_eq_and_or:
"x + y = (x OR y) + (x AND y)" using add_commute local.add.semigroup_axioms or_eq_and_not_plus semigroup.assoc by (fastforce simp: and_plus_not_and)
|
lemma plus_eq_and_or:
"x + y = (x OR y) + (x AND y)" using add_commute local.add.semigroup_axioms or_eq_and_not_plus semigroup.assoc by (fastforce simp: and_plus_not_and)
|
proof (prove)
goal (1 subgoal):
1. x + y = (x OR y) + (x AND y) proof (prove)
using this:
?a + ?b = ?b + ?a
semigroup (+)
?x OR ?y = (?x AND NOT ?y) + ?y
semigroup ?f \<Longrightarrow> ?f (?f ?a ?b) ?c = ?f ?a (?f ?b ?c)
goal (1 subgoal):
1. x + y = (x OR y) + (x AND y)
|
lemma plus_eq_and_or:
"x + y = (x OR y) + (x AND y)"
|
unnamed_thy_82
|
More_Bit_Ring
| 2
|
|
[] |
lemma xor_eq_or_minus_and:
"x XOR y = (x OR y) - (x AND y)" by (metis (no_types) bit.de_Morgan_conj bit.xor_def2 bit_and_iff bit_or_iff disjunctive_diff)
|
lemma xor_eq_or_minus_and:
"x XOR y = (x OR y) - (x AND y)" by (metis (no_types) bit.de_Morgan_conj bit.xor_def2 bit_and_iff bit_or_iff disjunctive_diff)
|
proof (prove)
goal (1 subgoal):
1. x XOR y = (x OR y) - (x AND y)
|
lemma xor_eq_or_minus_and:
"x XOR y = (x OR y) - (x AND y)"
|
unnamed_thy_83
|
More_Bit_Ring
| 1
|
|
[] |
lemma not_xor_eq_and_plus_not_or:
"NOT (x XOR y) = (x AND y) + NOT (x OR y)" by (metis (no_types, lifting) not_diff_distrib add.commute bit.de_Morgan_conj bit.xor_def2
bit_and_iff bit_or_iff disjunctive_diff)
|
lemma not_xor_eq_and_plus_not_or:
"NOT (x XOR y) = (x AND y) + NOT (x OR y)" by (metis (no_types, lifting) not_diff_distrib add.commute bit.de_Morgan_conj bit.xor_def2
bit_and_iff bit_or_iff disjunctive_diff)
|
proof (prove)
goal (1 subgoal):
1. NOT (x XOR y) = (x AND y) + NOT (x OR y)
|
lemma not_xor_eq_and_plus_not_or:
"NOT (x XOR y) = (x AND y) + NOT (x OR y)"
|
unnamed_thy_84
|
More_Bit_Ring
| 1
|
|
[] |
lemma not_xor_eq_and_minus_or:
"NOT (x XOR y) = (x AND y) - (x OR y) - 1" by (metis not_diff_distrib add.commute minus_diff_eq not_minus_eq_minus_1 not_xor_eq_and_plus_not_or)
|
lemma not_xor_eq_and_minus_or:
"NOT (x XOR y) = (x AND y) - (x OR y) - 1" by (metis not_diff_distrib add.commute minus_diff_eq not_minus_eq_minus_1 not_xor_eq_and_plus_not_or)
|
proof (prove)
goal (1 subgoal):
1. NOT (x XOR y) = (x AND y) - (x OR y) - (1::'a)
|
lemma not_xor_eq_and_minus_or:
"NOT (x XOR y) = (x AND y) - (x OR y) - 1"
|
unnamed_thy_85
|
More_Bit_Ring
| 1
|
|
[] |
lemma plus_eq_xor_plus_carry:
"x + y = (x XOR y) + 2 * (x AND y)" by (metis plus_eq_and_or add.commute add.left_commute diff_add_cancel mult_2 xor_eq_or_minus_and)
|
lemma plus_eq_xor_plus_carry:
"x + y = (x XOR y) + 2 * (x AND y)" by (metis plus_eq_and_or add.commute add.left_commute diff_add_cancel mult_2 xor_eq_or_minus_and)
|
proof (prove)
goal (1 subgoal):
1. x + y = (x XOR y) + (2::'a) * (x AND y)
|
lemma plus_eq_xor_plus_carry:
"x + y = (x XOR y) + 2 * (x AND y)"
|
unnamed_thy_86
|
More_Bit_Ring
| 1
|
|
[] |
lemma plus_eq_or_minus_xor:
"x + y = 2 * (x OR y) - (x XOR y)" by (metis add_diff_cancel_left' diff_diff_eq2 local.mult_2 plus_eq_and_or xor_eq_or_minus_and)
|
lemma plus_eq_or_minus_xor:
"x + y = 2 * (x OR y) - (x XOR y)" by (metis add_diff_cancel_left' diff_diff_eq2 local.mult_2 plus_eq_and_or xor_eq_or_minus_and)
|
proof (prove)
goal (1 subgoal):
1. x + y = (2::'a) * (x OR y) - (x XOR y)
|
lemma plus_eq_or_minus_xor:
"x + y = 2 * (x OR y) - (x XOR y)"
|
unnamed_thy_87
|
More_Bit_Ring
| 1
|
|
[] |
lemma plus_eq_minus_neg:
"x + y = x - NOT y - 1" using add_commute local.not_diff_distrib not_minus by auto
|
lemma plus_eq_minus_neg:
"x + y = x - NOT y - 1" using add_commute local.not_diff_distrib not_minus by auto
|
proof (prove)
goal (1 subgoal):
1. x + y = x - NOT y - (1::'a) proof (prove)
using this:
?a + ?b = ?b + ?a
NOT (?a - ?b) = NOT ?a + ?b
NOT (?x - ?y) = ?y - ?x - (1::'a)
goal (1 subgoal):
1. x + y = x - NOT y - (1::'a)
|
lemma plus_eq_minus_neg:
"x + y = x - NOT y - 1"
|
unnamed_thy_88
|
More_Bit_Ring
| 2
|
|
[] |
lemma minus_eq_plus_neg:
"x - y = x + NOT y + 1" by (simp add: add.semigroup_axioms diff_conv_add_uminus minus_eq_not_plus_1 semigroup.assoc)
|
lemma minus_eq_plus_neg:
"x - y = x + NOT y + 1" by (simp add: add.semigroup_axioms diff_conv_add_uminus minus_eq_not_plus_1 semigroup.assoc)
|
proof (prove)
goal (1 subgoal):
1. x - y = x + NOT y + (1::'a)
|
lemma minus_eq_plus_neg:
"x - y = x + NOT y + 1"
|
unnamed_thy_89
|
More_Bit_Ring
| 1
|
|
[] |
lemma minus_eq_and_not_minus_not_and:
"x - y = (x AND NOT y) - (NOT x AND y)" by (metis bit.de_Morgan_conj bit.double_compl not_diff_distrib plus_eq_and_or)
|
lemma minus_eq_and_not_minus_not_and:
"x - y = (x AND NOT y) - (NOT x AND y)" by (metis bit.de_Morgan_conj bit.double_compl not_diff_distrib plus_eq_and_or)
|
proof (prove)
goal (1 subgoal):
1. x - y = (x AND NOT y) - (NOT x AND y)
|
lemma minus_eq_and_not_minus_not_and:
"x - y = (x AND NOT y) - (NOT x AND y)"
|
unnamed_thy_90
|
More_Bit_Ring
| 1
|
|
[] |
lemma minus_eq_xor_minus_not_and:
"x - y = (x XOR y) - 2 * (NOT x AND y)" by (metis (no_types) bit.compl_eq_compl_iff bit.xor_compl_left not_diff_distrib
plus_eq_xor_plus_carry)
|
lemma minus_eq_xor_minus_not_and:
"x - y = (x XOR y) - 2 * (NOT x AND y)" by (metis (no_types) bit.compl_eq_compl_iff bit.xor_compl_left not_diff_distrib
plus_eq_xor_plus_carry)
|
proof (prove)
goal (1 subgoal):
1. x - y = (x XOR y) - (2::'a) * (NOT x AND y)
|
lemma minus_eq_xor_minus_not_and:
"x - y = (x XOR y) - 2 * (NOT x AND y)"
|
unnamed_thy_91
|
More_Bit_Ring
| 1
|
|
[] |
lemma minus_eq_and_not_minus_xor:
"x - y = 2 * (x AND NOT y) - (x XOR y)" by (metis and.commute minus_diff_eq minus_eq_xor_minus_not_and xor.commute)
|
lemma minus_eq_and_not_minus_xor:
"x - y = 2 * (x AND NOT y) - (x XOR y)" by (metis and.commute minus_diff_eq minus_eq_xor_minus_not_and xor.commute)
|
proof (prove)
goal (1 subgoal):
1. x - y = (2::'a) * (x AND NOT y) - (x XOR y)
|
lemma minus_eq_and_not_minus_xor:
"x - y = 2 * (x AND NOT y) - (x XOR y)"
|
unnamed_thy_92
|
More_Bit_Ring
| 1
|
|
[] |
lemma and_one_neq_simps[simp]:
"x AND 1 \<noteq> 0 \<longleftrightarrow> x AND 1 = 1"
"x AND 1 \<noteq> 1 \<longleftrightarrow> x AND 1 = 0" by (clarsimp simp: and_one_eq)+
|
lemma and_one_neq_simps[simp]:
"x AND 1 \<noteq> 0 \<longleftrightarrow> x AND 1 = 1"
"x AND 1 \<noteq> 1 \<longleftrightarrow> x AND 1 = 0" by (clarsimp simp: and_one_eq)+
|
proof (prove)
goal (1 subgoal):
1. (x AND (1::'a) \<noteq> (0::'a)) = (x AND (1::'a) = (1::'a)) &&& (x AND (1::'a) \<noteq> (1::'a)) = (x AND (1::'a) = (0::'a))
|
lemma and_one_neq_simps[simp]:
"x AND 1 \<noteq> 0 \<longleftrightarrow> x AND 1 = 1"
"x AND 1 \<noteq> 1 \<longleftrightarrow> x AND 1 = 0"
|
unnamed_thy_93
|
More_Bit_Ring
| 1
|
|
[] |
lemma unat_power_lower [simp]:
"unat ((2::'a::len word) ^ n) = 2 ^ n" if "n < LENGTH('a::len)" using that by transfer simp
|
lemma unat_power_lower [simp]:
"unat ((2::'a::len word) ^ n) = 2 ^ n" if "n < LENGTH('a::len)" using that by transfer simp
|
proof (prove)
goal (1 subgoal):
1. unat (2 ^ n) = 2 ^ n proof (prove)
using this:
n < LENGTH('a)
goal (1 subgoal):
1. unat (2 ^ n) = 2 ^ n
|
lemma unat_power_lower [simp]:
"unat ((2::'a::len word) ^ n) = 2 ^ n" if "n < LENGTH('a::len)"
|
unnamed_thy_95
|
More_Word
| 2
|
|
[] |
lemma word_div_lt_eq_0:
"x < y \<Longrightarrow> x div y = 0" for x :: "'a :: len word" by (fact div_word_less)
|
lemma word_div_lt_eq_0:
"x < y \<Longrightarrow> x div y = 0" for x :: "'a :: len word" by (fact div_word_less)
|
proof (prove)
goal (1 subgoal):
1. x < y \<Longrightarrow> x div y = 0
|
lemma word_div_lt_eq_0:
"x < y \<Longrightarrow> x div y = 0" for x :: "'a :: len word"
|
unnamed_thy_97
|
More_Word
| 1
|
|
[] |
lemma word_div_eq_1_iff: "n div m = 1 \<longleftrightarrow> n \<ge> m \<and> unat n < 2 * unat (m :: 'a :: len word)" apply (simp only: word_arith_nat_defs word_le_nat_alt word_of_nat_eq_iff flip: nat_div_eq_Suc_0_iff) apply (simp flip: unat_div unsigned_take_bit_eq) done
|
lemma word_div_eq_1_iff: "n div m = 1 \<longleftrightarrow> n \<ge> m \<and> unat n < 2 * unat (m :: 'a :: len word)" apply (simp only: word_arith_nat_defs word_le_nat_alt word_of_nat_eq_iff flip: nat_div_eq_Suc_0_iff) apply (simp flip: unat_div unsigned_take_bit_eq) done
|
proof (prove)
goal (1 subgoal):
1. (n div m = 1) = (m \<le> n \<and> unat n < 2 * unat m) proof (prove)
goal (1 subgoal):
1. (take_bit LENGTH('a) (unat n div unat m) = take_bit LENGTH('a) (Suc 0)) = (unat n div unat m = Suc 0) proof (prove)
goal:
No subgoals!
|
lemma word_div_eq_1_iff: "n div m = 1 \<longleftrightarrow> n \<ge> m \<and> unat n < 2 * unat (m :: 'a :: len word)"
|
unnamed_thy_98
|
More_Word
| 3
|
|
[] |
lemma AND_twice [simp]:
"(w AND m) AND m = w AND m" by (fact and.right_idem)
|
lemma AND_twice [simp]:
"(w AND m) AND m = w AND m" by (fact and.right_idem)
|
proof (prove)
goal (1 subgoal):
1. (w AND m) AND m = w AND m
|
lemma AND_twice [simp]:
"(w AND m) AND m = w AND m"
|
unnamed_thy_99
|
More_Word
| 1
|
|
[] |
lemma word_combine_masks:
"w AND m = z \<Longrightarrow> w AND m' = z' \<Longrightarrow> w AND (m OR m') = (z OR z')"
for w m m' z z' :: \<open>'a::len word\<close> by (simp add: bit.conj_disj_distrib)
|
lemma word_combine_masks:
"w AND m = z \<Longrightarrow> w AND m' = z' \<Longrightarrow> w AND (m OR m') = (z OR z')"
for w m m' z z' :: \<open>'a::len word\<close> by (simp add: bit.conj_disj_distrib)
|
proof (prove)
goal (1 subgoal):
1. \<lbrakk>w AND m = z; w AND m' = z'\<rbrakk> \<Longrightarrow> w AND (m OR m') = z OR z'
|
lemma word_combine_masks:
"w AND m = z \<Longrightarrow> w AND m' = z' \<Longrightarrow> w AND (m OR m') = (z OR z')"
for w m m' z z' :: \<open>'a::len word\<close>
|
unnamed_thy_100
|
More_Word
| 1
|
|
[] |
lemma p2_gt_0:
"(0 < (2 ^ n :: 'a :: len word)) = (n < LENGTH('a))" by (simp add : word_gt_0 not_le)
|
lemma p2_gt_0:
"(0 < (2 ^ n :: 'a :: len word)) = (n < LENGTH('a))" by (simp add : word_gt_0 not_le)
|
proof (prove)
goal (1 subgoal):
1. (0 < 2 ^ n) = (n < LENGTH('a))
|
lemma p2_gt_0:
"(0 < (2 ^ n :: 'a :: len word)) = (n < LENGTH('a))"
|
unnamed_thy_101
|
More_Word
| 1
|
|
[] |
lemma uint_2p_alt:
\<open>n < LENGTH('a::len) \<Longrightarrow> uint ((2::'a::len word) ^ n) = 2 ^ n\<close> using p2_gt_0 [of n, where ?'a = 'a] by (simp add: uint_2p)
|
lemma uint_2p_alt:
\<open>n < LENGTH('a::len) \<Longrightarrow> uint ((2::'a::len word) ^ n) = 2 ^ n\<close> using p2_gt_0 [of n, where ?'a = 'a] by (simp add: uint_2p)
|
proof (prove)
goal (1 subgoal):
1. n < LENGTH('a) \<Longrightarrow> uint (2 ^ n) = 2 ^ n proof (prove)
using this:
(0 < 2 ^ n) = (n < LENGTH('a))
goal (1 subgoal):
1. n < LENGTH('a) \<Longrightarrow> uint (2 ^ n) = 2 ^ n
|
lemma uint_2p_alt:
\<open>n < LENGTH('a::len) \<Longrightarrow> uint ((2::'a::len word) ^ n) = 2 ^ n\<close>
|
unnamed_thy_102
|
More_Word
| 2
|
|
[] |
lemma p2_eq_0:
\<open>(2::'a::len word) ^ n = 0 \<longleftrightarrow> LENGTH('a::len) \<le> n\<close> by (fact exp_eq_zero_iff)
|
lemma p2_eq_0:
\<open>(2::'a::len word) ^ n = 0 \<longleftrightarrow> LENGTH('a::len) \<le> n\<close> by (fact exp_eq_zero_iff)
|
proof (prove)
goal (1 subgoal):
1. (2 ^ n = 0) = (LENGTH('a) \<le> n)
|
lemma p2_eq_0:
\<open>(2::'a::len word) ^ n = 0 \<longleftrightarrow> LENGTH('a::len) \<le> n\<close>
|
unnamed_thy_103
|
More_Word
| 1
|
|
[] |
lemma p2len:
\<open>(2 :: 'a word) ^ LENGTH('a::len) = 0\<close> by (fact word_pow_0)
|
lemma p2len:
\<open>(2 :: 'a word) ^ LENGTH('a::len) = 0\<close> by (fact word_pow_0)
|
proof (prove)
goal (1 subgoal):
1. 2 ^ LENGTH('a) = 0
|
lemma p2len:
\<open>(2 :: 'a word) ^ LENGTH('a::len) = 0\<close>
|
unnamed_thy_104
|
More_Word
| 1
|
|
[] |
lemma neg_mask_is_div:
"w AND NOT (mask n) = (w div 2^n) * 2^n"
for w :: \<open>'a::len word\<close> by (rule bit_word_eqI)
(auto simp add: bit_simps simp flip: push_bit_eq_mult drop_bit_eq_div)
|
lemma neg_mask_is_div:
"w AND NOT (mask n) = (w div 2^n) * 2^n"
for w :: \<open>'a::len word\<close> by (rule bit_word_eqI)
(auto simp add: bit_simps simp flip: push_bit_eq_mult drop_bit_eq_div)
|
proof (prove)
goal (1 subgoal):
1. w AND NOT (mask n) = w div 2 ^ n * 2 ^ n
|
lemma neg_mask_is_div:
"w AND NOT (mask n) = (w div 2^n) * 2^n"
for w :: \<open>'a::len word\<close>
|
unnamed_thy_105
|
More_Word
| 1
|
|
[] |
lemma neg_mask_is_div':
"n < size w \<Longrightarrow> w AND NOT (mask n) = ((w div (2 ^ n)) * (2 ^ n))"
for w :: \<open>'a::len word\<close> by (rule neg_mask_is_div)
|
lemma neg_mask_is_div':
"n < size w \<Longrightarrow> w AND NOT (mask n) = ((w div (2 ^ n)) * (2 ^ n))"
for w :: \<open>'a::len word\<close> by (rule neg_mask_is_div)
|
proof (prove)
goal (1 subgoal):
1. n < size w \<Longrightarrow> w AND NOT (mask n) = w div 2 ^ n * 2 ^ n
|
lemma neg_mask_is_div':
"n < size w \<Longrightarrow> w AND NOT (mask n) = ((w div (2 ^ n)) * (2 ^ n))"
for w :: \<open>'a::len word\<close>
|
unnamed_thy_106
|
More_Word
| 1
|
End of preview. Expand
in Data Studio
README.md exists but content is empty.
- Downloads last month
- 10