Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend/lean/notation_cmds.cpp):
notation (name := ...)
syntax (
#754) This is an attempt to solve the issues in leanprover-community/mathport#158 once and for all. The main new user-facing behavior is that notations have names, and if you have an overlapping name the definition is rejected. That means that the following is now rejected: ```lean notation `foo` := nat notation `foo` := nat ``` To fix the issue, name one or the other using the new `(name := ...)` syntax: ```lean notation `foo` := nat notation (name := bar) `foo` := nat ``` Unlike declaration names, notation names are only required to be distinct within a scope. So the following is legal: ```lean section local notation (name := foo) `foo` := nat end local notation (name := foo) `foo` := nat ``` Reserved notations do not have names / do not cause name conflicts with regular notations, although you are syntactically allowed to name them.
- Loading branch information
Showing
45 changed files
with
164 additions
and
95 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
local infix ` + ` := nat.add | ||
@[class] local infix ` + ` := nat.add | ||
noncomputable local infix ` + ` := nat.add | ||
@[class] noncomputable local infix ` + ` := nat.add | ||
/-- foo -/ local infix ` + ` := nat.add | ||
local infix (name := plus1) ` + ` := nat.add | ||
@[class] local infix (name := plus2) ` + ` := nat.add | ||
noncomputable local infix (name := plus3) ` + ` := nat.add | ||
@[class] noncomputable local infix (name := plus4) ` + ` := nat.add | ||
/-- foo -/ local infix (name := plus5) ` + ` := nat.add |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,11 @@ | ||
-- | ||
inductive List (T : Type) : Type | nil {} : List | cons : T → List → List open List notation h :: t := cons h t notation `[` l:(foldr `,` (h t, cons h t) nil) `]` := l | ||
infixr `::` := cons | ||
inductive List (T : Type) : Type | ||
| nil {} : List | ||
| cons : T → List → List | ||
open List | ||
notation (name := cons2) h :: t := cons h t | ||
notation (name := list2) `[` l:(foldr `,` (h t, cons h t) nil) `]` := l | ||
infixr (name := cons) `::` := cons | ||
#check (1:nat) :: 2 :: nil | ||
#check (1:nat) :: 2 :: 3 :: 4 :: 5 :: nil | ||
#print ] |
Oops, something went wrong.