section ‹Division on integers›
theory IntDiv_ZF_IML imports Int_ZF_1 ZF.IntDiv
begin
text‹This theory translates some results form the Isabelle's
‹IntDiv.thy› theory to the notation used by IsarMathLib.›
subsection‹Quotient and reminder›
text‹For any integers $m,n$ , $n>0$ there are unique integers $q,p$
such that $0\leq p < n$ and $m = n\cdot q + p$. Number $p$ in this
decompsition is usually called $m$ mod $n$. Standard Isabelle denotes numbers
$q,p$ as ‹m zdiv n› and ‹m zmod n›, resp.,
and we will use the same notation.›
text‹The next lemma is sometimes called the "quotient-reminder theorem".›
lemma (in int0) IntDiv_ZF_1_L1: assumes "m∈ℤ" "n∈ℤ"
shows "m = n⋅(m zdiv n) \<ra> (m zmod n)"
using assms Int_ZF_1_L2 raw_zmod_zdiv_equality
by simp
text‹If $n$ is greater than $0$ then ‹m zmod n› is between $0$ and $n-1$.›
lemma (in int0) IntDiv_ZF_1_L2:
assumes A1: "m∈ℤ" and A2: "𝟬\<lsq>n" "n≠𝟬"
shows
"𝟬 \<lsq> m zmod n"
"m zmod n \<lsq> n" "m zmod n ≠ n"
"m zmod n \<lsq> n\<rs>𝟭"
proof -
from A2 have T: "n ∈ ℤ"
using Int_ZF_2_L1A by simp
from A2 have "#0 $< n" using Int_ZF_2_L9 Int_ZF_1_L8
by auto
with T show
"𝟬 \<lsq> m zmod n"
"m zmod n \<lsq> n"
"m zmod n ≠ n"
using pos_mod Int_ZF_1_L8 Int_ZF_1_L8A zmod_type
Int_ZF_2_L1 Int_ZF_2_L9AA
by auto
then show "m zmod n \<lsq> n\<rs>𝟭"
using Int_ZF_4_L1B by auto
qed
text‹$(m\cdot k)$ div $k = m$.›
lemma (in int0) IntDiv_ZF_1_L3:
assumes "m∈ℤ" "k∈ℤ" and "k≠𝟬"
shows
"(m⋅k) zdiv k = m"
"(k⋅m) zdiv k = m"
using assms zdiv_zmult_self1 zdiv_zmult_self2
Int_ZF_1_L8 Int_ZF_1_L2 by auto
text‹The next lemma essentially translates ‹zdiv_mono1› from
standard Isabelle to our notation.›
lemma (in int0) IntDiv_ZF_1_L4:
assumes A1: "m \<lsq> k" and A2: "𝟬\<lsq>n" "n≠𝟬"
shows "m zdiv n \<lsq> k zdiv n"
proof -
from A2 have "#0 \<lsq> n" "#0 ≠ n"
using Int_ZF_1_L8 by auto
with A1 have
"m zdiv n $≤ k zdiv n"
"m zdiv n ∈ ℤ" "m zdiv k ∈ ℤ"
using Int_ZF_2_L1A Int_ZF_2_L9 zdiv_mono1
by auto
then show "(m zdiv n) \<lsq> (k zdiv n)"
using Int_ZF_2_L1 by simp
qed
text‹A quotient-reminder theorem about integers greater than a given
product.›
lemma (in int0) IntDiv_ZF_1_L5:
assumes A1: "n ∈ ℤ⇩+" and A2: "n \<lsq> k" and A3: "k⋅n \<lsq> m"
shows
"m = n⋅(m zdiv n) \<ra> (m zmod n)"
"m = (m zdiv n)⋅n \<ra> (m zmod n)"
"(m zmod n) ∈ 𝟬..(n\<rs>𝟭)"
"k \<lsq> (m zdiv n)"
"m zdiv n ∈ ℤ⇩+"
proof -
from A2 A3 have T:
"m∈ℤ" "n∈ℤ" "k∈ℤ" "m zdiv n ∈ ℤ"
using Int_ZF_2_L1A by auto
then show "m = n⋅(m zdiv n) \<ra> (m zmod n)"
using IntDiv_ZF_1_L1 by simp
with T show "m = (m zdiv n)⋅n \<ra> (m zmod n)"
using Int_ZF_1_L4 by simp
from A1 have I: "𝟬\<lsq>n" "n≠𝟬"
using PositiveSet_def by auto
with T show "(m zmod n) ∈ 𝟬..(n\<rs>𝟭)"
using IntDiv_ZF_1_L2 Order_ZF_2_L1
by simp
from A3 I have "(k⋅n zdiv n) \<lsq> (m zdiv n)"
using IntDiv_ZF_1_L4 by simp
with I T show "k \<lsq> (m zdiv n)"
using IntDiv_ZF_1_L3 by simp
with A1 A2 show "m zdiv n ∈ ℤ⇩+"
using Int_ZF_1_5_L7 by blast
qed
end