-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Update examples to work with latest Lean nightly #107
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,10 +43,10 @@ constant of such a type. | |
# proof : p | ||
#check Proof -- Proof : Prop → Type | ||
|
||
axiom and_comm (p q : Prop) : Proof (Implies (And p q) (And q p)) | ||
axiom and_commutative (p q : Prop) : Proof (Implies (And p q) (And q p)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We now have On the other hand, the hidden |
||
|
||
variable (p q : Prop) | ||
#check and_comm p q -- Proof (Implies (And p q) (And q p)) | ||
#check and_commutative p q -- Proof (Implies (And p q) (And q p)) | ||
``` | ||
|
||
In addition to axioms, however, we would also need rules to build new | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -477,40 +477,30 @@ of the `Trans` type class. Type classes are introduced later, but the following | |
small example demonstrates how to extend the `calc` notation using new `Trans` instances. | ||
|
||
```lean | ||
def divides (x y : Nat) : Prop := | ||
def Divides (x y : Nat) : Prop := | ||
∃ k, k*x = y | ||
|
||
def divides_trans (h₁ : divides x y) (h₂ : divides y z) : divides x z := | ||
def Divides_trans (h₁ : Divides x y) (h₂ : Divides y z) : Divides x z := | ||
let ⟨k₁, d₁⟩ := h₁ | ||
let ⟨k₂, d₂⟩ := h₂ | ||
⟨k₁ * k₂, by rw [Nat.mul_comm k₁ k₂, Nat.mul_assoc, d₁, d₂]⟩ | ||
|
||
def divides_mul (x : Nat) (k : Nat) : divides x (k*x) := | ||
def Divides_mul (x : Nat) (k : Nat) : Divides x (k*x) := | ||
⟨k, rfl⟩ | ||
|
||
instance : Trans divides divides divides where | ||
trans := divides_trans | ||
instance : Trans Divides Divides Divides where | ||
trans := Divides_trans | ||
|
||
example (h₁ : divides x y) (h₂ : y = z) : divides x (2*z) := | ||
example (h₁ : Divides x y) (h₂ : y = z) : Divides x (2*z) := | ||
calc | ||
divides x y := h₁ | ||
Divides x y := h₁ | ||
_ = z := h₂ | ||
divides _ (2*z) := divides_mul .. | ||
Divides _ (2*z) := Divides_mul .. | ||
Comment on lines
+480
to
+498
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is just a rename to more closely follow Lean 4 conventions while I was here |
||
|
||
infix:50 " ∣ " => divides | ||
|
||
example (h₁ : divides x y) (h₂ : y = z) : divides x (2*z) := | ||
calc | ||
x ∣ y := h₁ | ||
_ = z := h₂ | ||
_ ∣ 2*z := divides_mul .. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This notation is now built-in, and they were conflicting. It didn't seem to be worth a longer aside in the text to save this, so I deleted it. |
||
``` | ||
|
||
The example above also makes it clear that you can use `calc` even if you | ||
do not have an infix notation for your relation. Finally we remark that | ||
the vertical bar `∣` in the example above is the unicode one. We use | ||
unicode to make sure we do not overload the ASCII `|` used in the | ||
`match .. with` expression. | ||
do not have an infix notation for your relation. | ||
|
||
With ``calc``, we can write the proof in the last section in a more | ||
natural and perspicuous way. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This fixes an error where
dif_pos
's implicit arguments were not being found (namely theDecidable
instance and the else branch). This lemma is really designed to be used withsimp
rather than directly, andsimp
solves the goal.