Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
879abad
fix(4.1.4): grammar
dfpetrin Apr 27, 2024
e4a62ac
fix(4.2.3): grammar
dfpetrin Jan 3, 2024
885f232
fix(4.2.9): error in odd case
dfpetrin Apr 27, 2024
747a9c7
fix(6.1.2): mixed up integers and nats
dfpetrin Apr 29, 2024
9134de0
fix(6.1.5): add le 2 assumption to inductive step
dfpetrin Jan 7, 2024
c17e564
fix(6.2.5): use correct multiplication dot
dfpetrin Jan 7, 2024
0532915
fix(6.2.5): use n! instead of A_n
dfpetrin Jan 7, 2024
39252e3
fix(6.2.5): misnumbered case
dfpetrin Apr 28, 2024
7ccd6d5
fix(6.3.6): 6. match paper and lean statements
dfpetrin Jan 8, 2024
24d28a3
fix(6.4.2): use more accurate name for hypothesis
dfpetrin Jan 9, 2024
13f8831
fix(6.5.3): prove correct base cases
dfpetrin Jan 9, 2024
5fa02ed
fix(6.6.1): nitpick: use consistent n*d order
dfpetrin Jan 10, 2024
7b8cabe
fix(6.6.2): state inductive hyp with correct vars
dfpetrin Jan 10, 2024
778230c
fix(6.6.4): case 4 of proof missing a small step
dfpetrin May 3, 2024
33301ce
fix(6.7.1): remove unneeded hypothesis
dfpetrin Jan 11, 2024
8fac911
fix(6.7.3): state correct inductive hypothesis
dfpetrin Jan 11, 2024
43ad906
fix(6.7.3): typo
dfpetrin Apr 28, 2024
d61408b
fix(6.7.5): state correct inductive hypothesis
dfpetrin Jan 11, 2024
3eab70e
fix(6.7.5): fix minus sign
dfpetrin Jan 11, 2024
9f838e4
fix(7.3): use accurate hypothesis names
dfpetrin May 5, 2024
d79769d
refactor(7.3): simplify irrat_aux proof
dfpetrin May 5, 2024
a101b73
fix(7.3): minor typo
dfpetrin May 5, 2024
53dc5c2
fix(7.3): state and prove correct theorem
dfpetrin May 5, 2024
d213b30
fix(8.1.3): use consistent definition of `q`
dfpetrin May 6, 2024
a54bab2
fix(8.1.12): reference correct exercise
dfpetrin May 19, 2024
6a87991
fix(8.1.13): 17. real numbers -> rational numbers
dfpetrin May 18, 2024
a978548
fix(8.1.13): 17. fix lt_trichotomy statement
dfpetrin May 18, 2024
43fdb5b
fix(8.3.1): use correct definition of `comp`
dfpetrin May 21, 2024
ee3e08b
fix(8.3.10): 2. use rationals instead of reals
dfpetrin May 22, 2024
c694d54
fix(8.3.10): 5. use correct codomain for `g`
dfpetrin May 22, 2024
a509b41
fix(8.3.10) 7. typo
dfpetrin May 22, 2024
ba28571
fix(8.4.1): grammar
dfpetrin May 26, 2024
da8bea2
fix(8.4.8): use correct Id function
dfpetrin May 26, 2024
7786e6b
fix(8.4.9): fix the FIXME; use dsimp [i]
dfpetrin May 26, 2024
29f0f7d
fix(8.4.9): prove without using zify
dfpetrin May 26, 2024
a24bd04
fix(8.4.10): 8. use correct Id function
dfpetrin May 26, 2024
7eff382
fix(9.1.6): typo in proof
dfpetrin May 27, 2024
8e93a94
fix(9.1.8): case number typo
dfpetrin May 27, 2024
fab12d2
fix(9.1.9): typos in problem and proof
dfpetrin May 27, 2024
4e90bbb
fix(9.1.10): 10. typo in proof statement
dfpetrin May 27, 2024
99939e4
fix(9.2.3): use correct numeric type
dfpetrin May 27, 2024
fc0cba5
fix(9.2.5): use correct numeric type
dfpetrin May 27, 2024
0a9216a
fix(9.2.6): typos in problem statement
dfpetrin May 27, 2024
d9cf8db
fix(9.2.8): 2. use correct problem statement
dfpetrin May 27, 2024
fc8481c
fix(9.2.8): only first four use the tactic
dfpetrin May 27, 2024
8f1c696
fix(9.3.6): 2. nitpick: consistent sequence notation
dfpetrin May 29, 2024
a3beb0d
fix(10.1.1): typo in div not symm proof
dfpetrin May 29, 2024
0ebacd1
fix(10.1.1): typos in proof of div antisymm
dfpetrin May 29, 2024
2ffa6d8
fix(10.2.2): typo in proof
dfpetrin May 30, 2024
85611b4
fix(10.2.3): define equiv class more precisely
dfpetrin May 30, 2024
b34ec0e
fix(index): fix sorting
dfpetrin May 30, 2024
65a05fb
fix(index): add list of missing tactics/keywords
dfpetrin May 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions Math2001/06_Induction/04_Strong_Induction.lean
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ namespace Nat

theorem exists_prime_factor {n : ℕ} (hn2 : 2 ≤ n) : ∃ p : ℕ, Prime p ∧ p ∣ n := by
by_cases hn : Prime n
. -- case 1: `n` is prime
· -- case 1: `n` is prime
use n
constructor
· apply hn
· use 1
ring
. -- case 2: `n` is not prime
obtain ⟨m, hmn, _, ⟨x, hx⟩⟩ := exists_factor_of_not_prime hn hn2
have IH : ∃ p, Prime p ∧ p ∣ m := exists_prime_factor hmn -- inductive hypothesis
· -- case 2: `n` is not prime
obtain ⟨m, hm2, _, ⟨x, hx⟩⟩ := exists_factor_of_not_prime hn hn2
have IH : ∃ p, Prime p ∧ p ∣ m := exists_prime_factor hm2 -- inductive hypothesis
obtain ⟨p, hp, y, hy⟩ := IH
use p
constructor
Expand Down
1 change: 0 additions & 1 deletion Math2001/06_Induction/07_Euclidean_Algorithm.lean
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ open Int
have H : 0 ≤ fmod a (-b)
· apply fmod_nonneg_of_pos
addarith [h1]
have h2 : 0 < -b := by addarith [h1]
calc b < 0 := h1
_ ≤ fmod a (-b) := H

Expand Down
22 changes: 10 additions & 12 deletions Math2001/07_Number_Theory/03_Sqrt_Two.lean
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import Library.Theory.NumberTheory
math2001_init


@[decreasing] theorem irrat_aux_wf (b k : ℕ) (hb : k ≠ 0) (hab : b ^ 2 = 2 * k ^ 2) :
@[decreasing] theorem irrat_aux_wf (b k : ℕ) (hk : k ≠ 0) (hbk : b ^ 2 = 2 * k ^ 2) :
k < b := by
have h :=
calc k ^ 2 < k ^ 2 + k ^ 2 := by extra
_ = 2 * k ^ 2 := by ring
_ = b ^ 2 := by rw [hab]
_ = b ^ 2 := by rw [hbk]
cancel 2 at h


Expand All @@ -34,10 +34,8 @@ theorem irrat_aux (a b : ℕ) (hb : b ≠ 0) : a ^ 2 ≠ 2 * b ^ 2 := by
_ = k * (2 * k) := by ring
cancel 2 * k at hk'
have hk'' : k ≠ 0 := ne_of_gt hk'
have IH := irrat_aux b k -- inductive hypothesis
have : b ^ 2 ≠ 2 * k ^ 2 := IH hk''
have IH := irrat_aux b k hk'' -- inductive hypothesis
contradiction
termination_by _ => b


example : ¬ ∃ a b : ℕ, b ≠ 0 ∧ a ^ 2 = 2 * b ^ 2 := by
Expand All @@ -47,7 +45,7 @@ example : ¬ ∃ a b : ℕ, b ≠ 0 ∧ a ^ 2 = 2 * b ^ 2 := by
contradiction


example : ¬ ∃ a b : ℤ, b ≠ 0 ∧ b ^ 2 = 2 * a ^ 2 := by
example : ¬ ∃ a b : ℤ, b ≠ 0 ∧ a ^ 2 = 2 * b ^ 2 := by
intro h
obtain ⟨a, b, hb, hab⟩ := h
have Ha : gcd a b ∣ a := gcd_dvd_left a b
Expand All @@ -57,11 +55,11 @@ example : ¬ ∃ a b : ℤ, b ≠ 0 ∧ b ^ 2 = 2 * a ^ 2 := by
obtain ⟨x, y, h⟩ := bezout a b
set d := gcd a b
have key :=
calc (2 * k * y + l * x) ^ 2 * d ^ 2
= (2 * (d * k) * y + (d * l) * x) ^ 2 := by ring
_ = (2 * a * y + b * x) ^ 2 := by rw [hk, hl]
_ = 2 * (x * a + y * b) ^ 2 + (x ^ 2 - 2 * y ^ 2) * (b ^ 2 - 2 * a ^ 2) := by ring
_ = 2 * d ^ 2 + (x ^ 2 - 2 * y ^ 2) * (b ^ 2 - b ^ 2) := by rw [h, hab]
calc (2 * l * x + k * y) ^ 2 * d ^ 2
= (2 * (d * l) * x + (d * k) * y) ^ 2 := by ring
_ = (2 * b * x + a * y) ^ 2 := by rw [hk, hl]
_ = 2 * (x * a + y * b) ^ 2 + (y ^ 2 - 2 * x ^ 2) * (a ^ 2 - 2 * b ^ 2) := by ring
_ = 2 * d ^ 2 + (y ^ 2 - 2 * x ^ 2) * (a ^ 2 - a ^ 2) := by rw [h, hab]
_ = 2 * d ^ 2 := by ring
have hd : d ≠ 0
· intro hd
Expand All @@ -71,5 +69,5 @@ example : ¬ ∃ a b : ℤ, b ≠ 0 ∧ b ^ 2 = 2 * a ^ 2 := by
_ = 0 := by ring
contradiction
cancel d ^ 2 at key
have := sq_ne_two (2 * k * y + l * x)
have := sq_ne_two (2 * l * x + k * y)
contradiction
4 changes: 2 additions & 2 deletions Math2001/08_Functions/03_Composition.lean
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,9 @@ example : b ∘ a = c := by
cases x <;> exhaust


def u (x : ) : := 5 * x + 1
def u (x : ) : := 5 * x + 1

noncomputable def v (x : ) : := sorry
def v (x : ) : := sorry

example : Inverse u v := by
sorry
Expand Down
13 changes: 5 additions & 8 deletions Math2001/08_Functions/04_Product_Types.lean
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@ def i : ℕ × ℕ → ℕ × ℕ
theorem p_comp_i (x : ℕ × ℕ) : p (i x) = p x + 1 := by
match x with
| (0, b) =>
calc p (i (0, b)) = p (b + 1, 0) := by rw [i]
calc p (i (0, b)) = p (b + 1, 0) := by dsimp [i]
_ = A ((b + 1) + 0) + 0 := by dsimp [p]
_ = A (b + 1) := by ring
_ = A b + b + 1 := by rw [A]
_ = (A (0 + b) + b) + 1 := by ring
_ = p (0, b) + 1 := by dsimp [p]
| (a + 1, b) =>
calc p (i (a + 1, b)) = p (a, b + 1) := by rw [i] ; rfl -- FIXME
calc p (i (a + 1, b)) = p (a, b + 1) := by dsimp [i]
_ = A (a + (b + 1)) + (b + 1) := by dsimp [p]
_ = (A ((a + 1) + b) + b) + 1 := by ring
_ = p (a + 1, b) + 1 := by rw [p]
Expand All @@ -190,13 +190,10 @@ example : Bijective p := by
· apply of_A_add_mono
rw [hab]
have hb : b1 = b2
· zify at hab ⊢
calc (b1:ℤ) = A (a2 + b2) + b2 - A (a1 + b1) := by addarith [hab]
_ = A (a2 + b2) + b2 - A (a2 + b2) := by rw [H]
_ = b2 := by ring
· rw [H] at hab
addarith [hab]
constructor
· zify at hb H ⊢
addarith [H, hb]
· addarith [H, hb]
· apply hb
· apply surjective_of_intertwining (x0 := (0, 0)) (i := i)
· calc p (0, 0) = A (0 + 0) + 0 := by dsimp [p]
Expand Down
8 changes: 4 additions & 4 deletions html/04_Proofs_with_Structure_II.html
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ <h3><span class="section-number">4.1.3. </span>Example<a class="headerlink" href
<h3><span class="section-number">4.1.4. </span>Example<a class="headerlink" href="#id4" title="Permalink to this headline">&#61633;</a></h3>
<div class="admonition-problem admonition">
<p class="admonition-title">Problem</p>
<p>Let <span class="math notranslate nohighlight">\(a\)</span> be real number whose square is at most 2, and which is greater than or equal to
<p>Let <span class="math notranslate nohighlight">\(a\)</span> be a real number whose square is at most 2, and which is greater than or equal to
any real number whose square is at most 2. <a class="footnote-reference brackets" href="#id11" id="id5">1</a> Let <span class="math notranslate nohighlight">\(b\)</span> be another real number with the same
two properties. Prove that <span class="math notranslate nohighlight">\(a=b\)</span>.</p>
</div>
Expand Down Expand Up @@ -636,8 +636,8 @@ <h3><span class="section-number">4.2.1. </span>Example<a class="headerlink" href
<p>First, suppose that <span class="math notranslate nohighlight">\(n\)</span> is odd. Then there exists an integer <span class="math notranslate nohighlight">\(k\)</span> such that
<span class="math notranslate nohighlight">\(n=2k+1\)</span>. Therefore <span class="math notranslate nohighlight">\(n-1=2k\)</span>, so <span class="math notranslate nohighlight">\(n-1\)</span> is divisible by 2, so
<span class="math notranslate nohighlight">\(n\equiv 1\mod 2\)</span>.</p>
<p>Conversely, suppose that <span class="math notranslate nohighlight">\(n\equiv 1\mod 2\)</span>. Then <span class="math notranslate nohighlight">\(2\mid n -1\)</span>, so there exists an
integer <span class="math notranslate nohighlight">\(k\)</span> such <span class="math notranslate nohighlight">\(n-1=2k\)</span>. Thus <span class="math notranslate nohighlight">\(n=2k+1\)</span> and so <span class="math notranslate nohighlight">\(n\)</span> is odd.</p>
<p>Conversely, suppose that <span class="math notranslate nohighlight">\(n\equiv 1\mod 2\)</span>. Then there exists an
integer <span class="math notranslate nohighlight">\(k\)</span> such that <span class="math notranslate nohighlight">\(n-1=2k\)</span>. Thus <span class="math notranslate nohighlight">\(n=2k+1\)</span> and so <span class="math notranslate nohighlight">\(n\)</span> is odd.</p>
</div>
<p>We name this example <code class="docutils literal notranslate"><span class="pre">Int.odd_iff_modEq</span></code> for future use.</p>
<div class="highlight-lean notranslate"><div class="highlight"><pre><span></span><span class="kd">theorem</span> <span class="n">odd_iff_modEq</span> <span class="o">(</span><span class="n">n</span> <span class="o">:</span> <span class="n">&#8484;</span><span class="o">)</span> <span class="o">:</span> <span class="n">Odd</span> <span class="n">n</span> <span class="bp">&#8596;</span> <span class="n">n</span> <span class="bp">&#8801;</span> <span class="mi">1</span> <span class="o">[</span><span class="n">ZMOD</span> <span class="mi">2</span><span class="o">]</span> <span class="o">:=</span> <span class="kd">by</span>
Expand Down Expand Up @@ -824,7 +824,7 @@ <h3><span class="section-number">4.2.8. </span>Example<a class="headerlink" href
<p>Let <span class="math notranslate nohighlight">\(n\)</span> be an integer. We do a case division according to the residue of <span class="math notranslate nohighlight">\(n\)</span>
modulo 2.</p>
<p>If <span class="math notranslate nohighlight">\(n\equiv 0\mod 2\)</span>, then <span class="math notranslate nohighlight">\(n\)</span> is even, and we are done.</p>
<p>If <span class="math notranslate nohighlight">\(n\equiv 0\mod 2\)</span>, then <span class="math notranslate nohighlight">\(n\)</span> is odd, and we are done.</p>
<p>If <span class="math notranslate nohighlight">\(n\equiv 1\mod 2\)</span>, then <span class="math notranslate nohighlight">\(n\)</span> is odd, and we are done.</p>
</div>
<p>Write this in Lean using the lemmas <code class="docutils literal notranslate"><span class="pre">Int.odd_iff_modEq</span></code> and <code class="docutils literal notranslate"><span class="pre">Int.even_iff_modEq</span></code> from
<a class="reference internal" href="#odd-iff-modeq"><span class="std std-numref">Example 4.2.3</span></a> and <a class="reference internal" href="#even-iff-modeq"><span class="std std-numref">Example 4.2.4</span></a>, together with the
Expand Down
Loading