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

lemma works not synonymously for theorem or def #5813

Closed
3 tasks done
LKlinke opened this issue Oct 22, 2024 · 3 comments
Closed
3 tasks done

lemma works not synonymously for theorem or def #5813

LKlinke opened this issue Oct 22, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@LKlinke
Copy link

LKlinke commented Oct 22, 2024

Prerequisites

Please put an X between the brackets as you perform the following steps:

Description

The following minimal example does not work:

def add2 x := x + 2

def add4 x := x + 4

lemma broken: (add4 x) = add2 (add2 x) := by simp [add4, add2]

whereas

def add2 x := x + 2

def add4 x := x + 4

theorem broken: (add4 x) = add2 (add2 x) := by simp [add4, add2]

works fine.

Expected behavior: Both programs should work fine.

Actual behavior: the theorem version works, the lemma version does not.

Versions

4.12.0-nightly-2024-10-22
live.lean-lang.org

Impact

Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.

@LKlinke LKlinke added the bug Something isn't working label Oct 22, 2024
@nomeata
Copy link
Collaborator

nomeata commented Oct 23, 2024

Thanks for the report. The lemma command is a feature of mathlib (or batteries) and simply does not exist in lean. Maybe it would be desirable to have a better error message when a command name is unknown or misspelled, or have stricter indentation rules that make this fail more clearly, but for now I'd say it works as advertised.

@nomeata nomeata closed this as completed Oct 23, 2024
@digama0
Copy link
Collaborator

digama0 commented Oct 23, 2024

Note that batteries has a lemma command which is implemented specifically so that it can tell you that it is not lean syntax and suggests theorem instead. I would like such support to be upstreamed, where it can be more useful.

@LKlinke
Copy link
Author

LKlinke commented Oct 23, 2024

I think my issue was that when reading the reference manual (Version 3) is says:

Lean provides ways of adding new objects to the environment. The following provide straightforward ways of declaring
new objects:

constant c : α : declares a constant named c of type α, where c is a declaration name.
axiom c : α : alternative syntax for constant
def c : α := t : defines c to denote t, which should have type α.
theorem c : p := t : similar to def, but intended to be used when p is a proposition.
lemma c : p := t : alternative syntax for theorem

Here it is never mentioned that lemma is only available when using additional libraries. Of course I should have read version 4 instead of version 3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants