@@ -945,6 +945,7 @@ open Lean Elab Meta Command Term
945945elab "create_lts" lt:ident name:ident : command => do
946946 liftTermElabM do
947947 let lt ← realizeGlobalConstNoOverloadWithInfo lt
948+ let (declName, _) ← mkDeclName (← getCurrNamespace) default name.getId
948949 let ci ← getConstInfo lt
949950 forallTelescope ci.type fun args ty => do
950951 let throwNotLT := throwError m! "type{ indentExpr ci.type} \n is not a labelled transition"
@@ -960,15 +961,15 @@ elab "create_lts" lt:ident name:ident : command => do
960961 let value ← mkLambdaFVars args[0 :args.size-3 ] bundle
961962 let type ← inferType value
962963 addAndCompile <| .defnDecl {
963- name := name.getId
964+ name := declName
964965 levelParams := ci.levelParams
965966 type
966967 value
967968 safety := .safe
968969 hints := Lean.ReducibilityHints.abbrev
969970 }
970- addTermInfo' name (.const name.getId params) (isBinder := true )
971- addDeclarationRangesFromSyntax name.getId name
971+ addTermInfo' name (.const declName params) (isBinder := true )
972+ addDeclarationRangesFromSyntax declName name
972973
973974/--
974975 This command adds transition notations for an `LTS`. This should not usually be called directly,
@@ -1004,22 +1005,21 @@ initialize Lean.registerBuiltinAttribute {
10041005 name := `lts_attr
10051006 descr := "Register notation for an LTS"
10061007 add := fun decl stx _ => MetaM.run' do
1008+ let currNamespace ← getCurrNamespace
10071009 match stx with
10081010 | `(attr | lts $lts $sym) =>
10091011 let mut sym := sym
10101012 unless sym.getString.endsWith " " do
10111013 sym := Syntax.mkStrLit (sym.getString ++ " " )
1012- let lts := lts.getId.updatePrefix decl.getPrefix |> Lean.mkIdent
1013- liftCommandElabM <| Command.elabCommand (← `(create_lts $(mkIdent decl) $lts))
1014- liftCommandElabM <| (do
1015- modifyScope ({ · with currNamespace := decl.getPrefix })
1016- Command.elabCommand (← `(scoped lts_transition_notation $lts $sym)))
1014+ liftCommandElabM <| do
1015+ modifyScope ({ · with currNamespace })
1016+ Command.elabCommand (← `(create_lts $(mkIdent decl) $lts))
1017+ Command.elabCommand (← `(scoped lts_transition_notation $lts $sym))
10171018 | `(attr | lts $lts) =>
1018- let lts := lts.getId.updatePrefix decl.getPrefix |> Lean.mkIdent
1019- liftCommandElabM <| Command.elabCommand (← `(create_lts $(mkIdent decl) $lts))
1020- liftCommandElabM <| (do
1021- modifyScope ({ · with currNamespace := decl.getPrefix })
1022- Command.elabCommand (← `(scoped lts_transition_notation $lts)))
1019+ liftCommandElabM <| do
1020+ modifyScope ({ · with currNamespace })
1021+ Command.elabCommand (← `(create_lts $(mkIdent decl) $lts))
1022+ Command.elabCommand (← `(scoped lts_transition_notation $lts))
10231023 | _ => throwError "invalid syntax for 'lts' attribute"
10241024}
10251025
0 commit comments