Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

david-christiansen
Copy link
Collaborator

These changes allow the tests to pass with the latest Lean nightly again.

@github-actions github-actions bot temporarily deployed to lean-lang.org/theorem_proving_in_lean4 March 1, 2024 19:54 Inactive
@github-actions github-actions bot temporarily deployed to lean-lang.org/theorem_proving_in_lean4 March 1, 2024 19:54 Inactive
@@ -1100,10 +1100,11 @@ theorem linv_comp_self {f : α → β} [Inhabited α]
have ex : ∃ a₁ : α, f a₁ = f a := ⟨a, rfl⟩
have feq : f (choose ex) = f a := choose_spec ex
calc linv f (f a)
_ = choose ex := dif_pos ex
_ = choose ex := by simp
Copy link
Collaborator Author

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 the Decidable instance and the else branch). This lemma is really designed to be used with simp rather than directly, and simp solves the goal.

@@ -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))
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have and_comm in scope by default. I chose to rename it here, rather than secretly stick it in a namespace, because I want code bits to work if people type them in.

On the other hand, the hidden Proof structure is not present, so this is a very weak argument for this solution. Happy to do the other one if you'd prefer.

calc
x ∣ y := h₁
_ = z := h₂
_ ∣ 2*z := divides_mul ..
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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.

Comment on lines +480 to +498
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 ..
Copy link
Collaborator Author

Choose a reason for hiding this comment

The 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

@david-christiansen
Copy link
Collaborator Author

@avigad - I believe you're the right one to approve these changes. If not, let me know, and I'll start working down the list of co-authors.

Thanks!

@david-christiansen david-christiansen mentioned this pull request Mar 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant