3. Parity and divisibility
The problems in this chapter concern some elementary properties of natural numbers
and integers: parity (whether a number is even or odd), divisibility, and
congruence modulo
There are no new logical symbols like
3.1. Definitions; parity
3.1.1. Example
When a mathematical term is introduced for the first time, it is given a definition.
Definition
An integer
Here’s how we make a definition in Lean.
def Odd (a : ℤ) : Prop := ∃ k, a = 2 * k + 1
On paper, you need to memorize every definition; this is crucial to be able to work with them.
In Lean, when you see a term whose definition you’d like to double-check, you can right-click
(Windows) / two-finger-click (Mac) to bring up an option “Go to Definition”. This will send you
to the place in the Lean code where the definition was introduced. (The keyboard shortcut
Ctrl
--
will bring you back from that definition to where you were working before.)
Problem
Show that
Solution
Here’s how this problem looks in Lean.
example : Odd (7:ℤ) := by
sorry
The goal state at the start is:
⊢ Odd 7
You can check a definition within a proof using the dsimp
(“definitional-simplify”) tactic.
Here, you can type dsimp [Odd]
within the proof to have the definition of “odd” unfolded for
you:
example : Odd (7:ℤ) := by
dsimp [Odd]
After doing this, the goal is displayed using the definition of “odd” rather than with the word “odd”:
⊢ ∃ (k : ℤ), 7 = 2 * k + 1
This is optional, though; the proof will still work if you delete the dsimp
line.
Here is the full Lean translation of the solution.
example : Odd (7 : ℤ) := by
dsimp [Odd]
use 3
numbers
If you don’t quite follow the proof – either in its text version or its Lean version – then reread some of the examples in Section 2.5, such as Example 2.5.3.
3.1.2. Example
Here’s a similar example.
Problem
Show that
example : Odd (-3 : ℤ) := by
sorry
You should show that
3.1.3. Example
Problem
Prove that if
Solution
Let n be odd. Then there exists an integer
so
In the Lean version of the problem, the goal state initially looks like this.
n : ℤ
hn : Odd n
⊢ Odd (3 * n + 2)
If you want to unfold the definition Odd
in the goal, you can use dsimp [Odd]
, as
discussed in Example 3.1.1. If you want to unfold the definition Odd
everywhere
(goals and hypotheses), you can use dsimp [Odd] at *
. After that the goal state looks like
this:
n : ℤ
hn : ∃ (k : ℤ), n = 2 * k + 1
⊢ ∃ (k : ℤ), 3 * n + 2 = 2 * k + 1
This is our first encounter with something which might be confusing. The variable inside an
existential is a “throwaway” variable, which exists only for the duration of the sentence. So the
same variable might occur within the goal state repeatedly, without meaning the same thing. Here
the k
in the hypothesis hn
is different from the k
in the goal; it’s just the default
name when the definition “odd” is unfolded.
example {n : ℤ} (hn : Odd n) : Odd (3 * n + 2) := by
dsimp [Odd] at *
obtain ⟨k, hk⟩ := hn
use 3 * k + 2
calc
3 * n + 2 = 3 * (2 * k + 1) + 2 := by rw [hk]
_ = 2 * (3 * k + 2) + 1 := by ring
Again, you can check that the dsimp
line is not actually needed in the solution.
3.1.4. Example
Problem
Let
example {n : ℤ} (hn : Odd n) : Odd (7 * n - 4) := by
sorry
3.1.5. Example
Problem
Prove that if the integers
Solution
Since
so
example {x y : ℤ} (hx : Odd x) (hy : Odd y) : Odd (x + y + 1) := by
obtain ⟨a, ha⟩ := hx
obtain ⟨b, hb⟩ := hy
use a + b + 1
calc
x + y + 1 = 2 * a + 1 + (2 * b + 1) + 1 := by rw [ha, hb]
_ = 2 * (a + b + 1) + 1 := by ring
3.1.6. Example
Problem
Prove that if the integers
Solution
Since
so
example {x y : ℤ} (hx : Odd x) (hy : Odd y) : Odd (x * y + 2 * y) := by
sorry
3.1.7. Example
You can probably guess the definition of “even”.
Definition
An integer
def Even (a : ℤ) : Prop := ∃ k, a = 2 * k
Problem
Let
Solution
Since m is odd, there exists an integer
so
example {m : ℤ} (hm : Odd m) : Even (3 * m - 5) := by
sorry
3.1.8. Example
Problem
Let
example {n : ℤ} (hn : Even n) : Odd (n ^ 2 + 2 * n - 5) := by
sorry
3.1.9. Example
In fact every integer is either even or odd; we will discuss how to prove this later, in Example 4.2.9.
In Lean this fact can be invoked as the lemma Int.even_or_odd
:
lemma Int.even_or_odd (n : ℤ) : Even n ∨ Odd n :=
Problem
Let
Solution
We consider two cases, depending on whether
If
so
If
so
example (n : ℤ) : Even (n ^ 2 + n + 4) := by
obtain hn | hn := Int.even_or_odd n
· obtain ⟨x, hx⟩ := hn
use 2 * x ^ 2 + x + 2
calc
n ^ 2 + n + 4 = (2 * x) ^ 2 + 2 * x + 4 := by rw [hx]
_ = 2 * (2 * x ^ 2 + x + 2) := by ring
· obtain ⟨x, hx⟩ := hn
use 2 * x ^ 2 + 3 * x + 3
calc
n ^ 2 + n + 4 = (2 * x + 1) ^ 2 + (2 * x + 1) + 4 := by rw [hx]
_ = 2 * (2 * x ^ 2 + 3 * x + 3) := by ring
3.1.10. Exercises
Prove that -9 is odd.
example : Odd (-9 : ℤ) := by sorry
Prove that 26 is even.
example : Even (26 : ℤ) := by sorry
Let
be an odd integer and be an even integer. Prove that is odd.example {m n : ℤ} (hm : Odd m) (hn : Even n) : Odd (n + m) := by sorry
Let
be an odd integer and let be an even integer. Show that is odd.example {p q : ℤ} (hp : Odd p) (hq : Even q) : Odd (p - q - 4) := by sorry
Let
be an even integer and let be an odd integer. Show that is even.example {a b : ℤ} (ha : Even a) (hb : Odd b) : Even (3 * a + b - 3) := by sorry
Prove that if the integers
and are odd, then is even.example {r s : ℤ} (hr : Odd r) (hs : Odd s) : Even (3 * r - 5 * s) := by sorry
Let
be an integer. Show that if is odd then so is .example {x : ℤ} (hx : Odd x) : Odd (x ^ 3) := by sorry
Let
be an odd integer. Show that is even.example {n : ℤ} (hn : Odd n) : Even (n ^ 2 - 3 * n + 2) := by sorry
Let
be an integer and suppose that is odd. Show that is odd.example {a : ℤ} (ha : Odd a) : Odd (a ^ 2 + 2 * a - 4) := by sorry
Let
be an odd integer. Show that is odd.example {p : ℤ} (hp : Odd p) : Odd (p ^ 2 + 3 * p - 5) := by sorry
Let
and be odd integers. Show that is odd.example {x y : ℤ} (hx : Odd x) (hy : Odd y) : Odd (x * y) := by sorry
Let
be an integer. Show that is odd.example (n : ℤ) : Odd (3 * n ^ 2 + 3 * n - 1) := by sorry
Let
be an integer. Show that there exists an integer which is odd.example (n : ℤ) : ∃ m ≥ n, Odd m := by sorry
Let
, and be integers. Show that at least one of , or is even. 1example (a b c : ℤ) : Even (a - b) ∨ Even (a + c) ∨ Even (b - c) := by sorry
Footnotes
- 1
Exercise taken from Hammack, Book of Proof, Chapter 9.
3.2. Divisibility
3.2.1. Example
Another mathematical definition you may have seen before is the definition of divisibility.
Definition
A natural number
For example,
Problem
Show that the natural number 88 is divisible by 11.
Solution
Divisibility is a very important concept, and there are several different names for it. All the following mean the same thing:
is divisible by is a multiple of is a divisor of is a factor of divides
We will most frequently use the last of these, “
In Lean, the definition of divisibility is already in the library,
together with many theorems about it. We will typically work with this definition in Lean using
the notation, ∣
, which you can type in Lean as \|
or \mid
. (In general, hover over a
symbol in VSCode with your mouse to find out how to type it.) Warning: this is different from the
visually similar symbol |
which appears on your keyboard and which we use in obtain
statements.
As in Section 3.1 with dsimp [Odd]
, it is possible to unfold the definition of
divisibility in the middle of a Lean proof to remind yourself of what it means in the current
context. You can write either dsimp [Dvd.dvd]
(this being the text name of the Lean notation
dsimp [(· ∣ ·)]
– unfortunately dsimp [∣]
without the
dots and parentheses does not work. As in the Section 3.1 examples, this unfolding
is optional – the proof still works without it.
example : (11 : ℕ) ∣ 88 := by
dsimp [(· ∣ ·)]
use 8
numbers
3.2.2. Example
Another feature of this definition is that, although we stated it above for natural numbers, we will also often want to consider divisibility of integers. Here is the corresponding definition for integers:
Definition
An integer
We also use all the same variant terminology and the same notation
Problem
Show that the integer 6 is divisible by -2.
Solution
example : (-2 : ℤ) ∣ 6 := by
sorry
3.2.3. Example
Problem
Let
Solution
Since
So
example {a b : ℤ} (hab : a ∣ b) : a ∣ b ^ 2 + 2 * b := by
obtain ⟨k, hk⟩ := hab
use k * (a * k + 2)
calc
b ^ 2 + 2 * b = (a * k) ^ 2 + 2 * (a * k) := by rw [hk]
_ = a * (k * (a * k + 2)) := by ring
3.2.4. Example
Problem
Let
Solution
Since
So
Translate this solution into Lean.
As usual, if you wish, you can use the command dsimp [(· ∣ ·)] at *
to unfold
example {a b c : ℕ} (hab : a ∣ b) (hbc : b ^ 2 ∣ c) : a ^ 2 ∣ c := by
sorry
3.2.5. Example
Problem
Let
Solution
Since
So
example {x y z : ℕ} (h : x * y ∣ z) : x ∣ z := by
sorry
3.2.6. Example
You might wonder how to show that a number is not divisible by another number. A convenient test
here is a theorem which we will prove later in the book, in
Example 4.5.8: if an integer
Problem
Show that 12 is not divisible by 5.
Solution
In Lean, this test is available as the lemma Int.not_dvd_of_exists_lt_and_lt
:
lemma Int.not_dvd_of_exists_lt_and_lt (a b : ℤ)
(h : ∃ q, b * q < a ∧ a < b * (q + 1)) :
¬b ∣ a :=
And here is the same solution written up in Lean.
example : ¬(5 : ℤ) ∣ 12 := by
apply Int.not_dvd_of_exists_lt_and_lt
use 2
constructor
· numbers -- show `5 * 2 < 12`
· numbers -- show `12 < 5 * (2 + 1)`
3.2.7. Example
Problem
Let
Solution
Since
We first note that
so
Now, we have
example {a b : ℕ} (hb : 0 < b) (hab : a ∣ b) : a ≤ b := by
obtain ⟨k, hk⟩ := hab
have H1 :=
calc
0 < b := hb
_ = a * k := hk
cancel a at H1
have H : 1 ≤ k := H1
calc
a = a * 1 := by ring
_ ≤ a * k := by rel [H]
_ = b := by rw [hk]
This lemma is available in the main Lean library under the name Nat.le_of_dvd
.
3.2.8. Example
Problem
Let
Solution
Since
We have
so
example {a b : ℕ} (hab : a ∣ b) (hb : 0 < b) : 0 < a := by
sorry
This lemma is also available in the main Lean library, under the name Nat.pos_of_dvd_of_pos
.
3.2.9. Exercises
Show that 0 is divisible by every integer
.example (t : ℤ) : t ∣ 0 := by sorry
Show that -10 is not divisible by 3.
example : ¬(3 : ℤ) ∣ -10 := by sorry
Let
and be integers and suppose that . Show that .example {x y : ℤ} (h : x ∣ y) : x ∣ 3 * y - 4 * y ^ 2 := by sorry
Let
and be integers and suppose that . Show that .example {m n : ℤ} (h : m ∣ n) : m ∣ 2 * n ^ 3 + n := by sorry
Let
and be integers and suppose that . Show that .example {a b : ℤ} (hab : a ∣ b) : a ∣ 2 * b ^ 3 - b ^ 2 + 3 * b := by sorry
Let
, and be integers and suppose that divides and divides . Show that divides .example {k l m : ℤ} (h1 : k ∣ l) (h2 : l ^ 3 ∣ m) : k ^ 3 ∣ m := by sorry
Let
, and be integers and suppose that divides and divides . Show that divides .example {p q r : ℤ} (hpq : p ^ 3 ∣ q) (hqr : q ^ 2 ∣ r) : p ^ 6 ∣ r := by sorry
Show that there exists a natural number
, such that is a factor of .example : ∃ n : ℕ, 0 < n ∧ 9 ∣ 2 ^ n - 1 := by sorry
Show that there exists integers
and , with , such that .example : ∃ a b : ℤ, 0 < b ∧ b < a ∧ a - b ∣ a + b := by sorry
3.3. Modular arithmetic: theory
Definition
The integers
We use the notation
def Int.ModEq (n a b : ℤ) : Prop := n ∣ a - b
notation:50 a " ≡ " b " [ZMOD " n "]" => Int.ModEq n a b
3.3.1. Example
Problem
Show that
Solution
example : 11 ≡ 3 [ZMOD 4] := by
use 2
numbers
3.3.2. Example
Problem
Show that
Solution
example : -5 ≡ 1 [ZMOD 3] := by
sorry
3.3.3. Example
Lemma (addition rule for modular arithmetic)
Let
Proof
Since
so
theorem Int.ModEq.add {n a b c d : ℤ} (h1 : a ≡ b [ZMOD n]) (h2 : c ≡ d [ZMOD n]) :
a + c ≡ b + d [ZMOD n] := by
dsimp [Int.ModEq] at *
obtain ⟨x, hx⟩ := h1
obtain ⟨y, hy⟩ := h2
use x + y
calc
a + c - (b + d) = a - b + (c - d) := by ring
_ = n * x + n * y := by rw [hx, hy]
_ = n * (x + y) := by ring
3.3.4. Exercise
Lemma (subtraction rule for modular arithmetic)
Let
theorem Int.ModEq.sub {n a b c d : ℤ} (h1 : a ≡ b [ZMOD n]) (h2 : c ≡ d [ZMOD n]) :
a - c ≡ b - d [ZMOD n] := by
sorry
3.3.5. Exercise
Lemma (negation rule for modular arithmetic)
Let
theorem Int.ModEq.neg {n a b : ℤ} (h1 : a ≡ b [ZMOD n]) : -a ≡ -b [ZMOD n] := by
sorry
3.3.6. Example
Lemma (multiplication rule for modular arithmetic)
Let
Proof
Since
so
theorem Int.ModEq.mul {n a b c d : ℤ} (h1 : a ≡ b [ZMOD n]) (h2 : c ≡ d [ZMOD n]) :
a * c ≡ b * d [ZMOD n] := by
obtain ⟨x, hx⟩ := h1
obtain ⟨y, hy⟩ := h2
use x * c + b * y
calc
a * c - b * d = (a - b) * c + b * (c - d) := by ring
_ = n * x * c + b * (n * y) := by rw [hx, hy]
_ = n * (x * c + b * y) := by ring
3.3.7. Example
Warning: There is no “division rule” for modular arithmetic!
Problem
It is possible to have integers
Solution
We can take
, so ; , so ; lies between the consecutive multiples and of 4, so .
Notice that here we’re using the test for non-divisibility from Example 3.2.6.
3.3.8. Example
Lemma (squaring rule for modular arithmetic)
Let
Proof
Since
theorem Int.ModEq.pow_two (h : a ≡ b [ZMOD n]) : a ^ 2 ≡ b ^ 2 [ZMOD n] := by
obtain ⟨x, hx⟩ := h
use x * (a + b)
calc
a ^ 2 - b ^ 2 = (a - b) * (a + b) := by ring
_ = n * x * (a + b) := by rw [hx]
_ = n * (x * (a + b)) := by ring
3.3.9. Exercise
Lemma (cubing rule for modular arithmetic)
Let
theorem Int.ModEq.pow_three (h : a ≡ b [ZMOD n]) : a ^ 3 ≡ b ^ 3 [ZMOD n] := by
sorry
In fact the same is true for any power, although we don’t yet have the tools to prove it. We’ll come back to this later in the book, in Example 6.1.3.
Lemma (power rule for modular arithmetic)
Let
theorem Int.ModEq.pow (k : ℕ) (h : a ≡ b [ZMOD n]) : a ^ k ≡ b ^ k [ZMOD n] :=
sorry -- we'll prove this later in the book
3.3.10. Example
Lemma (reflexivity rule for modular arithmetic)
Let
Proof
theorem Int.ModEq.refl (a : ℤ) : a ≡ a [ZMOD n] := by
use 0
ring
3.3.11. Example
Whew! That was a lot of lemmas. But they pay off, as you will now see. Suppose we now encounter
some very specific modular arithmetic problem of the same general type as we’ve seen before: the
congruence modulo
Problem
Let
We could solve this by working directly from the definition, which is rather painful:
example {a b : ℤ} (ha : a ≡ 2 [ZMOD 4]) :
a * b ^ 2 + a ^ 2 * b + 3 * a ≡ 2 * b ^ 2 + 2 ^ 2 * b + 3 * 2 [ZMOD 4] := by
obtain ⟨x, hx⟩ := ha
use x * (b ^ 2 + a * b + 2 * b + 3)
calc
a * b ^ 2 + a ^ 2 * b + 3 * a - (2 * b ^ 2 + 2 ^ 2 * b + 3 * 2) =
(a - 2) * (b ^ 2 + a * b + 2 * b + 3) :=
by ring
_ = 4 * x * (b ^ 2 + a * b + 2 * b + 3) := by rw [hx]
_ = 4 * (x * (b ^ 2 + a * b + 2 * b + 3)) := by ring
Or, better, we can solve this by applying the right combination of the lemmas we already proved, in the right order. This requires much less thinking:
example {a b : ℤ} (ha : a ≡ 2 [ZMOD 4]) :
a * b ^ 2 + a ^ 2 * b + 3 * a ≡ 2 * b ^ 2 + 2 ^ 2 * b + 3 * 2 [ZMOD 4] := by
apply Int.ModEq.add
apply Int.ModEq.add
apply Int.ModEq.mul
apply ha
apply Int.ModEq.refl
apply Int.ModEq.mul
apply Int.ModEq.pow
apply ha
apply Int.ModEq.refl
apply Int.ModEq.mul
apply Int.ModEq.refl
apply ha
3.3.12. Exercises
Show that
.example : 34 ≡ 104 [ZMOD 5] := by sorry
(symmetry rule for modular arithmetic) Let
, and be integers, and suppose that . Show that .theorem Int.ModEq.symm (h : a ≡ b [ZMOD n]) : b ≡ a [ZMOD n] := by sorry
(transitivity rule for modular arithmetic) Let
, , and be integers, and suppose that and . Show that .theorem Int.ModEq.trans (h1 : a ≡ b [ZMOD n]) (h2 : b ≡ c [ZMOD n]) : a ≡ c [ZMOD n] := by sorry
Let
, and be integers. Show that .example : a + n * c ≡ a [ZMOD n] := by sorry
Give an alternative solution (i.e., with different numbers) to Example 3.3.7.
Let
and be integers, and suppose that . Show that .Give two solutions, following the style of the two solutions in Example 3.3.11.
example {a b : ℤ} (h : a ≡ b [ZMOD 5]) : 2 * a + 3 ≡ 2 * b + 3 [ZMOD 5] := by sorry
Let
and be integers, and suppose that . Show that .Give two solutions, following the style of the two solutions in Example 3.3.11.
example {m n : ℤ} (h : m ≡ n [ZMOD 4]) : 3 * m - 1 ≡ 3 * n - 1 [ZMOD 4] := by sorry
Let
be an integer, and suppose that . Show that .Give two solutions, following the style of the two solutions in Example 3.3.11.
example {k : ℤ} (hb : k ≡ 3 [ZMOD 5]) : 4 * k + k ^ 3 + 3 ≡ 4 * 3 + 3 ^ 3 + 3 [ZMOD 5] := by sorry
3.4. Modular arithmetic: calculations
3.4.1. Example
Recall the problem from Example 3.3.11.
Problem
Let
After solving this and the many similar problems in Section 3.3, you probably feel like you can check the correctness of any statement of this style by sight. And that’s great! When we have built up enough theory that a particular class of statement can be checked by sight, we will stop requiring detailed proofs. So for now on we’ll take such statements for granted.
This is also usually the point at which it’s easy to write a Lean tactic which checks the
correctness of a class of statement. I’ve done exactly this, updating tactic rel
to cover this
kind of statement. We won’t discuss tactic-writing in this book, but effectively, the tactic
now throws the lemmas Int.ModEq.add
, Int.ModEq.neg
, Int.ModEq.sub
, Int.ModEq.mul
,
Int.ModEq.pow
, Int.ModEq.refl
and the provided hypotheses at the statement until (a) the
goal is solved or (b) none of these lemmas apply any more. And that’s exactly what we’re doing in
our heads when we check the paper statement of the problem.
example {a b : ℤ} (ha : a ≡ 2 [ZMOD 4]) :
a * b ^ 2 + a ^ 2 * b + 3 * a ≡ 2 * b ^ 2 + 2 ^ 2 * b + 3 * 2 [ZMOD 4] := by
rel [ha]
3.4.2. Example
From now on, we will solve more interesting modular arithmetic problems, dealing with steps like Example 3.3.11 in a single line.
Problem
Let
Solution
example {a b : ℤ} (ha : a ≡ 4 [ZMOD 5]) (hb : b ≡ 3 [ZMOD 5]) :
a * b + b ^ 3 + 3 ≡ 2 [ZMOD 5] :=
calc
a * b + b ^ 3 + 3 ≡ 4 * b + b ^ 3 + 3 [ZMOD 5] := by rel [ha]
_ ≡ 4 * 3 + 3 ^ 3 + 3 [ZMOD 5] := by rel [hb]
_ = 2 + 5 * 8 := by numbers
_ ≡ 2 [ZMOD 5] := by extra
3.4.3. Example
Problem
Show that there exists an integer
Solution
The integer 8 has this property. Indeed,
example : ∃ a : ℤ, 6 * a ≡ 4 [ZMOD 11] := by
use 8
calc
(6:ℤ) * 8 = 4 + 4 * 11 := by numbers
_ ≡ 4 [ZMOD 11] := by extra
3.4.4. Example
Problem
Let
Solution
We consider cases according to the residue of
Case 1 (
Case 2 (
Case 3 (
example {x : ℤ} : x ^ 3 ≡ x [ZMOD 3] := by
mod_cases hx : x % 3
calc
x ^ 3 ≡ 0 ^ 3 [ZMOD 3] := by rel [hx]
_ = 0 := by numbers
_ ≡ x [ZMOD 3] := by rel [hx]
calc
x ^ 3 ≡ 1 ^ 3 [ZMOD 3] := by rel [hx]
_ = 1 := by numbers
_ ≡ x [ZMOD 3] := by rel [hx]
calc
x ^ 3 ≡ 2 ^ 3 [ZMOD 3] := by rel [hx]
_ = 2 + 3 * 2 := by numbers
_ ≡ 2 [ZMOD 3] := by extra
_ ≡ x [ZMOD 3] := by rel [hx]
3.4.5. Exercises
Let
be an integer for which . Show that .example {n : ℤ} (hn : n ≡ 1 [ZMOD 3]) : n ^ 3 + 7 * n ≡ 2 [ZMOD 3] := sorry
Let
be an integer for which . Show that .example {a : ℤ} (ha : a ≡ 3 [ZMOD 4]) : a ^ 3 + 4 * a ^ 2 + 2 ≡ 1 [ZMOD 4] := sorry
Let
and be integers. Show that .example (a b : ℤ) : (a + b) ^ 3 ≡ a ^ 3 + b ^ 3 [ZMOD 3] := sorry
Show that there exists an integer
, such that .example : ∃ a : ℤ, 4 * a ≡ 1 [ZMOD 7] := by sorry
Show that there exists an integer
, such that .example : ∃ k : ℤ, 5 * k ≡ 6 [ZMOD 8] := by sorry
Let
be an integer. Show that .example (n : ℤ) : 5 * n ^ 2 + 3 * n + 7 ≡ 1 [ZMOD 2] := by sorry
Let
be an integer. Show that .example {x : ℤ} : x ^ 5 ≡ x [ZMOD 5] := by sorry
3.5. Bézout’s identity
3.5.1. Example
Problem
Let
Solution
Since
so
example {n : ℤ} (hn : 8 ∣ 5 * n) : 8 ∣ n := by
obtain ⟨a, ha⟩ := hn
use -3 * a + 2 * n
calc
n = -3 * (5 * n) + 16 * n := by ring
_ = -3 * (8 * a) + 16 * n := by rw [ha]
_ = 8 * (-3 * a + 2 * n) := by ring
Such a problem will typically have many possible solutions. Here is another solution.
Solution
Since
so
Try typing the variant solution up in Lean.
example {n : ℤ} (hn : 8 ∣ 5 * n) : 8 ∣ n := by
sorry
3.5.2. Example
Problem
Show that if for some integer
Solution
Since
so
example {n : ℤ} (h1 : 5 ∣ 3 * n) : 5 ∣ n := by
sorry
3.5.3. Example
Problem
Let
Solution
Since
so
example {m : ℤ} (h1 : 8 ∣ m) (h2 : 5 ∣ m) : 40 ∣ m := by
obtain ⟨a, ha⟩ := h1
obtain ⟨b, hb⟩ := h2
use -3 * a + 2 * b
calc
m = -15 * m + 16 * m := by ring
_ = -15 * (8 * a) + 16 * m := by rw [ha]
_ = -15 * (8 * a) + 16 * (5 * b) := by rw [hb]
_ = 40 * (-3 * a + 2 * b) := by ring
3.5.4. Exercises
Show that if 6 divides
, then it divides .example {n : ℤ} (hn : 6 ∣ 11 * n) : 6 ∣ n := by sorry
Let
be an integer and suppose that is a multiple of . Show that is also a multiple of .example {a : ℤ} (ha : 7 ∣ 5 * a) : 7 ∣ a := by sorry
Suppose that 7 and 9 are both factors of some integer
. Show that 63 is also a factor of .example {n : ℤ} (h1 : 7 ∣ n) (h2 : 9 ∣ n) : 63 ∣ n := by sorry
Let
be an integer which is divisible by 5 and by 13. Show that it is also divisible by 65.example {n : ℤ} (h1 : 5 ∣ n) (h2 : 13 ∣ n) : 65 ∣ n := by sorry