chore: binderIdent normalization

fixes #1411
This commit is contained in:
Leonardo de Moura 2022-08-04 21:09:16 -07:00
parent 659300597d
commit 55bb8e905a
6 changed files with 14 additions and 8 deletions

View file

@ -338,7 +338,7 @@ theorem Poly.denote_mul (ctx : Context) (k : Nat) (p : Poly) : (p.mul k).denote
by_cases h : k == 1 <;> simp [h]; simp [eq_of_beq h]
induction p with
| nil => simp
| cons kv m ih => cases kv with | _ k' v => simp [ih]
| cons kv m ih => cases kv with | mk k' v => simp [ih]
private theorem eq_of_not_blt_eq_true (h₁ : ¬ (Nat.blt x y = true)) (h₂ : ¬ (Nat.blt y x = true)) : x = y :=
have h₁ : ¬ x < y := fun h => h₁ (Nat.blt_eq.mpr h)

View file

@ -8,7 +8,7 @@ import Init.Notation
namespace Lean
syntax binderIdent := ident <|> "_"
syntax binderIdent := ident <|> hole
namespace Parser.Tactic
/-- `with_annotate_state stx t` annotates the lexical range of `stx : Syntax` with the initial and final state of running tactic `t`. -/
@ -34,7 +34,7 @@ For each hypothesis to be introduced, the remaining main goal's target type must
-/
syntax (name := intro) "intro " notFollowedBy("|") (colGt term:max)* : tactic
/-- `intros x...` behaves like `intro x...`, but then keeps introducing (anonymous) hypotheses until goal is not of a function type. -/
syntax (name := intros) "intros " (colGt (ident <|> "_"))* : tactic
syntax (name := intros) "intros " (colGt (ident <|> hole))* : tactic
/--
`rename t => x` renames the most recent hypothesis whose type matches `t` (which may contain placeholders) to `x`,
or fails if no such hypothesis could be found. -/
@ -253,7 +253,7 @@ should be constructor applications of the same constructor.
Given `h : a::b = c::d`, the tactic `injection h` adds two new hypothesis with types `a = c` and `b = d` to the main goal.
The tactic `injection h with h₁ h₂` uses the names `h₁` and `h₂` to name the new hypotheses.
-/
syntax (name := injection) "injection " term (" with " (colGt (ident <|> "_"))+)? : tactic
syntax (name := injection) "injection " term (" with " (colGt (ident <|> hole))+)? : tactic
/-- `injections` applies `injection` to all hypotheses recursively
(since `injection` can produce new hypotheses). Useful for destructing nested
@ -354,7 +354,7 @@ macro (priority := high) "have'" x:ident " := " p:term : tactic => `(have' $x :
/-- Similar to `let`, but using `refine'` -/
macro "let' " d:letDecl : tactic => `(refine_lift' let $d:letDecl; ?_)
syntax inductionAltLHS := "| " (("@"? ident) <|> "_") (ident <|> "_")*
syntax inductionAltLHS := "| " (("@"? ident) <|> hole) (ident <|> hole)*
syntax inductionAlt := ppDedent(ppLine) inductionAltLHS+ " => " (hole <|> syntheticHole <|> tacticSeq)
syntax inductionAlts := "with " (tactic)? withPosition( (colGe inductionAlt)+)
/--

View file

@ -98,7 +98,7 @@ inductive TerminationWF where
/-
```
def terminationByElement := leading_parser ppLine >> (ident <|> "_") >> many (ident <|> "_") >> " => " >> termParser >> optional ";"
def terminationByElement := leading_parser ppLine >> (ident <|> hole) >> many (ident <|> hole) >> " => " >> termParser >> optional ";"
def terminationBy := leading_parser ppLine >> "termination_by " >> many1chIndent terminationByElement
```
-/

View file

@ -21,7 +21,7 @@ open Meta
/-
Given an `inductionAlt` of the form
```
syntax inductionAltLHS := "| " (group("@"? ident) <|> "_") (ident <|> "_")*
syntax inductionAltLHS := "| " (group("@"? ident) <|> hole) (ident <|> hole)*
syntax inductionAlt := ppDedent(ppLine) inductionAltLHS+ " => " (hole <|> syntheticHole <|> tacticSeq)
```
-/

View file

@ -35,7 +35,7 @@ def terminationHint (p : Parser) := terminationHintMany p <|> terminationHint1 p
def terminationByCore := leading_parser "termination_by' " >> terminationHint termParser
def decreasingBy := leading_parser "decreasing_by " >> terminationHint Tactic.tacticSeq
def terminationByElement := leading_parser ppLine >> (ident <|> "_") >> many (ident <|> "_") >> " => " >> termParser >> optional ";"
def terminationByElement := leading_parser ppLine >> (ident <|> Term.hole) >> many (ident <|> Term.hole) >> " => " >> termParser >> optional ";"
def terminationBy := leading_parser ppLine >> "termination_by " >> many1Indent terminationByElement
def terminationSuffix := optional (terminationBy <|> terminationByCore) >> optional decreasingBy

6
tests/lean/run/1411.lean Normal file
View file

@ -0,0 +1,6 @@
namespace Lean
syntax "foo " binderIdent : term
example : Syntax → MacroM Syntax
| `(foo _) => `(_)
| `(foo $x:ident) => `($x:ident)
| _ => `(_)