Skip to content

Commit 95d6064

Browse files
committed
fix lean errors
1 parent 197df4b commit 95d6064

File tree

2 files changed

+12
-24
lines changed

2 files changed

+12
-24
lines changed

Analysis/Section_4_1.lean

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ abbrev Int := Quotient PreInt.instSetoid
5050

5151
abbrev Int.formalDiff (a b:ℕ) : Int := Quotient.mk PreInt.instSetoid ⟨ a,b ⟩
5252

53-
infix:70 " — " => Int.formalDiff
53+
infix:100 " — " => Int.formalDiff
5454

5555
/-- Definition 4.1.1 (Integers) -/
5656
theorem Int.eq (a b c d:ℕ): a — b = c — d ↔ a + d = c + b := by

Analysis/Section_4_2.lean

Lines changed: 11 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -31,43 +31,31 @@ theorem PreRat.eq (a b c d:ℤ) (hb: b ≠ 0) (hd: d ≠ 0): (⟨ a,b,hb ⟩: Pr
3131
abbrev Rat := Quotient PreRat.instSetoid
3232

3333
/-- We give division a "junk" value of 0//1 if the denominator is zero -/
34-
abbrev Rat.formalDiv (a b:ℤ) : Int := Quotient.mk PreInt.instSetoid if h:b ≠ 0 then ⟨ a,b,h ⟩ else0, 1, by decide ⟩
34+
abbrev Rat.formalDiv (a b:ℤ) : Rat := Quotient.mk PreRat.instSetoid (if h:b ≠ 0 then ⟨ a,b,h ⟩ else0, 1, by decide ⟩)
3535

36-
infix:70 " // " => Rat.formalDiv
36+
infix:100 " // " => Rat.formalDiv
3737

3838
/-- Definition 4.2.1 (Rationals) -/
3939
theorem Rat.eq (a c:ℤ) {b d:ℤ} (hb: b ≠ 0) (hd: d ≠ 0): a // b = c // d ↔ a * d = c * b := by
40-
simp [hb, hd]
41-
constructor
42-
. exact Quotient.exact
43-
intro h; exact Quotient.sound h
40+
simp [hb, hd, Setoid.r]
4441

4542
/-- Definition 4.2.1 (Rationals) -/
4643
theorem Rat.eq_diff (n:Rat) : ∃ a b, b ≠ 0 ∧ n = a // b := by
4744
apply Quot.ind _ n; intro ⟨ a, b, h ⟩
4845
use a, b; refine ⟨ h, ?_ ⟩
4946
simp [Rat.formalDiv, h]
50-
51-
/-- Lemma 4.2.3 (Addition well-defined) -/
52-
theorem Rat.add_congr_left (a b a' b' c d : ℤ) (hb: b ≠ 0) (hb': b' ≠ 0) (hd: d ≠ 0) (h: a // b = a' // b') : (a*d+b*c) // (b*d) = (a'*d+b'*c) // (b'*d) := by
53-
have hbd: b*d ≠ 0 := by sorry
54-
have hb'd: b'*d ≠ 0 := by sorry
55-
simp only [Rat.eq _ _ hb hb', Rat.eq _ _ hbd hb'd] at h ⊢
56-
calc
57-
_ = (a*b')*d*d + b*b'*c*d := by ring
58-
_ = (a'*b)*d*d + b*b'*c*d := by rw [h]
59-
_ = _ := by ring
60-
61-
theorem Rat.add_congr_right (a b c d c' d' : ℤ) (hb: b ≠ 0) (hd: d ≠ 0) (hd': d' ≠ 0) (h: c // d = c' // d') : (a*d+b*c) // (b*d) = (a*d'+b*c') // (b*d') := by sorry
62-
63-
theorem Rat.add_congr (a b c d a' b' c' d' : ℤ) (hb: b ≠ 0) (hb': b' ≠ 0) (hd: d ≠ 0) (hd': d' ≠ 0) (h: a // b = a' // b') : (a*d+b*c) // (b*d) = (a*d'+b*c') // (b*d') := by sorry
47+
rfl
6448

6549

6650
/-- Lemma 4.2.3 (Addition well-defined) -/
6751
instance Rat.add_inst : Add Rat where
6852
add := Quotient.lift₂ (fun ⟨ a, b, h1 ⟩ ⟨ c, d, h2 ⟩ ↦ (a*d+b*c) // (b*d)) (by
69-
intros ⟨ a, b, h1 ⟩ ⟨ c, d, h2 ⟩ ⟨ a', b', h1' ⟩ ⟨ c', d', h2' ⟩ h1 h2
70-
simp [Setoid.r] at *
71-
exact Rat.add_congr_left a b a' b' c d c' d' h1 h1' h2 h2')
53+
intro ⟨ a, b, h1 ⟩ ⟨ c, d, h2 ⟩ ⟨ a', b', h1' ⟩ ⟨ c', d', h2' ⟩ h3 h4
54+
simp [Setoid.r, h1, h2, h1', h2'] at *
55+
calc
56+
_ = (a*b')*d*d' + b*b'*(c*d') := by ring
57+
_ = (a'*b)*d*d' + b*b'*(c'*d) := by rw [h3, h4]
58+
_ = _ := by ring
59+
)
7260

7361
end Section_4_2

0 commit comments

Comments
 (0)