path
stringlengths 12
84
| imports
sequencelengths 0
4.45k
| premises
listlengths 0
625
|
---|---|---|
.lake/packages/lean4/src/lean/Lean/ParserCompiler/Attribute.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/ToExpr.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/InitAttr.lean"
] | [
{
"full_name": "Lean.ParserCompiler.CombinatorAttribute",
"code": "structure CombinatorAttribute where\n impl : AttributeImpl\n ext : SimplePersistentEnvExtension (Name Γ Name) (NameMap Name)\n deriving Inhabited",
"start": [
14,
1
],
"end": [
17,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.registerCombinatorAttribute",
"code": "def registerCombinatorAttribute (name : Name) (descr : String) (ref : Name := by exact decl_name%)\n : IO CombinatorAttribute := do\n let ext : SimplePersistentEnvExtension (Name Γ Name) (NameMap Name) β registerSimplePersistentEnvExtension {\n name := ref,\n addImportedFn := mkStateFromImportedEntries (fun s p => s.insert p.1 p.2) {},\n addEntryFn := fun (s : NameMap Name) (p : Name Γ Name) => s.insert p.1 p.2,\n }\n let attrImpl : AttributeImpl := {\n ref := ref,\n name := name,\n descr := descr,\n add := fun decl stx _ => do\n let env β getEnv\n let parserDeclName β Elab.realizeGlobalConstNoOverloadWithInfo (β Attribute.Builtin.getIdent stx)\n setEnv <| ext.addEntry env (parserDeclName, decl)\n }\n registerBuiltinAttribute attrImpl\n pure { impl := attrImpl, ext := ext }",
"start": [
20,
1
],
"end": [
37,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.CombinatorAttribute.getDeclFor?",
"code": "def getDeclFor? (attr : CombinatorAttribute) (env : Environment) (parserDecl : Name) : Option Name :=\n (attr.ext.getState env).find? parserDecl",
"start": [
41,
1
],
"end": [
42,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.CombinatorAttribute.setDeclFor",
"code": "def setDeclFor (attr : CombinatorAttribute) (env : Environment) (parserDecl : Name) (decl : Name) : Environment :=\n attr.ext.addEntry env (parserDecl, decl)",
"start": [
44,
1
],
"end": [
45,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.CombinatorAttribute.runDeclFor",
"code": "unsafe def runDeclFor {Ξ±} (attr : CombinatorAttribute) (parserDecl : Name) : CoreM Ξ± := do\n match attr.getDeclFor? (β getEnv) parserDecl with\n | some d => evalConst Ξ± d\n | _ => throwError \"no declaration of attribute [{attr.impl.name}] found for '{parserDecl}'\"",
"start": [
47,
1
],
"end": [
50,
99
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/StrInterpolation.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Basic.lean"
] | [
{
"full_name": "Lean.Parser.isQuotableCharForStrInterpolant",
"code": "def isQuotableCharForStrInterpolant (c : Char) : Bool :=\n c == '{' || isQuotableCharDefault c",
"start": [
10,
1
],
"end": [
11,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.interpolatedStrFn",
"code": "partial def interpolatedStrFn (p : ParserFn) : ParserFn := fun c s =>\n let input := c.input\n let stackSize := s.stackSize\n let rec parse (startPos : String.Pos) (c : ParserContext) (s : ParserState) : ParserState :=\n let i := s.pos\n if input.atEnd i then\n let s := s.mkError \"unterminated string literal\"\n s.mkNode interpolatedStrKind stackSize\n else\n let curr := input.get i\n let s := s.setPos (input.next i)\n if curr == '\\\"' then\n let s := mkNodeToken interpolatedStrLitKind startPos c s\n s.mkNode interpolatedStrKind stackSize\n else if curr == '\\\\' then\n andthenFn (quotedCharCoreFn isQuotableCharForStrInterpolant true) (parse startPos) c s\n else if curr == '{' then\n let s := mkNodeToken interpolatedStrLitKind startPos c s\n let s := p c s\n if s.hasError then s\n else\n let i := s.pos\n let curr := input.get i\n if curr == '}' then\n let s := s.setPos (input.next i)\n parse i c s\n else\n let s := s.mkError \"'}'\"\n s.mkNode interpolatedStrKind stackSize\n else\n parse startPos c s\n let startPos := s.pos\n if input.atEnd startPos then\n s.mkEOIError\n else\n let curr := input.get s.pos;\n if curr != '\\\"' then\n s.mkError \"interpolated string\"\n else\n let s := s.next input startPos\n parse startPos c s",
"start": [
13,
1
],
"end": [
53,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.interpolatedStrNoAntiquot",
"code": "@[inline] def interpolatedStrNoAntiquot (p : Parser) : Parser := {\n fn := interpolatedStrFn (withoutPosition p).fn,\n info := mkAtomicInfo \"interpolatedStr\"\n}",
"start": [
55,
1
],
"end": [
58,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.interpolatedStr",
"code": "def interpolatedStr (p : Parser) : Parser :=\n withAntiquot (mkAntiquot \"interpolatedStr\" interpolatedStrKind) $ interpolatedStrNoAntiquot p",
"start": [
60,
1
],
"end": [
72,
96
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/KeyedDeclsAttribute.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.runForNodeKind",
"code": "unsafe def runForNodeKind {Ξ±} (attr : KeyedDeclsAttribute Ξ±) (k : SyntaxNodeKind) (interp : ParserDescr β CoreM Ξ±) : CoreM Ξ± := do\n match attr.getValues (β getEnv) k with\n | p::_ => pure p\n | _ =>\n let info β getConstInfo k\n if info.type.isConstOf ``ParserDescr || info.type.isConstOf ``TrailingParserDescr then\n let d β evalConst ParserDescr k\n interp d\n else\n throwError \"no declaration of attribute [{attr.defn.name}] found for '{k}'\"",
"start": [
16,
1
],
"end": [
26,
82
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Parenthesizer.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Parser/StrInterpolation.lean",
".lake/packages/lean4/src/lean/Lean/ParserCompiler/Attribute.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Extension.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.Context",
"code": "structure Context where\n cat : Name := Name.anonymous",
"start": [
84,
1
],
"end": [
86,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.State",
"code": "structure State where\n stxTrav : Syntax.Traverser\n contPrec : Option Nat := none\n contCat : Name := Name.anonymous\n minPrec : Option Nat := none\n trailPrec : Option Nat := none\n trailCat : Name := Name.anonymous\n visitedToken : Bool := false",
"start": [
88,
1
],
"end": [
99,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ParenthesizerM",
"code": "abbrev ParenthesizerM := ReaderT Parenthesizer.Context $ StateRefT Parenthesizer.State CoreM",
"start": [
103,
1
],
"end": [
103,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer",
"code": "abbrev Parenthesizer := ParenthesizerM Unit",
"start": [
104,
1
],
"end": [
104,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ParenthesizerM.orElse",
"code": "@[inline] def ParenthesizerM.orElse (pβ : ParenthesizerM Ξ±) (pβ : Unit β ParenthesizerM Ξ±) : ParenthesizerM Ξ± := do\n let s β get\n catchInternalId backtrackExceptionId\n pβ\n (fun _ => do set s; pβ ())",
"start": [
106,
1
],
"end": [
110,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.mkParenthesizerAttribute",
"code": "unsafe def mkParenthesizerAttribute : IO (KeyedDeclsAttribute Parenthesizer) :=\n KeyedDeclsAttribute.init {\n builtinName := `builtin_parenthesizer,\n name := `parenthesizer,\n descr := \"Register a parenthesizer for a parser.\n\n [parenthesizer k] registers a declaration of type `Lean.PrettyPrinter.Parenthesizer` for the `SyntaxNodeKind` `k`.\",\n valueTypeName := `Lean.PrettyPrinter.Parenthesizer,\n evalKey := fun builtin stx => do\n let env β getEnv\n let stx β Attribute.Builtin.getIdent stx\n let id := stx.getId\n unless (builtin && (env.find? id).isSome) || Parser.isValidSyntaxNodeKind env id do\n throwError \"invalid [parenthesizer] argument, unknown syntax kind '{id}'\"\n if (β getEnv).contains id && (β Elab.getInfoState).enabled then\n Elab.addConstInfo stx id none\n pure id\n } `Lean.PrettyPrinter.parenthesizerAttribute",
"start": [
114,
1
],
"end": [
133,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.parenthesizerAttribute",
"code": "@[builtin_init mkParenthesizerAttribute] opaque parenthesizerAttribute : KeyedDeclsAttribute Parenthesizer",
"start": [
134,
1
],
"end": [
134,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.CategoryParenthesizer",
"code": "abbrev CategoryParenthesizer := (prec : Nat) β Parenthesizer",
"start": [
136,
1
],
"end": [
136,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.mkCategoryParenthesizerAttribute",
"code": "unsafe def mkCategoryParenthesizerAttribute : IO (KeyedDeclsAttribute CategoryParenthesizer) :=\n KeyedDeclsAttribute.init {\n builtinName := `builtin_category_parenthesizer,\n name := `category_parenthesizer,\n descr := \"Register a parenthesizer for a syntax category.\n\n [category_parenthesizer cat] registers a declaration of type `Lean.PrettyPrinter.CategoryParenthesizer` for the category `cat`,\n which is used when parenthesizing calls of `categoryParser cat prec`. Implementations should call `maybeParenthesize`\n with the precedence and `cat`. If no category parenthesizer is registered, the category will never be parenthesized,\n but still be traversed for parenthesizing nested categories.\",\n valueTypeName := `Lean.PrettyPrinter.CategoryParenthesizer,\n evalKey := fun _ stx => do\n let env β getEnv\n let stx β Attribute.Builtin.getIdent stx\n let id := stx.getId\n let some cat := (Parser.parserExtension.getState env).categories.find? id\n | throwError \"invalid [category_parenthesizer] argument, unknown parser category '{toString id}'\"\n if (β Elab.getInfoState).enabled && (β getEnv).contains cat.declName then\n Elab.addConstInfo stx cat.declName none\n pure id\n } `Lean.PrettyPrinter.categoryParenthesizerAttribute",
"start": [
138,
1
],
"end": [
158,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.categoryParenthesizerAttribute",
"code": "@[builtin_init mkCategoryParenthesizerAttribute] opaque categoryParenthesizerAttribute : KeyedDeclsAttribute CategoryParenthesizer",
"start": [
159,
1
],
"end": [
159,
131
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.mkCombinatorParenthesizerAttribute",
"code": "unsafe def mkCombinatorParenthesizerAttribute : IO ParserCompiler.CombinatorAttribute :=\n ParserCompiler.registerCombinatorAttribute\n `combinator_parenthesizer\n \"Register a parenthesizer for a parser combinator.\n\n [combinator_parenthesizer c] registers a declaration of type `Lean.PrettyPrinter.Parenthesizer` for the `Parser` declaration `c`.\n Note that, unlike with [parenthesizer], this is not a node kind since combinators usually do not introduce their own node kinds.\n The tagged declaration may optionally accept parameters corresponding to (a prefix of) those of `c`, where `Parser` is replaced\n with `Parenthesizer` in the parameter types.\"",
"start": [
161,
1
],
"end": [
169,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.combinatorParenthesizerAttribute",
"code": "@[builtin_init mkCombinatorParenthesizerAttribute] opaque combinatorParenthesizerAttribute : ParserCompiler.CombinatorAttribute",
"start": [
170,
1
],
"end": [
170,
128
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.throwBacktrack",
"code": "def throwBacktrack {Ξ±} : ParenthesizerM Ξ± :=\nthrow $ Exception.internal backtrackExceptionId",
"start": [
177,
1
],
"end": [
178,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.addPrecCheck",
"code": "def addPrecCheck (prec : Nat) : ParenthesizerM Unit :=\n modify fun st => { st with contPrec := Nat.min (st.contPrec.getD prec) prec, minPrec := Nat.min (st.minPrec.getD prec) prec }",
"start": [
188,
1
],
"end": [
189,
128
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.visitArgs",
"code": "def visitArgs (x : ParenthesizerM Unit) : ParenthesizerM Unit := do\n let stx β getCur\n if stx.getArgs.size > 0 then\n goDown (stx.getArgs.size - 1) *> x <* goUp\n goLeft",
"start": [
191,
1
],
"end": [
196,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.maybeParenthesize",
"code": "def maybeParenthesize (cat : Name) (canJuxtapose : Bool) (mkParen : Syntax β Syntax) (prec : Nat) (x : ParenthesizerM Unit) : ParenthesizerM Unit := do\n let stx β getCur\n let idx β getIdx\n let st β get\n set { stxTrav := st.stxTrav : State }\n trace[PrettyPrinter.parenthesize] \"parenthesizing (cont := {(st.contPrec, st.contCat)}){indentD (format stx)}\"\n x\n let { minPrec := some minPrec, trailPrec := trailPrec, trailCat := trailCat, .. } β get\n | trace[PrettyPrinter.parenthesize] \"visited a syntax tree without precedences?!{line ++ format stx}\"\n trace[PrettyPrinter.parenthesize] (m!\"...precedences are {prec} >? {minPrec}\" ++ if canJuxtapose then m!\", {(trailPrec, trailCat)} <=? {(st.contPrec, st.contCat)}\" else \"\")\n if (prec > minPrec || canJuxtapose && match trailPrec, st.contPrec with | some trailPrec, some contPrec => trailCat == st.contCat && trailPrec <= contPrec | _, _ => false) then\n if idx > 0 then goRight\n let mut stx β getCur\n if let SourceInfo.original _ pos trail endPos := stx.getHeadInfo then\n stx := stx.setHeadInfo (SourceInfo.original \"\".toSubstring pos trail endPos)\n if let SourceInfo.original lead pos _ endPos := stx.getTailInfo then\n stx := stx.setTailInfo (SourceInfo.original lead pos \"\".toSubstring endPos)\n let mut stx' := mkParen stx\n if let SourceInfo.original lead pos _ endPos := stx.getHeadInfo then\n stx' := stx'.setHeadInfo (SourceInfo.original lead pos \"\".toSubstring endPos)\n if let SourceInfo.original _ pos trail endPos := stx.getTailInfo then\n stx' := stx'.setTailInfo (SourceInfo.original \"\".toSubstring pos trail endPos)\n trace[PrettyPrinter.parenthesize] \"parenthesized: {stx'.formatStx none}\"\n setCur stx'\n goLeft\n modify (fun st => { st with contPrec := Parser.maxPrec, contCat := cat, trailPrec := none })\n let { trailPrec := trailPrec, .. } β get\n if st.visitedToken then\n modify fun stP => { stP with trailPrec := st.trailPrec, trailCat := st.trailCat }\n else\n let trailPrec := match trailPrec with\n | some trailPrec => Nat.min trailPrec prec\n | _ => prec\n modify fun stP => { stP with trailPrec := trailPrec, trailCat := cat }\n modify fun stP => { stP with minPrec := st.minPrec }",
"start": [
206,
1
],
"end": [
252,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.visitToken",
"code": "def visitToken : Parenthesizer := do\n modify fun st => { st with contPrec := none, contCat := Name.anonymous, visitedToken := true }\n goLeft",
"start": [
254,
1
],
"end": [
257,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.orelse.parenthesizer",
"code": "@[combinator_parenthesizer orelse] partial def orelse.parenthesizer (p1 p2 : Parenthesizer) : Parenthesizer := do\n let stx β getCur\n if stx.getKind == `choice then\n visitArgs $ stx.getArgs.size.forM fun _ => do\n orelse.parenthesizer p1 p2\n else\n p1 <|> p2",
"start": [
259,
1
],
"end": [
268,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.recover.parenthesizer",
"code": "@[combinator_parenthesizer recover]\ndef recover.parenthesizer (p : PrettyPrinter.Parenthesizer) : PrettyPrinter.Parenthesizer := p",
"start": [
270,
1
],
"end": [
271,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.recover'.parenthesizer",
"code": "@[combinator_parenthesizer recover']\ndef recover'.parenthesizer (p : PrettyPrinter.Parenthesizer) : PrettyPrinter.Parenthesizer := p",
"start": [
273,
1
],
"end": [
274,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.mkAntiquot.parenthesizer'",
"code": "@[extern \"lean_mk_antiquot_parenthesizer\"]\nopaque mkAntiquot.parenthesizer' (name : String) (kind : SyntaxNodeKind) (anonymous := true) (isPseudoKind := false) : Parenthesizer",
"start": [
280,
1
],
"end": [
281,
133
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.liftCoreM",
"code": "@[inline] def liftCoreM {Ξ±} (x : CoreM Ξ±) : ParenthesizerM Ξ± :=\n liftM x",
"start": [
283,
1
],
"end": [
284,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.interpretParserDescr'",
"code": "@[extern \"lean_pretty_printer_parenthesizer_interpret_parser_descr\"]\nopaque interpretParserDescr' : ParserDescr β CoreM Parenthesizer",
"start": [
287,
1
],
"end": [
288,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.parenthesizerForKindUnsafe",
"code": "unsafe def parenthesizerForKindUnsafe (k : SyntaxNodeKind) : Parenthesizer := do\n if k == `missing then\n pure ()\n else\n let p β runForNodeKind parenthesizerAttribute k interpretParserDescr'\n p",
"start": [
290,
1
],
"end": [
295,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.parenthesizerForKind",
"code": "@[implemented_by parenthesizerForKindUnsafe]\nopaque parenthesizerForKind (k : SyntaxNodeKind) : Parenthesizer",
"start": [
297,
1
],
"end": [
298,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.withAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer withAntiquot]\ndef withAntiquot.parenthesizer (antiP p : Parenthesizer) : Parenthesizer := do\n let stx β getCur\n if stx.isAntiquot || stx.isAntiquotSplice then\n orelse.parenthesizer antiP p\n else\n p",
"start": [
300,
1
],
"end": [
307,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.withAntiquotSuffixSplice.parenthesizer",
"code": "@[combinator_parenthesizer withAntiquotSuffixSplice]\ndef withAntiquotSuffixSplice.parenthesizer (_ : SyntaxNodeKind) (p suffix : Parenthesizer) : Parenthesizer := do\n if (β getCur).isAntiquotSuffixSplice then\n visitArgs <| suffix *> p\n else\n p",
"start": [
309,
1
],
"end": [
314,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.tokenWithAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer tokenWithAntiquot]\ndef tokenWithAntiquot.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n if (β getCur).isTokenAntiquot then\n visitArgs p\n else\n p",
"start": [
316,
1
],
"end": [
321,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.parenthesizeCategoryCore",
"code": "partial def parenthesizeCategoryCore (cat : Name) (_prec : Nat) : Parenthesizer :=\n withReader (fun ctx => { ctx with cat := cat }) do\n let stx β getCur\n if stx.getKind == `choice then\n visitArgs $ stx.getArgs.size.forM fun _ => do\n parenthesizeCategoryCore cat _prec\n else\n withAntiquot.parenthesizer (mkAntiquot.parenthesizer' cat.toString cat (isPseudoKind := true)) (parenthesizerForKind stx.getKind)\n modify fun st => { st with contCat := cat }",
"start": [
323,
1
],
"end": [
331,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.categoryParser.parenthesizer",
"code": "@[combinator_parenthesizer categoryParser]\ndef categoryParser.parenthesizer (cat : Name) (prec : Nat) : Parenthesizer := do\n let env β getEnv\n match categoryParenthesizerAttribute.getValues env cat with\n | p::_ => p prec\n | _ => parenthesizeCategoryCore cat prec",
"start": [
333,
1
],
"end": [
340,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.parserOfStack.parenthesizer",
"code": "@[combinator_parenthesizer parserOfStack]\ndef parserOfStack.parenthesizer (offset : Nat) (_prec : Nat := 0) : Parenthesizer := do\n let st β get\n let stx := st.stxTrav.parents.back.getArg (st.stxTrav.idxs.back - offset)\n parenthesizerForKind stx.getKind",
"start": [
342,
1
],
"end": [
346,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.term.parenthesizer",
"code": "@[builtin_category_parenthesizer term]\ndef term.parenthesizer : CategoryParenthesizer | prec => do\n maybeParenthesize `term true wrapParens prec $\n parenthesizeCategoryCore `term prec\nwhere\n \n wrapParens (stx : Syntax) : Syntax := Unhygienic.run do\n let pstx β `(($(β¨stxβ©)))\n return pstx.raw.setInfo (SourceInfo.fromRef stx)",
"start": [
348,
1
],
"end": [
361,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.tactic.parenthesizer",
"code": "@[builtin_category_parenthesizer tactic]\ndef tactic.parenthesizer : CategoryParenthesizer | prec => do\n maybeParenthesize `tactic false (fun stx => Unhygienic.run `(tactic|($(β¨stxβ©)))) prec $\n parenthesizeCategoryCore `tactic prec",
"start": [
363,
1
],
"end": [
366,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.level.parenthesizer",
"code": "@[builtin_category_parenthesizer level]\ndef level.parenthesizer : CategoryParenthesizer | prec => do\n maybeParenthesize `level false (fun stx => Unhygienic.run `(level|($(β¨stxβ©)))) prec $\n parenthesizeCategoryCore `level prec",
"start": [
368,
1
],
"end": [
371,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.rawStx.parenthesizer",
"code": "@[builtin_category_parenthesizer rawStx]\ndef rawStx.parenthesizer : CategoryParenthesizer | _ => do\n goLeft",
"start": [
373,
1
],
"end": [
375,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.error.parenthesizer",
"code": "@[combinator_parenthesizer error]\ndef error.parenthesizer (_msg : String) : Parenthesizer :=\n pure ()",
"start": [
377,
1
],
"end": [
379,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.errorAtSavedPos.parenthesizer",
"code": "@[combinator_parenthesizer errorAtSavedPos]\ndef errorAtSavedPos.parenthesizer (_msg : String) (_delta : Bool) : Parenthesizer :=\n pure ()",
"start": [
381,
1
],
"end": [
383,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.atomic.parenthesizer",
"code": "@[combinator_parenthesizer atomic]\ndef atomic.parenthesizer (p : Parenthesizer) : Parenthesizer :=\n p",
"start": [
385,
1
],
"end": [
387,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.lookahead.parenthesizer",
"code": "@[combinator_parenthesizer lookahead]\ndef lookahead.parenthesizer (_ : Parenthesizer) : Parenthesizer :=\n pure ()",
"start": [
389,
1
],
"end": [
391,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.notFollowedBy.parenthesizer",
"code": "@[combinator_parenthesizer notFollowedBy]\ndef notFollowedBy.parenthesizer (_ : Parenthesizer) : Parenthesizer :=\n pure ()",
"start": [
393,
1
],
"end": [
395,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.andthen.parenthesizer",
"code": "@[combinator_parenthesizer andthen]\ndef andthen.parenthesizer (p1 p2 : Parenthesizer) : Parenthesizer :=\n p2 *> p1",
"start": [
397,
1
],
"end": [
399,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkKind",
"code": "def checkKind (k : SyntaxNodeKind) : Parenthesizer := do\n let stx β getCur\n if k != stx.getKind then\n trace[PrettyPrinter.parenthesize.backtrack] \"unexpected node kind '{stx.getKind}', expected '{k}'\"\n throwBacktrack",
"start": [
401,
1
],
"end": [
406,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.node.parenthesizer",
"code": "@[combinator_parenthesizer node]\ndef node.parenthesizer (k : SyntaxNodeKind) (p : Parenthesizer) : Parenthesizer := do\n checkKind k\n visitArgs p",
"start": [
408,
1
],
"end": [
411,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkPrec.parenthesizer",
"code": "@[combinator_parenthesizer checkPrec]\ndef checkPrec.parenthesizer (prec : Nat) : Parenthesizer :=\n addPrecCheck prec",
"start": [
413,
1
],
"end": [
415,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.withFn.parenthesizer",
"code": "@[combinator_parenthesizer withFn]\ndef withFn.parenthesizer (_ : ParserFn β ParserFn) (p : Parenthesizer) : Parenthesizer := p",
"start": [
417,
1
],
"end": [
418,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.leadingNode.parenthesizer",
"code": "@[combinator_parenthesizer leadingNode]\ndef leadingNode.parenthesizer (k : SyntaxNodeKind) (prec : Nat) (p : Parenthesizer) : Parenthesizer := do\n node.parenthesizer k p\n addPrecCheck prec\n modify fun st => { st with contPrec := Nat.min (Parser.maxPrec-1) prec }",
"start": [
420,
1
],
"end": [
427,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.trailingNode.parenthesizer",
"code": "@[combinator_parenthesizer trailingNode]\ndef trailingNode.parenthesizer (k : SyntaxNodeKind) (prec lhsPrec : Nat) (p : Parenthesizer) : Parenthesizer := do\n checkKind k\n visitArgs do\n p\n addPrecCheck prec\n let ctx β read\n modify fun st => { st with contCat := ctx.cat }\n categoryParser.parenthesizer ctx.cat lhsPrec",
"start": [
429,
1
],
"end": [
441,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.rawCh.parenthesizer",
"code": "@[combinator_parenthesizer rawCh] def rawCh.parenthesizer (_ch : Char) := visitToken",
"start": [
443,
1
],
"end": [
443,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.symbolNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer symbolNoAntiquot] def symbolNoAntiquot.parenthesizer (_sym : String) := visitToken",
"start": [
445,
1
],
"end": [
445,
110
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.unicodeSymbolNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer unicodeSymbolNoAntiquot] def unicodeSymbolNoAntiquot.parenthesizer (_sym _asciiSym : String) := visitToken",
"start": [
446,
1
],
"end": [
446,
134
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.identNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer identNoAntiquot] def identNoAntiquot.parenthesizer := do checkKind identKind; visitToken",
"start": [
448,
1
],
"end": [
448,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.rawIdentNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer rawIdentNoAntiquot] def rawIdentNoAntiquot.parenthesizer := visitToken",
"start": [
449,
1
],
"end": [
449,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.identEq.parenthesizer",
"code": "@[combinator_parenthesizer identEq] def identEq.parenthesizer (_id : Name) := visitToken",
"start": [
450,
1
],
"end": [
450,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.nonReservedSymbolNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer nonReservedSymbolNoAntiquot] def nonReservedSymbolNoAntiquot.parenthesizer (_sym : String) (_includeIdent : Bool) := visitToken",
"start": [
451,
1
],
"end": [
451,
155
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.charLitNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer charLitNoAntiquot] def charLitNoAntiquot.parenthesizer := visitToken",
"start": [
453,
1
],
"end": [
453,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.strLitNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer strLitNoAntiquot] def strLitNoAntiquot.parenthesizer := visitToken",
"start": [
454,
1
],
"end": [
454,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.nameLitNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer nameLitNoAntiquot] def nameLitNoAntiquot.parenthesizer := visitToken",
"start": [
455,
1
],
"end": [
455,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.numLitNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer numLitNoAntiquot] def numLitNoAntiquot.parenthesizer := visitToken",
"start": [
456,
1
],
"end": [
456,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.scientificLitNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer scientificLitNoAntiquot] def scientificLitNoAntiquot.parenthesizer := visitToken",
"start": [
457,
1
],
"end": [
457,
108
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.fieldIdx.parenthesizer",
"code": "@[combinator_parenthesizer fieldIdx] def fieldIdx.parenthesizer := visitToken",
"start": [
458,
1
],
"end": [
458,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.manyNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer manyNoAntiquot]\ndef manyNoAntiquot.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n let stx β getCur\n visitArgs $ stx.getArgs.size.forM fun _ => p",
"start": [
460,
1
],
"end": [
463,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.many1NoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer many1NoAntiquot]\ndef many1NoAntiquot.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n manyNoAntiquot.parenthesizer p",
"start": [
465,
1
],
"end": [
467,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.many1Unbox.parenthesizer",
"code": "@[combinator_parenthesizer many1Unbox]\ndef many1Unbox.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n let stx β getCur\n if stx.getKind == nullKind then\n manyNoAntiquot.parenthesizer p\n else\n p",
"start": [
469,
1
],
"end": [
475,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.optionalNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer optionalNoAntiquot]\ndef optionalNoAntiquot.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n visitArgs p",
"start": [
477,
1
],
"end": [
479,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.sepByNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer sepByNoAntiquot]\ndef sepByNoAntiquot.parenthesizer (p pSep : Parenthesizer) : Parenthesizer := do\n let stx β getCur\n visitArgs <| (List.range stx.getArgs.size).reverse.forM fun i => if i % 2 == 0 then p else pSep",
"start": [
481,
1
],
"end": [
484,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.sepBy1NoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer sepBy1NoAntiquot] def sepBy1NoAntiquot.parenthesizer := sepByNoAntiquot.parenthesizer",
"start": [
486,
1
],
"end": [
486,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.withPosition.parenthesizer",
"code": "@[combinator_parenthesizer withPosition] def withPosition.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n modify fun st => { st with contPrec := none }\n p",
"start": [
488,
1
],
"end": [
491,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.withPositionAfterLinebreak.parenthesizer",
"code": "@[combinator_parenthesizer withPositionAfterLinebreak] def withPositionAfterLinebreak.parenthesizer (p : Parenthesizer) : Parenthesizer :=\n withPosition.parenthesizer p",
"start": [
492,
1
],
"end": [
494,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.withoutInfo.parenthesizer",
"code": "@[combinator_parenthesizer withoutInfo] def withoutInfo.parenthesizer (p : Parenthesizer) : Parenthesizer := p",
"start": [
496,
1
],
"end": [
496,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkStackTop.parenthesizer",
"code": "@[combinator_parenthesizer checkStackTop] def checkStackTop.parenthesizer : Parenthesizer := pure ()",
"start": [
498,
1
],
"end": [
498,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkWsBefore.parenthesizer",
"code": "@[combinator_parenthesizer checkWsBefore] def checkWsBefore.parenthesizer : Parenthesizer := pure ()",
"start": [
499,
1
],
"end": [
499,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkNoWsBefore.parenthesizer",
"code": "@[combinator_parenthesizer checkNoWsBefore] def checkNoWsBefore.parenthesizer : Parenthesizer := pure ()",
"start": [
500,
1
],
"end": [
500,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkLinebreakBefore.parenthesizer",
"code": "@[combinator_parenthesizer checkLinebreakBefore] def checkLinebreakBefore.parenthesizer : Parenthesizer := pure ()",
"start": [
501,
1
],
"end": [
501,
115
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkTailWs.parenthesizer",
"code": "@[combinator_parenthesizer checkTailWs] def checkTailWs.parenthesizer : Parenthesizer := pure ()",
"start": [
502,
1
],
"end": [
502,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkColEq.parenthesizer",
"code": "@[combinator_parenthesizer checkColEq] def checkColEq.parenthesizer : Parenthesizer := pure ()",
"start": [
503,
1
],
"end": [
503,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkColGe.parenthesizer",
"code": "@[combinator_parenthesizer checkColGe] def checkColGe.parenthesizer : Parenthesizer := pure ()",
"start": [
504,
1
],
"end": [
504,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkColGt.parenthesizer",
"code": "@[combinator_parenthesizer checkColGt] def checkColGt.parenthesizer : Parenthesizer := pure ()",
"start": [
505,
1
],
"end": [
505,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkLineEq.parenthesizer",
"code": "@[combinator_parenthesizer checkLineEq] def checkLineEq.parenthesizer : Parenthesizer := pure ()",
"start": [
506,
1
],
"end": [
506,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.eoi.parenthesizer",
"code": "@[combinator_parenthesizer eoi] def eoi.parenthesizer : Parenthesizer := pure ()",
"start": [
507,
1
],
"end": [
507,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.checkNoImmediateColon.parenthesizer",
"code": "@[combinator_parenthesizer checkNoImmediateColon] def checkNoImmediateColon.parenthesizer : Parenthesizer := pure ()",
"start": [
508,
1
],
"end": [
508,
117
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.skip.parenthesizer",
"code": "@[combinator_parenthesizer skip] def skip.parenthesizer : Parenthesizer := pure ()",
"start": [
509,
1
],
"end": [
509,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.pushNone.parenthesizer",
"code": "@[combinator_parenthesizer pushNone] def pushNone.parenthesizer : Parenthesizer := goLeft",
"start": [
511,
1
],
"end": [
511,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.hygieneInfoNoAntiquot.parenthesizer",
"code": "@[combinator_parenthesizer hygieneInfoNoAntiquot] def hygieneInfoNoAntiquot.parenthesizer : Parenthesizer := goLeft",
"start": [
512,
1
],
"end": [
512,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.interpolatedStr.parenthesizer",
"code": "@[combinator_parenthesizer interpolatedStr]\ndef interpolatedStr.parenthesizer (p : Parenthesizer) : Parenthesizer := do\n visitArgs $ (β getCur).getArgs.reverse.forM fun chunk =>\n if chunk.isOfKind interpolatedStrLitKind then\n goLeft\n else\n p",
"start": [
514,
1
],
"end": [
520,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.ite",
"code": "@[combinator_parenthesizer _root_.ite, macro_inline] def ite {_ : Type} (c : Prop) [Decidable c] (t e : Parenthesizer) : Parenthesizer :=\n if c then t else e",
"start": [
522,
1
],
"end": [
523,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.ParenthesizerAliasValue",
"code": "abbrev ParenthesizerAliasValue := AliasValue Parenthesizer",
"start": [
527,
1
],
"end": [
527,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.registerAlias",
"code": "def registerAlias (aliasName : Name) (v : ParenthesizerAliasValue) : IO Unit := do\n Parser.registerAliasCore parenthesizerAliasesRef aliasName v",
"start": [
531,
1
],
"end": [
532,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.parenthesize",
"code": "def parenthesize (parenthesizer : Parenthesizer) (stx : Syntax) : CoreM Syntax := do\n trace[PrettyPrinter.parenthesize.input] \"{format stx}\"\n catchInternalId backtrackExceptionId\n (do\n let (_, st) β (parenthesizer {}).run { stxTrav := Syntax.Traverser.fromSyntax stx }\n pure st.stxTrav.cur)\n (fun _ => throwError \"parenthesize: uncaught backtrack exception\")",
"start": [
541,
1
],
"end": [
548,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.parenthesizeCategory",
"code": "def parenthesizeCategory (cat : Name) := parenthesize <| categoryParser.parenthesizer cat 0",
"start": [
550,
1
],
"end": [
550,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.parenthesizeTerm",
"code": "def parenthesizeTerm := parenthesizeCategory `term",
"start": [
552,
1
],
"end": [
552,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.parenthesizeTactic",
"code": "def parenthesizeTactic := parenthesizeCategory `tactic",
"start": [
553,
1
],
"end": [
553,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.parenthesizeCommand",
"code": "def parenthesizeCommand := parenthesizeCategory `command",
"start": [
554,
1
],
"end": [
554,
57
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Formatter.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Basic.lean",
".lake/packages/lean4/src/lean/Lean/ParserCompiler/Attribute.lean",
".lake/packages/lean4/src/lean/Lean/KeyedDeclsAttribute.lean",
".lake/packages/lean4/src/lean/Lean/CoreM.lean",
".lake/packages/lean4/src/lean/Lean/Parser/StrInterpolation.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Extension.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Formatter.Context",
"code": "structure Context where\n options : Options\n table : Parser.TokenTable",
"start": [
27,
1
],
"end": [
29,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.State",
"code": "structure State where\n stxTrav : Syntax.Traverser\n leadWord : String := \"\"\n isUngrouped : Bool := false\n mustBeGrouped : Bool := true\n stack : Array Format := #[]",
"start": [
31,
1
],
"end": [
43,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.FormatterM",
"code": "abbrev FormatterM := ReaderT Formatter.Context $ StateRefT Formatter.State CoreM",
"start": [
47,
1
],
"end": [
47,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.FormatterM.orElse",
"code": "@[inline] def FormatterM.orElse {Ξ±} (pβ : FormatterM Ξ±) (pβ : Unit β FormatterM Ξ±) : FormatterM Ξ± := do\n let s β get\n catchInternalId backtrackExceptionId\n pβ\n (fun _ => do set s; pβ ())",
"start": [
49,
1
],
"end": [
53,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter",
"code": "abbrev Formatter := FormatterM Unit",
"start": [
57,
1
],
"end": [
57,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.mkFormatterAttribute",
"code": "unsafe def mkFormatterAttribute : IO (KeyedDeclsAttribute Formatter) :=\n KeyedDeclsAttribute.init {\n builtinName := `builtin_formatter,\n name := `formatter,\n descr := \"Register a formatter for a parser.\n\n [formatter k] registers a declaration of type `Lean.PrettyPrinter.Formatter` for the `SyntaxNodeKind` `k`.\",\n valueTypeName := `Lean.PrettyPrinter.Formatter,\n evalKey := fun builtin stx => do\n let env β getEnv\n let stx β Attribute.Builtin.getIdent stx\n let id := stx.getId\n unless (builtin && (env.find? id).isSome) || Parser.isValidSyntaxNodeKind env id do\n throwError \"invalid [formatter] argument, unknown syntax kind '{id}'\"\n if (β getEnv).contains id && (β Elab.getInfoState).enabled then\n Elab.addConstInfo stx id none\n pure id\n } `Lean.PrettyPrinter.formatterAttribute",
"start": [
59,
1
],
"end": [
78,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.formatterAttribute",
"code": "@[builtin_init mkFormatterAttribute] opaque formatterAttribute : KeyedDeclsAttribute Formatter",
"start": [
79,
1
],
"end": [
79,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.mkCombinatorFormatterAttribute",
"code": "unsafe def mkCombinatorFormatterAttribute : IO ParserCompiler.CombinatorAttribute :=\n ParserCompiler.registerCombinatorAttribute\n `combinator_formatter\n \"Register a formatter for a parser combinator.\n\n [combinator_formatter c] registers a declaration of type `Lean.PrettyPrinter.Formatter` for the `Parser` declaration `c`.\n Note that, unlike with [formatter], this is not a node kind since combinators usually do not introduce their own node kinds.\n The tagged declaration may optionally accept parameters corresponding to (a prefix of) those of `c`, where `Parser` is replaced\n with `Formatter` in the parameter types.\"",
"start": [
81,
1
],
"end": [
89,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.combinatorFormatterAttribute",
"code": "@[builtin_init mkCombinatorFormatterAttribute] opaque combinatorFormatterAttribute : ParserCompiler.CombinatorAttribute",
"start": [
90,
1
],
"end": [
90,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.throwBacktrack",
"code": "def throwBacktrack {Ξ±} : FormatterM Ξ± :=\nthrow $ Exception.internal backtrackExceptionId",
"start": [
97,
1
],
"end": [
98,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.getStack",
"code": "def getStack : FormatterM (Array Format) := do\n let st β get\n pure st.stack",
"start": [
108,
1
],
"end": [
110,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.getStackSize",
"code": "def getStackSize : FormatterM Nat := do\n let stack β getStack;\n pure stack.size",
"start": [
112,
1
],
"end": [
114,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.setStack",
"code": "def setStack (stack : Array Format) : FormatterM Unit :=\n modify fun st => { st with stack := stack }",
"start": [
116,
1
],
"end": [
117,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.push",
"code": "private def push (f : Format) : FormatterM Unit :=\n modify fun st => { st with stack := st.stack.push f, isUngrouped := false }",
"start": [
119,
1
],
"end": [
120,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.pushWhitespace",
"code": "def pushWhitespace (f : Format) : FormatterM Unit := do\n push f\n modify fun st => { st with leadWord := \"\", isUngrouped := false }",
"start": [
122,
1
],
"end": [
124,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.pushLine",
"code": "def pushLine : FormatterM Unit :=\n pushWhitespace Format.line",
"start": [
126,
1
],
"end": [
127,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.pushAlign",
"code": "def pushAlign (force : Bool) : FormatterM Unit :=\n pushWhitespace (.align force)",
"start": [
129,
1
],
"end": [
130,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.visitArgs",
"code": "def visitArgs (x : FormatterM Unit) : FormatterM Unit := do\n let stx β getCur\n if stx.getArgs.size > 0 then\n goDown (stx.getArgs.size - 1) *> x <* goUp\n goLeft",
"start": [
132,
1
],
"end": [
137,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.fold",
"code": "def fold (fn : Array Format β Format) (x : FormatterM Unit) : FormatterM Unit := do\n let sp β getStackSize\n x\n let stack β getStack\n let f := fn $ stack.extract sp stack.size\n setStack $ (stack.shrink sp).push f",
"start": [
139,
1
],
"end": [
145,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.concat",
"code": "def concat (x : FormatterM Unit) : FormatterM Unit := do\n fold (Array.foldl (fun acc f => if acc.isNil then f else f ++ acc) Format.nil) x",
"start": [
147,
1
],
"end": [
149,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.indent",
"code": "def indent (x : Formatter) (indent : Option Int := none) : Formatter := do\n concat x\n let ctx β read\n let indent := indent.getD $ Std.Format.getIndent ctx.options\n modify fun st => { st with stack := st.stack.modify (st.stack.size - 1) (Format.nest indent) }",
"start": [
151,
1
],
"end": [
155,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.fill",
"code": "def fill (x : Formatter) : Formatter := do\n concat x\n modify fun st => { st with\n stack := st.stack.modify (st.stack.size - 1) Format.fill\n isUngrouped := false\n }",
"start": [
157,
1
],
"end": [
162,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.group",
"code": "def group (x : Formatter) : Formatter := do\n concat x\n modify fun st => { st with\n stack := st.stack.modify (st.stack.size - 1) Format.group\n isUngrouped := false\n }",
"start": [
164,
1
],
"end": [
169,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.withMaybeTag",
"code": "def withMaybeTag (pos? : Option String.Pos) (x : FormatterM Unit) : Formatter := do\n if let some p := pos? then\n concat x\n modify fun st => {\n st with stack := st.stack.modify (st.stack.size - 1) fun fmt =>\n if fmt matches Format.tag .. then fmt\n else Format.tag p.byteIdx fmt\n }\n else\n x",
"start": [
171,
1
],
"end": [
182,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.orelse.formatter",
"code": "@[combinator_formatter orelse] partial def orelse.formatter (p1 p2 : Formatter) : Formatter := do\n let stx β getCur\n if stx.getKind == `choice then\n visitArgs do\n orelse.formatter p1 p2\n else\n p1 <|> p2",
"start": [
184,
1
],
"end": [
195,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.recover.formatter",
"code": "@[combinator_formatter recover]\ndef recover.formatter (fmt : PrettyPrinter.Formatter) := fmt",
"start": [
197,
1
],
"end": [
198,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.recover'.formatter",
"code": "@[combinator_formatter recover']\ndef recover'.formatter (fmt : PrettyPrinter.Formatter) := fmt",
"start": [
200,
1
],
"end": [
201,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.mkAntiquot.formatter'",
"code": "@[extern \"lean_mk_antiquot_formatter\"]\nopaque mkAntiquot.formatter' (name : String) (kind : SyntaxNodeKind) (anonymous := true) (isPseudoKind := false) : Formatter",
"start": [
207,
1
],
"end": [
208,
125
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.interpretParserDescr'",
"code": "@[extern \"lean_pretty_printer_formatter_interpret_parser_descr\"]\nopaque interpretParserDescr' : ParserDescr β CoreM Formatter",
"start": [
211,
1
],
"end": [
212,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.SourceInfo.getExprPos?",
"code": "private def SourceInfo.getExprPos? : SourceInfo β Option String.Pos\n | SourceInfo.synthetic (pos := pos) .. => pos\n | _ => none",
"start": [
214,
1
],
"end": [
216,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.getExprPos?",
"code": "private def getExprPos? : Syntax β Option String.Pos\n | Syntax.node info _ _ => SourceInfo.getExprPos? info\n | Syntax.atom info _ => SourceInfo.getExprPos? info\n | Syntax.ident info _ _ _ => SourceInfo.getExprPos? info\n | Syntax.missing => none",
"start": [
218,
1
],
"end": [
222,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.formatterForKindUnsafe",
"code": "unsafe def formatterForKindUnsafe (k : SyntaxNodeKind) : Formatter := do\n if k == `missing then\n push \"<missing>\"\n goLeft\n else\n let stx β getCur\n let f β runForNodeKind formatterAttribute k interpretParserDescr'\n withMaybeTag (getExprPos? stx) f",
"start": [
224,
1
],
"end": [
231,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.formatterForKind",
"code": "@[implemented_by formatterForKindUnsafe]\nopaque formatterForKind (k : SyntaxNodeKind) : Formatter",
"start": [
233,
1
],
"end": [
234,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.withAntiquot.formatter",
"code": "@[combinator_formatter withAntiquot]\ndef withAntiquot.formatter (antiP p : Formatter) : Formatter :=\n orelse.formatter antiP p",
"start": [
236,
1
],
"end": [
240,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.withAntiquotSuffixSplice.formatter",
"code": "@[combinator_formatter withAntiquotSuffixSplice]\ndef withAntiquotSuffixSplice.formatter (_ : SyntaxNodeKind) (p suffix : Formatter) : Formatter := do\n if (β getCur).isAntiquotSuffixSplice then\n visitArgs <| suffix *> p\n else\n p",
"start": [
242,
1
],
"end": [
247,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.tokenWithAntiquot.formatter",
"code": "@[combinator_formatter tokenWithAntiquot]\ndef tokenWithAntiquot.formatter (p : Formatter) : Formatter := do\n if (β getCur).isTokenAntiquot then\n visitArgs p\n else\n p",
"start": [
249,
1
],
"end": [
254,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.categoryFormatterCore",
"code": "def categoryFormatterCore (cat : Name) : Formatter := do\n modify fun st => { st with mustBeGrouped := true, isUngrouped := false }\n let stx β getCur\n trace[PrettyPrinter.format] \"formatting {indentD (format stx)}\"\n if stx.getKind == `choice then\n visitArgs do\n formatterForKind (β getCur).getKind\n else if cat == `rawStx then\n withAntiquot.formatter (mkAntiquot.formatter' cat.toString cat (isPseudoKind := true)) (push stx.formatStx *> goLeft)\n else\n withAntiquot.formatter (mkAntiquot.formatter' cat.toString cat (isPseudoKind := true)) (formatterForKind stx.getKind)\n modify fun st => { st with mustBeGrouped := true, isUngrouped := !st.mustBeGrouped }",
"start": [
256,
1
],
"end": [
269,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.categoryParser.formatter",
"code": "@[combinator_formatter categoryParser]\ndef categoryParser.formatter (cat : Name) : Formatter := do\n concat <| categoryFormatterCore cat\n unless (β get).isUngrouped do\n let indent := Std.Format.getIndent (β read).options\n modify fun st => { st with\n stack := st.stack.modify (st.stack.size - 1) fun fmt =>\n fmt.nest indent |>.fill\n }",
"start": [
271,
1
],
"end": [
279,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.categoryFormatter",
"code": "def categoryFormatter (cat : Name) : Formatter :=\n fill <| indent <| categoryFormatterCore cat",
"start": [
281,
1
],
"end": [
282,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.parserOfStack.formatter",
"code": "@[combinator_formatter parserOfStack]\ndef parserOfStack.formatter (offset : Nat) (_prec : Nat := 0) : Formatter := do\n let st β get\n let stx := st.stxTrav.parents.back.getArg (st.stxTrav.idxs.back - offset)\n formatterForKind stx.getKind",
"start": [
284,
1
],
"end": [
288,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.error.formatter",
"code": "@[combinator_formatter error]\ndef error.formatter (_msg : String) : Formatter := pure ()",
"start": [
290,
1
],
"end": [
291,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.errorAtSavedPos.formatter",
"code": "@[combinator_formatter errorAtSavedPos]\ndef errorAtSavedPos.formatter (_msg : String) (_delta : Bool) : Formatter := pure ()",
"start": [
292,
1
],
"end": [
293,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.lookahead.formatter",
"code": "@[combinator_formatter lookahead]\ndef lookahead.formatter (_ : Formatter) : Formatter := pure ()",
"start": [
294,
1
],
"end": [
295,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.notFollowedBy.formatter",
"code": "@[combinator_formatter notFollowedBy]\ndef notFollowedBy.formatter (_ : Formatter) : Formatter := pure ()",
"start": [
297,
1
],
"end": [
298,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.andthen.formatter",
"code": "@[combinator_formatter andthen]\ndef andthen.formatter (p1 p2 : Formatter) : Formatter := p2 *> p1",
"start": [
300,
1
],
"end": [
301,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkKind",
"code": "def checkKind (k : SyntaxNodeKind) : FormatterM Unit := do\n let stx β getCur\n if k != stx.getKind then\n trace[PrettyPrinter.format.backtrack] \"unexpected node kind '{stx.getKind}', expected '{k}'\"\n throwBacktrack",
"start": [
303,
1
],
"end": [
307,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.node.formatter",
"code": "@[combinator_formatter node]\ndef node.formatter (k : SyntaxNodeKind) (p : Formatter) : Formatter := do\n checkKind k;\n visitArgs p",
"start": [
309,
1
],
"end": [
312,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.withFn.formatter",
"code": "@[combinator_formatter withFn]\ndef withFn.formatter (_ : ParserFn β ParserFn) (p : Formatter) : Formatter := p",
"start": [
314,
1
],
"end": [
315,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.trailingNode.formatter",
"code": "@[combinator_formatter trailingNode]\ndef trailingNode.formatter (k : SyntaxNodeKind) (_ _ : Nat) (p : Formatter) : Formatter := do\n checkKind k\n visitArgs do\n p;\n categoryParser.formatter `foo",
"start": [
317,
1
],
"end": [
323,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.parseToken",
"code": "def parseToken (s : String) : FormatterM ParserState :=\n return (Parser.andthenFn Parser.whitespace (Parser.tokenFn [])).run {\n input := s,\n fileName := \"\",\n fileMap := FileMap.ofString \"\"\n } {\n env := β getEnv,\n options := β getOptions\n } ((β read).table) (Parser.mkParserState s)",
"start": [
325,
1
],
"end": [
334,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.pushToken",
"code": "def pushToken (info : SourceInfo) (tk : String) : FormatterM Unit := do\n match info with\n | SourceInfo.original _ _ ss _ =>\n let ss' := ss.trim\n if !ss'.isEmpty then\n let ws := { ss with startPos := ss'.stopPos }\n if ws.contains '\\n' then\n push s!\"\\n{ss'}\"\n else\n push s!\" {ss'}\"\n modify fun st => { st with leadWord := \"\" }\n | _ => pure ()\n\n let st β get\n if st.leadWord != \"\" && tk.trimRight == tk then\n let tk' := tk.trimLeft\n let t β parseToken $ tk' ++ st.leadWord\n if t.pos <= tk'.endPos then\n push tk\n modify fun st => { st with leadWord := if tk.trimLeft == tk then tk ++ st.leadWord else \"\" }\n else\n push $ tk ++ \" \"\n modify fun st => { st with leadWord := if tk.trimLeft == tk then tk else \"\" }\n else\n if st.leadWord == \"\" then\n push tk.trimRight\n else if tk.endsWith \" \" then\n pushLine\n push tk.trimRight\n else\n push tk modify fun st => { st with leadWord := if tk.trimLeft == tk then tk else \"\" }\n\n match info with\n | SourceInfo.original ss _ _ _ =>\n let ss' := ss.trim\n if !ss'.isEmpty then\n let ws := { ss with startPos := ss'.stopPos }\n if ws.contains '\\n' then do\n indent (push s!\"{ss'}\\n\") (some ((0:Int) - Std.Format.getIndent (β getOptions)))\n else\n pushLine\n push ss'.toString\n modify fun st => { st with leadWord := \"\" }\n | _ => pure ()",
"start": [
336,
1
],
"end": [
388,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.symbolNoAntiquot.formatter",
"code": "@[combinator_formatter symbolNoAntiquot]\ndef symbolNoAntiquot.formatter (sym : String) : Formatter := do\n let stx β getCur\n if stx.isToken sym then do\n let (Syntax.atom info _) β pure stx | unreachable!\n withMaybeTag (getExprPos? stx) (pushToken info sym)\n goLeft\n else do\n trace[PrettyPrinter.format.backtrack] \"unexpected syntax '{format stx}', expected symbol '{sym}'\"\n throwBacktrack",
"start": [
390,
1
],
"end": [
399,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.nonReservedSymbolNoAntiquot.formatter",
"code": "@[combinator_formatter nonReservedSymbolNoAntiquot] def nonReservedSymbolNoAntiquot.formatter := symbolNoAntiquot.formatter",
"start": [
401,
1
],
"end": [
401,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.rawCh.formatter",
"code": "@[combinator_formatter rawCh] def rawCh.formatter (ch : Char) := symbolNoAntiquot.formatter ch.toString",
"start": [
403,
1
],
"end": [
403,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.unicodeSymbolNoAntiquot.formatter",
"code": "@[combinator_formatter unicodeSymbolNoAntiquot]\ndef unicodeSymbolNoAntiquot.formatter (sym asciiSym : String) : Formatter := do\n let Syntax.atom info val β getCur\n | throwError m!\"not an atom: {β getCur}\"\n if val == sym.trim then\n pushToken info sym\n else\n pushToken info asciiSym;\n goLeft",
"start": [
405,
1
],
"end": [
413,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.identNoAntiquot.formatter",
"code": "@[combinator_formatter identNoAntiquot]\ndef identNoAntiquot.formatter : Formatter := do\n checkKind identKind\n let stx@(Syntax.ident info _ id _) β getCur\n | throwError m!\"not an ident: {β getCur}\"\n let id := id.simpMacroScopes\n withMaybeTag (getExprPos? stx) (pushToken info id.toString)\n goLeft",
"start": [
415,
1
],
"end": [
422,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.rawIdentNoAntiquot.formatter",
"code": "@[combinator_formatter rawIdentNoAntiquot] def rawIdentNoAntiquot.formatter : Formatter := do\n checkKind identKind\n let Syntax.ident info _ id _ β getCur\n | throwError m!\"not an ident: {β getCur}\"\n pushToken info id.toString\n goLeft",
"start": [
424,
1
],
"end": [
429,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.identEq.formatter",
"code": "@[combinator_formatter identEq] def identEq.formatter (_id : Name) := rawIdentNoAntiquot.formatter",
"start": [
431,
1
],
"end": [
431,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.visitAtom",
"code": "def visitAtom (k : SyntaxNodeKind) : Formatter := do\n let stx β getCur\n if k != Name.anonymous then\n checkKind k\n let Syntax.atom info val β pure $ stx.ifNode (fun n => n.getArg 0) (fun _ => stx)\n | throwError m!\"not an atom: {stx}\"\n pushToken info val\n goLeft",
"start": [
433,
1
],
"end": [
440,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.charLitNoAntiquot.formatter",
"code": "@[combinator_formatter charLitNoAntiquot] def charLitNoAntiquot.formatter := visitAtom charLitKind",
"start": [
442,
1
],
"end": [
442,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.strLitNoAntiquot.formatter",
"code": "@[combinator_formatter strLitNoAntiquot] def strLitNoAntiquot.formatter := visitAtom strLitKind",
"start": [
443,
1
],
"end": [
443,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.nameLitNoAntiquot.formatter",
"code": "@[combinator_formatter nameLitNoAntiquot] def nameLitNoAntiquot.formatter := visitAtom nameLitKind",
"start": [
444,
1
],
"end": [
444,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.numLitNoAntiquot.formatter",
"code": "@[combinator_formatter numLitNoAntiquot] def numLitNoAntiquot.formatter := visitAtom numLitKind",
"start": [
445,
1
],
"end": [
445,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.scientificLitNoAntiquot.formatter",
"code": "@[combinator_formatter scientificLitNoAntiquot] def scientificLitNoAntiquot.formatter := visitAtom scientificLitKind",
"start": [
446,
1
],
"end": [
446,
117
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.fieldIdx.formatter",
"code": "@[combinator_formatter fieldIdx] def fieldIdx.formatter := visitAtom fieldIdxKind",
"start": [
447,
1
],
"end": [
447,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.manyNoAntiquot.formatter",
"code": "@[combinator_formatter manyNoAntiquot]\ndef manyNoAntiquot.formatter (p : Formatter) : Formatter := do\n let stx β getCur\n visitArgs $ stx.getArgs.size.forM fun _ => p",
"start": [
449,
1
],
"end": [
452,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.many1NoAntiquot.formatter",
"code": "@[combinator_formatter many1NoAntiquot] def many1NoAntiquot.formatter (p : Formatter) : Formatter := manyNoAntiquot.formatter p",
"start": [
454,
1
],
"end": [
454,
128
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.optionalNoAntiquot.formatter",
"code": "@[combinator_formatter optionalNoAntiquot]\ndef optionalNoAntiquot.formatter (p : Formatter) : Formatter := visitArgs p",
"start": [
456,
1
],
"end": [
457,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.many1Unbox.formatter",
"code": "@[combinator_formatter many1Unbox]\ndef many1Unbox.formatter (p : Formatter) : Formatter := do\n let stx β getCur\n if stx.getKind == nullKind then do\n manyNoAntiquot.formatter p\n else\n p",
"start": [
459,
1
],
"end": [
465,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.sepByNoAntiquot.formatter",
"code": "@[combinator_formatter sepByNoAntiquot]\ndef sepByNoAntiquot.formatter (p pSep : Formatter) : Formatter := do\n let stx β getCur\n visitArgs <| (List.range stx.getArgs.size).reverse.forM fun i => if i % 2 == 0 then p else pSep",
"start": [
467,
1
],
"end": [
470,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.sepBy1NoAntiquot.formatter",
"code": "@[combinator_formatter sepBy1NoAntiquot] def sepBy1NoAntiquot.formatter := sepByNoAntiquot.formatter",
"start": [
472,
1
],
"end": [
472,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.withoutInfo.formatter",
"code": "@[combinator_formatter withoutInfo] def withoutInfo.formatter (p : Formatter) : Formatter := p",
"start": [
474,
1
],
"end": [
474,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkWsBefore.formatter",
"code": "@[combinator_formatter checkWsBefore] def checkWsBefore.formatter : Formatter := do\n let st β get\n if st.leadWord != \"\" then\n pushLine",
"start": [
475,
1
],
"end": [
478,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkPrec.formatter",
"code": "@[combinator_formatter checkPrec] def checkPrec.formatter : Formatter := pure ()",
"start": [
480,
1
],
"end": [
480,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkLhsPrec.formatter",
"code": "@[combinator_formatter checkLhsPrec] def checkLhsPrec.formatter : Formatter := pure ()",
"start": [
481,
1
],
"end": [
481,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.setLhsPrec.formatter",
"code": "@[combinator_formatter setLhsPrec] def setLhsPrec.formatter : Formatter := pure ()",
"start": [
482,
1
],
"end": [
482,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkStackTop.formatter",
"code": "@[combinator_formatter checkStackTop] def checkStackTop.formatter : Formatter := pure ()",
"start": [
483,
1
],
"end": [
483,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkNoWsBefore.formatter",
"code": "@[combinator_formatter checkNoWsBefore] def checkNoWsBefore.formatter : Formatter :=\n modify fun st => { st with leadWord := \"\" }",
"start": [
484,
1
],
"end": [
486,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkLinebreakBefore.formatter",
"code": "@[combinator_formatter checkLinebreakBefore] def checkLinebreakBefore.formatter : Formatter := pure ()",
"start": [
487,
1
],
"end": [
487,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkTailWs.formatter",
"code": "@[combinator_formatter checkTailWs] def checkTailWs.formatter : Formatter := pure ()",
"start": [
488,
1
],
"end": [
488,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkColEq.formatter",
"code": "@[combinator_formatter checkColEq] def checkColEq.formatter : Formatter := pure ()",
"start": [
489,
1
],
"end": [
489,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkColGe.formatter",
"code": "@[combinator_formatter checkColGe] def checkColGe.formatter : Formatter := pure ()",
"start": [
490,
1
],
"end": [
490,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkColGt.formatter",
"code": "@[combinator_formatter checkColGt] def checkColGt.formatter : Formatter := pure ()",
"start": [
491,
1
],
"end": [
491,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkLineEq.formatter",
"code": "@[combinator_formatter checkLineEq] def checkLineEq.formatter : Formatter := pure ()",
"start": [
492,
1
],
"end": [
492,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.eoi.formatter",
"code": "@[combinator_formatter eoi] def eoi.formatter : Formatter := pure ()",
"start": [
494,
1
],
"end": [
494,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.checkNoImmediateColon.formatter",
"code": "@[combinator_formatter checkNoImmediateColon] def checkNoImmediateColon.formatter : Formatter := pure ()",
"start": [
495,
1
],
"end": [
495,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.skip.formatter",
"code": "@[combinator_formatter skip] def skip.formatter : Formatter := pure ()",
"start": [
496,
1
],
"end": [
496,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.pushNone.formatter",
"code": "@[combinator_formatter pushNone] def pushNone.formatter : Formatter := goLeft",
"start": [
498,
1
],
"end": [
498,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.hygieneInfoNoAntiquot.formatter",
"code": "@[combinator_formatter hygieneInfoNoAntiquot] def hygieneInfoNoAntiquot.formatter : Formatter := goLeft",
"start": [
499,
1
],
"end": [
499,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.interpolatedStr.formatter",
"code": "@[combinator_formatter interpolatedStr]\ndef interpolatedStr.formatter (p : Formatter) : Formatter := do\n visitArgs $ (β getCur).getArgs.reverse.forM fun chunk =>\n match chunk.isLit? interpolatedStrLitKind with\n | some str => push str *> goLeft\n | none => p",
"start": [
501,
1
],
"end": [
506,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.ite",
"code": "@[combinator_formatter _root_.ite, macro_inline] def ite {_ : Type} (c : Prop) [Decidable c] (t e : Formatter) : Formatter :=\n if c then t else e",
"start": [
508,
1
],
"end": [
509,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.FormatterAliasValue",
"code": "abbrev FormatterAliasValue := AliasValue Formatter",
"start": [
511,
1
],
"end": [
511,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.registerAlias",
"code": "def registerAlias (aliasName : Name) (v : FormatterAliasValue) : IO Unit := do\n Parser.registerAliasCore formatterAliasesRef aliasName v",
"start": [
515,
1
],
"end": [
516,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.format",
"code": "def format (formatter : Formatter) (stx : Syntax) : CoreM Format := do\n trace[PrettyPrinter.format.input] \"{Std.format stx}\"\n let options β getOptions\n let table β Parser.builtinTokenTable.get\n catchInternalId backtrackExceptionId\n (do\n let (_, st) β (concat formatter { table, options }).run { stxTrav := .fromSyntax stx }\n let mut f := st.stack[0]!\n if pp.oneline.get options then\n let mut s := f.pretty' options |>.trim\n let lineEnd := s.find (Β· == '\\n')\n if lineEnd < s.endPos then\n s := s.extract 0 lineEnd ++ \" [...]\"\n f := s\n return .fill f)\n (fun _ => throwError \"format: uncaught backtrack exception\")",
"start": [
531,
1
],
"end": [
547,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.formatCategory",
"code": "def formatCategory (cat : Name) := format <| categoryFormatter cat",
"start": [
549,
1
],
"end": [
549,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.formatTerm",
"code": "def formatTerm := formatCategory `term",
"start": [
551,
1
],
"end": [
551,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.formatTactic",
"code": "def formatTactic := formatCategory `tactic",
"start": [
552,
1
],
"end": [
552,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.formatCommand",
"code": "def formatCommand := formatCategory `command",
"start": [
553,
1
],
"end": [
553,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/NatInstTesters.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.isInstOfNatNat",
"code": "def isInstOfNatNat (e : Expr) : MetaM Bool := do\n let_expr instOfNatNat _ β e | return false\n return true",
"start": [
14,
1
],
"end": [
16,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstAddNat",
"code": "def isInstAddNat (e : Expr) : MetaM Bool := do\n let_expr instAddNat β e | return false\n return true",
"start": [
17,
1
],
"end": [
19,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstSubNat",
"code": "def isInstSubNat (e : Expr) : MetaM Bool := do\n let_expr instSubNat β e | return false\n return true",
"start": [
20,
1
],
"end": [
22,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstMulNat",
"code": "def isInstMulNat (e : Expr) : MetaM Bool := do\n let_expr instMulNat β e | return false\n return true",
"start": [
23,
1
],
"end": [
25,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstDivNat",
"code": "def isInstDivNat (e : Expr) : MetaM Bool := do\n let_expr Nat.instDiv β e | return false\n return true",
"start": [
26,
1
],
"end": [
28,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstModNat",
"code": "def isInstModNat (e : Expr) : MetaM Bool := do\n let_expr Nat.instMod β e | return false\n return true",
"start": [
29,
1
],
"end": [
31,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstNatPowNat",
"code": "def isInstNatPowNat (e : Expr) : MetaM Bool := do\n let_expr instNatPowNat β e | return false\n return true",
"start": [
32,
1
],
"end": [
34,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstPowNat",
"code": "def isInstPowNat (e : Expr) : MetaM Bool := do\n let_expr instPowNat _ i β e | return false\n isInstNatPowNat i",
"start": [
35,
1
],
"end": [
37,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstHAddNat",
"code": "def isInstHAddNat (e : Expr) : MetaM Bool := do\n let_expr instHAdd _ i β e | return false\n isInstAddNat i",
"start": [
38,
1
],
"end": [
40,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstHSubNat",
"code": "def isInstHSubNat (e : Expr) : MetaM Bool := do\n let_expr instHSub _ i β e | return false\n isInstSubNat i",
"start": [
41,
1
],
"end": [
43,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstHMulNat",
"code": "def isInstHMulNat (e : Expr) : MetaM Bool := do\n let_expr instHMul _ i β e | return false\n isInstMulNat i",
"start": [
44,
1
],
"end": [
46,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstHDivNat",
"code": "def isInstHDivNat (e : Expr) : MetaM Bool := do\n let_expr instHDiv _ i β e | return false\n isInstDivNat i",
"start": [
47,
1
],
"end": [
49,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstHModNat",
"code": "def isInstHModNat (e : Expr) : MetaM Bool := do\n let_expr instHMod _ i β e | return false\n isInstModNat i",
"start": [
50,
1
],
"end": [
52,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstHPowNat",
"code": "def isInstHPowNat (e : Expr) : MetaM Bool := do\n let_expr instHPow _ _ i β e | return false\n isInstPowNat i",
"start": [
53,
1
],
"end": [
55,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstLTNat",
"code": "def isInstLTNat (e : Expr) : MetaM Bool := do\n let_expr instLTNat β e | return false\n return true",
"start": [
56,
1
],
"end": [
58,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstLENat",
"code": "def isInstLENat (e : Expr) : MetaM Bool := do\n let_expr instLENat β e | return false\n return true",
"start": [
59,
1
],
"end": [
61,
14
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Extra.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Formatter.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Parenthesizer.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Extension.lean"
] | [
{
"full_name": "Lean.Parser.optional",
"code": "@[run_builtin_parser_attribute_hooks] def optional (p : Parser) : Parser :=\n optionalNoAntiquot (withAntiquotSpliceAndSuffix `optional p (symbol \"?\"))",
"start": [
25,
1
],
"end": [
35,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.many",
"code": "@[run_builtin_parser_attribute_hooks] def many (p : Parser) : Parser :=\n manyNoAntiquot (withAntiquotSpliceAndSuffix `many p (symbol \"*\"))",
"start": [
37,
1
],
"end": [
45,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.many1",
"code": "@[run_builtin_parser_attribute_hooks] def many1 (p : Parser) : Parser :=\n many1NoAntiquot (withAntiquotSpliceAndSuffix `many p (symbol \"*\"))",
"start": [
47,
1
],
"end": [
60,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ident",
"code": "@[run_builtin_parser_attribute_hooks] def ident : Parser :=\n withAntiquot (mkAntiquot \"ident\" identKind) identNoAntiquot",
"start": [
62,
1
],
"end": [
74,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.identWithPartialTrailingDot",
"code": "@[run_builtin_parser_attribute_hooks] def identWithPartialTrailingDot :=\n ident >> optional (checkNoWsBefore >> \".\" >> checkNoWsBefore >> ident)",
"start": [
80,
1
],
"end": [
81,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawIdent",
"code": "@[run_builtin_parser_attribute_hooks] def rawIdent : Parser :=\n withAntiquot (mkAntiquot \"ident\" identKind) rawIdentNoAntiquot",
"start": [
84,
1
],
"end": [
85,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.hygieneInfo",
"code": "@[run_builtin_parser_attribute_hooks] def hygieneInfo : Parser :=\n withAntiquot (mkAntiquot \"hygieneInfo\" hygieneInfoKind (anonymous := false)) hygieneInfoNoAntiquot",
"start": [
87,
1
],
"end": [
100,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.numLit",
"code": "@[run_builtin_parser_attribute_hooks] def numLit : Parser :=\n withAntiquot (mkAntiquot \"num\" numLitKind) numLitNoAntiquot",
"start": [
102,
1
],
"end": [
113,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.scientificLit",
"code": "@[run_builtin_parser_attribute_hooks] def scientificLit : Parser :=\n withAntiquot (mkAntiquot \"scientific\" scientificLitKind) scientificLitNoAntiquot",
"start": [
115,
1
],
"end": [
121,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.strLit",
"code": "@[run_builtin_parser_attribute_hooks] def strLit : Parser :=\n withAntiquot (mkAntiquot \"str\" strLitKind) strLitNoAntiquot",
"start": [
123,
1
],
"end": [
131,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.charLit",
"code": "@[run_builtin_parser_attribute_hooks] def charLit : Parser :=\n withAntiquot (mkAntiquot \"char\" charLitKind) charLitNoAntiquot",
"start": [
133,
1
],
"end": [
142,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nameLit",
"code": "@[run_builtin_parser_attribute_hooks] def nameLit : Parser :=\n withAntiquot (mkAntiquot \"name\" nameLitKind) nameLitNoAntiquot",
"start": [
144,
1
],
"end": [
151,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.group",
"code": "@[run_builtin_parser_attribute_hooks, inline] def group (p : Parser) : Parser :=\n node groupKind p",
"start": [
153,
1
],
"end": [
160,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.many1Indent",
"code": "@[run_builtin_parser_attribute_hooks, inline] def many1Indent (p : Parser) : Parser :=\n withPosition $ many1 (checkColGe \"irrelevant\" >> p)",
"start": [
162,
1
],
"end": [
169,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.manyIndent",
"code": "@[run_builtin_parser_attribute_hooks, inline] def manyIndent (p : Parser) : Parser :=\n withPosition $ many (checkColGe \"irrelevant\" >> p)",
"start": [
171,
1
],
"end": [
178,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByIndent",
"code": "@[inline] def sepByIndent (p : Parser) (sep : String) (psep : Parser := symbol sep) (allowTrailingSep : Bool := false) : Parser :=\n let p := withAntiquotSpliceAndSuffix `sepBy p (symbol \"*\")\n withPosition $ sepBy (checkColGe \"irrelevant\" >> p) sep (psep <|> checkColEq \"irrelevant\" >> checkLinebreakBefore >> pushNone) allowTrailingSep",
"start": [
180,
1
],
"end": [
182,
146
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy1Indent",
"code": "@[inline] def sepBy1Indent (p : Parser) (sep : String) (psep : Parser := symbol sep) (allowTrailingSep : Bool := false) : Parser :=\n let p := withAntiquotSpliceAndSuffix `sepBy p (symbol \"*\")\n withPosition $ sepBy1 (checkColGe \"irrelevant\" >> p) sep (psep <|> checkColEq \"irrelevant\" >> checkLinebreakBefore >> pushNone) allowTrailingSep",
"start": [
184,
1
],
"end": [
186,
147
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByIndent.formatter",
"code": "@[combinator_formatter sepByIndent]\ndef sepByIndent.formatter (p : Formatter) (_sep : String) (pSep : Formatter) : Formatter := do\n let stx β getCur\n let hasNewlineSep := stx.getArgs.mapIdx (fun β¨i, _β© n =>\n i % 2 == 1 && n.matchesNull 0 && i != stx.getArgs.size - 1) |>.any id\n visitArgs do\n for i in (List.range stx.getArgs.size).reverse do\n if i % 2 == 0 then p else pSep <|>\n ((if i == stx.getArgs.size - 1 then pure () else pushWhitespace \"\\n\") *> goLeft)\n if hasNewlineSep then\n pushAlign (force := true)",
"start": [
189,
1
],
"end": [
202,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy1Indent.formatter",
"code": "@[combinator_formatter sepBy1Indent] def sepBy1Indent.formatter := sepByIndent.formatter",
"start": [
204,
1
],
"end": [
204,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.notSymbol",
"code": "@[run_builtin_parser_attribute_hooks] abbrev notSymbol (s : String) : Parser :=\n notFollowedBy (symbol s) s",
"start": [
208,
1
],
"end": [
209,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.patternIgnore",
"code": "@[inline, run_builtin_parser_attribute_hooks] def patternIgnore : Parser β Parser := node `patternIgnore",
"start": [
211,
1
],
"end": [
212,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppHardSpace",
"code": "@[inline] def ppHardSpace : Parser := skip",
"start": [
214,
1
],
"end": [
215,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppSpace",
"code": "@[inline] def ppSpace : Parser := skip",
"start": [
216,
1
],
"end": [
217,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppLine",
"code": "@[inline] def ppLine : Parser := skip",
"start": [
218,
1
],
"end": [
219,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppRealFill",
"code": "@[inline] def ppRealFill : Parser β Parser := id",
"start": [
220,
1
],
"end": [
221,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppRealGroup",
"code": "@[inline] def ppRealGroup : Parser β Parser := id",
"start": [
222,
1
],
"end": [
223,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppIndent",
"code": "@[inline] def ppIndent : Parser β Parser := id",
"start": [
224,
1
],
"end": [
225,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppGroup",
"code": "@[inline] def ppGroup (p : Parser) : Parser := ppRealFill (ppIndent p)",
"start": [
226,
1
],
"end": [
229,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppDedent",
"code": "@[inline] def ppDedent : Parser β Parser := id",
"start": [
230,
1
],
"end": [
233,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppAllowUngrouped",
"code": "@[inline] def ppAllowUngrouped : Parser := skip",
"start": [
235,
1
],
"end": [
245,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppDedentIfGrouped",
"code": "@[inline] def ppDedentIfGrouped : Parser β Parser := id",
"start": [
247,
1
],
"end": [
251,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ppHardLineUnlessUngrouped",
"code": "@[inline] def ppHardLineUnlessUngrouped : Parser := skip",
"start": [
253,
1
],
"end": [
257,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppHardSpace.formatter",
"code": "@[combinator_formatter ppHardSpace] def ppHardSpace.formatter : Formatter := Formatter.pushWhitespace \" \"",
"start": [
264,
1
],
"end": [
264,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppSpace.formatter",
"code": "@[combinator_formatter ppSpace] def ppSpace.formatter : Formatter := Formatter.pushLine",
"start": [
265,
1
],
"end": [
265,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppLine.formatter",
"code": "@[combinator_formatter ppLine] def ppLine.formatter : Formatter := Formatter.pushWhitespace \"\\n\"",
"start": [
266,
1
],
"end": [
266,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppRealFill.formatter",
"code": "@[combinator_formatter ppRealFill] def ppRealFill.formatter (p : Formatter) : Formatter := Formatter.fill p",
"start": [
267,
1
],
"end": [
267,
108
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppRealGroup.formatter",
"code": "@[combinator_formatter ppRealGroup] def ppRealGroup.formatter (p : Formatter) : Formatter := Formatter.group p",
"start": [
268,
1
],
"end": [
268,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppIndent.formatter",
"code": "@[combinator_formatter ppIndent] def ppIndent.formatter (p : Formatter) : Formatter := Formatter.indent p",
"start": [
269,
1
],
"end": [
269,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppDedent.formatter",
"code": "@[combinator_formatter ppDedent] def ppDedent.formatter (p : Formatter) : Formatter := do\n let opts β getOptions\n Formatter.indent p (some ((0:Int) - Std.Format.getIndent opts))",
"start": [
270,
1
],
"end": [
272,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppAllowUngrouped.formatter",
"code": "@[combinator_formatter ppAllowUngrouped] def ppAllowUngrouped.formatter : Formatter := do\n modify ({ Β· with mustBeGrouped := false })",
"start": [
274,
1
],
"end": [
275,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppDedentIfGrouped.formatter",
"code": "@[combinator_formatter ppDedentIfGrouped] def ppDedentIfGrouped.formatter (p : Formatter) : Formatter := do\n Formatter.concat p\n let indent := Std.Format.getIndent (β getOptions)\n unless (β get).isUngrouped do\n modify fun st => { st with stack := st.stack.modify (st.stack.size - 1) (Β·.nest (0 - indent)) }",
"start": [
276,
1
],
"end": [
280,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppHardLineUnlessUngrouped.formatter",
"code": "@[combinator_formatter ppHardLineUnlessUngrouped] def ppHardLineUnlessUngrouped.formatter : Formatter := do\n if (β get).isUngrouped then\n Formatter.pushLine\n else\n ppLine.formatter",
"start": [
281,
1
],
"end": [
285,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/GlobalInstances.lean | [
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.addGlobalInstance",
"code": "def addGlobalInstance (declName : Name) (attrKind : AttributeKind) : MetaM Unit := do\n globalInstanceExtension.add declName attrKind",
"start": [
18,
1
],
"end": [
19,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isGlobalInstance",
"code": "@[export lean_is_instance]\ndef isGlobalInstance (env : Environment) (declName : Name) : Bool :=\n globalInstanceExtension.getState env |>.contains declName",
"start": [
21,
1
],
"end": [
23,
60
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Offset.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/NatInstTesters.lean",
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean",
".lake/packages/lean4/src/lean/Lean/Data/LBool.lean"
] | [
{
"full_name": "Lean.Meta.withInstantiatedMVars",
"code": "private abbrev withInstantiatedMVars (e : Expr) (k : Expr β OptionT MetaM Ξ±) : OptionT MetaM Ξ± := do\n let eNew β instantiateMVars e\n if eNew.getAppFn.isMVar then\n failure\n else\n k eNew",
"start": [
13,
1
],
"end": [
18,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.evalNat",
"code": "partial def evalNat (e : Expr) : OptionT MetaM Nat := do\n match e with\n | .lit (.natVal n) => return n\n | .mdata _ e => evalNat e\n | .const ``Nat.zero .. => return 0\n | .app .. => visit e\n | .mvar .. => visit e\n | _ => failure\nwhere\n visit e := do\n match_expr e with\n | OfNat.ofNat _ n i => guard (β isInstOfNatNat i); evalNat n\n | Nat.succ a => return (β evalNat a) + 1\n | Nat.add a b => return (β evalNat a) + (β evalNat b)\n | Add.add _ i a b => guard (β isInstAddNat i); return (β evalNat a) + (β evalNat b)\n | HAdd.hAdd _ _ _ i a b => guard (β isInstHAddNat i); return (β evalNat a) + (β evalNat b)\n | Nat.sub a b => return (β evalNat a) - (β evalNat b)\n | Sub.sub _ i a b => guard (β isInstSubNat i); return (β evalNat a) - (β evalNat b)\n | HSub.hSub _ _ _ i a b => guard (β isInstHSubNat i); return (β evalNat a) - (β evalNat b)\n | Nat.mul a b => return (β evalNat a) * (β evalNat b)\n | Mul.mul _ i a b => guard (β isInstMulNat i); return (β evalNat a) * (β evalNat b)\n | HMul.hMul _ _ _ i a b => guard (β isInstHMulNat i); return (β evalNat a) * (β evalNat b)\n | Nat.div a b => return (β evalNat a) / (β evalNat b)\n | Div.div _ i a b => guard (β isInstDivNat i); return (β evalNat a) / (β evalNat b)\n | HDiv.hDiv _ _ _ i a b => guard (β isInstHDivNat i); return (β evalNat a) / (β evalNat b)\n | Nat.mod a b => return (β evalNat a) % (β evalNat b)\n | Mod.mod _ i a b => guard (β isInstModNat i); return (β evalNat a) % (β evalNat b)\n | HMod.hMod _ _ _ i a b => guard (β isInstHModNat i); return (β evalNat a) % (β evalNat b)\n | Nat.pow a b => return (β evalNat a) ^ (β evalNat b)\n | NatPow.pow _ i a b => guard (β isInstNatPowNat i); return (β evalNat a) ^ (β evalNat b)\n | Pow.pow _ _ i a b => guard (β isInstPowNat i); return (β evalNat a) ^ (β evalNat b)\n | HPow.hPow _ _ _ i a b => guard (β isInstHPowNat i); return (β evalNat a) ^ (β evalNat b)\n | _ => failure",
"start": [
20,
1
],
"end": [
55,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchesInstance",
"code": "def matchesInstance (e inst : Expr) : MetaM Bool :=\n withNewMCtxDepth (withTransparency .instances (isDefEq e inst))",
"start": [
57,
1
],
"end": [
65,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getOffset",
"code": "private partial def getOffset (e : Expr) : MetaM (Expr Γ Nat) :=\n return (β isOffset? e).getD (e, 0)",
"start": [
69,
1
],
"end": [
75,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isOffset?",
"code": "partial def isOffset? (e : Expr) : OptionT MetaM (Expr Γ Nat) := do\n let add (a b : Expr) := do\n let v β evalNat b\n let (s, k) β getOffset a\n return (s, k+v)\n match_expr e with\n | Nat.succ a =>\n let (s, k) β getOffset a\n return (s, k+1)\n | Nat.add a b => add a b\n | Add.add _ i a b => guard (β matchesInstance i Nat.mkInstAdd); add a b\n | HAdd.hAdd _ _ _ i a b => guard (β matchesInstance i Nat.mkInstHAdd); add a b\n | _ => failure",
"start": [
77,
1
],
"end": [
92,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isNatZero",
"code": "private def isNatZero (e : Expr) : MetaM Bool := do\n match (β evalNat e) with\n | some v => return v == 0\n | _ => return false",
"start": [
96,
1
],
"end": [
99,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkOffset",
"code": "private def mkOffset (e : Expr) (offset : Nat) : MetaM Expr := do\n if offset == 0 then\n return e\n else if (β isNatZero e) then\n return mkNatLit offset\n else\n return mkNatAdd e (mkNatLit offset)",
"start": [
101,
1
],
"end": [
107,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isDefEqOffset",
"code": "def isDefEqOffset (s t : Expr) : MetaM LBool := do\n let ifNatExpr (x : MetaM LBool) : MetaM LBool := do\n let type β inferType s\n if (β withNewMCtxDepth <| Meta.isExprDefEqAux type (mkConst ``Nat)) then\n x\n else\n return LBool.undef\n let isDefEq (s t) : MetaM LBool :=\n ifNatExpr <| toLBoolM <| Meta.isExprDefEqAux s t\n if !(β getConfig).offsetCnstrs then\n return LBool.undef\n else\n match (β isOffset? s) with\n | some (s, kβ) =>\n match (β isOffset? t) with\n | some (t, kβ) => if kβ == kβ then\n isDefEq s t\n else if kβ < kβ then\n isDefEq s (β mkOffset t (kβ - kβ))\n else\n isDefEq (β mkOffset s (kβ - kβ)) t\n | none =>\n match (β evalNat t) with\n | some vβ => if vβ β₯ kβ then\n isDefEq s (mkNatLit <| vβ - kβ)\n else\n ifNatExpr <| return LBool.false\n | none =>\n return LBool.undef\n | none =>\n match (β evalNat s) with\n | some vβ =>\n match (β isOffset? t) with\n | some (t, kβ) => if vβ β₯ kβ then\n isDefEq (mkNatLit <| vβ - kβ) t\n else\n ifNatExpr <| return LBool.false\n | none =>\n match (β evalNat t) with\n | some vβ => ifNatExpr <| return (vβ == vβ).toLBool | none => return LBool.undef\n | none => return LBool.undef",
"start": [
109,
1
],
"end": [
154,
35
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/LitValues.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.getRawNatValue?",
"code": "def getRawNatValue? (e : Expr) : Option Nat :=\n match e.consumeMData with\n | .lit (.natVal n) => some n\n | _ => none",
"start": [
22,
1
],
"end": [
26,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getOfNatValue?",
"code": "def getOfNatValue? (e : Expr) (typeDeclName : Name) : MetaM (Option (Nat Γ Expr)) := OptionT.run do\n let_expr OfNat.ofNat type n _ β e | failure\n let type β whnfD type\n guard <| type.getAppFn.isConstOf typeDeclName\n let .lit (.natVal n) := n.consumeMData | failure\n return (n, type)",
"start": [
28,
1
],
"end": [
34,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getNatValue?",
"code": "def getNatValue? (e : Expr) : MetaM (Option Nat) := do\n let e := e.consumeMData\n if let some n := getRawNatValue? e then\n return some n\n let some (n, _) β getOfNatValue? e ``Nat | return none\n return some n",
"start": [
36,
1
],
"end": [
42,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getIntValue?",
"code": "def getIntValue? (e : Expr) : MetaM (Option Int) := do\n if let some (n, _) β getOfNatValue? e ``Int then\n return some n\n let_expr Neg.neg _ _ a β e | return none\n let some (n, _) β getOfNatValue? a ``Int | return none\n return some (-βn)",
"start": [
44,
1
],
"end": [
50,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getCharValue?",
"code": "def getCharValue? (e : Expr) : MetaM (Option Char) := do\n let_expr Char.ofNat n β e | return none\n let some n β getNatValue? n | return none\n return some (Char.ofNat n)",
"start": [
52,
1
],
"end": [
56,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getStringValue?",
"code": "def getStringValue? (e : Expr) : (Option String) :=\n match e with\n | .lit (.strVal s) => some s\n | _ => none",
"start": [
58,
1
],
"end": [
62,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFinValue?",
"code": "def getFinValue? (e : Expr) : MetaM (Option ((n : Nat) Γ Fin n)) := OptionT.run do\n let (v, type) β getOfNatValue? e ``Fin\n let n β getNatValue? (β whnfD type.appArg!)\n match n with\n | 0 => failure\n | m+1 => return β¨m+1, Fin.ofNat vβ©",
"start": [
64,
1
],
"end": [
70,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getBitVecValue?",
"code": "def getBitVecValue? (e : Expr) : MetaM (Option ((n : Nat) Γ BitVec n)) := OptionT.run do\n match_expr e with\n | BitVec.ofNat nExpr vExpr =>\n let n β getNatValue? nExpr\n let v β getNatValue? vExpr\n return β¨n, BitVec.ofNat n vβ©\n | BitVec.ofNatLt nExpr vExpr _ =>\n let n β getNatValue? nExpr\n let v β getNatValue? vExpr\n return β¨n, BitVec.ofNat n vβ©\n | _ =>\n let (v, type) β getOfNatValue? e ``BitVec\n let n β getNatValue? (β whnfD type.appArg!)\n return β¨n, BitVec.ofNat n vβ©",
"start": [
72,
1
],
"end": [
92,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUInt8Value?",
"code": "def getUInt8Value? (e : Expr) : MetaM (Option UInt8) := OptionT.run do\n let (n, _) β getOfNatValue? e ``UInt8\n return UInt8.ofNat n",
"start": [
94,
1
],
"end": [
97,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUInt16Value?",
"code": "def getUInt16Value? (e : Expr) : MetaM (Option UInt16) := OptionT.run do\n let (n, _) β getOfNatValue? e ``UInt16\n return UInt16.ofNat n",
"start": [
99,
1
],
"end": [
102,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUInt32Value?",
"code": "def getUInt32Value? (e : Expr) : MetaM (Option UInt32) := OptionT.run do\n let (n, _) β getOfNatValue? e ``UInt32\n return UInt32.ofNat n",
"start": [
104,
1
],
"end": [
107,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUInt64Value?",
"code": "def getUInt64Value? (e : Expr) : MetaM (Option UInt64) := OptionT.run do\n let (n, _) β getOfNatValue? e ``UInt64\n return UInt64.ofNat n",
"start": [
109,
1
],
"end": [
112,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.normLitValue",
"code": "def normLitValue (e : Expr) : MetaM Expr := do\n let e β instantiateMVars e\n if let some n β getNatValue? e then return toExpr n\n if let some n β getIntValue? e then return toExpr n\n if let some β¨_, nβ© β getFinValue? e then return toExpr n\n if let some β¨_, nβ© β getBitVecValue? e then return toExpr n\n if let some s := getStringValue? e then return toExpr s\n if let some c β getCharValue? e then return toExpr c\n if let some n β getUInt8Value? e then return toExpr n\n if let some n β getUInt16Value? e then return toExpr n\n if let some n β getUInt32Value? e then return toExpr n\n if let some n β getUInt64Value? e then return toExpr n\n return e",
"start": [
116,
1
],
"end": [
132,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isLitValue",
"code": "def isLitValue (e : Expr) : MetaM Bool := do\n let e β instantiateMVars e\n if (β getNatValue? e).isSome then return true\n if (β getIntValue? e).isSome then return true\n if (β getFinValue? e).isSome then return true\n if (β getBitVecValue? e).isSome then return true\n if (getStringValue? e).isSome then return true\n if (β getCharValue? e).isSome then return true\n if (β getUInt8Value? e).isSome then return true\n if (β getUInt16Value? e).isSome then return true\n if (β getUInt32Value? e).isSome then return true\n if (β getUInt64Value? e).isSome then return true\n return false",
"start": [
134,
1
],
"end": [
149,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.litToCtor",
"code": "def litToCtor (e : Expr) : MetaM Expr := do\n let e β instantiateMVars e\n if let some n β getNatValue? e then\n if n = 0 then\n return mkConst ``Nat.zero\n else\n return .app (mkConst ``Nat.succ) (toExpr (n-1))\n if let some n β getIntValue? e then\n if n < 0 then\n return .app (mkConst ``Int.negSucc) (toExpr (- (n+1)).toNat)\n else\n return .app (mkConst ``Int.ofNat) (toExpr n.toNat)\n if let some β¨n, vβ© β getFinValue? e then\n let i := toExpr v.val\n let n := toExpr n\n let p := mkApp4 (mkConst ``LT.lt [0]) (mkConst ``Nat) (mkConst ``instLTNat) i n\n let h := mkApp3 (mkConst ``of_decide_eq_true) p\n (mkApp2 (mkConst ``Nat.decLt) i n)\n (mkApp2 (mkConst ``Eq.refl [1]) (mkConst ``Bool) (mkConst ``true))\n return mkApp3 (mkConst ``Fin.mk) n i h\n return e",
"start": [
151,
1
],
"end": [
177,
11
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Level.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Extra.lean"
] | [
{
"full_name": "Lean.Parser.levelParser",
"code": "@[inline] def levelParser (rbp : Nat := 0) : Parser :=\n categoryParser `level rbp",
"start": [
15,
1
],
"end": [
16,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.paren",
"code": "@[builtin_level_parser] def paren := leading_parser\n \"(\" >> withoutPosition levelParser >> \")\"",
"start": [
20,
1
],
"end": [
21,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.max",
"code": "@[builtin_level_parser] def max := leading_parser\n nonReservedSymbol \"max\" true >> many1 (ppSpace >> levelParser maxPrec)",
"start": [
22,
1
],
"end": [
23,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.imax",
"code": "@[builtin_level_parser] def imax := leading_parser\n nonReservedSymbol \"imax\" true >> many1 (ppSpace >> levelParser maxPrec)",
"start": [
24,
1
],
"end": [
25,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.hole",
"code": "@[builtin_level_parser] def hole := leading_parser\n \"_\"",
"start": [
26,
1
],
"end": [
27,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.num",
"code": "@[builtin_level_parser] def num :=\n checkPrec maxPrec >> numLit",
"start": [
28,
1
],
"end": [
29,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.ident",
"code": "@[builtin_level_parser] def ident :=\n checkPrec maxPrec >> Parser.ident",
"start": [
30,
1
],
"end": [
31,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Level.addLit",
"code": "@[builtin_level_parser] def addLit := trailing_parser:65\n \" + \" >> numLit",
"start": [
32,
1
],
"end": [
33,
18
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Attr.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Extra.lean"
] | [
{
"full_name": "Lean.Parser.priorityParser",
"code": "@[inline] def priorityParser (rbp : Nat := 0) : Parser :=\n categoryParser `prio rbp",
"start": [
20,
1
],
"end": [
21,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.attrParser",
"code": "@[inline] def attrParser (rbp : Nat := 0) : Parser :=\n categoryParser `attr rbp",
"start": [
23,
1
],
"end": [
24,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Priority.numPrio",
"code": "@[builtin_prio_parser] def numPrio := checkPrec maxPrec >> numLit",
"start": [
30,
1
],
"end": [
30,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.simple",
"code": "@[builtin_attr_parser] def simple := leading_parser ident >> optional (ppSpace >> (priorityParser <|> ident))",
"start": [
36,
1
],
"end": [
36,
114
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.macro",
"code": "@[builtin_attr_parser] def Β«macroΒ» := leading_parser \"macro \" >> ident",
"start": [
38,
1
],
"end": [
38,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.export",
"code": "@[builtin_attr_parser] def Β«exportΒ» := leading_parser \"export \" >> ident",
"start": [
39,
1
],
"end": [
39,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.recursor",
"code": "@[builtin_attr_parser] def recursor := leading_parser nonReservedSymbol \"recursor \" >> numLit",
"start": [
42,
1
],
"end": [
42,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.class",
"code": "@[builtin_attr_parser] def Β«classΒ» := leading_parser \"class\"",
"start": [
43,
1
],
"end": [
43,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.instance",
"code": "@[builtin_attr_parser] def Β«instanceΒ» := leading_parser \"instance\" >> optional (ppSpace >> priorityParser)",
"start": [
44,
1
],
"end": [
44,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.default_instance",
"code": "@[builtin_attr_parser] def default_instance := leading_parser nonReservedSymbol \"default_instance\" >> optional (ppSpace >> priorityParser)",
"start": [
45,
1
],
"end": [
45,
139
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.specialize",
"code": "@[builtin_attr_parser] def Β«specializeΒ» := leading_parser (nonReservedSymbol \"specialize\") >> many (ppSpace >> (ident <|> numLit))",
"start": [
46,
1
],
"end": [
46,
135
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.externEntry",
"code": "def externEntry := leading_parser\n optional (ident >> ppSpace) >> optional (nonReservedSymbol \"inline \") >> strLit",
"start": [
48,
1
],
"end": [
49,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.extern",
"code": "@[builtin_attr_parser] def extern := leading_parser\n nonReservedSymbol \"extern\" >> optional (ppSpace >> numLit) >> many (ppSpace >> externEntry)",
"start": [
50,
1
],
"end": [
51,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.tactic_alt",
"code": "@[builtin_attr_parser] def Β«tactic_altΒ» := leading_parser\n \"tactic_alt\" >> ppSpace >> ident",
"start": [
53,
1
],
"end": [
61,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Attr.tactic_tag",
"code": "@[builtin_attr_parser] def Β«tactic_tagΒ» := leading_parser\n \"tactic_tag\" >> many1 (ppSpace >> ident)",
"start": [
63,
1
],
"end": [
69,
43
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/GetUnfoldableConst.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/GlobalInstances.lean"
] | [
{
"full_name": "Lean.Meta.canUnfoldDefault",
"code": "private def canUnfoldDefault (cfg : Config) (info : ConstantInfo) : CoreM Bool := do\n match cfg.transparency with\n | .all => return true\n | .default => return !(β isIrreducible info.name)\n | m =>\n if (β isReducible info.name) then\n return true\n else if m == .instances && isGlobalInstance (β getEnv) info.name then\n return true\n else\n return false",
"start": [
11,
1
],
"end": [
21,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.canUnfold",
"code": "def canUnfold (info : ConstantInfo) : MetaM Bool := do\n let ctx β read\n if let some f := ctx.canUnfold? then\n f ctx.config info\n else\n canUnfoldDefault ctx.config info",
"start": [
23,
1
],
"end": [
28,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUnfoldableConst?",
"code": "def getUnfoldableConst? (constName : Name) : MetaM (Option ConstantInfo) := do\n match (β getEnv).find? constName with\n | some (info@(.thmInfo _)) => getTheoremInfo info\n | some (info@(.defnInfo _)) => if (β canUnfold info) then return info else return none\n | some info => return some info\n | none => throwUnknownConstant constName",
"start": [
30,
1
],
"end": [
43,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUnfoldableConstNoEx?",
"code": "def getUnfoldableConstNoEx? (constName : Name) : MetaM (Option ConstantInfo) := do\n match (β getEnv).find? constName with\n | some (info@(.thmInfo _)) => getTheoremInfo info\n | some (info@(.defnInfo _)) => if (β canUnfold info) then return info else return none\n | some info => return some info\n | none => return none",
"start": [
45,
1
],
"end": [
53,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/FunInfo.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.checkFunInfoCache",
"code": "@[inline] private def checkFunInfoCache (fn : Expr) (maxArgs? : Option Nat) (k : MetaM FunInfo) : MetaM FunInfo := do\n let t β getTransparency\n match (β get).cache.funInfo.find? β¨t, fn, maxArgs?β© with\n | some finfo => pure finfo\n | none => do\n let finfo β k\n modify fun s => { s with cache := { s.cache with funInfo := s.cache.funInfo.insert β¨t, fn, maxArgs?β© finfo } }\n pure finfo",
"start": [
12,
1
],
"end": [
19,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whenHasVar",
"code": "@[inline] private def whenHasVar {Ξ±} (e : Expr) (deps : Ξ±) (k : Ξ± β Ξ±) : Ξ± :=\n if e.hasFVar then k deps else deps",
"start": [
21,
1
],
"end": [
22,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.collectDeps",
"code": "private def collectDeps (fvars : Array Expr) (e : Expr) : Array Nat :=\n let rec visit (e : Expr) (deps : Array Nat) : Array Nat :=\n match e with\n | .app f a => whenHasVar e deps (visit a β visit f)\n | .forallE _ d b _ => whenHasVar e deps (visit b β visit d)\n | .lam _ d b _ => whenHasVar e deps (visit b β visit d)\n | .letE _ t v b _ => whenHasVar e deps (visit b β visit v β visit t)\n | .proj _ _ e => visit e deps\n | .mdata _ e => visit e deps\n | .fvar .. =>\n match fvars.indexOf? e with\n | none => deps\n | some i => if deps.contains i.val then deps else deps.push i.val\n | _ => deps\n let deps := visit e #[]\n deps.qsort (fun i j => i < j)",
"start": [
24,
1
],
"end": [
39,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.updateHasFwdDeps",
"code": "private def updateHasFwdDeps (pinfo : Array ParamInfo) (backDeps : Array Nat) : Array ParamInfo :=\n if backDeps.size == 0 then\n pinfo\n else\n pinfo.mapIdx fun i info =>\n if info.hasFwdDeps then\n info\n else if backDeps.contains i then\n { info with hasFwdDeps := true }\n else\n info",
"start": [
41,
1
],
"end": [
53,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFunInfoAux",
"code": "private def getFunInfoAux (fn : Expr) (maxArgs? : Option Nat) : MetaM FunInfo :=\n checkFunInfoCache fn maxArgs? do\n let fnType β inferType fn\n withTransparency TransparencyMode.default do\n forallBoundedTelescope fnType maxArgs? fun fvars type => do\n let mut paramInfo := #[]\n let mut higherOrderOutParams : FVarIdSet := {}\n for i in [:fvars.size] do\n let fvar := fvars[i]!\n let decl β getFVarLocalDecl fvar\n let backDeps := collectDeps fvars decl.type\n let dependsOnHigherOrderOutParam :=\n !higherOrderOutParams.isEmpty\n && Option.isSome (decl.type.find? fun e => e.isFVar && higherOrderOutParams.contains e.fvarId!)\n paramInfo := updateHasFwdDeps paramInfo backDeps\n paramInfo := paramInfo.push {\n backDeps, dependsOnHigherOrderOutParam\n binderInfo := decl.binderInfo\n isProp := (β isProp decl.type)\n isDecInst := (β forallTelescopeReducing decl.type fun _ type => return type.isAppOf ``Decidable)\n }\n if decl.binderInfo == .instImplicit then\n \n if let some className β isClass? decl.type then\n if let some outParamPositions := getOutParamPositions? (β getEnv) className then\n unless outParamPositions.isEmpty do\n let args := decl.type.getAppArgs\n for i in [:args.size] do\n if outParamPositions.contains i then\n let arg := args[i]!\n if let some idx := fvars.indexOf? arg then\n if (β whnf (β inferType arg)).isForall then\n paramInfo := paramInfo.modify idx fun info => { info with higherOrderOutParam := true }\n higherOrderOutParams := higherOrderOutParams.insert arg.fvarId!\n let resultDeps := collectDeps fvars type\n paramInfo := updateHasFwdDeps paramInfo resultDeps\n return { resultDeps, paramInfo }",
"start": [
55,
1
],
"end": [
91,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFunInfo",
"code": "def getFunInfo (fn : Expr) : MetaM FunInfo :=\n getFunInfoAux fn none",
"start": [
93,
1
],
"end": [
94,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFunInfoNArgs",
"code": "def getFunInfoNArgs (fn : Expr) (nargs : Nat) : MetaM FunInfo :=\n getFunInfoAux fn (some nargs)",
"start": [
96,
1
],
"end": [
97,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FunInfo.getArity",
"code": "def FunInfo.getArity (info : FunInfo) : Nat :=\n info.paramInfo.size",
"start": [
99,
1
],
"end": [
100,
22
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/CtorRecognizer.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/LitValues.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Offset.lean"
] | [
{
"full_name": "Lean.Meta.getConstructorVal?",
"code": "private def getConstructorVal? (env : Environment) (ctorName : Name) : Option ConstructorVal :=\n match env.find? ctorName with\n | some (.ctorInfo v) => v\n | _ => none",
"start": [
12,
1
],
"end": [
15,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isConstructorAppCore?",
"code": "def isConstructorAppCore? (e : Expr) : MetaM (Option ConstructorVal) := do\n let .const n _ := e.getAppFn | return none\n let some v := getConstructorVal? (β getEnv) n | return none\n if v.numParams + v.numFields == e.getAppNumArgs then\n return some v\n else\n return none",
"start": [
17,
1
],
"end": [
27,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isConstructorApp?",
"code": "def isConstructorApp? (e : Expr) : MetaM (Option ConstructorVal) := do\n isConstructorAppCore? (β litToCtor e)",
"start": [
29,
1
],
"end": [
34,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isConstructorApp'?",
"code": "def isConstructorApp'? (e : Expr) : MetaM (Option ConstructorVal) := do\n if let some r β isConstructorApp? e then\n return r\n isConstructorApp? (β whnf e)",
"start": [
36,
1
],
"end": [
42,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isConstructorApp",
"code": "def isConstructorApp (e : Expr) : MetaM Bool :=\n return (β isConstructorApp? e).isSome",
"start": [
44,
1
],
"end": [
49,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isConstructorApp'",
"code": "def isConstructorApp' (e : Expr) : MetaM Bool := do\n if (β isConstructorApp e) then return true\n return (β isConstructorApp (β whnf e))",
"start": [
51,
1
],
"end": [
56,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.constructorApp?",
"code": "def constructorApp? (e : Expr) : MetaM (Option (ConstructorVal Γ Array Expr)) := do\n let e β litToCtor e\n let .const declName _ := e.getAppFn | return none\n let some v := getConstructorVal? (β getEnv) declName | return none\n if v.numParams + v.numFields == e.getAppNumArgs then\n return some (v, e.getAppArgs)\n else\n return none",
"start": [
58,
1
],
"end": [
69,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.constructorApp'?",
"code": "def constructorApp'? (e : Expr) : MetaM (Option (ConstructorVal Γ Array Expr)) := do\n if let some (e, k) β isOffset? e then\n if k = 0 then\n return none\n else\n let .ctorInfo val β getConstInfo ``Nat.succ | return none\n if k = 1 then return some (val, #[e])\n else return some (val, #[mkNatAdd e (toExpr (k-1))])\n else if let some r β constructorApp? e then\n return some r\n else\n constructorApp? (β whnf e)",
"start": [
71,
1
],
"end": [
86,
31
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Match/MatchPatternAttr.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean"
] | [
{
"full_name": "Lean.hasMatchPatternAttribute",
"code": "@[export lean_has_match_pattern_attribute]\ndef hasMatchPatternAttribute (env : Environment) (n : Name) : Bool :=\n matchPatternAttr.hasTag env n",
"start": [
14,
1
],
"end": [
16,
32
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Match/MatcherInfo.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.Match.DiscrInfo",
"code": "structure DiscrInfo where\n \n hName? : Option Name := none\n deriving Inhabited",
"start": [
12,
1
],
"end": [
15,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo",
"code": "structure MatcherInfo where\n numParams : Nat\n numDiscrs : Nat\n altNumParams : Array Nat\n uElimPos? : Option Nat\n \n discrInfos : Array DiscrInfo",
"start": [
17,
1
],
"end": [
34,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.numAlts",
"code": "def MatcherInfo.numAlts (info : MatcherInfo) : Nat :=\n info.altNumParams.size",
"start": [
36,
1
],
"end": [
37,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.arity",
"code": "def MatcherInfo.arity (info : MatcherInfo) : Nat :=\n info.numParams + 1 + info.numDiscrs + info.numAlts",
"start": [
39,
1
],
"end": [
40,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.getFirstDiscrPos",
"code": "def MatcherInfo.getFirstDiscrPos (info : MatcherInfo) : Nat :=\n info.numParams + 1",
"start": [
42,
1
],
"end": [
43,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.getDiscrRange",
"code": "def MatcherInfo.getDiscrRange (info : MatcherInfo) : Std.Range :=\n { start := info.getFirstDiscrPos, stop := info.getFirstDiscrPos + info.numDiscrs }",
"start": [
45,
1
],
"end": [
46,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.getFirstAltPos",
"code": "def MatcherInfo.getFirstAltPos (info : MatcherInfo) : Nat :=\n info.numParams + 1 + info.numDiscrs",
"start": [
48,
1
],
"end": [
49,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.getAltRange",
"code": "def MatcherInfo.getAltRange (info : MatcherInfo) : Std.Range :=\n { start := info.getFirstAltPos, stop := info.getFirstAltPos + info.numAlts }",
"start": [
51,
1
],
"end": [
52,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.getMotivePos",
"code": "def MatcherInfo.getMotivePos (info : MatcherInfo) : Nat :=\n info.numParams",
"start": [
54,
1
],
"end": [
55,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.getNumEqsFromDiscrInfos",
"code": "def getNumEqsFromDiscrInfos (infos : Array DiscrInfo) : Nat := Id.run do\n let mut r := 0\n for info in infos do\n if info.hName?.isSome then\n r := r + 1\n return r",
"start": [
57,
1
],
"end": [
62,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.MatcherInfo.getNumDiscrEqs",
"code": "def MatcherInfo.getNumDiscrEqs (info : MatcherInfo) : Nat :=\n getNumEqsFromDiscrInfos info.discrInfos",
"start": [
64,
1
],
"end": [
65,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.Extension.Entry",
"code": "structure Entry where\n name : Name\n info : MatcherInfo",
"start": [
69,
1
],
"end": [
71,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.Extension.State",
"code": "structure State where\n map : SMap Name MatcherInfo := {}",
"start": [
73,
1
],
"end": [
74,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.Extension.State.addEntry",
"code": "def State.addEntry (s : State) (e : Entry) : State := { s with map := s.map.insert e.name e.info }",
"start": [
78,
1
],
"end": [
78,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.Extension.State.switch",
"code": "def State.switch (s : State) : State := { s with map := s.map.switch }",
"start": [
79,
1
],
"end": [
79,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.Extension.addMatcherInfo",
"code": "def addMatcherInfo (env : Environment) (matcherName : Name) (info : MatcherInfo) : Environment :=\n extension.addEntry env { name := matcherName, info := info }",
"start": [
87,
1
],
"end": [
88,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.Extension.getMatcherInfo?",
"code": "def getMatcherInfo? (env : Environment) (declName : Name) : Option MatcherInfo :=\n (extension.getState env).map.find? declName",
"start": [
90,
1
],
"end": [
91,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Match.addMatcherInfo",
"code": "def addMatcherInfo (matcherName : Name) (info : MatcherInfo) : MetaM Unit :=\n modifyEnv fun env => Extension.addMatcherInfo env matcherName info",
"start": [
95,
1
],
"end": [
96,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMatcherInfoCore?",
"code": "def getMatcherInfoCore? (env : Environment) (declName : Name) : Option MatcherInfo :=\n Match.Extension.getMatcherInfo? env declName",
"start": [
102,
1
],
"end": [
103,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMatcherInfo?",
"code": "def getMatcherInfo? [Monad m] [MonadEnv m] (declName : Name) : m (Option MatcherInfo) :=\n return getMatcherInfoCore? (β getEnv) declName",
"start": [
105,
1
],
"end": [
106,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMatcherCore",
"code": "@[export lean_is_matcher]\ndef isMatcherCore (env : Environment) (declName : Name) : Bool :=\n getMatcherInfoCore? env declName |>.isSome",
"start": [
108,
1
],
"end": [
110,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMatcher",
"code": "def isMatcher [Monad m] [MonadEnv m] (declName : Name) : m Bool :=\n return isMatcherCore (β getEnv) declName",
"start": [
112,
1
],
"end": [
113,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMatcherAppCore?",
"code": "def isMatcherAppCore? (env : Environment) (e : Expr) : Option MatcherInfo :=\n let fn := e.getAppFn\n if fn.isConst then\n if let some matcherInfo := getMatcherInfoCore? env fn.constName! then\n if e.getAppNumArgs β₯ matcherInfo.arity then some matcherInfo else none\n else\n none\n else\n none",
"start": [
115,
1
],
"end": [
123,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMatcherAppCore",
"code": "def isMatcherAppCore (env : Environment) (e : Expr) : Bool :=\n isMatcherAppCore? env e |>.isSome",
"start": [
125,
1
],
"end": [
126,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMatcherApp",
"code": "def isMatcherApp [Monad m] [MonadEnv m] (e : Expr) : m Bool :=\n return isMatcherAppCore (β getEnv) e",
"start": [
128,
1
],
"end": [
129,
39
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/Recognizers.lean | [
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.Expr.const?",
"code": "@[inline] def const? (e : Expr) : Option (Name Γ List Level) :=\n match e with\n | Expr.const n us => some (n, us)\n | _ => none",
"start": [
12,
1
],
"end": [
15,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.app1?",
"code": "@[inline] def app1? (e : Expr) (fName : Name) : Option Expr :=\n if e.isAppOfArity fName 1 then\n some e.appArg!\n else\n none",
"start": [
17,
1
],
"end": [
21,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.app2?",
"code": "@[inline] def app2? (e : Expr) (fName : Name) : Option (Expr Γ Expr) :=\n if e.isAppOfArity fName 2 then\n some (e.appFn!.appArg!, e.appArg!)\n else\n none",
"start": [
23,
1
],
"end": [
27,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.app3?",
"code": "@[inline] def app3? (e : Expr) (fName : Name) : Option (Expr Γ Expr Γ Expr) :=\n if e.isAppOfArity fName 3 then\n some (e.appFn!.appFn!.appArg!, e.appFn!.appArg!, e.appArg!)\n else\n none",
"start": [
29,
1
],
"end": [
33,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.app4?",
"code": "@[inline] def app4? (e : Expr) (fName : Name) : Option (Expr Γ Expr Γ Expr Γ Expr) :=\n if e.isAppOfArity fName 4 then\n some (e.appFn!.appFn!.appFn!.appArg!, e.appFn!.appFn!.appArg!, e.appFn!.appArg!, e.appArg!)\n else\n none",
"start": [
35,
1
],
"end": [
39,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.eq?",
"code": "@[inline] def eq? (p : Expr) : Option (Expr Γ Expr Γ Expr) :=\n p.app3? ``Eq",
"start": [
41,
1
],
"end": [
42,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ne?",
"code": "@[inline] def ne? (p : Expr) : Option (Expr Γ Expr Γ Expr) :=\n p.app3? ``Ne",
"start": [
44,
1
],
"end": [
45,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.iff?",
"code": "@[inline] def iff? (p : Expr) : Option (Expr Γ Expr) :=\n p.app2? ``Iff",
"start": [
47,
1
],
"end": [
48,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.eqOrIff?",
"code": "@[inline] def eqOrIff? (p : Expr) : Option (Expr Γ Expr) :=\n if let some (_, lhs, rhs) := p.app3? ``Eq then\n some (lhs, rhs)\n else\n p.iff?",
"start": [
50,
1
],
"end": [
54,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.not?",
"code": "@[inline] def not? (p : Expr) : Option Expr :=\n p.app1? ``Not",
"start": [
56,
1
],
"end": [
57,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.notNot?",
"code": "@[inline] def notNot? (p : Expr) : Option Expr :=\n match p.not? with\n | some p => p.not?\n | none => none",
"start": [
59,
1
],
"end": [
62,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.and?",
"code": "@[inline] def and? (p : Expr) : Option (Expr Γ Expr) :=\n p.app2? ``And",
"start": [
64,
1
],
"end": [
65,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.heq?",
"code": "@[inline] def heq? (p : Expr) : Option (Expr Γ Expr Γ Expr Γ Expr) :=\n p.app4? ``HEq",
"start": [
67,
1
],
"end": [
68,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.natAdd?",
"code": "def natAdd? (e : Expr) : Option (Expr Γ Expr) :=\n e.app2? ``Nat.add",
"start": [
70,
1
],
"end": [
71,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.arrow?",
"code": "@[inline] def arrow? : Expr β Option (Expr Γ Expr)\n | Expr.forallE _ Ξ± Ξ² _ => if Ξ².hasLooseBVars then none else some (Ξ±, Ξ²)\n | _ => none",
"start": [
73,
1
],
"end": [
75,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isEq",
"code": "def isEq (e : Expr) :=\n e.isAppOfArity ``Eq 3",
"start": [
77,
1
],
"end": [
78,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isHEq",
"code": "def isHEq (e : Expr) :=\n e.isAppOfArity ``HEq 4",
"start": [
80,
1
],
"end": [
81,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isIte",
"code": "def isIte (e : Expr) :=\n e.isAppOfArity ``ite 5",
"start": [
83,
1
],
"end": [
84,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isDIte",
"code": "def isDIte (e : Expr) :=\n e.isAppOfArity ``dite 5",
"start": [
86,
1
],
"end": [
87,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.listLit?",
"code": "partial def listLit? (e : Expr) : Option (Expr Γ List Expr) :=\n let rec loop (e : Expr) (acc : List Expr) :=\n if e.isAppOfArity' ``List.nil 1 then\n some (e.appArg!', acc.reverse)\n else if e.isAppOfArity' ``List.cons 3 then\n loop e.appArg!' (e.appFn!'.appArg!' :: acc)\n else\n none\n loop e []",
"start": [
89,
1
],
"end": [
97,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.arrayLit?",
"code": "def arrayLit? (e : Expr) : Option (Expr Γ List Expr) :=\n if e.isAppOfArity' ``List.toArray 2 then\n listLit? e.appArg!'\n else\n none",
"start": [
99,
1
],
"end": [
103,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.prod?",
"code": "def prod? (e : Expr) : Option (Expr Γ Expr) :=\n e.app2? ``Prod",
"start": [
105,
1
],
"end": [
107,
17
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Structure.lean | [
".lake/packages/lean4/src/lean/Lean/ProjFns.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.StructureFieldInfo",
"code": "structure StructureFieldInfo where\n fieldName : Name\n projFn : Name\n \n subobject? : Option Name\n binderInfo : BinderInfo\n autoParam? : Option Expr := none\n deriving Inhabited, Repr",
"start": [
14,
1
],
"end": [
21,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.StructureFieldInfo.lt",
"code": "def StructureFieldInfo.lt (iβ iβ : StructureFieldInfo) : Bool :=\n Name.quickLt iβ.fieldName iβ.fieldName",
"start": [
23,
1
],
"end": [
24,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.StructureInfo",
"code": "structure StructureInfo where\n structName : Name\n fieldNames : Array Name := #[] fieldInfo : Array StructureFieldInfo := #[] deriving Inhabited",
"start": [
26,
1
],
"end": [
30,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.StructureInfo.lt",
"code": "def StructureInfo.lt (iβ iβ : StructureInfo) : Bool :=\n Name.quickLt iβ.structName iβ.structName",
"start": [
32,
1
],
"end": [
33,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.StructureInfo.getProjFn?",
"code": "def StructureInfo.getProjFn? (info : StructureInfo) (i : Nat) : Option Name :=\n if h : i < info.fieldNames.size then\n let fieldName := info.fieldNames.get β¨i, hβ©\n info.fieldInfo.binSearch { fieldName := fieldName, projFn := default, subobject? := none, binderInfo := default } StructureFieldInfo.lt |>.map (Β·.projFn)\n else\n none",
"start": [
35,
1
],
"end": [
40,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.StructureState",
"code": "private structure StructureState where\n map : PersistentHashMap Name StructureInfo := {}\n deriving Inhabited",
"start": [
42,
1
],
"end": [
45,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.StructureDescr",
"code": "structure StructureDescr where\n structName : Name\n fields : Array StructureFieldInfo deriving Inhabited",
"start": [
53,
1
],
"end": [
56,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerStructure",
"code": "def registerStructure (env : Environment) (e : StructureDescr) : Environment :=\n structureExt.addEntry env {\n structName := e.structName\n fieldNames := e.fields.map fun e => e.fieldName\n fieldInfo := e.fields.qsort StructureFieldInfo.lt\n }",
"start": [
58,
1
],
"end": [
63,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getStructureInfo?",
"code": "def getStructureInfo? (env : Environment) (structName : Name) : Option StructureInfo :=\n match env.getModuleIdxFor? structName with\n | some modIdx => structureExt.getModuleEntries env modIdx |>.binSearch { structName } StructureInfo.lt\n | none => structureExt.getState env |>.map.find? structName",
"start": [
65,
1
],
"end": [
68,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getStructureCtor",
"code": "def getStructureCtor (env : Environment) (constName : Name) : ConstructorVal :=\n match env.find? constName with\n | some (.inductInfo { isRec := false, ctors := [ctorName], .. }) =>\n match env.find? ctorName with\n | some (ConstantInfo.ctorInfo val) => val\n | _ => panic! \"ill-formed environment\"\n | _ => panic! \"structure expected\"",
"start": [
70,
1
],
"end": [
76,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getStructureFields",
"code": "def getStructureFields (env : Environment) (structName : Name) : Array Name :=\n if let some info := getStructureInfo? env structName then\n info.fieldNames\n else\n panic! \"structure expected\"",
"start": [
78,
1
],
"end": [
83,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getFieldInfo?",
"code": "def getFieldInfo? (env : Environment) (structName : Name) (fieldName : Name) : Option StructureFieldInfo :=\n if let some info := getStructureInfo? env structName then\n info.fieldInfo.binSearch { fieldName := fieldName, projFn := default, subobject? := none, binderInfo := default } StructureFieldInfo.lt\n else\n none",
"start": [
85,
1
],
"end": [
89,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isSubobjectField?",
"code": "def isSubobjectField? (env : Environment) (structName : Name) (fieldName : Name) : Option Name :=\n if let some fieldInfo := getFieldInfo? env structName fieldName then\n fieldInfo.subobject?\n else\n none",
"start": [
91,
1
],
"end": [
96,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getParentStructures",
"code": "def getParentStructures (env : Environment) (structName : Name) : Array Name :=\n let fieldNames := getStructureFields env structName;\n fieldNames.foldl (init := #[]) fun acc fieldName =>\n match isSubobjectField? env structName fieldName with\n | some parentStructName => acc.push parentStructName\n | none => acc",
"start": [
98,
1
],
"end": [
104,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getAllParentStructures",
"code": "partial def getAllParentStructures (env : Environment) (structName : Name) : Array Name :=\n visit structName |>.run #[] |>.2\nwhere\n visit (structName : Name) : StateT (Array Name) Id Unit := do\n for p in getParentStructures env structName do\n modify fun s => s.push p\n visit p",
"start": [
106,
1
],
"end": [
113,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findField?",
"code": "partial def findField? (env : Environment) (structName : Name) (fieldName : Name) : Option Name :=\n if (getStructureFields env structName).contains fieldName then\n some structName\n else\n getParentStructures env structName |>.findSome? fun parentStructName => findField? env parentStructName fieldName",
"start": [
115,
1
],
"end": [
120,
118
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getStructureFieldsFlattenedAux",
"code": "private partial def getStructureFieldsFlattenedAux (env : Environment) (structName : Name) (fullNames : Array Name) (includeSubobjectFields : Bool) : Array Name :=\n (getStructureFields env structName).foldl (init := fullNames) fun fullNames fieldName =>\n match isSubobjectField? env structName fieldName with\n | some parentStructName =>\n let fullNames := if includeSubobjectFields then fullNames.push fieldName else fullNames\n getStructureFieldsFlattenedAux env parentStructName fullNames includeSubobjectFields\n | none => fullNames.push fieldName",
"start": [
122,
1
],
"end": [
128,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getStructureFieldsFlattened",
"code": "def getStructureFieldsFlattened (env : Environment) (structName : Name) (includeSubobjectFields := true) : Array Name :=\n getStructureFieldsFlattenedAux env structName #[] includeSubobjectFields",
"start": [
130,
1
],
"end": [
140,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isStructure",
"code": "def isStructure (env : Environment) (constName : Name) : Bool :=\n getStructureInfo? env constName |>.isSome",
"start": [
142,
1
],
"end": [
149,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getProjFnForField?",
"code": "def getProjFnForField? (env : Environment) (structName : Name) (fieldName : Name) : Option Name :=\n if let some fieldInfo := getFieldInfo? env structName fieldName then\n some fieldInfo.projFn\n else\n none",
"start": [
151,
1
],
"end": [
155,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getProjFnInfoForField?",
"code": "def getProjFnInfoForField? (env : Environment) (structName : Name) (fieldName : Name) : Option (Name Γ ProjectionFunctionInfo) :=\n if let some projFn := getProjFnForField? env structName fieldName then\n (projFn, Β·) <$> env.getProjectionFnInfo? projFn\n else\n none",
"start": [
157,
1
],
"end": [
161,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkDefaultFnOfProjFn",
"code": "def mkDefaultFnOfProjFn (projFn : Name) : Name :=\n projFn ++ `_default",
"start": [
163,
1
],
"end": [
164,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getDefaultFnForField?",
"code": "def getDefaultFnForField? (env : Environment) (structName : Name) (fieldName : Name) : Option Name :=\n if let some projName := getProjFnForField? env structName fieldName then\n let defFn := mkDefaultFnOfProjFn projName\n if env.contains defFn then defFn else none\n else\n let defFn := mkDefaultFnOfProjFn (structName ++ fieldName)\n if env.contains defFn then defFn else none",
"start": [
166,
1
],
"end": [
173,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPathToBaseStructureAux",
"code": "partial def getPathToBaseStructureAux (env : Environment) (baseStructName : Name) (structName : Name) (path : List Name) : Option (List Name) :=\n if baseStructName == structName then\n some path.reverse\n else\n let fieldNames := getStructureFields env structName;\n fieldNames.findSome? fun fieldName =>\n match isSubobjectField? env structName fieldName with\n | none => none\n | some parentStructName =>\n match getProjFnForField? env structName fieldName with\n | none => none\n | some projFn => getPathToBaseStructureAux env baseStructName parentStructName (projFn :: path)",
"start": [
175,
1
],
"end": [
186,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPathToBaseStructure?",
"code": "def getPathToBaseStructure? (env : Environment) (baseStructName : Name) (structName : Name) : Option (List Name) :=\n getPathToBaseStructureAux env baseStructName structName []",
"start": [
188,
1
],
"end": [
193,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isStructureLike",
"code": "def isStructureLike (env : Environment) (constName : Name) : Bool :=\n match env.find? constName with\n | some (.inductInfo { isRec := false, ctors := [_], numIndices := 0, .. }) => true\n | _ => false",
"start": [
195,
1
],
"end": [
199,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getStructureLikeNumFields",
"code": "def getStructureLikeNumFields (env : Environment) (constName : Name) : Nat :=\n match env.find? constName with\n | some (.inductInfo { isRec := false, ctors := [ctor], numIndices := 0, .. }) =>\n match env.find? ctor with\n | some (.ctorInfo { numFields := n, .. }) => n\n | _ => 0\n | _ => 0",
"start": [
201,
1
],
"end": [
208,
11
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Term.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Attr.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Level.lean"
] | [
{
"full_name": "Lean.Parser.Command.commentBody",
"code": "def commentBody : Parser :=\n{ fn := rawFn (finishCommentBlock (pushMissingOnError := true) 1) (trailingWs := true) }",
"start": [
14,
1
],
"end": [
15,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.commentBody.parenthesizer",
"code": "@[combinator_parenthesizer commentBody]\ndef commentBody.parenthesizer := PrettyPrinter.Parenthesizer.visitToken",
"start": [
17,
1
],
"end": [
18,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.commentBody.formatter",
"code": "@[combinator_formatter commentBody]\ndef commentBody.formatter := PrettyPrinter.Formatter.visitAtom Name.anonymous",
"start": [
19,
1
],
"end": [
20,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.docComment",
"code": "def docComment := leading_parser\n ppDedent $ \"",
"start": [
22,
1
],
"end": [
28,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.tacticParser",
"code": "@[inline] def tacticParser (rbp : Nat := 0) : Parser :=\n categoryParser `tactic rbp",
"start": [
35,
1
],
"end": [
36,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.convParser",
"code": "@[inline] def convParser (rbp : Nat := 0) : Parser :=\n categoryParser `conv rbp",
"start": [
38,
1
],
"end": [
39,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.sepByIndentSemicolon",
"code": "@[run_builtin_parser_attribute_hooks]\ndef sepByIndentSemicolon (p : Parser) : Parser :=\n sepByIndent p \"; \" (allowTrailingSep := true)",
"start": [
43,
1
],
"end": [
54,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.sepBy1IndentSemicolon",
"code": "@[run_builtin_parser_attribute_hooks]\ndef sepBy1IndentSemicolon (p : Parser) : Parser :=\n sepBy1Indent p \"; \" (allowTrailingSep := true)",
"start": [
56,
1
],
"end": [
67,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.tacticSeq1Indented",
"code": "def tacticSeq1Indented : Parser := leading_parser\n sepBy1IndentSemicolon tacticParser",
"start": [
73,
1
],
"end": [
74,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.tacticSeqBracketed",
"code": "def tacticSeqBracketed : Parser := leading_parser\n \"{\" >> sepByIndentSemicolon tacticParser >> ppDedent (ppLine >> \"}\")",
"start": [
75,
1
],
"end": [
78,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.tacticSeq",
"code": "def tacticSeq := leading_parser\n tacticSeqBracketed <|> tacticSeq1Indented",
"start": [
80,
1
],
"end": [
83,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.tacticSeqIndentGt",
"code": "def tacticSeqIndentGt := withAntiquot (mkAntiquot \"tacticSeq\" ``tacticSeq) <| node ``tacticSeq <|\n tacticSeqBracketed <|> (checkColGt \"indented tactic sequence\" >> tacticSeq1Indented)",
"start": [
85,
1
],
"end": [
89,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.seq1",
"code": "def seq1 :=\n node `Lean.Parser.Tactic.seq1 $ sepBy1 tacticParser \";\\n\" (allowTrailingSep := true)",
"start": [
92,
1
],
"end": [
93,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.darrow",
"code": "def darrow : Parser := \" => \"",
"start": [
97,
1
],
"end": [
97,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.semicolonOrLinebreak",
"code": "def semicolonOrLinebreak := \";\" <|> checkLinebreakBefore >> pushNone",
"start": [
98,
1
],
"end": [
98,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.byTactic",
"code": "@[builtin_term_parser] def byTactic := leading_parser:leadPrec\n ppAllowUngrouped >> \"by \" >> Tactic.tacticSeqIndentGt",
"start": [
105,
1
],
"end": [
107,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.byTactic'",
"code": "def byTactic' := leading_parser\n \"by \" >> Tactic.tacticSeqIndentGt",
"start": [
115,
1
],
"end": [
116,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.optSemicolon",
"code": "def optSemicolon (p : Parser) : Parser :=\n ppDedent $ semicolonOrLinebreak >> ppLine >> p",
"start": [
119,
1
],
"end": [
120,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.ident",
"code": "@[builtin_term_parser] def ident :=\n checkPrec maxPrec >> Parser.ident",
"start": [
123,
1
],
"end": [
124,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.num",
"code": "@[builtin_term_parser] def num : Parser :=\n checkPrec maxPrec >> numLit",
"start": [
125,
1
],
"end": [
126,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.scientific",
"code": "@[builtin_term_parser] def scientific : Parser :=\n checkPrec maxPrec >> scientificLit",
"start": [
127,
1
],
"end": [
128,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.str",
"code": "@[builtin_term_parser] def str : Parser :=\n checkPrec maxPrec >> strLit",
"start": [
129,
1
],
"end": [
130,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.char",
"code": "@[builtin_term_parser] def char : Parser :=\n checkPrec maxPrec >> charLit",
"start": [
131,
1
],
"end": [
132,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.type",
"code": "@[builtin_term_parser] def type := leading_parser\n \"Type\" >> optional (checkWsBefore \"\" >> checkPrec leadPrec >> checkColGt >> levelParser maxPrec)",
"start": [
133,
1
],
"end": [
135,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.sort",
"code": "@[builtin_term_parser] def sort := leading_parser\n \"Sort\" >> optional (checkWsBefore \"\" >> checkPrec leadPrec >> checkColGt >> levelParser maxPrec)",
"start": [
136,
1
],
"end": [
138,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.prop",
"code": "@[builtin_term_parser] def prop := leading_parser\n \"Prop\"",
"start": [
139,
1
],
"end": [
141,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.hole",
"code": "@[builtin_term_parser] def hole := leading_parser\n \"_\"",
"start": [
142,
1
],
"end": [
144,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.syntheticHole",
"code": "@[builtin_term_parser] def syntheticHole := leading_parser\n \"?\" >> (ident <|> hole)",
"start": [
145,
1
],
"end": [
148,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.omission",
"code": "@[builtin_term_parser] def omission := leading_parser\n \"β―\"",
"start": [
149,
1
],
"end": [
158,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binderIdent",
"code": "def binderIdent : Parser := ident <|> hole",
"start": [
159,
1
],
"end": [
159,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.sorry",
"code": "@[builtin_term_parser] def Β«sorryΒ» := leading_parser\n \"sorry\"",
"start": [
160,
1
],
"end": [
162,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.cdot",
"code": "@[builtin_term_parser] def cdot := leading_parser\n symbol \"Β·\" <|> \".\"",
"start": [
163,
1
],
"end": [
168,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.typeAscription",
"code": "@[builtin_term_parser] def typeAscription := leading_parser\n \"(\" >> (withoutPosition (withoutForbidden (termParser >> \" :\" >> optional (ppSpace >> termParser)))) >> \")\"",
"start": [
169,
1
],
"end": [
176,
110
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.tuple",
"code": "@[builtin_term_parser] def tuple := leading_parser\n \"(\" >> optional (withoutPosition (withoutForbidden (termParser >> \", \" >> sepBy1 termParser \", \" (allowTrailingSep := true)))) >> \")\"",
"start": [
177,
1
],
"end": [
179,
136
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.paren",
"code": "@[builtin_term_parser] def paren := leading_parser\n \"(\" >> withoutPosition (withoutForbidden (ppDedentIfGrouped termParser)) >> \")\"",
"start": [
180,
1
],
"end": [
190,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.anonymousCtor",
"code": "@[builtin_term_parser] def anonymousCtor := leading_parser\n \"β¨\" >> withoutPosition (withoutForbidden (sepBy termParser \", \" (allowTrailingSep := true))) >> \"β©\"",
"start": [
191,
1
],
"end": [
199,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.optIdent",
"code": "def optIdent : Parser :=\n optional (atomic (ident >> \" : \"))",
"start": [
200,
1
],
"end": [
201,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.fromTerm",
"code": "def fromTerm := leading_parser\n \"from \" >> termParser",
"start": [
202,
1
],
"end": [
203,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.showRhs",
"code": "def showRhs := fromTerm <|> byTactic'",
"start": [
204,
1
],
"end": [
204,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.sufficesDecl",
"code": "def sufficesDecl := leading_parser\n (atomic (group (binderIdent >> \" : \")) <|> hygieneInfo) >> termParser >> ppSpace >> showRhs",
"start": [
205,
1
],
"end": [
208,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.suffices",
"code": "@[builtin_term_parser] def Β«sufficesΒ» := leading_parser:leadPrec\n withPosition (\"suffices \" >> sufficesDecl) >> optSemicolon termParser",
"start": [
209,
1
],
"end": [
210,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.show",
"code": "@[builtin_term_parser] def Β«showΒ» := leading_parser:leadPrec \"show \" >> termParser >> ppSpace >> showRhs",
"start": [
211,
1
],
"end": [
211,
109
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.structInstArrayRef",
"code": "def structInstArrayRef := leading_parser\n \"[\" >> withoutPosition termParser >> \"]\"",
"start": [
212,
1
],
"end": [
213,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.structInstLVal",
"code": "def structInstLVal := leading_parser\n (ident <|> fieldIdx <|> structInstArrayRef) >>\n many (group (\".\" >> (ident <|> fieldIdx)) <|> structInstArrayRef)",
"start": [
214,
1
],
"end": [
216,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.structInstField",
"code": "def structInstField := ppGroup $ leading_parser\n structInstLVal >> \" := \" >> termParser",
"start": [
217,
1
],
"end": [
218,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.structInstFieldAbbrev",
"code": "def structInstFieldAbbrev := leading_parser\n atomic (ident >> notFollowedBy (\".\" <|> \":=\" <|> symbol \"[\") \"invalid field abbreviation\")",
"start": [
219,
1
],
"end": [
221,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.optEllipsis",
"code": "def optEllipsis := leading_parser\n optional \" ..\"",
"start": [
222,
1
],
"end": [
223,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.structInst",
"code": "@[builtin_term_parser] def structInst := leading_parser\n \"{ \" >> withoutPosition (optional (atomic (sepBy1 termParser \", \" >> \" with \"))\n >> sepByIndent (structInstFieldAbbrev <|> structInstField) \", \" (allowTrailingSep := true)\n >> optEllipsis\n >> optional (\" : \" >> termParser)) >> \" }\"",
"start": [
224,
1
],
"end": [
237,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.typeSpec",
"code": "def typeSpec := leading_parser \" : \" >> termParser",
"start": [
238,
1
],
"end": [
238,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.optType",
"code": "def optType : Parser := optional typeSpec",
"start": [
239,
1
],
"end": [
239,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.explicit",
"code": "@[builtin_term_parser] def explicit := leading_parser\n \"@\" >> termParser maxPrec",
"start": [
240,
1
],
"end": [
245,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.inaccessible",
"code": "@[builtin_term_parser] def inaccessible := leading_parser\n \".(\" >> withoutPosition termParser >> \")\"",
"start": [
246,
1
],
"end": [
251,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binderType",
"code": "def binderType (requireType := false) : Parser :=\n if requireType then node nullKind (\" : \" >> termParser) else optional (\" : \" >> termParser)",
"start": [
252,
1
],
"end": [
253,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binderTactic",
"code": "def binderTactic := leading_parser\n atomic (symbol \" := \" >> \" by \") >> Tactic.tacticSeq",
"start": [
254,
1
],
"end": [
255,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binderDefault",
"code": "def binderDefault := leading_parser\n \" := \" >> termParser",
"start": [
256,
1
],
"end": [
257,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binderDefault.parenthesizer",
"code": "@[combinator_parenthesizer Lean.Parser.Term.binderDefault] def binderDefault.parenthesizer : Parenthesizer := do\n let prec := match (β getCur) with\n | `(binderDefault| := by $_) => maxPrec\n | _ => 0\n visitArgs do\n term.parenthesizer prec\n visitToken",
"start": [
260,
1
],
"end": [
267,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.explicitBinder",
"code": "def explicitBinder (requireType := false) := leading_parser ppGroup <|\n \"(\" >> withoutPosition (many1 binderIdent >> binderType requireType >> optional (binderTactic <|> binderDefault)) >> \")\"",
"start": [
269,
1
],
"end": [
274,
123
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.implicitBinder",
"code": "def implicitBinder (requireType := false) := leading_parser ppGroup <|\n \"{\" >> withoutPosition (many1 binderIdent >> binderType requireType) >> \"}\"",
"start": [
275,
1
],
"end": [
285,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.strictImplicitLeftBracket",
"code": "def strictImplicitLeftBracket := atomic (group (symbol \"{\" >> \"{\")) <|> \"β¦\"",
"start": [
286,
1
],
"end": [
286,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.strictImplicitRightBracket",
"code": "def strictImplicitRightBracket := atomic (group (symbol \"}\" >> \"}\")) <|> \"β¦\"",
"start": [
287,
1
],
"end": [
287,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.strictImplicitBinder",
"code": "def strictImplicitBinder (requireType := false) := leading_parser ppGroup <|\n strictImplicitLeftBracket >> many1 binderIdent >>\n binderType requireType >> strictImplicitRightBracket",
"start": [
288,
1
],
"end": [
303,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.instBinder",
"code": "def instBinder := leading_parser ppGroup <|\n \"[\" >> withoutPosition (optIdent >> termParser) >> \"]\"",
"start": [
304,
1
],
"end": [
312,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.bracketedBinder",
"code": "def bracketedBinder (requireType := false) :=\n withAntiquot (mkAntiquot \"bracketedBinder\" decl_name% (isPseudoKind := true)) <|\n explicitBinder requireType <|> strictImplicitBinder requireType <|>\n implicitBinder requireType <|> instBinder",
"start": [
313,
1
],
"end": [
322,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.depArrow",
"code": "@[builtin_term_parser] def depArrow := leading_parser:25\n bracketedBinder true >> unicodeSymbol \" β \" \" -> \" >> termParser",
"start": [
339,
1
],
"end": [
340,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.forall",
"code": "@[builtin_term_parser]\ndef Β«forallΒ» := leading_parser:leadPrec\n unicodeSymbol \"β\" \"forall\" >>\n many1 (ppSpace >> (binderIdent <|> bracketedBinder)) >>\n optType >> \", \" >> termParser",
"start": [
342,
1
],
"end": [
346,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchAlt",
"code": "def matchAlt (rhsParser : Parser := termParser) : Parser :=\n leading_parser (withAnonymousAntiquot := false)\n \"| \" >> ppIndent (\n sepBy1 (sepBy1 termParser \", \") \" | \" >> darrow >>\n checkColGe \"alternative right-hand-side to start in a column greater than or equal to the corresponding '|'\" >>\n rhsParser)",
"start": [
348,
1
],
"end": [
353,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchAltExpr",
"code": "def matchAltExpr := matchAlt",
"start": [
354,
1
],
"end": [
357,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchAlts",
"code": "def matchAlts (rhsParser : Parser := termParser) : Parser :=\n leading_parser withPosition $ many1Indent (ppLine >> matchAlt rhsParser)",
"start": [
362,
1
],
"end": [
363,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchDiscr",
"code": "def matchDiscr := leading_parser\n optional (atomic (ident >> \" : \")) >> termParser",
"start": [
365,
1
],
"end": [
368,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.trueVal",
"code": "def trueVal := leading_parser nonReservedSymbol \"true\"",
"start": [
370,
1
],
"end": [
370,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.falseVal",
"code": "def falseVal := leading_parser nonReservedSymbol \"false\"",
"start": [
371,
1
],
"end": [
371,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.generalizingParam",
"code": "def generalizingParam := leading_parser\n atomic (\"(\" >> nonReservedSymbol \"generalizing\") >> \" := \" >>\n (trueVal <|> falseVal) >> \")\" >> ppSpace",
"start": [
372,
1
],
"end": [
374,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.motive",
"code": "def motive := leading_parser\n atomic (\"(\" >> nonReservedSymbol \"motive\" >> \" := \") >>\n withoutPosition termParser >> \")\" >> ppSpace",
"start": [
376,
1
],
"end": [
378,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.match",
"code": "@[builtin_term_parser] def Β«matchΒ» := leading_parser:leadPrec\n \"match \" >> optional generalizingParam >> optional motive >> sepBy1 matchDiscr \", \" >>\n \" with\" >> ppDedent matchAlts",
"start": [
380,
1
],
"end": [
415,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.nomatch",
"code": "@[builtin_term_parser] def Β«nomatchΒ» := leading_parser:leadPrec \"nomatch \" >> sepBy1 termParser \", \"",
"start": [
416,
1
],
"end": [
421,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.nofun",
"code": "@[builtin_term_parser] def Β«nofunΒ» := leading_parser \"nofun\"",
"start": [
423,
1
],
"end": [
423,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.funImplicitBinder",
"code": "def funImplicitBinder := withAntiquot (mkAntiquot \"implicitBinder\" ``implicitBinder) <|\n atomic (lookahead (\"{\" >> many1 binderIdent >> (symbol \" : \" <|> \"}\"))) >> implicitBinder",
"start": [
425,
1
],
"end": [
426,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.funStrictImplicitBinder",
"code": "def funStrictImplicitBinder :=\n atomic (lookahead (\n strictImplicitLeftBracket >> many1 binderIdent >>\n (symbol \" : \" <|> strictImplicitRightBracket))) >>\n strictImplicitBinder",
"start": [
427,
1
],
"end": [
431,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.funBinder",
"code": "def funBinder : Parser :=\n withAntiquot (mkAntiquot \"funBinder\" decl_name% (isPseudoKind := true)) <|\n funStrictImplicitBinder <|> funImplicitBinder <|> instBinder <|> termParser maxPrec",
"start": [
432,
1
],
"end": [
434,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.basicFun",
"code": "def basicFun : Parser := leading_parser (withAnonymousAntiquot := false)\n ppGroup (many1 (ppSpace >> funBinder) >> optType >> unicodeSymbol \" β¦\" \" =>\") >> ppSpace >> termParser",
"start": [
437,
1
],
"end": [
438,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.fun",
"code": "@[builtin_term_parser] def Β«funΒ» := leading_parser:maxPrec\n ppAllowUngrouped >> unicodeSymbol \"Ξ»\" \"fun\" >> (basicFun <|> matchAlts)",
"start": [
439,
1
],
"end": [
440,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.optExprPrecedence",
"code": "def optExprPrecedence := optional (atomic \":\" >> termParser maxPrec)",
"start": [
442,
1
],
"end": [
442,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.withAnonymousAntiquot",
"code": "def withAnonymousAntiquot := leading_parser\n atomic (\" (\" >> nonReservedSymbol \"withAnonymousAntiquot\" >> \" := \") >>\n (trueVal <|> falseVal) >> \")\"",
"start": [
443,
1
],
"end": [
445,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.leading_parser",
"code": "@[builtin_term_parser] def Β«leading_parserΒ» := leading_parser:leadPrec\n \"leading_parser\" >> optExprPrecedence >> optional withAnonymousAntiquot >> ppSpace >> termParser",
"start": [
446,
1
],
"end": [
447,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.trailing_parser",
"code": "@[builtin_term_parser] def Β«trailing_parserΒ» := leading_parser:leadPrec\n \"trailing_parser\" >> optExprPrecedence >> optExprPrecedence >> ppSpace >> termParser",
"start": [
448,
1
],
"end": [
449,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.borrowed",
"code": "@[builtin_term_parser] def borrowed := leading_parser\n \"@& \" >> termParser leadPrec",
"start": [
451,
1
],
"end": [
452,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.quotedName",
"code": "@[builtin_term_parser] def quotedName := leading_parser nameLit",
"start": [
453,
1
],
"end": [
454,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doubleQuotedName",
"code": "@[builtin_term_parser] def doubleQuotedName := leading_parser\n \"`\" >> checkNoWsBefore >> rawCh '`' (trailingWs := false) >> ident",
"start": [
455,
1
],
"end": [
462,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letIdBinder",
"code": "def letIdBinder :=\n withAntiquot (mkAntiquot \"letIdBinder\" decl_name% (isPseudoKind := true)) <|\n binderIdent <|> bracketedBinder",
"start": [
464,
1
],
"end": [
466,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letIdLhs",
"code": "def letIdLhs : Parser :=\n binderIdent >> notFollowedBy (checkNoWsBefore \"\" >> \"[\")\n \"space is required before instance '[...]' binders to distinguish them from array updates `let x[i] := e; ...`\" >>\n many (ppSpace >> letIdBinder) >> optType",
"start": [
468,
1
],
"end": [
471,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letIdDecl",
"code": "def letIdDecl := leading_parser (withAnonymousAntiquot := false)\n atomic (letIdLhs >> \" := \") >> termParser",
"start": [
472,
1
],
"end": [
473,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letPatDecl",
"code": "def letPatDecl := leading_parser (withAnonymousAntiquot := false)\n atomic (termParser >> pushNone >> optType >> \" := \") >> termParser",
"start": [
474,
1
],
"end": [
475,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letEqnsDecl",
"code": "def letEqnsDecl := leading_parser (withAnonymousAntiquot := false)\n letIdLhs >> (\" := \" <|> matchAlts)",
"start": [
492,
1
],
"end": [
493,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letDecl",
"code": "def letDecl := leading_parser (withAnonymousAntiquot := false)\n notFollowedBy (nonReservedSymbol \"rec\") \"rec\" >>\n (letIdDecl <|> letPatDecl <|> letEqnsDecl)",
"start": [
494,
1
],
"end": [
502,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.let",
"code": "@[builtin_term_parser] def Β«letΒ» := leading_parser:leadPrec\n withPosition (\"let \" >> letDecl) >> optSemicolon termParser",
"start": [
503,
1
],
"end": [
525,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.let_fun",
"code": "@[builtin_term_parser] def Β«let_funΒ» := leading_parser:leadPrec\n withPosition ((symbol \"let_fun \" <|> \"let_Ξ» \") >> letDecl) >> optSemicolon termParser",
"start": [
526,
1
],
"end": [
532,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.let_delayed",
"code": "@[builtin_term_parser] def Β«let_delayedΒ» := leading_parser:leadPrec\n withPosition (\"let_delayed \" >> letDecl) >> optSemicolon termParser",
"start": [
533,
1
],
"end": [
537,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.let_tmp",
"code": "@[builtin_term_parser] def Β«let_tmpΒ» := leading_parser:leadPrec\n withPosition (\"let_tmp \" >> letDecl) >> optSemicolon termParser",
"start": [
538,
1
],
"end": [
543,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.haveId",
"code": "def haveId := leading_parser (withAnonymousAntiquot := false)\n (ppSpace >> binderIdent) <|> hygieneInfo",
"start": [
545,
1
],
"end": [
546,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.haveIdLhs",
"code": "def haveIdLhs :=\n haveId >> many (ppSpace >> letIdBinder) >> optType",
"start": [
548,
1
],
"end": [
549,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.haveIdDecl",
"code": "def haveIdDecl := leading_parser (withAnonymousAntiquot := false)\n atomic (haveIdLhs >> \" := \") >> termParser",
"start": [
550,
1
],
"end": [
551,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.haveEqnsDecl",
"code": "def haveEqnsDecl := leading_parser (withAnonymousAntiquot := false)\n haveIdLhs >> matchAlts",
"start": [
552,
1
],
"end": [
553,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.haveDecl",
"code": "def haveDecl := leading_parser (withAnonymousAntiquot := false)\n haveIdDecl <|> (ppSpace >> letPatDecl) <|> haveEqnsDecl",
"start": [
554,
1
],
"end": [
558,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.have",
"code": "@[builtin_term_parser] def Β«haveΒ» := leading_parser:leadPrec\n withPosition (\"have\" >> haveDecl) >> optSemicolon termParser",
"start": [
559,
1
],
"end": [
560,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.haveI",
"code": "@[builtin_term_parser] def Β«haveIΒ» := leading_parser\n withPosition (\"haveI \" >> haveDecl) >> optSemicolon termParser",
"start": [
561,
1
],
"end": [
563,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letI",
"code": "@[builtin_term_parser] def Β«letIΒ» := leading_parser\n withPosition (\"letI \" >> haveDecl) >> optSemicolon termParser",
"start": [
564,
1
],
"end": [
566,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.scoped",
"code": "def Β«scopedΒ» := leading_parser \"scoped \"",
"start": [
568,
1
],
"end": [
568,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.local",
"code": "def Β«localΒ» := leading_parser \"local \"",
"start": [
569,
1
],
"end": [
569,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.attrKind",
"code": "def attrKind := leading_parser optional (Β«scopedΒ» <|> Β«localΒ»)",
"start": [
570,
1
],
"end": [
571,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.attrInstance",
"code": "def attrInstance := ppGroup $ leading_parser attrKind >> attrParser",
"start": [
572,
1
],
"end": [
572,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.attributes",
"code": "def attributes := leading_parser\n \"@[\" >> withoutPosition (sepBy1 attrInstance \", \") >> \"] \"",
"start": [
574,
1
],
"end": [
575,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Termination.terminationBy",
"code": "def terminationBy := leading_parser\n \"termination_by \" >>\n optional (atomic (many (ppSpace >> Term.binderIdent) >> \" => \")) >>\n termParser",
"start": [
585,
1
],
"end": [
605,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Termination.terminationBy?",
"code": "@[inherit_doc terminationBy]\ndef terminationBy? := leading_parser\n \"termination_by?\"",
"start": [
607,
1
],
"end": [
609,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Termination.decreasingBy",
"code": "def decreasingBy := leading_parser\n ppDedent ppLine >> \"decreasing_by \" >> Tactic.tacticSeqIndentGt",
"start": [
611,
1
],
"end": [
618,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Termination.suffix",
"code": "def suffix := leading_parser\n optional (ppDedent ppLine >> (terminationBy? <|> terminationBy)) >> optional decreasingBy",
"start": [
620,
1
],
"end": [
624,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letRecDecl",
"code": "def letRecDecl := leading_parser\n optional Command.docComment >> optional Β«attributesΒ» >> letDecl >> Termination.suffix",
"start": [
629,
1
],
"end": [
632,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letRecDecls",
"code": "def letRecDecls := leading_parser\n sepBy1 letRecDecl \", \"",
"start": [
633,
1
],
"end": [
635,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letrec",
"code": "@[builtin_term_parser]\ndef Β«letrecΒ» := leading_parser:leadPrec\n withPosition (group (\"let \" >> nonReservedSymbol \"rec \") >> letRecDecls) >>\n optSemicolon termParser",
"start": [
636,
1
],
"end": [
639,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.whereDecls",
"code": "@[run_builtin_parser_attribute_hooks]\ndef whereDecls := leading_parser\n ppDedent ppLine >> \"where\" >> sepBy1Indent (ppGroup letRecDecl) \"; \" (allowTrailingSep := true)",
"start": [
641,
1
],
"end": [
643,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchAltsWhereDecls",
"code": "@[run_builtin_parser_attribute_hooks]\ndef matchAltsWhereDecls := leading_parser\n matchAlts >> Termination.suffix >> optional whereDecls",
"start": [
645,
1
],
"end": [
647,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.noindex",
"code": "@[builtin_term_parser] def noindex := leading_parser\n \"no_index \" >> termParser maxPrec",
"start": [
649,
1
],
"end": [
650,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.unsafe",
"code": "@[builtin_term_parser] def Β«unsafeΒ» := leading_parser:leadPrec \"unsafe \" >> termParser",
"start": [
652,
1
],
"end": [
663,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binrel",
"code": "@[builtin_term_parser] def binrel := leading_parser\n \"binrel% \" >> ident >> ppSpace >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
665,
1
],
"end": [
667,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binrel_no_prop",
"code": "@[builtin_term_parser] def binrel_no_prop := leading_parser\n \"binrel_no_prop% \" >> ident >> ppSpace >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
668,
1
],
"end": [
670,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binop",
"code": "@[builtin_term_parser] def binop := leading_parser\n \"binop% \" >> ident >> ppSpace >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
671,
1
],
"end": [
673,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.binop_lazy",
"code": "@[builtin_term_parser] def binop_lazy := leading_parser\n \"binop_lazy% \" >> ident >> ppSpace >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
674,
1
],
"end": [
676,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.leftact",
"code": "@[builtin_term_parser] def leftact := leading_parser\n \"leftact% \" >> ident >> ppSpace >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
677,
1
],
"end": [
680,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.rightact",
"code": "@[builtin_term_parser] def rightact := leading_parser\n \"rightact% \" >> ident >> ppSpace >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
681,
1
],
"end": [
684,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.unop",
"code": "@[builtin_term_parser] def unop := leading_parser\n \"unop% \" >> ident >> ppSpace >> termParser maxPrec",
"start": [
685,
1
],
"end": [
687,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.forInMacro",
"code": "@[builtin_term_parser] def forInMacro := leading_parser\n \"for_in% \" >> termParser maxPrec >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
689,
1
],
"end": [
690,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.forInMacro'",
"code": "@[builtin_term_parser] def forInMacro' := leading_parser\n \"for_in'% \" >> termParser maxPrec >> termParser maxPrec >> ppSpace >> termParser maxPrec",
"start": [
691,
1
],
"end": [
692,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.declName",
"code": "@[builtin_term_parser] def declName := leading_parser \"decl_name%\"",
"start": [
694,
1
],
"end": [
695,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.withDeclName",
"code": "@[builtin_term_parser] def withDeclName := leading_parser\n \"with_decl_name% \" >> optional \"?\" >> ident >> ppSpace >> termParser",
"start": [
697,
1
],
"end": [
704,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.typeOf",
"code": "@[builtin_term_parser] def typeOf := leading_parser\n \"type_of% \" >> termParser maxPrec",
"start": [
705,
1
],
"end": [
706,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.ensureTypeOf",
"code": "@[builtin_term_parser] def ensureTypeOf := leading_parser\n \"ensure_type_of% \" >> termParser maxPrec >> strLit >> ppSpace >> termParser",
"start": [
707,
1
],
"end": [
708,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.ensureExpectedType",
"code": "@[builtin_term_parser] def ensureExpectedType := leading_parser\n \"ensure_expected_type% \" >> strLit >> ppSpace >> termParser maxPrec",
"start": [
709,
1
],
"end": [
710,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.noImplicitLambda",
"code": "@[builtin_term_parser] def noImplicitLambda := leading_parser\n \"no_implicit_lambda% \" >> termParser maxPrec",
"start": [
711,
1
],
"end": [
712,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.clear",
"code": "@[builtin_term_parser] def clear := leading_parser\n \"clear% \" >> ident >> semicolonOrLinebreak >> ppDedent ppLine >> termParser",
"start": [
714,
1
],
"end": [
719,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letMVar",
"code": "@[builtin_term_parser] def letMVar := leading_parser\n \"let_mvar% \" >> \"?\" >> ident >> \" := \" >> termParser >> \"; \" >> termParser",
"start": [
721,
1
],
"end": [
722,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.waitIfTypeMVar",
"code": "@[builtin_term_parser] def waitIfTypeMVar := leading_parser\n \"wait_if_type_mvar% \" >> \"?\" >> ident >> \"; \" >> termParser",
"start": [
723,
1
],
"end": [
724,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.waitIfTypeContainsMVar",
"code": "@[builtin_term_parser] def waitIfTypeContainsMVar := leading_parser\n \"wait_if_type_contains_mvar% \" >> \"?\" >> ident >> \"; \" >> termParser",
"start": [
725,
1
],
"end": [
726,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.waitIfContainsMVar",
"code": "@[builtin_term_parser] def waitIfContainsMVar := leading_parser\n \"wait_if_contains_mvar% \" >> \"?\" >> ident >> \"; \" >> termParser",
"start": [
727,
1
],
"end": [
728,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.defaultOrOfNonempty",
"code": "@[builtin_term_parser] def defaultOrOfNonempty := leading_parser\n \"default_or_ofNonempty% \" >> optional \"unsafe\"",
"start": [
730,
1
],
"end": [
731,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.noErrorIfUnused",
"code": "@[builtin_term_parser] def noErrorIfUnused := leading_parser\n \"no_error_if_unused% \" >> termParser",
"start": [
733,
1
],
"end": [
738,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.namedArgument",
"code": "def namedArgument := leading_parser (withAnonymousAntiquot := false)\n atomic (\"(\" >> ident >> \" := \") >> withoutPosition termParser >> \")\"",
"start": [
740,
1
],
"end": [
741,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.ellipsis",
"code": "def ellipsis := leading_parser (withAnonymousAntiquot := false)\n \"..\" >> notFollowedBy \".\" \"`.` immediately after `..`\"",
"start": [
742,
1
],
"end": [
743,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.argument",
"code": "def argument :=\n checkWsBefore \"expected space\" >>\n checkColGt \"expected to be indented\" >>\n (namedArgument <|> ellipsis <|> termParser argPrec)",
"start": [
744,
1
],
"end": [
747,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.app",
"code": "@[builtin_term_parser] def app := trailing_parser:leadPrec:maxPrec many1 argument",
"start": [
751,
1
],
"end": [
751,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.proj",
"code": "@[builtin_term_parser] def proj := trailing_parser\n checkNoWsBefore >> \".\" >> checkNoWsBefore >> (fieldIdx <|> rawIdent)",
"start": [
753,
1
],
"end": [
766,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.completion",
"code": "@[builtin_term_parser] def completion := trailing_parser\n checkNoWsBefore >> \".\"",
"start": [
767,
1
],
"end": [
768,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.arrow",
"code": "@[builtin_term_parser] def arrow := trailing_parser\n checkPrec 25 >> unicodeSymbol \" β \" \" -> \" >> termParser 25",
"start": [
769,
1
],
"end": [
770,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.identProjKind",
"code": "def identProjKind := `Lean.Parser.Term.identProj",
"start": [
772,
1
],
"end": [
781,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.isIdent",
"code": "def isIdent (stx : Syntax) : Bool :=\n stx.isAntiquot || stx.isIdent",
"start": [
783,
1
],
"end": [
785,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.explicitUniv",
"code": "@[builtin_term_parser] def explicitUniv : TrailingParser := trailing_parser\n checkStackTop isIdent \"expected preceding identifier\" >>\n checkNoWsBefore \"no space before '.{'\" >> \".{\" >>\n sepBy1 levelParser \", \" >> \"}\"",
"start": [
787,
1
],
"end": [
791,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.namedPattern",
"code": "@[builtin_term_parser] def namedPattern : TrailingParser := trailing_parser\n checkStackTop isIdent \"expected preceding identifier\" >>\n checkNoWsBefore \"no space before '@'\" >> \"@\" >>\n optional (atomic (ident >> \":\")) >> termParser maxPrec",
"start": [
792,
1
],
"end": [
797,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.pipeProj",
"code": "@[builtin_term_parser] def pipeProj := trailing_parser:minPrec\n \" |>.\" >> checkNoWsBefore >> (fieldIdx <|> rawIdent) >> many argument",
"start": [
799,
1
],
"end": [
804,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.pipeCompletion",
"code": "@[builtin_term_parser] def pipeCompletion := trailing_parser:minPrec\n \" |>.\"",
"start": [
805,
1
],
"end": [
806,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.subst",
"code": "@[builtin_term_parser] def subst := trailing_parser:75\n \" βΈ \" >> sepBy1 (termParser 75) \" βΈ \"",
"start": [
808,
1
],
"end": [
821,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.bracketedBinderF",
"code": "def bracketedBinderF := bracketedBinder",
"start": [
823,
1
],
"end": [
823,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.panic",
"code": "@[builtin_term_parser] def panic := leading_parser:leadPrec\n \"panic! \" >> termParser",
"start": [
826,
1
],
"end": [
835,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.unreachable",
"code": "@[builtin_term_parser] def unreachable := leading_parser:leadPrec\n \"unreachable!\"",
"start": [
836,
1
],
"end": [
838,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.dbgTrace",
"code": "@[builtin_term_parser] def dbgTrace := leading_parser:leadPrec\n withPosition (\"dbg_trace\" >> (interpolatedStr termParser <|> termParser)) >>\n optSemicolon termParser",
"start": [
839,
1
],
"end": [
845,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.assert",
"code": "@[builtin_term_parser] def assert := leading_parser:leadPrec\n withPosition (\"assert! \" >> termParser) >> optSemicolon termParser",
"start": [
846,
1
],
"end": [
848,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.macroArg",
"code": "def macroArg := termParser maxPrec",
"start": [
850,
1
],
"end": [
850,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.macroDollarArg",
"code": "def macroDollarArg := leading_parser \"$\" >> termParser 10",
"start": [
851,
1
],
"end": [
851,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.macroLastArg",
"code": "def macroLastArg := macroDollarArg <|> macroArg",
"start": [
852,
1
],
"end": [
852,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.stateRefT",
"code": "@[builtin_term_parser] def stateRefT := leading_parser\n \"StateRefT \" >> macroArg >> ppSpace >> macroLastArg",
"start": [
855,
1
],
"end": [
856,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.dynamicQuot",
"code": "@[builtin_term_parser] def dynamicQuot := withoutPosition <| leading_parser\n \"`(\" >> ident >> \"| \" >> incQuotDepth (parserOfStack 1) >> \")\"",
"start": [
858,
1
],
"end": [
859,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.dotIdent",
"code": "@[builtin_term_parser] def dotIdent := leading_parser\n \".\" >> checkNoWsBefore >> rawIdent",
"start": [
861,
1
],
"end": [
862,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.showTermElabImpl",
"code": "@[builtin_term_parser] def showTermElabImpl :=\n leading_parser:leadPrec \"show_term_elab \" >> termParser",
"start": [
864,
1
],
"end": [
868,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchExprPat",
"code": "def matchExprPat := leading_parser optional (atomic (ident >> \"@\")) >> ident >> many binderIdent",
"start": [
874,
1
],
"end": [
874,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchExprAlt",
"code": "def matchExprAlt (rhsParser : Parser) := leading_parser \"| \" >> ppIndent (matchExprPat >> \" => \" >> rhsParser)",
"start": [
875,
1
],
"end": [
875,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchExprElseAlt",
"code": "def matchExprElseAlt (rhsParser : Parser) := leading_parser \"| \" >> ppIndent (hole >> \" => \" >> rhsParser)",
"start": [
876,
1
],
"end": [
876,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchExprAlts",
"code": "def matchExprAlts (rhsParser : Parser) :=\n leading_parser withPosition $\n many (ppLine >> checkColGe \"irrelevant\" >> notFollowedBy (symbol \"| \" >> \" _ \") \"irrelevant\" >> matchExprAlt rhsParser)\n >> (ppLine >> checkColGe \"else-alternative for `match_expr`, i.e., `| _ => ...`\" >> matchExprElseAlt rhsParser)",
"start": [
877,
1
],
"end": [
880,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.matchExpr",
"code": "@[builtin_term_parser] def matchExpr := leading_parser:leadPrec\n \"match_expr \" >> termParser >> \" with\" >> ppDedent (matchExprAlts termParser)",
"start": [
881,
1
],
"end": [
882,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letExpr",
"code": "@[builtin_term_parser] def letExpr := leading_parser:leadPrec\n withPosition (\"let_expr \" >> matchExprPat >> \" := \" >> termParser >> checkColGt >> \" | \" >> termParser) >> optSemicolon termParser",
"start": [
884,
1
],
"end": [
885,
133
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.quot",
"code": "@[builtin_term_parser default+1] def Tactic.quot : Parser := leading_parser\n \"`(tactic| \" >> withoutPosition (incQuotDepth tacticParser) >> \")\"",
"start": [
889,
1
],
"end": [
890,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.quotSeq",
"code": "@[builtin_term_parser] def Tactic.quotSeq : Parser := leading_parser\n \"`(tactic| \" >> withoutPosition (incQuotDepth Tactic.seq1) >> \")\"",
"start": [
891,
1
],
"end": [
892,
68
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/CollectMVars.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.CollectMVars.State",
"code": "structure State where\n visitedExpr : ExprSet := {}\n result : Array MVarId := #[]",
"start": [
13,
1
],
"end": [
15,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectMVars.Visitor",
"code": "abbrev Visitor := State β State",
"start": [
19,
1
],
"end": [
19,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectMVars.visit",
"code": "partial def visit (e : Expr) : Visitor := fun s =>\n if !e.hasExprMVar || s.visitedExpr.contains e then s\n else main e { s with visitedExpr := s.visitedExpr.insert e }",
"start": [
22,
3
],
"end": [
24,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectMVars.main",
"code": "partial def main : Expr β Visitor\n | Expr.proj _ _ e => visit e\n | Expr.forallE _ d b _ => visit b β visit d\n | Expr.lam _ d b _ => visit b β visit d\n | Expr.letE _ t v b _ => visit b β visit v β visit t\n | Expr.app f a => visit a β visit f\n | Expr.mdata _ b => visit b\n | Expr.mvar mvarId => fun s => { s with result := s.result.push mvarId }\n | _ => id",
"start": [
26,
3
],
"end": [
34,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.collectMVars",
"code": "def Expr.collectMVars (s : CollectMVars.State) (e : Expr) : CollectMVars.State :=\n CollectMVars.visit e s",
"start": [
39,
1
],
"end": [
40,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Transform.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.TransformStep",
"code": "inductive TransformStep where\n \n | done (e : Expr)\n \n | visit (e : Expr)\n \n | continue (e? : Option Expr := none)\n deriving Inhabited, Repr",
"start": [
11,
1
],
"end": [
24,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.transform",
"code": "partial def transform {m} [Monad m] [MonadLiftT CoreM m] [MonadControlT CoreM m]\n (input : Expr)\n (pre : Expr β m TransformStep := fun _ => return .continue)\n (post : Expr β m TransformStep := fun e => return .done e)\n : m Expr :=\n let _ : STWorld IO.RealWorld m := β¨β©\n let _ : MonadLiftT (ST IO.RealWorld) m := { monadLift := fun x => liftM (m := CoreM) (liftM (m := ST IO.RealWorld) x) }\n let rec visit (e : Expr) : MonadCacheT ExprStructEq Expr m Expr :=\n checkCache { val := e : ExprStructEq } fun _ => Core.withIncRecDepth do\n let rec visitPost (e : Expr) : MonadCacheT ExprStructEq Expr m Expr := do\n match (β post e) with\n | .done e => pure e\n | .visit e => visit e\n | .continue e? => pure (e?.getD e)\n match (β pre e) with\n | .done e => pure e\n | .visit e => visitPost (β visit e)\n | .continue e? =>\n let e := e?.getD e\n match e with\n | Expr.forallE _ d b _ => visitPost (e.updateForallE! (β visit d) (β visit b))\n | Expr.lam _ d b _ => visitPost (e.updateLambdaE! (β visit d) (β visit b))\n | Expr.letE _ t v b _ => visitPost (e.updateLet! (β visit t) (β visit v) (β visit b))\n | Expr.app .. => e.withApp fun f args => do visitPost (mkAppN (β visit f) (β args.mapM visit))\n | Expr.mdata _ b => visitPost (e.updateMData! (β visit b))\n | Expr.proj _ _ b => visitPost (e.updateProj! (β visit b))\n | _ => visitPost e\n visit input |>.run",
"start": [
28,
1
],
"end": [
67,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.betaReduce",
"code": "def betaReduce (e : Expr) : CoreM Expr :=\n transform e (pre := fun e => return if e.isHeadBetaTarget then .visit e.headBeta else .continue)",
"start": [
69,
1
],
"end": [
70,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.transform",
"code": "partial def transform {m} [Monad m] [MonadLiftT MetaM m] [MonadControlT MetaM m]\n (input : Expr)\n (pre : Expr β m TransformStep := fun _ => return .continue)\n (post : Expr β m TransformStep := fun e => return .done e)\n (usedLetOnly := false)\n (skipConstInApp := false)\n : m Expr := do\n let _ : STWorld IO.RealWorld m := β¨β©\n let _ : MonadLiftT (ST IO.RealWorld) m := { monadLift := fun x => liftM (m := MetaM) (liftM (m := ST IO.RealWorld) x) }\n let rec visit (e : Expr) : MonadCacheT ExprStructEq Expr m Expr :=\n checkCache { val := e : ExprStructEq } fun _ => Meta.withIncRecDepth do\n let rec visitPost (e : Expr) : MonadCacheT ExprStructEq Expr m Expr := do\n match (β post e) with\n | .done e => pure e\n | .visit e => visit e\n | .continue e? => pure (e?.getD e)\n let rec visitLambda (fvars : Array Expr) (e : Expr) : MonadCacheT ExprStructEq Expr m Expr := do\n match e with\n | Expr.lam n d b c =>\n withLocalDecl n c (β visit (d.instantiateRev fvars)) fun x =>\n visitLambda (fvars.push x) b\n | e => visitPost (β mkLambdaFVars (usedLetOnly := usedLetOnly) fvars (β visit (e.instantiateRev fvars)))\n let rec visitForall (fvars : Array Expr) (e : Expr) : MonadCacheT ExprStructEq Expr m Expr := do\n match e with\n | Expr.forallE n d b c =>\n withLocalDecl n c (β visit (d.instantiateRev fvars)) fun x =>\n visitForall (fvars.push x) b\n | e => visitPost (β mkForallFVars (usedLetOnly := usedLetOnly) fvars (β visit (e.instantiateRev fvars)))\n let rec visitLet (fvars : Array Expr) (e : Expr) : MonadCacheT ExprStructEq Expr m Expr := do\n match e with\n | Expr.letE n t v b _ =>\n withLetDecl n (β visit (t.instantiateRev fvars)) (β visit (v.instantiateRev fvars)) fun x =>\n visitLet (fvars.push x) b\n | e => visitPost (β mkLetFVars (usedLetOnly := usedLetOnly) fvars (β visit (e.instantiateRev fvars)))\n let visitApp (e : Expr) : MonadCacheT ExprStructEq Expr m Expr :=\n e.withApp fun f args => do\n if skipConstInApp && f.isConst then\n visitPost (mkAppN f (β args.mapM visit))\n else\n visitPost (mkAppN (β visit f) (β args.mapM visit))\n match (β pre e) with\n | .done e => pure e\n | .visit e => visit e\n | .continue e? =>\n let e := e?.getD e\n match e with\n | Expr.forallE .. => visitForall #[] e\n | Expr.lam .. => visitLambda #[] e\n | Expr.letE .. => visitLet #[] e\n | Expr.app .. => visitApp e\n | Expr.mdata _ b => visitPost (e.updateMData! (β visit b))\n | Expr.proj _ _ b => visitPost (e.updateProj! (β visit b))\n | _ => visitPost e\n visit input |>.run",
"start": [
76,
1
],
"end": [
137,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.zetaReduce",
"code": "def zetaReduce (e : Expr) : MetaM Expr := do\n let pre (e : Expr) : MetaM TransformStep := do\n match e with\n | Expr.fvar fvarId =>\n match (β getLCtx).find? fvarId with\n | none => return TransformStep.done e\n | some localDecl =>\n if let some value := localDecl.value? then\n return TransformStep.visit value\n else\n return TransformStep.done e\n | _ => return .continue\n transform e (pre := pre) (usedLetOnly := true)",
"start": [
140,
1
],
"end": [
152,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.unfoldDeclsFrom",
"code": "def unfoldDeclsFrom (biggerEnv : Environment) (e : Expr) : CoreM Expr := do\n withoutModifyingEnv do\n let env β getEnv\n setEnv biggerEnv let pre (e : Expr) : CoreM TransformStep := do\n match e with\n | Expr.const declName us .. =>\n if env.contains declName then\n return TransformStep.done e\n else if let some info := biggerEnv.find? declName then\n if info.hasValue then\n return TransformStep.visit (β instantiateValueLevelParams info us)\n else\n return TransformStep.done e\n else\n return TransformStep.done e\n | _ => return .continue\n Core.transform e (pre := pre)",
"start": [
154,
1
],
"end": [
172,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.eraseInaccessibleAnnotations",
"code": "def eraseInaccessibleAnnotations (e : Expr) : CoreM Expr :=\n Core.transform e (post := fun e => return TransformStep.done <| if let some e := inaccessible? e then e else e)",
"start": [
174,
1
],
"end": [
175,
114
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.erasePatternRefAnnotations",
"code": "def erasePatternRefAnnotations (e : Expr) : CoreM Expr :=\n Core.transform e (post := fun e => return TransformStep.done <| if let some (_, e) := patternWithRef? e then e else e)",
"start": [
177,
1
],
"end": [
178,
121
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/WHNF.lean | [
".lake/packages/lean4/src/lean/Lean/Structure.lean",
".lake/packages/lean4/src/lean/Lean/Util/Recognizers.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Match/MatcherInfo.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Match/MatchPatternAttr.lean",
".lake/packages/lean4/src/lean/Lean/Meta/CtorRecognizer.lean",
".lake/packages/lean4/src/lean/Lean/Meta/FunInfo.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Offset.lean",
".lake/packages/lean4/src/lean/Lean/Meta/GetUnfoldableConst.lean"
] | [
{
"full_name": "Lean.Meta.getStructuralRecArgPos?",
"code": "@[extern \"lean_get_structural_rec_arg_pos\"]\nopaque getStructuralRecArgPos? (declName : Name) : CoreM (Option Nat)",
"start": [
22,
1
],
"end": [
28,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.smartUnfoldingSuffix",
"code": "def smartUnfoldingSuffix := \"_sunfold\"",
"start": [
30,
1
],
"end": [
30,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSmartUnfoldingNameFor",
"code": "@[inline] def mkSmartUnfoldingNameFor (declName : Name) : Name :=\n Name.mkStr declName smartUnfoldingSuffix",
"start": [
32,
1
],
"end": [
33,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.hasSmartUnfoldingDecl",
"code": "def hasSmartUnfoldingDecl (env : Environment) (declName : Name) : Bool :=\n env.contains (mkSmartUnfoldingNameFor declName)",
"start": [
35,
1
],
"end": [
36,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.markSmartUnfoldingMatch",
"code": "def markSmartUnfoldingMatch (e : Expr) : Expr :=\n mkAnnotation `sunfoldMatch e",
"start": [
43,
1
],
"end": [
45,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.smartUnfoldingMatch?",
"code": "def smartUnfoldingMatch? (e : Expr) : Option Expr :=\n annotation? `sunfoldMatch e",
"start": [
47,
1
],
"end": [
48,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.markSmartUnfoldingMatchAlt",
"code": "def markSmartUnfoldingMatchAlt (e : Expr) : Expr :=\n mkAnnotation `sunfoldMatchAlt e",
"start": [
50,
1
],
"end": [
52,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.smartUnfoldingMatchAlt?",
"code": "def smartUnfoldingMatchAlt? (e : Expr) : Option Expr :=\n annotation? `sunfoldMatchAlt e",
"start": [
54,
1
],
"end": [
55,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isAuxDef",
"code": "def isAuxDef (constName : Name) : MetaM Bool := do\n let env β getEnv\n return isAuxRecursor env constName || isNoConfusion env constName",
"start": [
61,
1
],
"end": [
63,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchConstAux",
"code": "@[inline] private def matchConstAux {Ξ±} (e : Expr) (failK : Unit β MetaM Ξ±) (k : ConstantInfo β List Level β MetaM Ξ±) : MetaM Ξ± := do\n let .const name lvls := e\n | failK ()\n let (some cinfo) β getUnfoldableConst? name\n | failK ()\n k cinfo lvls",
"start": [
65,
1
],
"end": [
70,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFirstCtor",
"code": "private def getFirstCtor (d : Name) : MetaM (Option Name) := do\n let some (ConstantInfo.inductInfo { ctors := ctor::_, ..}) β getUnfoldableConstNoEx? d |\n return none\n return some ctor",
"start": [
76,
1
],
"end": [
79,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkNullaryCtor",
"code": "private def mkNullaryCtor (type : Expr) (nparams : Nat) : MetaM (Option Expr) := do\n let .const d lvls := type.getAppFn\n | return none\n let (some ctor) β getFirstCtor d | pure none\n return mkAppN (mkConst ctor lvls) (type.getAppArgs.shrink nparams)",
"start": [
81,
1
],
"end": [
85,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getRecRuleFor",
"code": "private def getRecRuleFor (recVal : RecursorVal) (major : Expr) : Option RecursorRule :=\n match major.getAppFn with\n | .const fn _ => recVal.rules.find? fun r => r.ctor == fn\n | _ => none",
"start": [
87,
1
],
"end": [
90,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.toCtorWhenK",
"code": "private def toCtorWhenK (recVal : RecursorVal) (major : Expr) : MetaM Expr := do\n let majorType β inferType major\n let majorType β instantiateMVars (β whnf majorType)\n let majorTypeI := majorType.getAppFn\n if !majorTypeI.isConstOf recVal.getInduct then\n return major\n else if majorType.hasExprMVar && majorType.getAppArgs[recVal.numParams:].any Expr.hasExprMVar then\n return major\n else do\n let (some newCtorApp) β mkNullaryCtor majorType recVal.numParams | pure major\n let newType β inferType newCtorApp\n \n if (β withAtLeastTransparency TransparencyMode.default <| withNewMCtxDepth <| isDefEq majorType newType) then\n return newCtorApp\n else\n return major",
"start": [
92,
1
],
"end": [
113,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkProjFn",
"code": "def mkProjFn (ctorVal : ConstructorVal) (us : List Level) (params : Array Expr) (i : Nat) (major : Expr) : CoreM Expr := do\n match getStructureInfo? (β getEnv) ctorVal.induct with\n | none => return mkProj ctorVal.induct i major\n | some info => match info.getProjFn? i with\n | none => return mkProj ctorVal.induct i major\n | some projFn => return mkApp (mkAppN (mkConst projFn us) params) major",
"start": [
115,
1
],
"end": [
124,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.toCtorWhenStructure",
"code": "private def toCtorWhenStructure (inductName : Name) (major : Expr) : MetaM Expr := do\n unless (β useEtaStruct inductName) do\n return major\n let env β getEnv\n if !isStructureLike env inductName then\n return major\n else if let some _ β isConstructorApp? major then\n return major\n else\n let majorType β inferType major\n let majorType β instantiateMVars (β whnf majorType)\n let majorTypeI := majorType.getAppFn\n if !majorTypeI.isConstOf inductName then\n return major\n match majorType.getAppFn with\n | Expr.const d us =>\n if (β whnfD (β inferType majorType)) == mkSort levelZero then\n return major else\n let some ctorName β getFirstCtor d | pure major\n let ctorInfo β getConstInfoCtor ctorName\n let params := majorType.getAppArgs.shrink ctorInfo.numParams\n let mut result := mkAppN (mkConst ctorName us) params\n for i in [:ctorInfo.numFields] do\n result := mkApp result (β mkProjFn ctorInfo us params i major)\n return result\n | _ => return major",
"start": [
126,
1
],
"end": [
158,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isWFRec",
"code": "private def isWFRec (declName : Name) : Bool :=\n declName == ``Acc.rec || declName == ``WellFounded.rec",
"start": [
162,
1
],
"end": [
163,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.cleanupNatOffsetMajor",
"code": "private def cleanupNatOffsetMajor (e : Expr) : MetaM Expr := do\n let some (e, k) β isOffset? e | return e\n if k = 0 then\n return e\n else if k = 1 then\n return mkNatSucc e\n else\n return mkNatSucc (mkNatAdd e (toExpr (k - 1)))",
"start": [
165,
1
],
"end": [
179,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceRec",
"code": "private def reduceRec (recVal : RecursorVal) (recLvls : List Level) (recArgs : Array Expr) (failK : Unit β MetaM Ξ±) (successK : Expr β MetaM Ξ±) : MetaM Ξ± :=\n let majorIdx := recVal.getMajorIdx\n if h : majorIdx < recArgs.size then do\n let major := recArgs.get β¨majorIdx, hβ©\n let mut major β if isWFRec recVal.name && (β getTransparency) == .default then\n withTransparency .all <| whnf major\n else\n whnf major\n if recVal.k then\n major β toCtorWhenK recVal major\n major := major.toCtorIfLit\n major β cleanupNatOffsetMajor major\n major β toCtorWhenStructure recVal.getInduct major\n match getRecRuleFor recVal major with\n | some rule =>\n let majorArgs := major.getAppArgs\n if recLvls.length != recVal.levelParams.length then\n failK ()\n else\n let rhs := rule.rhs.instantiateLevelParams recVal.levelParams recLvls\n let rhs := mkAppRange rhs 0 (recVal.numParams+recVal.numMotives+recVal.numMinors) recArgs\n \n let nparams := majorArgs.size - rule.nfields\n let rhs := mkAppRange rhs nparams majorArgs.size majorArgs\n let rhs := mkAppRange rhs (majorIdx + 1) recArgs.size recArgs\n successK rhs\n | none => failK ()\n else\n failK ()",
"start": [
181,
1
],
"end": [
217,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceQuotRec",
"code": "private def reduceQuotRec (recVal : QuotVal) (recArgs : Array Expr) (failK : Unit β MetaM Ξ±) (successK : Expr β MetaM Ξ±) : MetaM Ξ± :=\n let process (majorPos argPos : Nat) : MetaM Ξ± :=\n if h : majorPos < recArgs.size then do\n let major := recArgs.get β¨majorPos, hβ©\n let major β whnf major\n match major with\n | Expr.app (Expr.app (Expr.app (Expr.const majorFn _) _) _) majorArg => do\n let some (ConstantInfo.quotInfo { kind := QuotKind.ctor, .. }) β getUnfoldableConstNoEx? majorFn | failK ()\n let f := recArgs[argPos]!\n let r := mkApp f majorArg\n let recArity := majorPos + 1\n successK <| mkAppRange r recArity recArgs.size recArgs\n | _ => failK ()\n else\n failK ()\n match recVal.kind with\n | QuotKind.lift => process 5 3\n | QuotKind.ind => process 4 3\n | _ => failK ()",
"start": [
223,
1
],
"end": [
242,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isRecStuck?",
"code": "private partial def isRecStuck? (recVal : RecursorVal) (recArgs : Array Expr) : MetaM (Option MVarId) :=\n if recVal.k then\n return none\n else do\n let majorIdx := recVal.getMajorIdx\n if h : majorIdx < recArgs.size then do\n let major := recArgs.get β¨majorIdx, hβ©\n let major β whnf major\n getStuckMVar? major\n else\n return none",
"start": [
249,
3
],
"end": [
260,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isQuotRecStuck?",
"code": "private partial def isQuotRecStuck? (recVal : QuotVal) (recArgs : Array Expr) : MetaM (Option MVarId) :=\n let process? (majorPos : Nat) : MetaM (Option MVarId) :=\n if h : majorPos < recArgs.size then do\n let major := recArgs.get β¨majorPos, hβ©\n let major β whnf major\n getStuckMVar? major\n else\n return none\n match recVal.kind with\n | QuotKind.lift => process? 5\n | QuotKind.ind => process? 4\n | _ => return none",
"start": [
262,
3
],
"end": [
273,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getStuckMVar?",
"code": "partial def getStuckMVar? (e : Expr) : MetaM (Option MVarId) := do\n match e with\n | .mdata _ e => getStuckMVar? e\n | .proj _ _ e => getStuckMVar? (β whnf e)\n | .mvar .. =>\n let e β instantiateMVars e\n match e with\n | .mvar mvarId => return some mvarId\n | _ => getStuckMVar? e\n | .app f .. =>\n let f := f.getAppFn\n match f with\n | .mvar .. =>\n let e β instantiateMVars e\n match e.getAppFn with\n | .mvar mvarId => return some mvarId\n | _ => getStuckMVar? e\n | .const fName _ =>\n match (β getUnfoldableConstNoEx? fName) with\n | some <| .recInfo recVal => isRecStuck? recVal e.getAppArgs\n | some <| .quotInfo recVal => isQuotRecStuck? recVal e.getAppArgs\n | _ =>\n unless e.hasExprMVar do return none\n let some projInfo β getProjectionFnInfo? fName | return none\n unless projInfo.fromClass do return none\n let args := e.getAppArgs\n if let some major := args.get? projInfo.numParams then\n if let some mvarId β getStuckMVar? major then\n return mvarId\n \n let info β getFunInfo f\n for pinfo in info.paramInfo, arg in args do\n if pinfo.isExplicit then\n if let some mvarId β getStuckMVar? arg then\n return some mvarId\n return none\n | .proj _ _ e => getStuckMVar? (β whnf e)\n | _ => return none\n | _ => return none",
"start": [
275,
3
],
"end": [
322,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ProjReductionKind",
"code": "inductive ProjReductionKind where\n \n | no\n \n | yes\n \n | yesWithDelta\n \n | yesWithDeltaI\n deriving DecidableEq, Inhabited, Repr",
"start": [
329,
1
],
"end": [
355,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.WhnfCoreConfig",
"code": "structure WhnfCoreConfig where\n \n iota : Bool := true\n \n beta : Bool := true\n \n proj : ProjReductionKind := .yesWithDelta\n \n zeta : Bool := true\n \n zetaDelta : Bool := true",
"start": [
357,
1
],
"end": [
384,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfEasyCases",
"code": "@[specialize] partial def whnfEasyCases (e : Expr) (k : Expr β MetaM Expr) (config : WhnfCoreConfig := {}) : MetaM Expr := do\n match e with\n | .forallE .. => return e\n | .lam .. => return e\n | .sort .. => return e\n | .lit .. => return e\n | .bvar .. => panic! \"loose bvar in expression\"\n | .letE .. => k e\n | .const .. => k e\n | .app .. => k e\n | .proj .. => k e\n | .mdata _ e => whnfEasyCases e k config\n | .fvar fvarId =>\n let decl β fvarId.getDecl\n match decl with\n | .cdecl .. => return e\n | .ldecl (value := v) .. =>\n unless config.zetaDelta || decl.isImplementationDetail do return e\n if (β getConfig).trackZetaDelta then\n modify fun s => { s with zetaDeltaFVarIds := s.zetaDeltaFVarIds.insert fvarId }\n whnfEasyCases v k config\n | .mvar mvarId =>\n match (β getExprMVarAssignment? mvarId) with\n | some v => whnfEasyCases v k config\n | none => return e",
"start": [
386,
1
],
"end": [
413,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.deltaDefinition",
"code": "@[specialize] private def deltaDefinition (c : ConstantInfo) (lvls : List Level)\n (failK : Unit β MetaM Ξ±) (successK : Expr β MetaM Ξ±) : MetaM Ξ± := do\n if c.levelParams.length != lvls.length then\n failK ()\n else\n successK (β instantiateValueLevelParams c lvls)",
"start": [
415,
1
],
"end": [
420,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.deltaBetaDefinition",
"code": "@[specialize] private def deltaBetaDefinition (c : ConstantInfo) (lvls : List Level) (revArgs : Array Expr)\n (failK : Unit β MetaM Ξ±) (successK : Expr β MetaM Ξ±) (preserveMData := false) : MetaM Ξ± := do\n if c.levelParams.length != lvls.length then\n failK ()\n else\n let val β instantiateValueLevelParams c lvls\n let val := val.betaRev revArgs (preserveMData := preserveMData)\n successK val",
"start": [
422,
1
],
"end": [
429,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ReduceMatcherResult",
"code": "inductive ReduceMatcherResult where\n | reduced (val : Expr)\n | stuck (val : Expr)\n | notMatcher\n | partialApp",
"start": [
431,
1
],
"end": [
435,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.canUnfoldAtMatcher",
"code": "def canUnfoldAtMatcher (cfg : Config) (info : ConstantInfo) : CoreM Bool := do\n match cfg.transparency with\n | .all => return true\n | .default => return !(β isIrreducible info.name)\n | _ =>\n if (β isReducible info.name) || isGlobalInstance (β getEnv) info.name then\n return true\n else if hasMatchPatternAttribute (β getEnv) info.name then\n return true\n else\n return info.name == ``ite\n || info.name == ``dite\n || info.name == ``decEq\n || info.name == ``Nat.decEq\n || info.name == ``Char.ofNat || info.name == ``Char.ofNatAux\n || info.name == ``String.decEq || info.name == ``List.hasDecEq\n || info.name == ``Fin.ofNat\n || info.name == ``Fin.ofNat' || info.name == ``UInt8.ofNat || info.name == ``UInt8.decEq\n || info.name == ``UInt16.ofNat || info.name == ``UInt16.decEq\n || info.name == ``UInt32.ofNat || info.name == ``UInt32.decEq\n || info.name == ``UInt64.ofNat || info.name == ``UInt64.decEq\n \n || info.name == ``HMod.hMod || info.name == ``Mod.mod",
"start": [
437,
1
],
"end": [
489,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfMatcher",
"code": "private def whnfMatcher (e : Expr) : MetaM Expr := do\n \n if (β getTransparency) matches .instances | .reducible then\n withTransparency .instances <| withReader (fun ctx => { ctx with canUnfold? := canUnfoldAtMatcher }) do\n whnf e\n else\n whnf e",
"start": [
491,
1
],
"end": [
505,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceMatcher?",
"code": "def reduceMatcher? (e : Expr) : MetaM ReduceMatcherResult := do\n let .const declName declLevels := e.getAppFn\n | return .notMatcher\n let some info β getMatcherInfo? declName\n | return .notMatcher\n let args := e.getAppArgs\n let prefixSz := info.numParams + 1 + info.numDiscrs\n if args.size < prefixSz + info.numAlts then\n return ReduceMatcherResult.partialApp\n let constInfo β getConstInfo declName\n let f β instantiateValueLevelParams constInfo declLevels\n let auxApp := mkAppN f args[0:prefixSz]\n let auxAppType β inferType auxApp\n forallBoundedTelescope auxAppType info.numAlts fun hs _ => do\n let auxApp β whnfMatcher (mkAppN auxApp hs)\n let auxAppFn := auxApp.getAppFn\n let mut i := prefixSz\n for h in hs do\n if auxAppFn == h then\n let result := mkAppN args[i]! auxApp.getAppArgs\n let result := mkAppN result args[prefixSz + info.numAlts:args.size]\n return ReduceMatcherResult.reduced result.headBeta\n i := i + 1\n return ReduceMatcherResult.stuck auxApp",
"start": [
507,
1
],
"end": [
530,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.projectCore?",
"code": "def projectCore? (e : Expr) (i : Nat) : MetaM (Option Expr) := do\n let e := e.toCtorIfLit\n matchConstCtor e.getAppFn (fun _ => pure none) fun ctorVal _ =>\n let numArgs := e.getAppNumArgs\n let idx := ctorVal.numParams + i\n if idx < numArgs then\n return some (e.getArg! idx)\n else\n return none",
"start": [
532,
1
],
"end": [
540,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.project?",
"code": "def project? (e : Expr) (i : Nat) : MetaM (Option Expr) := do\n projectCore? (β whnf e) i",
"start": [
542,
1
],
"end": [
543,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceProj?",
"code": "def reduceProj? (e : Expr) : MetaM (Option Expr) := do\n match e with\n | .proj _ i c => project? c i\n | _ => return none",
"start": [
545,
1
],
"end": [
549,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfDelayedAssigned?",
"code": "private def whnfDelayedAssigned? (f' : Expr) (e : Expr) : MetaM (Option Expr) := do\n if f'.isMVar then\n match (β getDelayedMVarAssignment? f'.mvarId!) with\n | none => return none\n | some { fvars, mvarIdPending } =>\n let args := e.getAppArgs\n if fvars.size > args.size then\n return none\n else\n let newVal β instantiateMVars (mkMVar mvarIdPending)\n if newVal.hasExprMVar then\n return none\n else\n let newVal := newVal.abstract fvars\n let result := newVal.instantiateRevRange 0 fvars.size args\n return mkAppRange result fvars.size args.size args\n else\n return none",
"start": [
551,
1
],
"end": [
574,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfCore",
"code": "partial def whnfCore (e : Expr) (config : WhnfCoreConfig := {}): MetaM Expr :=\n go e\nwhere\n go (e : Expr) : MetaM Expr :=\n whnfEasyCases e (config := config) fun e => do\n trace[Meta.whnf] e\n match e with\n | .const .. => pure e\n | .letE _ _ v b _ => if config.zeta then go <| b.instantiate1 v else return e\n | .app f .. =>\n if config.zeta then\n if let some (args, _, _, v, b) := e.letFunAppArgs? then\n return (β go <| mkAppN (b.instantiate1 v) args)\n let f := f.getAppFn\n let f' β go f\n if config.beta && f'.isLambda then\n let revArgs := e.getAppRevArgs\n go <| f'.betaRev revArgs\n else if let some eNew β whnfDelayedAssigned? f' e then\n go eNew\n else\n let e := if f == f' then e else e.updateFn f'\n unless config.iota do return e\n match (β reduceMatcher? e) with\n | .reduced eNew => go eNew\n | .partialApp => pure e\n | .stuck _ => pure e\n | .notMatcher =>\n matchConstAux f' (fun _ => return e) fun cinfo lvls =>\n match cinfo with\n | .recInfo rec => reduceRec rec lvls e.getAppArgs (fun _ => return e) (fun e => do recordUnfold cinfo.name; go e)\n | .quotInfo rec => reduceQuotRec rec e.getAppArgs (fun _ => return e) (fun e => do recordUnfold cinfo.name; go e)\n | c@(.defnInfo _) => do\n if (β isAuxDef c.name) then\n recordUnfold c.name\n deltaBetaDefinition c lvls e.getAppRevArgs (fun _ => return e) go\n else\n return e\n | _ => return e\n | .proj _ i c =>\n let k (c : Expr) := do\n match (β projectCore? c i) with\n | some e => go e\n | none => return e\n match config.proj with\n | .no => return e\n | .yes => k (β go c)\n | .yesWithDelta => k (β whnf c)\n | .yesWithDeltaI => k (β whnfAtMostI c)\n | _ => unreachable!",
"start": [
576,
1
],
"end": [
631,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.smartUnfoldingReduce?",
"code": "partial def smartUnfoldingReduce? (e : Expr) : MetaM (Option Expr) :=\n go e |>.run\nwhere\n go (e : Expr) : OptionT MetaM Expr := do\n match e with\n | .letE n t v b _ => withLetDecl n t (β go v) fun x => do mkLetFVars #[x] (β go (b.instantiate1 x))\n | .lam .. => lambdaTelescope e fun xs b => do mkLambdaFVars xs (β go b)\n | .app f a .. => return mkApp (β go f) (β go a)\n | .proj _ _ s => return e.updateProj! (β go s)\n | .mdata _ b =>\n if let some m := smartUnfoldingMatch? e then\n goMatch m\n else\n return e.updateMData! (β go b)\n | _ => return e\n\n goMatch (e : Expr) : OptionT MetaM Expr := do\n match (β reduceMatcher? e) with\n | ReduceMatcherResult.reduced e =>\n if let some alt := smartUnfoldingMatchAlt? e then\n return alt\n else\n go e\n | ReduceMatcherResult.stuck e' =>\n let mvarId β getStuckMVar? e'\n \n if (β Meta.synthPending mvarId) then\n goMatch e\n else\n failure\n | _ => failure",
"start": [
633,
1
],
"end": [
693,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.unfoldProjInst?",
"code": "partial def unfoldProjInst? (e : Expr) : MetaM (Option Expr) := do\n match e.getAppFn with\n | .const declName .. =>\n match (β getProjectionFnInfo? declName) with\n | some { fromClass := true, .. } =>\n match (β withDefault <| unfoldDefinition? e) with\n | none => return none\n | some e =>\n match (β withReducibleAndInstances <| reduceProj? e.getAppFn) with\n | none => return none\n | some r => recordUnfold declName; return mkAppN r e.getAppArgs |>.headBeta\n | _ => return none\n | _ => return none",
"start": [
697,
3
],
"end": [
712,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.unfoldProjInstWhenInstances?",
"code": "partial def unfoldProjInstWhenInstances? (e : Expr) : MetaM (Option Expr) := do\n if (β getTransparency) != TransparencyMode.instances then\n return none\n else\n unfoldProjInst? e",
"start": [
714,
3
],
"end": [
723,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.unfoldDefinition?",
"code": "partial def unfoldDefinition? (e : Expr) : MetaM (Option Expr) :=\n match e with\n | .app f _ =>\n matchConstAux f.getAppFn (fun _ => unfoldProjInstWhenInstances? e) fun fInfo fLvls => do\n if fInfo.levelParams.length != fLvls.length then\n return none\n else\n let unfoldDefault (_ : Unit) : MetaM (Option Expr) := do\n if fInfo.hasValue then\n recordUnfold fInfo.name\n deltaBetaDefinition fInfo fLvls e.getAppRevArgs (fun _ => pure none) (fun e => pure (some e))\n else\n return none\n if smartUnfolding.get (β getOptions) then\n match ((β getEnv).find? (mkSmartUnfoldingNameFor fInfo.name)) with\n | some fAuxInfo@(.defnInfo _) =>\n deltaBetaDefinition fAuxInfo fLvls e.getAppRevArgs (preserveMData := true) (fun _ => pure none) fun eβ => do\n let some r β smartUnfoldingReduce? eβ | return none\n \n let some recArgPos β getStructuralRecArgPos? fInfo.name\n | recordUnfold fInfo.name; return some r\n let numArgs := e.getAppNumArgs\n if recArgPos >= numArgs then return none\n let recArg := e.getArg! recArgPos numArgs\n if !(β isConstructorApp (β whnfMatcher recArg)) then return none\n recordUnfold fInfo.name\n return some r\n | _ =>\n if (β getMatcherInfo? fInfo.name).isSome then\n return none\n else\n unfoldDefault ()\n else\n unfoldDefault ()\n | .const declName lvls => do\n if smartUnfolding.get (β getOptions) && (β getEnv).contains (mkSmartUnfoldingNameFor declName) then\n return none\n else\n let some cinfo β getUnfoldableConstNoEx? declName | pure none\n unless cinfo.hasValue do return none\n deltaDefinition cinfo lvls\n (fun _ => pure none)\n (fun e => do recordUnfold declName; pure (some e))\n | _ => return none",
"start": [
725,
3
],
"end": [
808,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.unfoldDefinition",
"code": "def unfoldDefinition (e : Expr) : MetaM Expr := do\n let some e β unfoldDefinition? e | throwError \"failed to unfold definition{indentExpr e}\"\n return e",
"start": [
811,
1
],
"end": [
813,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfHeadPred",
"code": "@[specialize] partial def whnfHeadPred (e : Expr) (pred : Expr β MetaM Bool) : MetaM Expr :=\n whnfEasyCases e fun e => do\n let e β whnfCore e\n if (β pred e) then\n match (β unfoldDefinition? e) with\n | some e => whnfHeadPred e pred\n | none => return e\n else\n return e",
"start": [
815,
1
],
"end": [
823,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfUntil",
"code": "def whnfUntil (e : Expr) (declName : Name) : MetaM (Option Expr) := do\n let e β whnfHeadPred e (fun e => return !e.isAppOf declName)\n if e.isAppOf declName then\n return e\n else\n return none",
"start": [
825,
1
],
"end": [
830,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceRecMatcher?",
"code": "def reduceRecMatcher? (e : Expr) : MetaM (Option Expr) := do\n if !e.isApp then\n return none\n else match (β reduceMatcher? e) with\n | .reduced e => return e\n | _ => matchConstAux e.getAppFn (fun _ => pure none) fun cinfo lvls => do\n match cinfo with\n | .recInfo Β«recΒ» => reduceRec Β«recΒ» lvls e.getAppArgs (fun _ => pure none) (fun e => do recordUnfold cinfo.name; pure (some e))\n | .quotInfo Β«recΒ» => reduceQuotRec Β«recΒ» e.getAppArgs (fun _ => pure none) (fun e => do recordUnfold cinfo.name; pure (some e))\n | c@(.defnInfo _) =>\n if (β isAuxDef c.name) then\n deltaBetaDefinition c lvls e.getAppRevArgs (fun _ => pure none) (fun e => do recordUnfold c.name; pure (some e))\n else\n return none\n | _ => return none",
"start": [
832,
1
],
"end": [
847,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceBoolNativeUnsafe",
"code": "unsafe def reduceBoolNativeUnsafe (constName : Name) : MetaM Bool := evalConstCheck Bool `Bool constName",
"start": [
849,
1
],
"end": [
849,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceNatNativeUnsafe",
"code": "unsafe def reduceNatNativeUnsafe (constName : Name) : MetaM Nat := evalConstCheck Nat `Nat constName",
"start": [
850,
1
],
"end": [
850,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceBoolNative",
"code": "@[implemented_by reduceBoolNativeUnsafe] opaque reduceBoolNative (constName : Name) : MetaM Bool",
"start": [
851,
1
],
"end": [
851,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceNatNative",
"code": "@[implemented_by reduceNatNativeUnsafe] opaque reduceNatNative (constName : Name) : MetaM Nat",
"start": [
852,
1
],
"end": [
852,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceNative?",
"code": "def reduceNative? (e : Expr) : MetaM (Option Expr) :=\n match e with\n | Expr.app (Expr.const fName _) (Expr.const argName _) =>\n if fName == ``Lean.reduceBool then do\n return toExpr (β reduceBoolNative argName)\n else if fName == ``Lean.reduceNat then do\n return toExpr (β reduceNatNative argName)\n else\n return none\n | _ =>\n return none",
"start": [
854,
1
],
"end": [
864,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNatValue",
"code": "@[inline] def withNatValue (a : Expr) (k : Nat β MetaM (Option Ξ±)) : MetaM (Option Ξ±) := do\n if !a.hasExprMVar && a.hasFVar then\n return none\n let a β instantiateMVars a\n if a.hasExprMVar || a.hasFVar then\n return none\n let a β whnf a\n match a with\n | .const ``Nat.zero _ => k 0\n | .lit (.natVal v) => k v\n | _ => return none",
"start": [
866,
1
],
"end": [
876,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceUnaryNatOp",
"code": "def reduceUnaryNatOp (f : Nat β Nat) (a : Expr) : MetaM (Option Expr) :=\n withNatValue a fun a =>\n return mkRawNatLit <| f a",
"start": [
878,
1
],
"end": [
880,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceBinNatOp",
"code": "def reduceBinNatOp (f : Nat β Nat β Nat) (a b : Expr) : MetaM (Option Expr) :=\n withNatValue a fun a =>\n withNatValue b fun b => do\n trace[Meta.isDefEq.whnf.reduceBinOp] \"{a} op {b}\"\n return mkRawNatLit <| f a b",
"start": [
882,
1
],
"end": [
886,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceBinNatPred",
"code": "def reduceBinNatPred (f : Nat β Nat β Bool) (a b : Expr) : MetaM (Option Expr) := do\n withNatValue a fun a =>\n withNatValue b fun b =>\n return toExpr <| f a b",
"start": [
888,
1
],
"end": [
891,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceNat?",
"code": "def reduceNat? (e : Expr) : MetaM (Option Expr) :=\n match e with\n | .app (.const fn _) a =>\n if fn == ``Nat.succ then\n reduceUnaryNatOp Nat.succ a\n else\n return none\n | .app (.app (.const fn _) a1) a2 =>\n match fn with\n | ``Nat.add => reduceBinNatOp Nat.add a1 a2\n | ``Nat.sub => reduceBinNatOp Nat.sub a1 a2\n | ``Nat.mul => reduceBinNatOp Nat.mul a1 a2\n | ``Nat.div => reduceBinNatOp Nat.div a1 a2\n | ``Nat.mod => reduceBinNatOp Nat.mod a1 a2\n | ``Nat.pow => reduceBinNatOp Nat.pow a1 a2\n | ``Nat.gcd => reduceBinNatOp Nat.gcd a1 a2\n | ``Nat.beq => reduceBinNatPred Nat.beq a1 a2\n | ``Nat.ble => reduceBinNatPred Nat.ble a1 a2\n | ``Nat.land => reduceBinNatOp Nat.land a1 a2\n | ``Nat.lor => reduceBinNatOp Nat.lor a1 a2\n | ``Nat.xor => reduceBinNatOp Nat.xor a1 a2\n | ``Nat.shiftLeft => reduceBinNatOp Nat.shiftLeft a1 a2\n | ``Nat.shiftRight => reduceBinNatOp Nat.shiftRight a1 a2\n | _ => return none\n | _ =>\n return none",
"start": [
893,
1
],
"end": [
918,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.useWHNFCache",
"code": "@[inline] private def useWHNFCache (e : Expr) : MetaM Bool := do\n if e.hasFVar || e.hasExprMVar || (β read).canUnfold?.isSome then\n return false\n else\n match (β getConfig).transparency with\n | .default => return true\n | .all => return true\n | _ => return false",
"start": [
921,
1
],
"end": [
930,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.cached?",
"code": "@[inline] private def cached? (useCache : Bool) (e : Expr) : MetaM (Option Expr) := do\n if useCache then\n match (β getConfig).transparency with\n | .default => return (β get).cache.whnfDefault.find? e\n | .all => return (β get).cache.whnfAll.find? e\n | _ => unreachable!\n else\n return none",
"start": [
932,
1
],
"end": [
939,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.cache",
"code": "private def cache (useCache : Bool) (e r : Expr) : MetaM Expr := do\n if useCache then\n match (β getConfig).transparency with\n | .default => modify fun s => { s with cache.whnfDefault := s.cache.whnfDefault.insert e r }\n | .all => modify fun s => { s with cache.whnfAll := s.cache.whnfAll.insert e r }\n | _ => unreachable!\n return r",
"start": [
941,
1
],
"end": [
947,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfImp",
"code": "@[export lean_whnf]\npartial def whnfImp (e : Expr) : MetaM Expr :=\n withIncRecDepth <| whnfEasyCases e fun e => do\n let useCache β useWHNFCache e\n match (β cached? useCache e) with\n | some e' => pure e'\n | none =>\n withTraceNode `Meta.whnf (fun _ => return m!\"Non-easy whnf: {e}\") do\n checkSystem \"whnf\"\n let e' β whnfCore e\n match (β reduceNat? e') with\n | some v => cache useCache e v\n | none =>\n match (β reduceNative? e') with\n | some v => cache useCache e v\n | none =>\n match (β unfoldDefinition? e') with\n | some e'' => cache useCache e (β whnfImp e'')\n | none => cache useCache e e'",
"start": [
949,
1
],
"end": [
967,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceProjOf?",
"code": "def reduceProjOf? (e : Expr) (p : Name β Bool) : MetaM (Option Expr) := do\n if !e.isApp then\n pure none\n else match e.getAppFn with\n | .const name .. => do\n let env β getEnv\n match env.getProjectionStructureName? name with\n | some structName =>\n if p structName then\n Meta.unfoldDefinition? e\n else\n pure none\n | none => pure none\n | _ => pure none",
"start": [
969,
1
],
"end": [
983,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/DiscrTreeTypes.lean | [
".lake/packages/lean4/src/lean/Lean/ToExpr.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.Meta.DiscrTree.Key",
"code": "inductive Key where\n | const : Name β Nat β Key\n | fvar : FVarId β Nat β Key\n | lit : Literal β Key\n | star : Key\n | other : Key\n | arrow : Key\n | proj : Name β Nat β Nat β Key\n deriving Inhabited, BEq, Repr",
"start": [
15,
1
],
"end": [
26,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Key.hash",
"code": "protected def Key.hash : Key β UInt64\n | .const n a => mixHash 5237 $ mixHash (hash n) (hash a)\n | .fvar n a => mixHash 3541 $ mixHash (hash n) (hash a)\n | .lit v => mixHash 1879 $ hash v\n | .star => 7883\n | .other => 2411\n | .arrow => 17\n | .proj s i a => mixHash (hash a) $ mixHash (hash s) (hash i)",
"start": [
28,
1
],
"end": [
35,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie",
"code": "inductive Trie (Ξ± : Type) where\n | node (vs : Array Ξ±) (children : Array (Key Γ Trie Ξ±)) : Trie Ξ±",
"start": [
50,
1
],
"end": [
54,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree",
"code": "structure DiscrTree (Ξ± : Type) where\n root : PersistentHashMap Key (Trie Ξ±) := {}",
"start": [
92,
1
],
"end": [
96,
46
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Do.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Term.lean"
] | [
{
"full_name": "Lean.Parser.doElemParser",
"code": "@[inline] def doElemParser (rbp : Nat := 0) : Parser :=\n categoryParser `doElem rbp",
"start": [
15,
1
],
"end": [
16,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.leftArrow",
"code": "def leftArrow : Parser := unicodeSymbol \"β \" \"<- \"",
"start": [
19,
1
],
"end": [
19,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.liftMethod",
"code": "@[builtin_term_parser] def liftMethod := leading_parser:minPrec\n leftArrow >> termParser",
"start": [
20,
1
],
"end": [
21,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doSeqItem",
"code": "def doSeqItem := leading_parser\n ppLine >> doElemParser >> optional \"; \"",
"start": [
23,
1
],
"end": [
24,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doSeqIndent",
"code": "def doSeqIndent := leading_parser\n many1Indent doSeqItem",
"start": [
25,
1
],
"end": [
26,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doSeqBracketed",
"code": "def doSeqBracketed := leading_parser\n \"{\" >> withoutPosition (many1 doSeqItem) >> ppLine >> \"}\"",
"start": [
27,
1
],
"end": [
28,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doSeq",
"code": "def doSeq :=\n withAntiquot (mkAntiquot \"doSeq\" decl_name% (isPseudoKind := true)) <|\n doSeqBracketed <|> doSeqIndent",
"start": [
29,
1
],
"end": [
35,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.termBeforeDo",
"code": "def termBeforeDo := withForbidden \"do\" termParser",
"start": [
36,
1
],
"end": [
40,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.notFollowedByRedefinedTermToken",
"code": "def notFollowedByRedefinedTermToken :=\n notFollowedBy (\"set_option\" <|> \"open\" <|> \"if\" <|> \"match\" <|> \"match_expr\" <|> \"let\" <|> \"let_expr\" <|> \"have\" <|>\n \"do\" <|> \"dbg_trace\" <|> \"assert!\" <|> \"for\" <|> \"unless\" <|> \"return\" <|> symbol \"try\")\n \"token at 'do' element\"",
"start": [
48,
1
],
"end": [
55,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doLet",
"code": "@[builtin_doElem_parser] def doLet := leading_parser\n \"let \" >> optional \"mut \" >> letDecl",
"start": [
57,
1
],
"end": [
58,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doLetElse",
"code": "@[builtin_doElem_parser] def doLetElse := leading_parser\n \"let \" >> optional \"mut \" >> termParser >> \" := \" >> termParser >>\n checkColGt >> \" | \" >> doSeq",
"start": [
59,
1
],
"end": [
61,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doLetExpr",
"code": "@[builtin_doElem_parser] def doLetExpr := leading_parser\n \"let_expr \" >> matchExprPat >> \" := \" >> termParser >>\n checkColGt >> \" | \" >> doSeq",
"start": [
63,
1
],
"end": [
65,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doLetMetaExpr",
"code": "@[builtin_doElem_parser] def doLetMetaExpr := leading_parser\n \"let_expr \" >> matchExprPat >> \" β \" >> termParser >>\n checkColGt >> \" | \" >> doSeq",
"start": [
67,
1
],
"end": [
69,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doLetRec",
"code": "@[builtin_doElem_parser] def doLetRec := leading_parser\n group (\"let \" >> nonReservedSymbol \"rec \") >> letRecDecls",
"start": [
71,
1
],
"end": [
72,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIdDecl",
"code": "def doIdDecl := leading_parser\n atomic (ident >> optType >> ppSpace >> leftArrow) >>\n doElemParser",
"start": [
73,
1
],
"end": [
75,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doPatDecl",
"code": "def doPatDecl := leading_parser\n atomic (termParser >> ppSpace >> leftArrow) >>\n doElemParser >> optional (checkColGt >> \" | \" >> doSeq)",
"start": [
76,
1
],
"end": [
78,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doLetArrow",
"code": "@[builtin_doElem_parser] def doLetArrow := leading_parser\n withPosition (\"let \" >> optional \"mut \" >> (doIdDecl <|> doPatDecl))",
"start": [
79,
1
],
"end": [
80,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.letIdDeclNoBinders",
"code": "def letIdDeclNoBinders := node ``letIdDecl <|\n atomic (ident >> pushNone >> optType >> \" := \") >> termParser",
"start": [
84,
1
],
"end": [
85,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doReassign",
"code": "@[builtin_doElem_parser] def doReassign := leading_parser\n notFollowedByRedefinedTermToken >> (letIdDeclNoBinders <|> letPatDecl)",
"start": [
87,
1
],
"end": [
88,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doReassignArrow",
"code": "@[builtin_doElem_parser] def doReassignArrow := leading_parser\n notFollowedByRedefinedTermToken >> (doIdDecl <|> doPatDecl)",
"start": [
89,
1
],
"end": [
90,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doHave",
"code": "@[builtin_doElem_parser] def doHave := leading_parser\n \"have\" >> Term.haveDecl",
"start": [
91,
1
],
"end": [
92,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.elseIf",
"code": "def elseIf := atomic (group (withPosition (\"else \" >> checkLineEq >> \" if \")))",
"start": [
123,
1
],
"end": [
123,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIfLetPure",
"code": "def doIfLetPure := leading_parser \" := \" >> termParser",
"start": [
125,
1
],
"end": [
125,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIfLetBind",
"code": "def doIfLetBind := leading_parser \" β \" >> termParser",
"start": [
126,
1
],
"end": [
126,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIfLet",
"code": "def doIfLet := leading_parser (withAnonymousAntiquot := false)\n \"let \" >> termParser >> (doIfLetPure <|> doIfLetBind)",
"start": [
127,
1
],
"end": [
128,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIfProp",
"code": "def doIfProp := leading_parser (withAnonymousAntiquot := false)\n optIdent >> termParser",
"start": [
129,
1
],
"end": [
130,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIfCond",
"code": "def doIfCond :=\n withAntiquot (mkAntiquot \"doIfCond\" decl_name% (anonymous := false) (isPseudoKind := true)) <|\n doIfLet <|> doIfProp",
"start": [
131,
1
],
"end": [
133,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doIf",
"code": "@[builtin_doElem_parser] def doIf := leading_parser withResetCache <| withPositionAfterLinebreak <| ppRealGroup <|\n ppRealFill (ppIndent (\"if \" >> doIfCond >> \" then\") >> ppSpace >> doSeq) >>\n many (checkColGe \"'else if' in 'do' must be indented\" >>\n group (ppDedent ppSpace >> ppRealFill (elseIf >> doIfCond >> \" then \" >> doSeq))) >>\n optional (checkColGe \"'else' in 'do' must be indented\" >>\n ppDedent ppSpace >> ppRealFill (\"else \" >> doSeq))",
"start": [
136,
1
],
"end": [
141,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doUnless",
"code": "@[builtin_doElem_parser] def doUnless := leading_parser\n \"unless \" >> withForbidden \"do\" termParser >> \" do \" >> doSeq",
"start": [
142,
1
],
"end": [
143,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doForDecl",
"code": "def doForDecl := leading_parser\n optional (atomic (ident >> \" : \")) >> termParser >> \" in \" >> withForbidden \"do\" termParser",
"start": [
144,
1
],
"end": [
145,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doFor",
"code": "@[builtin_doElem_parser] def doFor := leading_parser\n \"for \" >> sepBy1 doForDecl \", \" >> \"do \" >> doSeq",
"start": [
146,
1
],
"end": [
154,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doMatchAlts",
"code": "def doMatchAlts := ppDedent <| matchAlts (rhsParser := doSeq)",
"start": [
156,
1
],
"end": [
156,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doMatch",
"code": "@[builtin_doElem_parser] def doMatch := leading_parser:leadPrec\n \"match \" >> optional Term.generalizingParam >> optional Term.motive >>\n sepBy1 matchDiscr \", \" >> \" with\" >> doMatchAlts",
"start": [
157,
1
],
"end": [
159,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doMatchExprAlts",
"code": "def doMatchExprAlts := ppDedent <| matchExprAlts (rhsParser := doSeq)",
"start": [
161,
1
],
"end": [
161,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.optMetaFalse",
"code": "def optMetaFalse :=\n optional (atomic (\"(\" >> nonReservedSymbol \"meta\" >> \" := \" >> nonReservedSymbol \"false\" >> \") \"))",
"start": [
162,
1
],
"end": [
163,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doMatchExpr",
"code": "@[builtin_doElem_parser] def doMatchExpr := leading_parser:leadPrec\n \"match_expr \" >> optMetaFalse >> termParser >> \" with\" >> doMatchExprAlts",
"start": [
164,
1
],
"end": [
165,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doCatch",
"code": "def doCatch := leading_parser\n ppDedent ppLine >> atomic (\"catch \" >> binderIdent) >> optional (\" : \" >> termParser) >> darrow >> doSeq",
"start": [
167,
1
],
"end": [
168,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doCatchMatch",
"code": "def doCatchMatch := leading_parser\n ppDedent ppLine >> \"catch \" >> doMatchAlts",
"start": [
169,
1
],
"end": [
170,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doFinally",
"code": "def doFinally := leading_parser\n ppDedent ppLine >> \"finally \" >> doSeq",
"start": [
171,
1
],
"end": [
172,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doTry",
"code": "@[builtin_doElem_parser] def doTry := leading_parser\n \"try \" >> doSeq >> many (doCatch <|> doCatchMatch) >> optional doFinally",
"start": [
173,
1
],
"end": [
174,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doBreak",
"code": "@[builtin_doElem_parser] def doBreak := leading_parser \"break\"",
"start": [
176,
1
],
"end": [
177,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doContinue",
"code": "@[builtin_doElem_parser] def doContinue := leading_parser \"continue\"",
"start": [
178,
1
],
"end": [
179,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doReturn",
"code": "@[builtin_doElem_parser] def doReturn := leading_parser:leadPrec\n withPosition (\"return\" >> optional (ppSpace >> checkLineEq >> termParser))",
"start": [
180,
1
],
"end": [
191,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doDbgTrace",
"code": "@[builtin_doElem_parser] def doDbgTrace := leading_parser:leadPrec\n \"dbg_trace \" >> ((interpolatedStr termParser) <|> termParser)",
"start": [
192,
1
],
"end": [
197,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doAssert",
"code": "@[builtin_doElem_parser] def doAssert := leading_parser:leadPrec\n \"assert! \" >> termParser",
"start": [
198,
1
],
"end": [
202,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doExpr",
"code": "@[builtin_doElem_parser] def doExpr := leading_parser\n notFollowedByRedefinedTermToken >> termParser >>\n notFollowedBy (symbol \":=\" <|> symbol \"β\" <|> symbol \"<-\")\n \"unexpected token after 'expr' in 'do' block\"",
"start": [
220,
1
],
"end": [
223,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.doNested",
"code": "@[builtin_doElem_parser] def doNested := leading_parser\n \"do \" >> doSeq",
"start": [
224,
1
],
"end": [
225,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.do",
"code": "@[builtin_term_parser] def Β«doΒ» := leading_parser:argPrec\n ppAllowUngrouped >> \"do \" >> doSeq",
"start": [
227,
1
],
"end": [
228,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.termUnless",
"code": "@[builtin_term_parser] def termUnless := leading_parser\n \"unless \" >> withForbidden \"do\" termParser >> \" do \" >> doSeq",
"start": [
235,
1
],
"end": [
237,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.termFor",
"code": "@[builtin_term_parser] def termFor := leading_parser\n \"for \" >> sepBy1 doForDecl \", \" >> \" do \" >> doSeq",
"start": [
238,
1
],
"end": [
239,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.termTry",
"code": "@[builtin_term_parser] def termTry := leading_parser\n \"try \" >> doSeq >> many (doCatch <|> doCatchMatch) >> optional doFinally",
"start": [
240,
1
],
"end": [
241,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.termReturn",
"code": "@[builtin_term_parser] def termReturn := leading_parser:leadPrec\n withPosition (\"return\" >> optional (ppSpace >> checkLineEq >> termParser))",
"start": [
242,
1
],
"end": [
247,
77
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/CollectMVars.lean | [
".lake/packages/lean4/src/lean/Lean/Util/CollectMVars.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.collectMVars",
"code": "partial def collectMVars (e : Expr) : StateRefT CollectMVars.State MetaM Unit := do\n let e β instantiateMVars e\n let s β get\n let resultSavedSize := s.result.size\n let s := e.collectMVars s\n set s\n for mvarId in s.result[resultSavedSize:] do\n match (β getDelayedMVarAssignment? mvarId) with\n | none => pure ()\n | some d => collectMVars (mkMVar d.mvarIdPending)",
"start": [
12,
1
],
"end": [
30,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVars",
"code": "def getMVars (e : Expr) : MetaM (Array MVarId) := do\n let (_, s) β (collectMVars e).run {}\n pure s.result",
"start": [
32,
1
],
"end": [
35,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarsNoDelayed",
"code": "def getMVarsNoDelayed (e : Expr) : MetaM (Array MVarId) := do\n let mvarIds β getMVars e\n mvarIds.filterM fun mvarId => not <$> mvarId.isDelayedAssigned",
"start": [
37,
1
],
"end": [
40,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.collectMVarsAtDecl",
"code": "def collectMVarsAtDecl (d : Declaration) : StateRefT CollectMVars.State MetaM Unit :=\n d.forExprM collectMVars",
"start": [
42,
1
],
"end": [
43,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarsAtDecl",
"code": "def getMVarsAtDecl (d : Declaration) : MetaM (Array MVarId) := do\n let (_, s) β (collectMVarsAtDecl d).run {}\n pure s.result",
"start": [
45,
1
],
"end": [
47,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.getMVarDependencies",
"code": "partial def _root_.Lean.MVarId.getMVarDependencies (mvarId : MVarId) (includeDelayed := false) :\n MetaM (HashSet MVarId) :=\n (Β·.snd) <$> (go mvarId).run {}\nwhere\n \n addMVars (e : Expr) : StateRefT (HashSet MVarId) MetaM Unit := do\n let mvars β getMVars e\n let mut s β get\n set ({} : HashSet MVarId) for mvarId in mvars do\n if β pure includeDelayed <||> notM (mvarId.isDelayedAssigned) then\n s := s.insert mvarId\n set s\n mvars.forM go\n\n \n go (mvarId : MVarId) : StateRefT (HashSet MVarId) MetaM Unit :=\n withIncRecDepth do\n let mdecl β mvarId.getDecl\n addMVars mdecl.type\n for ldecl in mdecl.lctx do\n addMVars ldecl.type\n if let (some val) := ldecl.value? then\n addMVars val\n if let (some ass) β getDelayedMVarAssignment? mvarId then\n let pendingMVarId := ass.mvarIdPending\n if β notM pendingMVarId.isAssignedOrDelayedAssigned then\n modify (Β·.insert pendingMVarId)\n go pendingMVarId",
"start": [
49,
1
],
"end": [
82,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/DiscrTree.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/DiscrTreeTypes.lean",
".lake/packages/lean4/src/lean/Lean/Meta/WHNF.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Transform.lean"
] | [
{
"full_name": "Lean.Meta.DiscrTree.Key.ctorIdx",
"code": "def Key.ctorIdx : Key β Nat\n | .star => 0\n | .other => 1\n | .lit .. => 2\n | .fvar .. => 3\n | .const .. => 4\n | .arrow => 5\n | .proj .. => 6",
"start": [
52,
1
],
"end": [
59,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Key.lt",
"code": "def Key.lt : Key β Key β Bool\n | .lit vβ, .lit vβ => vβ < vβ\n | .fvar nβ aβ, .fvar nβ aβ => Name.quickLt nβ.name nβ.name || (nβ == nβ && aβ < aβ)\n | .const nβ aβ, .const nβ aβ => Name.quickLt nβ nβ || (nβ == nβ && aβ < aβ)\n | .proj sβ iβ aβ, .proj sβ iβ aβ => Name.quickLt sβ sβ || (sβ == sβ && iβ < iβ) || (sβ == sβ && iβ == iβ && aβ < aβ)\n | kβ, kβ => kβ.ctorIdx < kβ.ctorIdx",
"start": [
61,
1
],
"end": [
66,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Key.format",
"code": "def Key.format : Key β Format\n | .star => \"*\"\n | .other => \"βΎ\"\n | .lit (.natVal v) => Std.format v\n | .lit (.strVal v) => repr v\n | .const k _ => Std.format k\n | .proj s i _ => Std.format s ++ \".\" ++ Std.format i\n | .fvar k _ => Std.format k.name\n | .arrow => \"β\"",
"start": [
71,
1
],
"end": [
79,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.keysAsPattern",
"code": "partial def keysAsPattern (keys : Array Key) : CoreM MessageData := do\n go (parenIfNonAtomic := false) |>.run' keys.toList\nwhere\n next? : StateRefT (List Key) CoreM (Option Key) := do\n let key :: keys β get | return none\n set keys\n return some key\n\n mkApp (f : MessageData) (args : Array MessageData) (parenIfNonAtomic : Bool) : CoreM MessageData := do\n if args.isEmpty then\n return f\n else\n let mut r := f\n for arg in args do\n r := r ++ m!\" {arg}\"\n if parenIfNonAtomic then\n return m!\"({r})\"\n else\n return r\n\n go (parenIfNonAtomic := true) : StateRefT (List Key) CoreM MessageData := do\n let some key β next? | return .nil\n match key with\n | .const declName nargs =>\n mkApp m!\"{β mkConstWithLevelParams declName}\" (β goN nargs) parenIfNonAtomic\n | .fvar fvarId nargs =>\n mkApp m!\"{mkFVar fvarId}\" (β goN nargs) parenIfNonAtomic\n | .proj _ i nargs =>\n mkApp m!\"{β go}.{i+1}\" (β goN nargs) parenIfNonAtomic\n | .arrow => return \"<arrow>\"\n | .star => return \"_\"\n | .other => return \"<other>\"\n | .lit (.natVal v) => return m!\"{v}\"\n | .lit (.strVal v) => return m!\"{v}\"\n\n goN (num : Nat) : StateRefT (List Key) CoreM (Array MessageData) := do\n let mut r := #[]\n for _ in [: num] do\n r := r.push (β go)\n return r",
"start": [
83,
1
],
"end": [
126,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Key.arity",
"code": "def Key.arity : Key β Nat\n | .const _ a => a\n | .fvar _ a => a\n \n | .arrow => 0\n | .proj _ _ a => 1 + a\n | _ => 0",
"start": [
128,
1
],
"end": [
148,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.empty",
"code": "def empty : DiscrTree Ξ± := { root := {} }",
"start": [
152,
1
],
"end": [
152,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.format",
"code": "partial def Trie.format [ToFormat Ξ±] : Trie Ξ± β Format\n | .node vs cs => Format.group $ Format.paren $\n \"node\" ++ (if vs.isEmpty then Format.nil else \" \" ++ Std.format vs)\n ++ Format.join (cs.toList.map fun β¨k, cβ© => Format.line ++ Format.paren (Std.format k ++ \" => \" ++ format c))",
"start": [
154,
1
],
"end": [
157,
114
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.format",
"code": "partial def format [ToFormat Ξ±] (d : DiscrTree Ξ±) : Format :=\n let (_, r) := d.root.foldl\n (fun (p : Bool Γ Format) k c =>\n (false, p.2 ++ (if p.1 then Format.nil else Format.line) ++ Format.paren (Std.format k ++ \" => \" ++ Std.format c)))\n (true, Format.nil)\n Format.group r",
"start": [
161,
1
],
"end": [
166,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.tmpMVarId",
"code": "private def tmpMVarId : MVarId := { name := `_discr_tree_tmp }",
"start": [
170,
1
],
"end": [
172,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.tmpStar",
"code": "private def tmpStar := mkMVar tmpMVarId",
"start": [
173,
1
],
"end": [
173,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.ignoreArg",
"code": "private def ignoreArg (a : Expr) (i : Nat) (infos : Array ParamInfo) : MetaM Bool := do\n if h : i < infos.size then\n let info := infos.get β¨i, hβ©\n if info.isInstImplicit then\n return true\n else if info.isImplicit || info.isStrictImplicit then\n return not (β isType a)\n else\n isProof a\n else\n isProof a",
"start": [
178,
1
],
"end": [
218,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.pushArgsAux",
"code": "private partial def pushArgsAux (infos : Array ParamInfo) : Nat β Expr β Array Expr β MetaM (Array Expr)\n | i, .app f a, todo => do\n if (β ignoreArg a i infos) then\n pushArgsAux infos (i-1) f (todo.push tmpStar)\n else\n pushArgsAux infos (i-1) f (todo.push a)\n | _, _, todo => return todo",
"start": [
220,
1
],
"end": [
226,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.isNumeral",
"code": "private partial def isNumeral (e : Expr) : Bool :=\n if e.isRawNatLit then true\n else\n let f := e.getAppFn\n if !f.isConst then false\n else\n let fName := f.constName!\n if fName == ``Nat.succ && e.getAppNumArgs == 1 then isNumeral e.appArg!\n else if fName == ``OfNat.ofNat && e.getAppNumArgs == 3 then isNumeral (e.getArg! 1)\n else if fName == ``Nat.zero && e.getAppNumArgs == 0 then true\n else false",
"start": [
228,
1
],
"end": [
244,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.toNatLit?",
"code": "private partial def toNatLit? (e : Expr) : Option Literal :=\n if isNumeral e then\n if let some n := loop e then\n some (.natVal n)\n else\n none\n else\n none\nwhere\n loop (e : Expr) : OptionT Id Nat := do\n let f := e.getAppFn\n match f with\n | .lit (.natVal n) => return n\n | .const fName .. =>\n if fName == ``Nat.succ && e.getAppNumArgs == 1 then\n let r β loop e.appArg!\n return r+1\n else if fName == ``OfNat.ofNat && e.getAppNumArgs == 3 then\n loop (e.getArg! 1)\n else if fName == ``Nat.zero && e.getAppNumArgs == 0 then\n return 0\n else\n failure\n | _ => failure",
"start": [
246,
1
],
"end": [
269,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.isNatType",
"code": "private def isNatType (e : Expr) : MetaM Bool :=\n return (β whnf e).isConstOf ``Nat",
"start": [
271,
1
],
"end": [
272,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.isOffset",
"code": "private def isOffset (fName : Name) (e : Expr) : MetaM Bool := do\n if fName == ``Nat.add && e.getAppNumArgs == 2 then\n return isNumeral e.appArg!\n else if fName == ``Add.add && e.getAppNumArgs == 4 then\n if (β isNatType (e.getArg! 0)) then return isNumeral e.appArg! else return false\n else if fName == ``HAdd.hAdd && e.getAppNumArgs == 6 then\n if (β isNatType (e.getArg! 1)) then return isNumeral e.appArg! else return false\n else\n return fName == ``Nat.succ && e.getAppNumArgs == 1",
"start": [
274,
1
],
"end": [
290,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.shouldAddAsStar",
"code": "private def shouldAddAsStar (fName : Name) (e : Expr) : MetaM Bool := do\n isOffset fName e",
"start": [
292,
1
],
"end": [
303,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.mkNoindexAnnotation",
"code": "def mkNoindexAnnotation (e : Expr) : Expr :=\n mkAnnotation `noindex e",
"start": [
305,
1
],
"end": [
306,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.hasNoindexAnnotation",
"code": "def hasNoindexAnnotation (e : Expr) : Bool :=\n annotation? `noindex e |>.isSome",
"start": [
308,
1
],
"end": [
309,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.reduce",
"code": "partial def reduce (e : Expr) (config : WhnfCoreConfig) : MetaM Expr := do\n let e β whnfCore e config\n match (β unfoldDefinition? e) with\n | some e => reduce e config\n | none => match e.etaExpandedStrict? with\n | some e => reduce e config\n | none => return e",
"start": [
311,
1
],
"end": [
323,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.isBadKey",
"code": "private def isBadKey (fn : Expr) : Bool :=\n match fn with\n | .lit .. => false\n | .const .. => false\n | .fvar .. => false\n | .proj .. => false\n | .forallE .. => false\n | _ => true",
"start": [
325,
1
],
"end": [
338,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.reduceUntilBadKey",
"code": "private partial def reduceUntilBadKey (e : Expr) (config : WhnfCoreConfig) : MetaM Expr := do\n let e β step e\n match e.etaExpandedStrict? with\n | some e => reduceUntilBadKey e config\n | none => return e\nwhere\n step (e : Expr) := do\n let e β whnfCore e config\n match (β unfoldDefinition? e) with\n | some e' => if isBadKey e'.getAppFn then return e else step e'\n | none => return e",
"start": [
340,
1
],
"end": [
354,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.reduceDT",
"code": "def reduceDT (e : Expr) (root : Bool) (config : WhnfCoreConfig) : MetaM Expr :=\n if root then reduceUntilBadKey e config else reduce e config",
"start": [
356,
1
],
"end": [
358,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.pushWildcards",
"code": "private def pushWildcards (n : Nat) (todo : Array Expr) : Array Expr :=\n match n with\n | 0 => todo\n | n+1 => pushWildcards n (todo.push tmpStar)",
"start": [
362,
1
],
"end": [
368,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.pushArgs",
"code": "private def pushArgs (root : Bool) (todo : Array Expr) (e : Expr) (config : WhnfCoreConfig) (noIndexAtArgs : Bool) : MetaM (Key Γ Array Expr) := do\n if hasNoindexAnnotation e then\n return (.star, todo)\n else\n let e β reduceDT e root config\n let fn := e.getAppFn\n let push (k : Key) (nargs : Nat) (todo : Array Expr): MetaM (Key Γ Array Expr) := do\n let info β getFunInfoNArgs fn nargs\n let todo β if noIndexAtArgs then\n pure <| pushWildcards nargs todo\n else\n pushArgsAux info.paramInfo (nargs-1) e todo\n return (k, todo)\n match fn with\n | .lit v =>\n return (.lit v, todo)\n | .const c _ =>\n unless root do\n if let some v := toNatLit? e then\n return (.lit v, todo)\n if (β shouldAddAsStar c e) then\n return (.star, todo)\n let nargs := e.getAppNumArgs\n push (.const c nargs) nargs todo\n | .proj s i a =>\n \n let a := if isClass (β getEnv) s then mkNoindexAnnotation a else a\n let nargs := e.getAppNumArgs\n push (.proj s i nargs) nargs (todo.push a)\n | .fvar fvarId =>\n let nargs := e.getAppNumArgs\n push (.fvar fvarId nargs) nargs todo\n | .mvar mvarId =>\n if mvarId == tmpMVarId then\n return (.star, todo)\n else if (β mvarId.isReadOnlyOrSyntheticOpaque) then\n return (.other, todo)\n else\n return (.star, todo)\n | .forallE .. => return (.arrow, todo)\n | _ => return (.other, todo)",
"start": [
370,
1
],
"end": [
426,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.mkPathAux",
"code": "@[inherit_doc pushArgs]\npartial def mkPathAux (root : Bool) (todo : Array Expr) (keys : Array Key) (config : WhnfCoreConfig) (noIndexAtArgs : Bool) : MetaM (Array Key) := do\n if todo.isEmpty then\n return keys\n else\n let e := todo.back\n let todo := todo.pop\n let (k, todo) β pushArgs root todo e config noIndexAtArgs\n mkPathAux false todo (keys.push k) config noIndexAtArgs",
"start": [
428,
1
],
"end": [
436,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.initCapacity",
"code": "private def initCapacity := 8",
"start": [
438,
1
],
"end": [
438,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.mkPath",
"code": "@[inherit_doc pushArgs]\ndef mkPath (e : Expr) (config : WhnfCoreConfig) (noIndexAtArgs := false) : MetaM (Array Key) := do\n withReducible do\n let todo : Array Expr := .mkEmpty initCapacity\n let keys : Array Key := .mkEmpty initCapacity\n mkPathAux (root := true) (todo.push e) keys config noIndexAtArgs",
"start": [
440,
1
],
"end": [
445,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.createNodes",
"code": "private partial def createNodes (keys : Array Key) (v : Ξ±) (i : Nat) : Trie Ξ± :=\n if h : i < keys.size then\n let k := keys.get β¨i, hβ©\n let c := createNodes keys v (i+1)\n .node #[] #[(k, c)]\n else\n .node #[v] #[]",
"start": [
447,
1
],
"end": [
453,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.insertVal",
"code": "private def insertVal [BEq Ξ±] (vs : Array Ξ±) (v : Ξ±) : Array Ξ± :=\n loop 0\nwhere\n loop (i : Nat) : Array Ξ± :=\n if h : i < vs.size then\n if v == vs[i] then\n vs.set β¨i,hβ© v\n else\n loop (i+1)\n else\n vs.push v\n termination_by vs.size - i",
"start": [
455,
1
],
"end": [
472,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.insertAux",
"code": "private partial def insertAux [BEq Ξ±] (keys : Array Key) (v : Ξ±) : Nat β Trie Ξ± β Trie Ξ±\n | i, .node vs cs =>\n if h : i < keys.size then\n let k := keys.get β¨i, hβ©\n let c := Id.run $ cs.binInsertM\n (fun a b => a.1 < b.1)\n (fun β¨_, sβ© => let c := insertAux keys v (i+1) s; (k, c)) (fun _ => let c := createNodes keys v (i+1); (k, c))\n (k, default)\n .node vs c\n else\n .node (insertVal vs v) cs",
"start": [
474,
1
],
"end": [
485,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.insertCore",
"code": "def insertCore [BEq Ξ±] (d : DiscrTree Ξ±) (keys : Array Key) (v : Ξ±) : DiscrTree Ξ± :=\n if keys.isEmpty then panic! \"invalid key sequence\"\n else\n let k := keys[0]!\n match d.root.find? k with\n | none =>\n let c := createNodes keys v 1\n { root := d.root.insert k c }\n | some c =>\n let c := insertAux keys v 1 c\n { root := d.root.insert k c }",
"start": [
487,
1
],
"end": [
497,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.insert",
"code": "def insert [BEq Ξ±] (d : DiscrTree Ξ±) (e : Expr) (v : Ξ±) (config : WhnfCoreConfig) (noIndexAtArgs := false) : MetaM (DiscrTree Ξ±) := do\n let keys β mkPath e config noIndexAtArgs\n return d.insertCore keys v",
"start": [
499,
1
],
"end": [
501,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.insertIfSpecific",
"code": "def insertIfSpecific [BEq Ξ±] (d : DiscrTree Ξ±) (e : Expr) (v : Ξ±) (config : WhnfCoreConfig) (noIndexAtArgs := false) : MetaM (DiscrTree Ξ±) := do\n let keys β mkPath e config noIndexAtArgs\n return if keys == #[Key.star] || keys == #[Key.const `Eq 3, Key.star, Key.star, Key.star] then\n d\n else\n d.insertCore keys v",
"start": [
503,
1
],
"end": [
512,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getKeyArgs",
"code": "private def getKeyArgs (e : Expr) (isMatch root : Bool) (config : WhnfCoreConfig) : MetaM (Key Γ Array Expr) := do\n let e β reduceDT e root config\n unless root do\n if let some v := toNatLit? e then\n return (.lit v, #[])\n match e.getAppFn with\n | .lit v => return (.lit v, #[])\n | .const c _ =>\n if (β getConfig).isDefEqStuckEx && e.hasExprMVar then\n if (β isReducible c) then\n \n Meta.throwIsDefEqStuck\n else if let some matcherInfo := isMatcherAppCore? (β getEnv) e then\n let args := e.getAppArgs\n for arg in args[matcherInfo.getFirstDiscrPos: matcherInfo.getFirstDiscrPos + matcherInfo.numDiscrs] do\n if arg.hasExprMVar then\n Meta.throwIsDefEqStuck\n else if (β isRec c) then\n \n Meta.throwIsDefEqStuck\n let nargs := e.getAppNumArgs\n return (.const c nargs, e.getAppRevArgs)\n | .fvar fvarId =>\n let nargs := e.getAppNumArgs\n return (.fvar fvarId nargs, e.getAppRevArgs)\n | .mvar mvarId =>\n if isMatch then\n return (.other, #[])\n else do\n let ctx β read\n if ctx.config.isDefEqStuckEx then\n \n return (.star, #[])\n else if (β mvarId.isReadOnlyOrSyntheticOpaque) then\n return (.other, #[])\n else\n return (.star, #[])\n | .proj s i a .. =>\n let nargs := e.getAppNumArgs\n return (.proj s i nargs, #[a] ++ e.getAppRevArgs)\n | .forallE .. => return (.arrow, #[])\n | _ => return (.other, #[])",
"start": [
514,
1
],
"end": [
585,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchKeyArgs",
"code": "private abbrev getMatchKeyArgs (e : Expr) (root : Bool) (config : WhnfCoreConfig) : MetaM (Key Γ Array Expr) :=\n getKeyArgs e (isMatch := true) (root := root) (config := config)",
"start": [
587,
1
],
"end": [
588,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getUnifyKeyArgs",
"code": "private abbrev getUnifyKeyArgs (e : Expr) (root : Bool) (config : WhnfCoreConfig) : MetaM (Key Γ Array Expr) :=\n getKeyArgs e (isMatch := false) (root := root) (config := config)",
"start": [
590,
1
],
"end": [
591,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getStarResult",
"code": "private def getStarResult (d : DiscrTree Ξ±) : Array Ξ± :=\n let result : Array Ξ± := .mkEmpty initCapacity\n match d.root.find? .star with\n | none => result\n | some (.node vs _) => result ++ vs",
"start": [
593,
1
],
"end": [
597,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.findKey",
"code": "private abbrev findKey (cs : Array (Key Γ Trie Ξ±)) (k : Key) : Option (Key Γ Trie Ξ±) :=\n cs.binSearch (k, default) (fun a b => a.1 < b.1)",
"start": [
599,
1
],
"end": [
600,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchLoop",
"code": "private partial def getMatchLoop (todo : Array Expr) (c : Trie Ξ±) (result : Array Ξ±) (config : WhnfCoreConfig) : MetaM (Array Ξ±) := do\n match c with\n | .node vs cs =>\n if todo.isEmpty then\n return result ++ vs\n else if cs.isEmpty then\n return result\n else\n let e := todo.back\n let todo := todo.pop\n let first := cs[0]! \n let (k, args) β getMatchKeyArgs e (root := false) config\n \n let visitStar (result : Array Ξ±) : MetaM (Array Ξ±) :=\n if first.1 == .star then\n getMatchLoop todo first.2 result config\n else\n return result\n let visitNonStar (k : Key) (args : Array Expr) (result : Array Ξ±) : MetaM (Array Ξ±) :=\n match findKey cs k with\n | none => return result\n | some c => getMatchLoop (todo ++ args) c.2 result config\n let result β visitStar result\n match k with\n | .star => return result\n | _ => visitNonStar k args result",
"start": [
602,
1
],
"end": [
629,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchRoot",
"code": "private def getMatchRoot (d : DiscrTree Ξ±) (k : Key) (args : Array Expr) (result : Array Ξ±) (config : WhnfCoreConfig) : MetaM (Array Ξ±) :=\n match d.root.find? k with\n | none => return result\n | some c => getMatchLoop args c result config",
"start": [
631,
1
],
"end": [
634,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchCore",
"code": "private def getMatchCore (d : DiscrTree Ξ±) (e : Expr) (config : WhnfCoreConfig) : MetaM (Key Γ Array Ξ±) :=\n withReducible do\n let result := getStarResult d\n let (k, args) β getMatchKeyArgs e (root := true) config\n match k with\n | .star => return (k, result)\n | _ => return (k, (β getMatchRoot d k args result config))",
"start": [
636,
1
],
"end": [
642,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatch",
"code": "def getMatch (d : DiscrTree Ξ±) (e : Expr) (config : WhnfCoreConfig) : MetaM (Array Ξ±) :=\n return (β getMatchCore d e config).2",
"start": [
644,
1
],
"end": [
648,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchWithExtra",
"code": "partial def getMatchWithExtra (d : DiscrTree Ξ±) (e : Expr) (config : WhnfCoreConfig) : MetaM (Array (Ξ± Γ Nat)) := do\n let (k, result) β getMatchCore d e config\n let result := result.map (Β·, 0)\n if !e.isApp then\n return result\n else if !(β mayMatchPrefix k) then\n return result\n else\n go e.appFn! 1 result\nwhere\n mayMatchPrefix (k : Key) : MetaM Bool :=\n let cont (k : Key) : MetaM Bool :=\n if d.root.find? k |>.isSome then\n return true\n else\n mayMatchPrefix k\n match k with\n | .const f (n+1) => cont (.const f n)\n | .fvar f (n+1) => cont (.fvar f n)\n | .proj s i (n+1) => cont (.proj s i n)\n | _ => return false\n\n go (e : Expr) (numExtra : Nat) (result : Array (Ξ± Γ Nat)) : MetaM (Array (Ξ± Γ Nat)) := do\n let result := result ++ (β getMatchCore d e config).2.map (., numExtra)\n if e.isApp then\n go e.appFn! (numExtra + 1) result\n else\n return result",
"start": [
650,
1
],
"end": [
680,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchKeyRootFor",
"code": "def getMatchKeyRootFor (e : Expr) (config : WhnfCoreConfig) : MetaM (Key Γ Nat) := do\n let e β reduceDT e (root := true) config\n let numArgs := e.getAppNumArgs\n let key := match e.getAppFn with\n | .lit v => .lit v\n | .fvar fvarId => .fvar fvarId numArgs\n | .mvar _ => .other\n | .proj s i _ .. => .proj s i numArgs\n | .forallE .. => .arrow\n | .const c _ =>\n .const c numArgs\n | _ => .other\n return (key, numArgs)",
"start": [
682,
1
],
"end": [
699,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getAllValuesForKey",
"code": "private partial def getAllValuesForKey (d : DiscrTree Ξ±) (k : Key) (result : Array Ξ±) : Array Ξ± :=\n match d.root.find? k with\n | none => result\n | some trie => go trie result\nwhere\n go (trie : Trie Ξ±) (result : Array Ξ±) : Array Ξ± := Id.run do\n match trie with\n | .node vs cs =>\n let mut result := result ++ vs\n for (_, trie) in cs do\n result := go trie result\n return result",
"start": [
701,
1
],
"end": [
715,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getMatchLiberal",
"code": "def getMatchLiberal (d : DiscrTree Ξ±) (e : Expr) (config : WhnfCoreConfig) : MetaM (Array Ξ± Γ Nat) := do\n withReducible do\n let result := getStarResult d\n let (k, numArgs) β getMatchKeyRootFor e config\n match k with\n | .star => return (result, numArgs)\n | _ => return (getAllValuesForKey d k result, numArgs)",
"start": [
717,
1
],
"end": [
729,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.getUnify",
"code": "partial def getUnify (d : DiscrTree Ξ±) (e : Expr) (config : WhnfCoreConfig) : MetaM (Array Ξ±) :=\n withReducible do\n let (k, args) β getUnifyKeyArgs e (root := true) config\n match k with\n | .star => d.root.foldlM (init := #[]) fun result k c => process k.arity #[] c result\n | _ =>\n let result := getStarResult d\n match d.root.find? k with\n | none => return result\n | some c => process 0 args c result\nwhere\n process (skip : Nat) (todo : Array Expr) (c : Trie Ξ±) (result : Array Ξ±) : MetaM (Array Ξ±) := do\n match skip, c with\n | skip+1, .node _ cs =>\n if cs.isEmpty then\n return result\n else\n cs.foldlM (init := result) fun result β¨k, cβ© => process (skip + k.arity) todo c result\n | 0, .node vs cs => do\n if todo.isEmpty then\n return result ++ vs\n else if cs.isEmpty then\n return result\n else\n let e := todo.back\n let todo := todo.pop\n let (k, args) β getUnifyKeyArgs e (root := false) config\n let visitStar (result : Array Ξ±) : MetaM (Array Ξ±) :=\n let first := cs[0]!\n if first.1 == .star then\n process 0 todo first.2 result\n else\n return result\n let visitNonStar (k : Key) (args : Array Expr) (result : Array Ξ±) : MetaM (Array Ξ±) :=\n match findKey cs k with\n | none => return result\n | some c => process 0 (todo ++ args) c.2 result\n match k with\n | .star => cs.foldlM (init := result) fun result β¨k, cβ© => process k.arity todo c result\n | _ => visitNonStar k args (β visitStar result)",
"start": [
731,
1
],
"end": [
770,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.foldM",
"code": "partial def foldM [Monad m] (initialKeys : Array Key)\n (f : Ο β Array Key β Ξ± β m Ο) : (init : Ο) β Trie Ξ± β m Ο\n | init, Trie.node vs children => do\n let s β vs.foldlM (init := init) fun s v => f s initialKeys v\n children.foldlM (init := s) fun s (k, t) =>\n t.foldM (initialKeys.push k) f s",
"start": [
777,
1
],
"end": [
785,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.fold",
"code": "@[inline]\ndef fold (initialKeys : Array Key) (f : Ο β Array Key β Ξ± β Ο) (init : Ο) (t : Trie Ξ±) : Ο :=\n Id.run <| t.foldM initialKeys (init := init) fun s k a => return f s k a",
"start": [
787,
1
],
"end": [
792,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.foldValuesM",
"code": "partial def foldValuesM [Monad m] (f : Ο β Ξ± β m Ο) : (init : Ο) β Trie Ξ± β m Ο\n | init, node vs children => do\n let s β vs.foldlM (init := init) f\n children.foldlM (init := s) fun s (_, c) => c.foldValuesM (init := s) f",
"start": [
794,
1
],
"end": [
800,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.foldValues",
"code": "@[inline]\ndef foldValues (f : Ο β Ξ± β Ο) (init : Ο) (t : Trie Ξ±) : Ο :=\n Id.run <| t.foldValuesM (init := init) f",
"start": [
802,
1
],
"end": [
807,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.size",
"code": "partial def size : Trie Ξ± β Nat\n | Trie.node vs children =>\n children.foldl (init := vs.size) fun n (_, c) => n + size c",
"start": [
809,
1
],
"end": [
814,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.foldM",
"code": "@[inline]\ndef foldM [Monad m] (f : Ο β Array Key β Ξ± β m Ο) (init : Ο)\n (t : DiscrTree Ξ±) : m Ο :=\n t.root.foldlM (init := init) fun s k t => t.foldM #[k] (init := s) f",
"start": [
819,
1
],
"end": [
825,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.fold",
"code": "@[inline]\ndef fold (f : Ο β Array Key β Ξ± β Ο) (init : Ο) (t : DiscrTree Ξ±) : Ο :=\n Id.run <| t.foldM (init := init) fun s keys a => return f s keys a",
"start": [
827,
1
],
"end": [
832,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.foldValuesM",
"code": "@[inline]\ndef foldValuesM [Monad m] (f : Ο β Ξ± β m Ο) (init : Ο) (t : DiscrTree Ξ±) :\n m Ο :=\n t.root.foldlM (init := init) fun s _ t => t.foldValuesM (init := s) f",
"start": [
834,
1
],
"end": [
840,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.foldValues",
"code": "@[inline]\ndef foldValues (f : Ο β Ξ± β Ο) (init : Ο) (t : DiscrTree Ξ±) : Ο :=\n Id.run <| t.foldValuesM (init := init) f",
"start": [
842,
1
],
"end": [
847,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.containsValueP",
"code": "@[inline]\ndef containsValueP (t : DiscrTree Ξ±) (f : Ξ± β Bool) : Bool :=\n t.foldValues (init := false) fun r a => r || f a",
"start": [
849,
1
],
"end": [
854,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.values",
"code": "@[inline]\ndef values (t : DiscrTree Ξ±) : Array Ξ± :=\n t.foldValues (init := #[]) fun as a => as.push a",
"start": [
856,
1
],
"end": [
861,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.toArray",
"code": "@[inline]\ndef toArray (t : DiscrTree Ξ±) : Array (Array Key Γ Ξ±) :=\n t.fold (init := #[]) fun as keys a => as.push (keys, a)",
"start": [
863,
1
],
"end": [
868,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.size",
"code": "@[inline]\ndef size (t : DiscrTree Ξ±) : Nat :=\n t.root.foldl (init := 0) fun n _ t => n + t.size",
"start": [
870,
1
],
"end": [
875,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.Trie.mapArraysM",
"code": "partial def Trie.mapArraysM (t : DiscrTree.Trie Ξ±) (f : Array Ξ± β m (Array Ξ²)) :\n m (DiscrTree.Trie Ξ²) :=\n match t with\n | .node vs children =>\n return .node (β f vs) (β children.mapM fun (k, t') => do pure (k, β t'.mapArraysM f))",
"start": [
879,
1
],
"end": [
884,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.mapArraysM",
"code": "def mapArraysM (d : DiscrTree Ξ±) (f : Array Ξ± β m (Array Ξ²)) : m (DiscrTree Ξ²) := do\n pure { root := β d.root.mapM (fun t => t.mapArraysM f) }",
"start": [
886,
1
],
"end": [
888,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DiscrTree.mapArrays",
"code": "def mapArrays (d : DiscrTree Ξ±) (f : Array Ξ± β Array Ξ²) : DiscrTree Ξ² :=\n Id.run <| d.mapArraysM fun A => pure (f A)",
"start": [
890,
1
],
"end": [
892,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Command.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Term.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Do.lean"
] | [
{
"full_name": "Lean.Parser.Term.quot",
"code": "@[builtin_term_parser] def Term.quot := leading_parser\n \"`(\" >> withoutPosition (incQuotDepth termParser) >> \")\"",
"start": [
13,
1
],
"end": [
15,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.precheckedQuot",
"code": "@[builtin_term_parser] def Term.precheckedQuot := leading_parser\n \"`\" >> Term.quot",
"start": [
16,
1
],
"end": [
17,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.skipUntil",
"code": "private def skipUntil (pred : Char β Bool) : Parser where\n fn :=\n andthenFn\n (takeUntilFn pred)\n (takeWhileFn Char.isWhitespace)",
"start": [
21,
1
],
"end": [
26,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.skipUntilWs",
"code": "private def skipUntilWs : Parser := skipUntil Char.isWhitespace",
"start": [
28,
1
],
"end": [
29,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.skipUntilWsOrDelim",
"code": "private def skipUntilWsOrDelim : Parser := skipUntil fun c =>\n c.isWhitespace || c == '(' || c == ')' || c == ':' || c == '{' || c == '}' || c == '|'",
"start": [
31,
1
],
"end": [
34,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.quot",
"code": "@[builtin_term_parser low] def quot := leading_parser\n \"`(\" >> withoutPosition (incQuotDepth (many1Unbox commandParser)) >> \")\"",
"start": [
36,
1
],
"end": [
45,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.moduleDoc",
"code": "@[builtin_command_parser]\ndef moduleDoc := leading_parser ppDedent <|\n \"",
"start": [
47,
1
],
"end": [
54,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.namedPrio",
"code": "def namedPrio := leading_parser\n atomic (\" (\" >> nonReservedSymbol \"priority\") >> \" := \" >> withoutPosition priorityParser >> \")\"",
"start": [
56,
1
],
"end": [
57,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optNamedPrio",
"code": "def optNamedPrio := optional namedPrio",
"start": [
58,
1
],
"end": [
58,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.private",
"code": "def Β«privateΒ» := leading_parser \"private \"",
"start": [
60,
1
],
"end": [
60,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.protected",
"code": "def Β«protectedΒ» := leading_parser \"protected \"",
"start": [
61,
1
],
"end": [
61,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.visibility",
"code": "def visibility := Β«privateΒ» <|> Β«protectedΒ»",
"start": [
62,
1
],
"end": [
62,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.noncomputable",
"code": "def Β«noncomputableΒ» := leading_parser \"noncomputable \"",
"start": [
63,
1
],
"end": [
63,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.unsafe",
"code": "def Β«unsafeΒ» := leading_parser \"unsafe \"",
"start": [
64,
1
],
"end": [
64,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.partial",
"code": "def Β«partialΒ» := leading_parser \"partial \"",
"start": [
65,
1
],
"end": [
65,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.nonrec",
"code": "def Β«nonrecΒ» := leading_parser \"nonrec \"",
"start": [
66,
1
],
"end": [
66,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declModifiers",
"code": "def declModifiers (inline : Bool) := leading_parser\n optional docComment >>\n optional (Term.Β«attributesΒ» >> if inline then skip else ppDedent ppLine) >>\n optional visibility >>\n optional Β«noncomputableΒ» >>\n optional Β«unsafeΒ» >>\n optional (Β«partialΒ» <|> Β«nonrecΒ»)",
"start": [
68,
1
],
"end": [
87,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declId",
"code": "def declId := leading_parser\n ident >> optional (\".{\" >> sepBy1 (recover ident (skipUntil (fun c => c.isWhitespace || c β [',', '}']))) \", \" >> \"}\")",
"start": [
88,
1
],
"end": [
90,
121
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declSig",
"code": "def declSig := leading_parser\n many (ppSpace >> (Term.binderIdent <|> Term.bracketedBinder)) >> Term.typeSpec",
"start": [
91,
1
],
"end": [
93,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optDeclSig",
"code": "def optDeclSig := leading_parser\n many (ppSpace >> (Term.binderIdent <|> Term.bracketedBinder)) >> Term.optType",
"start": [
94,
1
],
"end": [
96,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declBody",
"code": "def declBody : Parser :=\n \n lookahead (setExpected [] \"by\") >> termParser leadPrec <|>\n termParser",
"start": [
97,
1
],
"end": [
122,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declBody.parenthesizer",
"code": "@[combinator_parenthesizer declBody] def declBody.parenthesizer : Parenthesizer :=\n Parenthesizer.categoryParser.parenthesizer `term 0",
"start": [
127,
1
],
"end": [
128,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declValSimple",
"code": "def declValSimple := leading_parser\n \" :=\" >> ppHardLineUnlessUngrouped >> declBody >> Termination.suffix >> optional Term.whereDecls",
"start": [
130,
1
],
"end": [
131,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declValEqns",
"code": "def declValEqns := leading_parser\n Term.matchAltsWhereDecls",
"start": [
132,
1
],
"end": [
133,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.whereStructField",
"code": "def whereStructField := leading_parser\n Term.letDecl",
"start": [
134,
1
],
"end": [
135,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.whereStructInst",
"code": "def whereStructInst := leading_parser\n ppIndent ppSpace >> \"where\" >> sepByIndent (ppGroup whereStructField) \"; \" (allowTrailingSep := true) >>\n optional Term.whereDecls",
"start": [
136,
1
],
"end": [
138,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declVal",
"code": "def declVal :=\n withAntiquot (mkAntiquot \"declVal\" `Lean.Parser.Command.declVal (isPseudoKind := true)) <|\n declValSimple <|> declValEqns <|> whereStructInst",
"start": [
139,
1
],
"end": [
149,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.abbrev",
"code": "def Β«abbrevΒ» := leading_parser\n \"abbrev \" >> declId >> ppIndent optDeclSig >> declVal",
"start": [
150,
1
],
"end": [
151,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optDefDeriving",
"code": "def optDefDeriving :=\n optional (ppDedent ppLine >> atomic (\"deriving \" >> notSymbol \"instance\") >> sepBy1 ident \", \")",
"start": [
152,
1
],
"end": [
153,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.definition",
"code": "def definition := leading_parser\n \"def \" >> recover declId skipUntilWsOrDelim >> ppIndent optDeclSig >> declVal >> optDefDeriving",
"start": [
154,
1
],
"end": [
155,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.theorem",
"code": "def Β«theoremΒ» := leading_parser\n \"theorem \" >> recover declId skipUntilWsOrDelim >> ppIndent declSig >> declVal",
"start": [
156,
1
],
"end": [
157,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.opaque",
"code": "def Β«opaqueΒ» := leading_parser\n \"opaque \" >> recover declId skipUntilWsOrDelim >> ppIndent declSig >> optional declValSimple",
"start": [
158,
1
],
"end": [
159,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.instance",
"code": "def Β«instanceΒ» := leading_parser\n Term.attrKind >> \"instance\" >> optNamedPrio >>\n optional (ppSpace >> declId) >> ppIndent declSig >> declVal",
"start": [
162,
1
],
"end": [
164,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.axiom",
"code": "def Β«axiomΒ» := leading_parser\n \"axiom \" >> recover declId skipUntilWsOrDelim >> ppIndent declSig",
"start": [
165,
1
],
"end": [
166,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.example",
"code": "def Β«exampleΒ» := leading_parser\n \"example\" >> ppIndent optDeclSig >> declVal",
"start": [
168,
1
],
"end": [
169,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.ctor",
"code": "def ctor := leading_parser\n atomic (optional docComment >> \"\\n| \") >>\n ppGroup (declModifiers true >> rawIdent >> optDeclSig)",
"start": [
170,
1
],
"end": [
172,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.derivingClasses",
"code": "def derivingClasses := sepBy1 (group (ident >> optional (\" with \" >> ppIndent Term.structInst))) \", \"",
"start": [
173,
1
],
"end": [
173,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optDeriving",
"code": "def optDeriving := leading_parser\n optional (ppLine >> atomic (\"deriving \" >> notSymbol \"instance\") >> derivingClasses)",
"start": [
174,
1
],
"end": [
175,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.computedField",
"code": "def computedField := leading_parser\n declModifiers true >> ident >> \" : \" >> termParser >> Term.matchAlts",
"start": [
176,
1
],
"end": [
177,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.computedFields",
"code": "def computedFields := leading_parser\n \"with\" >> manyIndent (ppLine >> ppGroup computedField)",
"start": [
178,
1
],
"end": [
179,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.inductive",
"code": "def Β«inductiveΒ» := leading_parser\n \"inductive \" >> recover declId skipUntilWsOrDelim >> ppIndent optDeclSig >> optional (symbol \" :=\" <|> \" where\") >>\n many ctor >> optional (ppDedent ppLine >> computedFields) >> optDeriving",
"start": [
180,
1
],
"end": [
200,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.classInductive",
"code": "def classInductive := leading_parser\n atomic (group (symbol \"class \" >> \"inductive \")) >>\n recover declId skipUntilWsOrDelim >> ppIndent optDeclSig >>\n optional (symbol \" :=\" <|> \" where\") >> many ctor >> optDeriving",
"start": [
201,
1
],
"end": [
204,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structExplicitBinder",
"code": "def structExplicitBinder := leading_parser\n atomic (declModifiers true >> \"(\") >>\n withoutPosition (many1 ident >> ppIndent optDeclSig >>\n optional (Term.binderTactic <|> Term.binderDefault)) >> \")\"",
"start": [
205,
1
],
"end": [
208,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structImplicitBinder",
"code": "def structImplicitBinder := leading_parser\n atomic (declModifiers true >> \"{\") >> withoutPosition (many1 ident >> declSig) >> \"}\"",
"start": [
209,
1
],
"end": [
210,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structInstBinder",
"code": "def structInstBinder := leading_parser\n atomic (declModifiers true >> \"[\") >> withoutPosition (many1 ident >> declSig) >> \"]\"",
"start": [
211,
1
],
"end": [
212,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structSimpleBinder",
"code": "def structSimpleBinder := leading_parser\n atomic (declModifiers true >> ident) >> optDeclSig >>\n optional (Term.binderTactic <|> Term.binderDefault)",
"start": [
213,
1
],
"end": [
215,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structFields",
"code": "def structFields := leading_parser\n manyIndent <|\n ppLine >> checkColGe >> ppGroup (\n structExplicitBinder <|> structImplicitBinder <|>\n structInstBinder <|> structSimpleBinder)",
"start": [
216,
1
],
"end": [
220,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structCtor",
"code": "def structCtor := leading_parser\n atomic (ppIndent (declModifiers true >> ident >> \" :: \"))",
"start": [
221,
1
],
"end": [
222,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structureTk",
"code": "def structureTk := leading_parser\n \"structure \"",
"start": [
223,
1
],
"end": [
224,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.classTk",
"code": "def classTk := leading_parser\n \"class \"",
"start": [
225,
1
],
"end": [
226,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.extends",
"code": "def Β«extendsΒ» := leading_parser\n \" extends \" >> sepBy1 termParser \", \"",
"start": [
227,
1
],
"end": [
228,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.structure",
"code": "def Β«structureΒ» := leading_parser\n (structureTk <|> classTk) >>\n declId >>\n ppIndent (many (ppSpace >> Term.bracketedBinder) >> optional Β«extendsΒ» >> Term.optType) >>\n optional ((symbol \" := \" <|> \" where \") >> optional structCtor >> structFields) >>\n optDeriving",
"start": [
229,
1
],
"end": [
235,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declaration",
"code": "@[builtin_command_parser] def declaration := leading_parser\n declModifiers false >>\n (Β«abbrevΒ» <|> definition <|> Β«theoremΒ» <|> Β«opaqueΒ» <|> Β«instanceΒ» <|> Β«axiomΒ» <|> Β«exampleΒ» <|>\n Β«inductiveΒ» <|> classInductive <|> Β«structureΒ»)",
"start": [
236,
1
],
"end": [
239,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.deriving",
"code": "@[builtin_command_parser] def Β«derivingΒ» := leading_parser\n \"deriving \" >> \"instance \" >> derivingClasses >> \" for \" >> sepBy1 (recover ident skip) \", \"",
"start": [
240,
1
],
"end": [
241,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.noncomputableSection",
"code": "@[builtin_command_parser] def noncomputableSection := leading_parser\n \"noncomputable \" >> \"section\" >> optional (ppSpace >> checkColGt >> ident)",
"start": [
242,
1
],
"end": [
243,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.section",
"code": "@[builtin_command_parser] def Β«sectionΒ» := leading_parser\n \"section\" >> optional (ppSpace >> checkColGt >> ident)",
"start": [
244,
1
],
"end": [
251,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.namespace",
"code": "@[builtin_command_parser] def Β«namespaceΒ» := leading_parser\n \"namespace \" >> checkColGt >> ident",
"start": [
252,
1
],
"end": [
269,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.end",
"code": "@[builtin_command_parser] def Β«endΒ» := leading_parser\n \"end\" >> optional (ppSpace >> checkColGt >> ident)",
"start": [
270,
1
],
"end": [
275,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.variable",
"code": "@[builtin_command_parser] def Β«variableΒ» := leading_parser\n \"variable\" >> many1 (ppSpace >> checkColGt >> Term.bracketedBinder)",
"start": [
276,
1
],
"end": [
373,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.universe",
"code": "@[builtin_command_parser] def Β«universeΒ» := leading_parser\n \"universe\" >> many1 (ppSpace >> checkColGt >> ident)",
"start": [
374,
1
],
"end": [
433,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.check",
"code": "@[builtin_command_parser] def check := leading_parser\n \"#check \" >> termParser",
"start": [
434,
1
],
"end": [
435,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.check_failure",
"code": "@[builtin_command_parser] def check_failure := leading_parser\n \"#check_failure \" >> termParser",
"start": [
436,
1
],
"end": [
437,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.eval",
"code": "@[builtin_command_parser] def eval := leading_parser\n \"#eval \" >> termParser",
"start": [
438,
1
],
"end": [
439,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.synth",
"code": "@[builtin_command_parser] def synth := leading_parser\n \"#synth \" >> termParser",
"start": [
440,
1
],
"end": [
441,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.exit",
"code": "@[builtin_command_parser] def exit := leading_parser\n \"#exit\"",
"start": [
442,
1
],
"end": [
443,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.print",
"code": "@[builtin_command_parser] def print := leading_parser\n \"#print \" >> (ident <|> strLit)",
"start": [
444,
1
],
"end": [
445,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.printAxioms",
"code": "@[builtin_command_parser] def printAxioms := leading_parser\n \"#print \" >> nonReservedSymbol \"axioms \" >> ident",
"start": [
446,
1
],
"end": [
447,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.printEqns",
"code": "@[builtin_command_parser] def printEqns := leading_parser\n \"#print \" >> (nonReservedSymbol \"equations \" <|> nonReservedSymbol \"eqns \") >> ident",
"start": [
448,
1
],
"end": [
449,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.printTacTags",
"code": "@[builtin_command_parser] def printTacTags := leading_parser\n \"#print \" >> nonReservedSymbol \"tactic \" >> nonReservedSymbol \"tags\"",
"start": [
450,
1
],
"end": [
454,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.init_quot",
"code": "@[builtin_command_parser] def Β«init_quotΒ» := leading_parser\n \"init_quot\"",
"start": [
455,
1
],
"end": [
456,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optionValue",
"code": "def optionValue := nonReservedSymbol \"true\" <|> nonReservedSymbol \"false\" <|> strLit <|> numLit",
"start": [
457,
1
],
"end": [
457,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.set_option",
"code": "@[builtin_command_parser] def Β«set_optionΒ» := leading_parser\n \"set_option \" >> identWithPartialTrailingDot >> ppSpace >> optionValue",
"start": [
458,
1
],
"end": [
474,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.eraseAttr",
"code": "def eraseAttr := leading_parser\n \"-\" >> rawIdent",
"start": [
475,
1
],
"end": [
476,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.attribute",
"code": "@[builtin_command_parser] def Β«attributeΒ» := leading_parser\n \"attribute \" >> \"[\" >>\n withoutPosition (sepBy1 (eraseAttr <|> Term.attrInstance) \", \") >>\n \"]\" >> many1 (ppSpace >> ident)",
"start": [
477,
1
],
"end": [
480,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.export",
"code": "@[builtin_command_parser] def Β«exportΒ» := leading_parser\n \"export \" >> ident >> \" (\" >> many1 ident >> \")\"",
"start": [
481,
1
],
"end": [
506,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.import",
"code": "@[builtin_command_parser] def Β«importΒ» := leading_parser\n \"import\"",
"start": [
507,
1
],
"end": [
508,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openHiding",
"code": "def openHiding := leading_parser\n ppSpace >> atomic (ident >> \" hiding\") >> many1 (ppSpace >> checkColGt >> ident)",
"start": [
509,
1
],
"end": [
510,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openRenamingItem",
"code": "def openRenamingItem := leading_parser\n ident >> unicodeSymbol \" β \" \" -> \" >> checkColGt >> ident",
"start": [
511,
1
],
"end": [
512,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openRenaming",
"code": "def openRenaming := leading_parser\n ppSpace >> atomic (ident >> \" renaming \") >> sepBy1 openRenamingItem \", \"",
"start": [
513,
1
],
"end": [
514,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openOnly",
"code": "def openOnly := leading_parser\n ppSpace >> atomic (ident >> \" (\") >> many1 ident >> \")\"",
"start": [
515,
1
],
"end": [
516,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openSimple",
"code": "def openSimple := leading_parser\n many1 (ppSpace >> checkColGt >> ident)",
"start": [
517,
1
],
"end": [
518,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openScoped",
"code": "def openScoped := leading_parser\n \" scoped\" >> many1 (ppSpace >> checkColGt >> ident)",
"start": [
519,
1
],
"end": [
520,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.openDecl",
"code": "def openDecl :=\n withAntiquot (mkAntiquot \"openDecl\" `Lean.Parser.Command.openDecl (isPseudoKind := true)) <|\n openHiding <|> openRenaming <|> openOnly <|> openSimple <|> openScoped",
"start": [
521,
1
],
"end": [
524,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.open",
"code": "@[builtin_command_parser] def Β«openΒ» := leading_parser\n withPosition (\"open\" >> openDecl)",
"start": [
525,
1
],
"end": [
638,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.mutual",
"code": "@[builtin_command_parser] def Β«mutualΒ» := leading_parser\n \"mutual\" >> many1 (ppLine >> notSymbol \"end\" >> commandParser) >>\n ppDedent (ppLine >> \"end\")",
"start": [
640,
1
],
"end": [
642,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.initializeKeyword",
"code": "def initializeKeyword := leading_parser\n \"initialize \" <|> \"builtin_initialize \"",
"start": [
643,
1
],
"end": [
644,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.initialize",
"code": "@[builtin_command_parser] def Β«initializeΒ» := leading_parser\n declModifiers false >> initializeKeyword >>\n optional (atomic (ident >> Term.typeSpec >> ppSpace >> Term.leftArrow)) >> Term.doSeq",
"start": [
645,
1
],
"end": [
647,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.in",
"code": "@[builtin_command_parser] def Β«inΒ» := trailing_parser\n withOpen (ppDedent (\" in \" >> commandParser))",
"start": [
649,
1
],
"end": [
650,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.addDocString",
"code": "@[builtin_command_parser] def addDocString := leading_parser\n docComment >> \"add_decl_doc \" >> ident",
"start": [
652,
1
],
"end": [
675,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.register_tactic_tag",
"code": "@[builtin_command_parser] def Β«register_tactic_tagΒ» := leading_parser\n optional (docComment >> ppLine) >>\n \"register_tactic_tag \" >> ident >> strLit",
"start": [
677,
1
],
"end": [
684,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.tactic_extension",
"code": "@[builtin_command_parser] def Β«tactic_extensionΒ» := leading_parser\n optional (docComment >> ppLine) >>\n \"tactic_extension \" >> ident",
"start": [
686,
1
],
"end": [
694,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.genInjectiveTheorems",
"code": "@[builtin_command_parser] def genInjectiveTheorems := leading_parser\n \"gen_injective_theorems% \" >> ident",
"start": [
697,
1
],
"end": [
702,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.eoi",
"code": "@[run_builtin_parser_attribute_hooks] def eoi : Parser := leading_parser \"\"",
"start": [
704,
1
],
"end": [
705,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declModifiersF",
"code": "@[run_builtin_parser_attribute_hooks, inherit_doc declModifiers]\nabbrev declModifiersF := declModifiers false",
"start": [
710,
1
],
"end": [
711,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.declModifiersT",
"code": "@[run_builtin_parser_attribute_hooks, inherit_doc declModifiers]\nabbrev declModifiersT := declModifiers true",
"start": [
712,
1
],
"end": [
713,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.open",
"code": "@[builtin_term_parser] def Β«openΒ» := leading_parser:leadPrec\n \"open\" >> Command.openDecl >> withOpenDecl (\" in \" >> termParser)",
"start": [
728,
1
],
"end": [
733,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Term.set_option",
"code": "@[builtin_term_parser] def Β«set_optionΒ» := leading_parser:leadPrec\n \"set_option \" >> identWithPartialTrailingDot >> ppSpace >> Command.optionValue >> \" in \" >> termParser",
"start": [
735,
1
],
"end": [
740,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.open",
"code": "@[builtin_tactic_parser] def Β«openΒ» := leading_parser:leadPrec\n \"open \" >> Command.openDecl >> withOpenDecl (\" in \" >> tacticSeq)",
"start": [
744,
1
],
"end": [
747,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.set_option",
"code": "@[builtin_tactic_parser] def Β«set_optionΒ» := leading_parser:leadPrec\n \"set_option \" >> identWithPartialTrailingDot >> ppSpace >> Command.optionValue >> \" in \" >> tacticSeq",
"start": [
749,
1
],
"end": [
752,
104
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Check.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean"
] | [
{
"full_name": "Lean.Meta.ensureType",
"code": "private def ensureType (e : Expr) : MetaM Unit := do\n discard <| getLevel e",
"start": [
16,
1
],
"end": [
17,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwLetTypeMismatchMessage",
"code": "def throwLetTypeMismatchMessage {Ξ±} (fvarId : FVarId) : MetaM Ξ± := do\n let lctx β getLCtx\n match lctx.find? fvarId with\n | some (LocalDecl.ldecl _ _ _ t v _ _) => do\n let vType β inferType v\n throwError \"invalid let declaration, term{indentExpr v}\\nhas type{indentExpr vType}\\nbut is expected to have type{indentExpr t}\"\n | _ => unreachable!",
"start": [
19,
1
],
"end": [
25,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkConstant",
"code": "private def checkConstant (constName : Name) (us : List Level) : MetaM Unit := do\n let cinfo β getConstInfo constName\n unless us.length == cinfo.levelParams.length do\n throwIncorrectNumberOfLevels constName us",
"start": [
27,
1
],
"end": [
30,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFunctionDomain",
"code": "private def getFunctionDomain (f : Expr) : MetaM (Expr Γ BinderInfo) := do\n let fType β inferType f\n let fType β whnfD fType\n match fType with\n | Expr.forallE _ d _ c => return (d, c)\n | _ => throwFunctionExpected f",
"start": [
32,
1
],
"end": [
37,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addPPExplicitToExposeDiff",
"code": "partial def addPPExplicitToExposeDiff (a b : Expr) : MetaM (Expr Γ Expr) := do\n if (β getOptions).getBool `pp.all false || (β getOptions).getBool `pp.explicit false then\n return (a, b)\n else\n visit (β instantiateMVars a) (β instantiateMVars b)\nwhere\n visit (a b : Expr) : MetaM (Expr Γ Expr) := do\n try\n if !a.isApp || !b.isApp then\n return (a, b)\n else if a.getAppNumArgs != b.getAppNumArgs then\n return (a, b)\n else if not (β isDefEq a.getAppFn b.getAppFn) then\n return (a, b)\n else\n let fType β inferType a.getAppFn\n forallBoundedTelescope fType a.getAppNumArgs fun xs _ => do\n let mut as := a.getAppArgs\n let mut bs := b.getAppArgs\n if let some (as', bs') β hasExplicitDiff? xs as bs then\n return (mkAppN a.getAppFn as', mkAppN b.getAppFn bs')\n else\n for i in [:as.size] do\n unless (β isDefEq as[i]! bs[i]!) do\n let (ai, bi) β visit as[i]! bs[i]!\n as := as.set! i ai\n bs := bs.set! i bi\n let a := mkAppN a.getAppFn as\n let b := mkAppN b.getAppFn bs\n return (a.setAppPPExplicit, b.setAppPPExplicit)\n catch _ =>\n return (a, b)\n\n hasExplicitDiff? (xs as bs : Array Expr) : MetaM (Option (Array Expr Γ Array Expr)) := do\n for i in [:xs.size] do\n let localDecl β xs[i]!.fvarId!.getDecl\n if localDecl.binderInfo.isExplicit then\n unless (β isDefEq as[i]! bs[i]!) do\n let (ai, bi) β visit as[i]! bs[i]!\n return some (as.set! i ai, bs.set! i bi)\n return none",
"start": [
39,
1
],
"end": [
113,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHasTypeButIsExpectedMsg",
"code": "def mkHasTypeButIsExpectedMsg (givenType expectedType : Expr) : MetaM MessageData := do\n try\n let givenTypeType β inferType givenType\n let expectedTypeType β inferType expectedType\n let (givenType, expectedType) β addPPExplicitToExposeDiff givenType expectedType\n let (givenTypeType, expectedTypeType) β addPPExplicitToExposeDiff givenTypeType expectedTypeType\n return m!\"has type{indentD m!\"{givenType} : {givenTypeType}\"}\\nbut is expected to have type{indentD m!\"{expectedType} : {expectedTypeType}\"}\"\n catch _ =>\n let (givenType, expectedType) β addPPExplicitToExposeDiff givenType expectedType\n return m!\"has type{indentExpr givenType}\\nbut is expected to have type{indentExpr expectedType}\"",
"start": [
115,
1
],
"end": [
127,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwAppTypeMismatch",
"code": "def throwAppTypeMismatch (f a : Expr) : MetaM Ξ± := do\n let (expectedType, binfo) β getFunctionDomain f\n let mut e := mkApp f a\n unless binfo.isExplicit do\n e := e.setAppPPExplicit\n let aType β inferType a\n throwError \"application type mismatch{indentExpr e}\\nargument{indentExpr a}\\n{β mkHasTypeButIsExpectedMsg aType expectedType}\"",
"start": [
129,
1
],
"end": [
135,
129
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkApp",
"code": "def checkApp (f a : Expr) : MetaM Unit := do\n let fType β inferType f\n let fType β whnf fType\n match fType with\n | Expr.forallE _ d _ _ =>\n let aType β inferType a\n unless (β isDefEq d aType) do\n throwAppTypeMismatch f a\n | _ => throwFunctionExpected (mkApp f a)",
"start": [
137,
1
],
"end": [
145,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkAux",
"code": "private partial def checkAux (e : Expr) : MetaM Unit := do\n check e |>.run\nwhere\n check (e : Expr) : MonadCacheT ExprStructEq Unit MetaM Unit :=\n checkCache { val := e : ExprStructEq } fun _ => do\n match e with\n | .forallE .. => checkForall e\n | .lam .. => checkLambdaLet e\n | .letE .. => checkLambdaLet e\n | .const c lvls => checkConstant c lvls\n | .app f a => check f; check a; checkApp f a\n | .mdata _ e => check e\n | .proj _ _ e => check e\n | _ => return ()\n\n checkLambdaLet (e : Expr) : MonadCacheT ExprStructEq Unit MetaM Unit :=\n lambdaLetTelescope e fun xs b => do\n xs.forM fun x => do\n let xDecl β getFVarLocalDecl x;\n match xDecl with\n | .cdecl (type := t) .. =>\n ensureType t\n check t\n | .ldecl (type := t) (value := v) .. =>\n ensureType t\n check t\n let vType β inferType v\n unless (β isDefEq t vType) do throwLetTypeMismatchMessage x.fvarId!\n check v\n check b\n\n checkForall (e : Expr) : MonadCacheT ExprStructEq Unit MetaM Unit :=\n forallTelescope e fun xs b => do\n xs.forM fun x => do\n let xDecl β getFVarLocalDecl x\n ensureType xDecl.type\n check xDecl.type\n ensureType b\n check b",
"start": [
147,
1
],
"end": [
185,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.check",
"code": "def check (e : Expr) : MetaM Unit :=\n withTraceNode `Meta.check (fun res =>\n return m!\"{if res.isOk then checkEmoji else crossEmoji} {e}\") do\n try\n withTransparency TransparencyMode.all $ checkAux e\n catch ex =>\n trace[Meta.check] ex.toMessageData\n throw ex",
"start": [
187,
1
],
"end": [
197,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isTypeCorrect",
"code": "def isTypeCorrect (e : Expr) : MetaM Bool := do\n try\n check e\n pure true\n catch _ =>\n pure false",
"start": [
199,
1
],
"end": [
207,
15
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array/InsertionSort.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean"
] | [
{
"full_name": "Array.insertionSort",
"code": "@[inline] def Array.insertionSort (a : Array Ξ±) (lt : Ξ± β Ξ± β Bool) : Array Ξ± :=\n traverse a 0 a.size\nwhere\n @[specialize] traverse (a : Array Ξ±) (i : Nat) (fuel : Nat) : Array Ξ± :=\n match fuel with\n | 0 => a\n | fuel+1 =>\n if h : i < a.size then\n traverse (swapLoop a i h) (i+1) fuel\n else\n a\n @[specialize] swapLoop (a : Array Ξ±) (j : Nat) (h : j < a.size) : Array Ξ± :=\n match (generalizing := false) he:j with | 0 => a\n | j'+1 =>\n have h' : j' < a.size := by subst j; exact Nat.lt_trans (Nat.lt_succ_self _) h\n if lt a[j] a[j'] then\n swapLoop (a.swap β¨j, hβ© β¨j', h'β©) j' (by rw [size_swap]; assumption; done)\n else\n a",
"start": [
9,
1
],
"end": [
28,
10
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/AbstractMVars.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.AbstractMVars.State",
"code": "structure State where\n ngen : NameGenerator\n lctx : LocalContext\n mctx : MetavarContext\n nextParamIdx : Nat := 0\n paramNames : Array Name := #[]\n fvars : Array Expr := #[]\n lmap : HashMap LMVarId Level := {}\n emap : HashMap MVarId Expr := {}\n abstractLevels : Bool",
"start": [
12,
1
],
"end": [
21,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AbstractMVars.M",
"code": "abbrev M := StateM State",
"start": [
23,
1
],
"end": [
23,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AbstractMVars.mkFreshId",
"code": "def mkFreshId : M Name := do\n let s β get\n let fresh := s.ngen.curr\n modify fun s => { s with ngen := s.ngen.next }\n pure fresh",
"start": [
30,
1
],
"end": [
34,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AbstractMVars.mkFreshFVarId",
"code": "def mkFreshFVarId : M FVarId :=\n return { name := (β mkFreshId) }",
"start": [
36,
1
],
"end": [
37,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AbstractMVars.abstractLevelMVars",
"code": "private partial def abstractLevelMVars (u : Level) : M Level := do\n if !(β get).abstractLevels then\n return u\n if !u.hasMVar then\n return u\n else\n match u with\n | Level.zero => return u\n | Level.param _ => return u\n | Level.succ v => return u.updateSucc! (β abstractLevelMVars v)\n | Level.max v w => return u.updateMax! (β abstractLevelMVars v) (β abstractLevelMVars w)\n | Level.imax v w => return u.updateIMax! (β abstractLevelMVars v) (β abstractLevelMVars w)\n | Level.mvar mvarId =>\n let s β get\n let depth := s.mctx.getLevelDepth mvarId;\n if depth != s.mctx.depth then\n return u else\n match s.lmap.find? mvarId with\n | some u => pure u\n | none =>\n let paramId := Name.mkNum `_abstMVar s.nextParamIdx\n let u := mkLevelParam paramId\n modify fun s => { s with nextParamIdx := s.nextParamIdx + 1, lmap := s.lmap.insert mvarId u, paramNames := s.paramNames.push paramId }\n return u",
"start": [
39,
1
],
"end": [
63,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AbstractMVars.abstractExprMVars",
"code": "partial def abstractExprMVars (e : Expr) : M Expr := do\n if !e.hasMVar then\n return e\n else\n match e with\n | e@(Expr.lit _) => return e\n | e@(Expr.bvar _) => return e\n | e@(Expr.fvar _) => return e\n | e@(Expr.sort u) => return e.updateSort! (β abstractLevelMVars u)\n | e@(Expr.const _ us) => return e.updateConst! (β us.mapM abstractLevelMVars)\n | e@(Expr.proj _ _ s) => return e.updateProj! (β abstractExprMVars s)\n | e@(Expr.app f a) => return e.updateApp! (β abstractExprMVars f) (β abstractExprMVars a)\n | e@(Expr.mdata _ b) => return e.updateMData! (β abstractExprMVars b)\n | e@(Expr.lam _ d b _) => return e.updateLambdaE! (β abstractExprMVars d) (β abstractExprMVars b)\n | e@(Expr.forallE _ d b _) => return e.updateForallE! (β abstractExprMVars d) (β abstractExprMVars b)\n | e@(Expr.letE _ t v b _) => return e.updateLet! (β abstractExprMVars t) (β abstractExprMVars v) (β abstractExprMVars b)\n | e@(Expr.mvar mvarId) =>\n let decl := (β getMCtx).getDecl mvarId\n if decl.depth != (β getMCtx).depth then\n return e\n else\n let eNew β instantiateMVars e\n if e != eNew then\n abstractExprMVars eNew\n else\n match (β get).emap.find? mvarId with\n | some e =>\n return e\n | none =>\n let type β abstractExprMVars decl.type\n let fvarId β mkFreshFVarId\n let fvar := mkFVar fvarId;\n let userName β if decl.userName.isAnonymous then\n pure <| (`x).appendIndexAfter (β get).fvars.size\n else\n pure decl.userName\n modify fun s => {\n s with\n emap := s.emap.insert mvarId fvar,\n fvars := s.fvars.push fvar,\n lctx := s.lctx.mkLocalDecl fvarId userName type }\n return fvar",
"start": [
65,
1
],
"end": [
106,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.abstractMVars",
"code": "def abstractMVars (e : Expr) (levels : Bool := true): MetaM AbstractMVarsResult := do\n let e β instantiateMVars e\n let (e, s) := AbstractMVars.abstractExprMVars e\n { mctx := (β getMCtx), lctx := (β getLCtx), ngen := (β getNGen), abstractLevels := levels }\n setNGen s.ngen\n setMCtx s.mctx\n let e := s.lctx.mkLambda s.fvars e\n pure { paramNames := s.paramNames, numMVars := s.fvars.size, expr := e }",
"start": [
110,
1
],
"end": [
137,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.openAbstractMVarsResult",
"code": "def openAbstractMVarsResult (a : AbstractMVarsResult) : MetaM (Array Expr Γ Array BinderInfo Γ Expr) := do\n let us β a.paramNames.mapM fun _ => mkFreshLevelMVar\n let e := a.expr.instantiateLevelParamsArray a.paramNames us\n lambdaMetaTelescope e (some a.numMVars)",
"start": [
139,
1
],
"end": [
142,
42
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Instances.lean | [
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Meta/DiscrTree.lean",
".lake/packages/lean4/src/lean/Lean/Meta/GlobalInstances.lean",
".lake/packages/lean4/src/lean/Lean/Meta/CollectMVars.lean"
] | [
{
"full_name": "Lean.Meta.InstanceKey",
"code": "abbrev InstanceKey := DiscrTree.Key",
"start": [
41,
1
],
"end": [
41,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.InstanceEntry",
"code": "structure InstanceEntry where\n keys : Array InstanceKey\n val : Expr\n priority : Nat\n globalName? : Option Name := none\n \n synthOrder : Array Nat\n \n attrKind : AttributeKind\n deriving Inhabited",
"start": [
43,
1
],
"end": [
57,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.InstanceTree",
"code": "abbrev InstanceTree := DiscrTree InstanceEntry",
"start": [
67,
1
],
"end": [
67,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Instances",
"code": "structure Instances where\n discrTree : InstanceTree := DiscrTree.empty\n instanceNames : PHashMap Name InstanceEntry := {}\n erased : PHashSet Name := {}\n deriving Inhabited",
"start": [
69,
1
],
"end": [
73,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.tcDtConfig",
"code": "def tcDtConfig : WhnfCoreConfig := {}",
"start": [
75,
1
],
"end": [
76,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addInstanceEntry",
"code": "def addInstanceEntry (d : Instances) (e : InstanceEntry) : Instances :=\n match e.globalName? with\n | some n => { d with discrTree := d.discrTree.insertCore e.keys e, instanceNames := d.instanceNames.insert n e, erased := d.erased.erase n }\n | none => { d with discrTree := d.discrTree.insertCore e.keys e }",
"start": [
78,
1
],
"end": [
81,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Instances.eraseCore",
"code": "def Instances.eraseCore (d : Instances) (declName : Name) : Instances :=\n { d with erased := d.erased.insert declName, instanceNames := d.instanceNames.erase declName }",
"start": [
83,
1
],
"end": [
84,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Instances.erase",
"code": "def Instances.erase [Monad m] [MonadError m] (d : Instances) (declName : Name) : m Instances := do\n unless d.instanceNames.contains declName do\n throwError \"'{declName}' does not have [instance] attribute\"\n return d.eraseCore declName",
"start": [
86,
1
],
"end": [
89,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkInstanceKey",
"code": "private def mkInstanceKey (e : Expr) : MetaM (Array InstanceKey) := do\n let type β inferType e\n withNewMCtxDepth do\n let (_, _, type) β forallMetaTelescopeReducing type\n DiscrTree.mkPath type tcDtConfig",
"start": [
97,
1
],
"end": [
101,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.computeSynthOrder",
"code": "private partial def computeSynthOrder (inst : Expr) : MetaM (Array Nat) :=\n withReducible do\n let instTy β inferType inst\n\n let rec getSemiOutParamPositionsOf (classTy : Expr) : MetaM (Array Nat) := do\n if let .const className .. := classTy.getAppFn then\n forallTelescopeReducing (β inferType classTy.getAppFn) fun args _ => do\n let mut pos := (getOutParamPositions? (β getEnv) className).getD #[]\n for arg in args, i in [:args.size] do\n if (β inferType arg).isAppOf ``semiOutParam then\n pos := pos.push i\n return pos\n else\n return #[]\n\n let (argMVars, argBIs, ty) β forallMetaTelescopeReducing instTy\n let ty β whnf ty\n forallTelescopeReducing instTy fun argVars _ => do\n\n let rec assignMVarsIn (e : Expr) : MetaM Unit := do\n for mvarId in β getMVars e do\n if let some i := argMVars.findIdx? (Β·.mvarId! == mvarId) then\n mvarId.assign argVars[i]!\n assignMVarsIn (β inferType (.mvar mvarId))\n\n let tyOutParams β getSemiOutParamPositionsOf ty\n let tyArgs := ty.getAppArgs\n for tyArg in tyArgs, i in [:tyArgs.size] do\n unless tyOutParams.contains i do assignMVarsIn tyArg\n\n let mut synthed := #[]\n let mut toSynth := List.range argMVars.size |>.filter (argBIs[Β·]! == .instImplicit) |>.toArray\n while !toSynth.isEmpty do\n let next? β toSynth.findM? fun i => do\n forallTelescopeReducing (β instantiateMVars (β inferType argMVars[i]!)) fun _ argTy => do\n let argTy β whnf argTy\n let argOutParams β getSemiOutParamPositionsOf argTy\n let argTyArgs := argTy.getAppArgs\n for i in [:argTyArgs.size], argTyArg in argTyArgs do\n if !argOutParams.contains i && argTyArg.hasExprMVar then\n return false\n return true\n let next β\n match next? with\n | some next => pure next\n | none =>\n if synthInstance.checkSynthOrder.get (β getOptions) then\n let typeLines := (\"\" : MessageData).joinSep <| Array.toList <| β toSynth.mapM fun i => do\n let ty β instantiateMVars (β inferType argMVars[i]!)\n return indentExpr (ty.setPPExplicit true)\n logError m!\"cannot find synthesization order for instance {inst} with type{indentExpr instTy}\\nall remaining arguments have metavariables:{typeLines}\"\n pure toSynth[0]!\n synthed := synthed.push next\n toSynth := toSynth.filter (Β· != next)\n assignMVarsIn (β inferType argMVars[next]!)\n assignMVarsIn argMVars[next]!\n\n if synthInstance.checkSynthOrder.get (β getOptions) then\n let ty β instantiateMVars ty\n if ty.hasExprMVar then\n logError m!\"instance does not provide concrete values for (semi-)out-params{indentExpr (ty.setPPExplicit true)}\"\n\n trace[Meta.synthOrder] \"synthesizing the arguments of {inst} in the order {synthed}:{(\"\" : MessageData).joinSep (β synthed.mapM fun i => return indentExpr (β inferType argVars[i]!)).toList}\"\n\n return synthed",
"start": [
103,
1
],
"end": [
192,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addInstance",
"code": "def addInstance (declName : Name) (attrKind : AttributeKind) (prio : Nat) : MetaM Unit := do\n let c β mkConstWithLevelParams declName\n let keys β mkInstanceKey c\n addGlobalInstance declName attrKind\n let synthOrder β computeSynthOrder c\n instanceExtension.add { keys, val := c, priority := prio, globalName? := declName, attrKind, synthOrder } attrKind",
"start": [
194,
1
],
"end": [
199,
117
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getGlobalInstancesIndex",
"code": "def getGlobalInstancesIndex : CoreM (DiscrTree InstanceEntry) :=\n return Meta.instanceExtension.getState (β getEnv) |>.discrTree",
"start": [
214,
1
],
"end": [
215,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getErasedInstances",
"code": "def getErasedInstances : CoreM (PHashSet Name) :=\n return Meta.instanceExtension.getState (β getEnv) |>.erased",
"start": [
217,
1
],
"end": [
218,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstanceCore",
"code": "def isInstanceCore (env : Environment) (declName : Name) : Bool :=\n Meta.instanceExtension.getState env |>.instanceNames.contains declName",
"start": [
220,
1
],
"end": [
221,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInstance",
"code": "def isInstance (declName : Name) : CoreM Bool :=\n return isInstanceCore (β getEnv) declName",
"start": [
223,
1
],
"end": [
224,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getInstancePriority?",
"code": "def getInstancePriority? (declName : Name) : CoreM (Option Nat) := do\n let some entry := Meta.instanceExtension.getState (β getEnv) |>.instanceNames.find? declName | return none\n return entry.priority",
"start": [
226,
1
],
"end": [
228,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getInstanceAttrKind?",
"code": "def getInstanceAttrKind? (declName : Name) : CoreM (Option AttributeKind) := do\n let some entry := Meta.instanceExtension.getState (β getEnv) |>.instanceNames.find? declName | return none\n return entry.attrKind",
"start": [
230,
1
],
"end": [
232,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DefaultInstanceEntry",
"code": "structure DefaultInstanceEntry where\n className : Name\n instanceName : Name\n priority : Nat",
"start": [
236,
1
],
"end": [
239,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.PrioritySet",
"code": "abbrev PrioritySet := RBTree Nat (fun x y => compare y x)",
"start": [
241,
1
],
"end": [
241,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DefaultInstances",
"code": "structure DefaultInstances where\n defaultInstances : NameMap (List (Name Γ Nat)) := {}\n priorities : PrioritySet := {}\n deriving Inhabited",
"start": [
243,
1
],
"end": [
246,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addDefaultInstanceEntry",
"code": "def addDefaultInstanceEntry (d : DefaultInstances) (e : DefaultInstanceEntry) : DefaultInstances :=\n let d := { d with priorities := d.priorities.insert e.priority }\n match d.defaultInstances.find? e.className with\n | some insts => { d with defaultInstances := d.defaultInstances.insert e.className <| (e.instanceName, e.priority) :: insts }\n | none => { d with defaultInstances := d.defaultInstances.insert e.className [(e.instanceName, e.priority)] }",
"start": [
248,
1
],
"end": [
252,
118
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addDefaultInstance",
"code": "def addDefaultInstance (declName : Name) (prio : Nat := 0) : MetaM Unit := do\n match (β getEnv).find? declName with\n | none => throwError \"unknown constant '{declName}'\"\n | some info =>\n forallTelescopeReducing info.type fun _ type => do\n match type.getAppFn with\n | Expr.const className _ =>\n unless isClass (β getEnv) className do\n throwError \"invalid default instance '{declName}', it has type '({className} ...)', but {className}' is not a type class\"\n setEnv <| defaultInstanceExtension.addEntry (β getEnv) { className := className, instanceName := declName, priority := prio }\n | _ => throwError \"invalid default instance '{declName}', type must be of the form '(C ...)' where 'C' is a type class\"",
"start": [
260,
1
],
"end": [
270,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getDefaultInstancesPriorities",
"code": "def getDefaultInstancesPriorities [Monad m] [MonadEnv m] : m PrioritySet :=\n return defaultInstanceExtension.getState (β getEnv) |>.priorities",
"start": [
283,
1
],
"end": [
284,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getDefaultInstances",
"code": "def getDefaultInstances [Monad m] [MonadEnv m] (className : Name) : m (List (Name Γ Nat)) :=\n return defaultInstanceExtension.getState (β getEnv) |>.defaultInstances.find? className |>.getD []",
"start": [
286,
1
],
"end": [
287,
101
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Util.lean | [
".lake/packages/lean4/src/lean/Lean/KeyedDeclsAttribute.lean",
".lake/packages/lean4/src/lean/Lean/Elab/Exception.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Command.lean"
] | [
{
"full_name": "Lean.Syntax.prettyPrint",
"code": "def Syntax.prettyPrint (stx : Syntax) : Format :=\n match stx.unsetTrailing.reprint with | some str => format str.toFormat\n | none => format stx",
"start": [
13,
1
],
"end": [
16,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MacroScopesView.format",
"code": "def MacroScopesView.format (view : MacroScopesView) (mainModule : Name) : Format :=\n Std.format <|\n if view.scopes.isEmpty then\n view.name\n else if view.mainModule == mainModule then\n view.scopes.foldl Name.mkNum (view.name ++ view.imported)\n else\n view.scopes.foldl Name.mkNum (view.name ++ view.imported ++ view.mainModule)",
"start": [
18,
1
],
"end": [
25,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MacroScopesView.equalScope",
"code": "def MacroScopesView.equalScope (a b : MacroScopesView) : Bool :=\n a.scopes == b.scopes && a.mainModule == b.mainModule && a.imported == b.imported",
"start": [
27,
1
],
"end": [
32,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.expandOptNamedPrio",
"code": "def expandOptNamedPrio (stx : Syntax) : MacroM Nat :=\n if stx.isNone then\n return eval_prio default\n else match stx[0] with\n | `(Parser.Command.namedPrio| (priority := $prio)) => evalPrio prio\n | _ => Macro.throwUnsupported",
"start": [
36,
1
],
"end": [
41,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.MacroStackElem",
"code": "structure MacroStackElem where\n before : Syntax\n after : Syntax",
"start": [
43,
1
],
"end": [
45,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.MacroStack",
"code": "abbrev MacroStack := List MacroStackElem",
"start": [
47,
1
],
"end": [
47,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.getBetterRef",
"code": "def getBetterRef (ref : Syntax) (macroStack : MacroStack) : Syntax :=\n match ref.getPos? with\n | some _ => ref\n | none =>\n match macroStack.find? (Β·.before.getPos? != none) with\n | some elem => elem.before\n | none => ref",
"start": [
49,
1
],
"end": [
56,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.addMacroStack",
"code": "def addMacroStack {m} [Monad m] [MonadOptions m] (msgData : MessageData) (macroStack : MacroStack) : m MessageData := do\n if !pp.macroStack.get (β getOptions) then pure msgData else\n match macroStack with\n | [] => pure msgData\n | stack@(top::_) =>\n let msgData := msgData ++ Format.line ++ \"with resulting expansion\" ++ indentD top.after\n pure $ stack.foldl\n (fun (msgData : MessageData) (elem : MacroStackElem) =>\n msgData ++ Format.line ++ \"while expanding\" ++ indentD elem.before)\n msgData",
"start": [
64,
1
],
"end": [
73,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.checkSyntaxNodeKind",
"code": "def checkSyntaxNodeKind [Monad m] [MonadEnv m] [MonadError m] (k : Name) : m Name := do\n if Parser.isValidSyntaxNodeKind (β getEnv) k then pure k\n else throwError \"failed\"",
"start": [
75,
1
],
"end": [
77,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.checkSyntaxNodeKindAtNamespaces",
"code": "def checkSyntaxNodeKindAtNamespaces [Monad m] [MonadEnv m] [MonadError m] (k : Name) : Name β m Name\n | n@(.str p _) => checkSyntaxNodeKind (n ++ k) <|> checkSyntaxNodeKindAtNamespaces k p\n | .anonymous => checkSyntaxNodeKind k\n | _ => throwError \"failed\"",
"start": [
79,
1
],
"end": [
82,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.checkSyntaxNodeKindAtCurrentNamespaces",
"code": "def checkSyntaxNodeKindAtCurrentNamespaces (k : Name) : AttrM Name := do\n let ctx β read\n checkSyntaxNodeKindAtNamespaces k ctx.currNamespace",
"start": [
84,
1
],
"end": [
86,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.syntaxNodeKindOfAttrParam",
"code": "def syntaxNodeKindOfAttrParam (defaultParserNamespace : Name) (stx : Syntax) : AttrM SyntaxNodeKind := do\n let k β Attribute.Builtin.getId stx\n checkSyntaxNodeKindAtCurrentNamespaces k\n <|>\n checkSyntaxNodeKind (defaultParserNamespace ++ k)\n <|>\n throwError \"invalid syntax node kind '{k}'\"",
"start": [
88,
1
],
"end": [
94,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.evalSyntaxConstantUnsafe",
"code": "private unsafe def evalSyntaxConstantUnsafe (env : Environment) (opts : Options) (constName : Name) : ExceptT String Id Syntax :=\n env.evalConstCheck Syntax opts `Lean.Syntax constName",
"start": [
96,
1
],
"end": [
97,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.evalSyntaxConstant",
"code": "@[implemented_by evalSyntaxConstantUnsafe]\nopaque evalSyntaxConstant (env : Environment) (opts : Options) (constName : Name) : ExceptT String Id Syntax := throw \"\"",
"start": [
99,
1
],
"end": [
100,
121
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkElabAttribute",
"code": "unsafe def mkElabAttribute (Ξ³) (attrBuiltinName attrName : Name) (parserNamespace : Name) (typeName : Name) (kind : String)\n (attrDeclName : Name := by exact decl_name%) : IO (KeyedDeclsAttribute Ξ³) :=\n KeyedDeclsAttribute.init {\n builtinName := attrBuiltinName\n name := attrName\n descr := kind ++ \" elaborator\"\n valueTypeName := typeName\n evalKey := fun _ stx => do\n let kind β syntaxNodeKindOfAttrParam parserNamespace stx\n \n if (β getEnv).contains kind && (β getInfoState).enabled then\n addConstInfo stx[1] kind none\n return kind\n onAdded := fun builtin declName => do\n if builtin then\n declareBuiltinDocStringAndRanges declName\n } attrDeclName",
"start": [
102,
1
],
"end": [
118,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkMacroAttributeUnsafe",
"code": "unsafe def mkMacroAttributeUnsafe (ref : Name) : IO (KeyedDeclsAttribute Macro) :=\n mkElabAttribute Macro `builtin_macro `macro Name.anonymous `Lean.Macro \"macro\" ref",
"start": [
120,
1
],
"end": [
121,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkMacroAttribute",
"code": "@[implemented_by mkMacroAttributeUnsafe]\nopaque mkMacroAttribute (ref : Name) : IO (KeyedDeclsAttribute Macro)",
"start": [
123,
1
],
"end": [
124,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.expandMacroImpl?",
"code": "def expandMacroImpl? (env : Environment) : Syntax β MacroM (Option (Name Γ Except Macro.Exception Syntax)) := fun stx => do\n for e in macroAttribute.getEntries env stx.getKind do\n try\n let stx' β withFreshMacroScope (e.value stx)\n return (e.declName, Except.ok stx')\n catch\n | Macro.Exception.unsupportedSyntax => pure ()\n | ex => return (e.declName, Except.error ex)\n return none",
"start": [
128,
1
],
"end": [
140,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.MonadMacroAdapter",
"code": "class MonadMacroAdapter (m : Type β Type) where\n getCurrMacroScope : m MacroScope\n getNextMacroScope : m MacroScope\n setNextMacroScope : MacroScope β m Unit",
"start": [
142,
1
],
"end": [
145,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.liftMacroM",
"code": "def liftMacroM [Monad m] [MonadMacroAdapter m] [MonadEnv m] [MonadRecDepth m] [MonadError m] [MonadResolveName m] [MonadTrace m] [MonadOptions m] [AddMessageContext m] [MonadLiftT IO m] (x : MacroM Ξ±) : m Ξ± := do\n let env β getEnv\n let currNamespace β getCurrNamespace\n let openDecls β getOpenDecls\n let methods := Macro.mkMethods {\n expandMacro? := fun stx => do\n match (β expandMacroImpl? env stx) with\n | some (_, stx?) => liftExcept stx?\n | none => return none\n hasDecl := fun declName => return env.contains declName\n getCurrNamespace := return currNamespace\n resolveNamespace := fun n => return ResolveName.resolveNamespace env currNamespace openDecls n\n resolveGlobalName := fun n => return ResolveName.resolveGlobalName env currNamespace openDecls n\n }\n match x { methods := methods\n ref := β getRef\n currMacroScope := β MonadMacroAdapter.getCurrMacroScope\n mainModule := env.mainModule\n currRecDepth := β MonadRecDepth.getRecDepth\n maxRecDepth := β MonadRecDepth.getMaxRecDepth\n } { macroScope := (β MonadMacroAdapter.getNextMacroScope) } with\n | EStateM.Result.error Macro.Exception.unsupportedSyntax _ => throwUnsupportedSyntax\n | EStateM.Result.error (Macro.Exception.error ref msg) _ =>\n if msg == maxRecDepthErrorMessage then\n throwMaxRecDepthAt ref\n else\n throwErrorAt ref msg\n | EStateM.Result.ok a s =>\n MonadMacroAdapter.setNextMacroScope s.macroScope\n s.traceMsgs.reverse.forM fun (clsName, msg) => trace clsName fun _ => msg\n return a",
"start": [
154,
1
],
"end": [
186,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.adaptMacro",
"code": "@[inline] def adaptMacro {m : Type β Type} [Monad m] [MonadMacroAdapter m] [MonadEnv m] [MonadRecDepth m] [MonadError m] [MonadResolveName m] [MonadTrace m] [MonadOptions m] [AddMessageContext m] [MonadLiftT IO m] (x : Macro) (stx : Syntax) : m Syntax :=\n liftMacroM (x stx)",
"start": [
188,
1
],
"end": [
189,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkUnusedBaseName",
"code": "partial def mkUnusedBaseName (baseName : Name) : MacroM Name := do\n let currNamespace β Macro.getCurrNamespace\n if β Macro.hasDecl (currNamespace ++ baseName) then\n let rec loop (idx : Nat) := do\n let name := baseName.appendIndexAfter idx\n if β Macro.hasDecl (currNamespace ++ name) then\n loop (idx+1)\n else\n return name\n loop 1\n else\n return baseName",
"start": [
191,
1
],
"end": [
202,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.logException",
"code": "def logException [Monad m] [MonadLog m] [AddMessageContext m] [MonadOptions m] [MonadLiftT IO m] (ex : Exception) : m Unit := do\n match ex with\n | Exception.error ref msg => logErrorAt ref msg\n | Exception.internal id _ =>\n unless isAbortExceptionId id || id == Core.interruptExceptionId do\n let name β id.getName\n logError m!\"internal exception: {name}\"",
"start": [
204,
1
],
"end": [
210,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.withLogging",
"code": "def withLogging [Monad m] [MonadLog m] [MonadExcept Exception m] [AddMessageContext m] [MonadOptions m] [MonadLiftT IO m]\n (x : m Unit) : m Unit := do\n try x catch ex => logException ex",
"start": [
212,
1
],
"end": [
217,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.nestedExceptionToMessageData",
"code": "def nestedExceptionToMessageData [Monad m] [MonadLog m] (ex : Exception) : m MessageData := do\n let pos β getRefPos\n match ex.getRef.getPos? with\n | none => return ex.toMessageData\n | some exPos =>\n if pos == exPos then\n return ex.toMessageData\n else\n let exPosition := (β getFileMap).toPosition exPos\n return m!\"{exPosition.line}:{exPosition.column} {ex.toMessageData}\"",
"start": [
219,
1
],
"end": [
228,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwErrorWithNestedErrors",
"code": "def throwErrorWithNestedErrors [MonadError m] [Monad m] [MonadLog m] (msg : MessageData) (exs : Array Exception) : m Ξ± := do\n throwError \"{msg}, errors {toMessageList (β exs.mapM fun | ex => nestedExceptionToMessageData ex)}\"",
"start": [
230,
1
],
"end": [
231,
102
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/DecLevel.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.DecLevelContext",
"code": "structure DecLevelContext where\n \n canAssignMVars : Bool := true",
"start": [
12,
1
],
"end": [
17,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.decAux?",
"code": "private partial def decAux? : Level β ReaderT DecLevelContext MetaM (Option Level)\n | Level.zero => return none\n | Level.param _ => return none\n | Level.mvar mvarId => do\n match (β getLevelMVarAssignment? mvarId) with\n | some u => decAux? u\n | none =>\n if (β mvarId.isReadOnly) || !(β read).canAssignMVars then\n return none\n else\n let u β mkFreshLevelMVar\n trace[Meta.isLevelDefEq.step] \"decAux?, {mkLevelMVar mvarId} := {mkLevelSucc u}\"\n assignLevelMVar mvarId (mkLevelSucc u)\n return u\n | Level.succ u => return u\n | u =>\n let processMax (u v : Level) : ReaderT DecLevelContext MetaM (Option Level) := do\n \n withReader (fun _ => { canAssignMVars := false }) do\n match (β decAux? u) with\n | none => return none\n | some u => do\n match (β decAux? v) with\n | none => return none\n | some v => return mkLevelMax' u v\n match u with\n | Level.max u v => processMax u v\n \n | Level.imax u v => processMax u v\n | _ => unreachable!",
"start": [
19,
1
],
"end": [
52,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.decLevel?",
"code": "def decLevel? (u : Level) : MetaM (Option Level) := do\n let mctx β getMCtx\n match (β decAux? u |>.run {}) with\n | some v => return some v\n | none => do\n modify fun s => { s with mctx := mctx }\n return none",
"start": [
54,
1
],
"end": [
60,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.decLevel",
"code": "def decLevel (u : Level) : MetaM Level := do\n match (β decLevel? u) with\n | some u => return u\n | none => throwError \"invalid universe level, {u} is not greater than 0\"",
"start": [
62,
1
],
"end": [
65,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getDecLevel",
"code": "def getDecLevel (type : Expr) : MetaM Level := do\n decLevel (β getLevel type)",
"start": [
67,
1
],
"end": [
71,
29
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/SynthInstance.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Instances.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AbstractMVars.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/InsertionSort.lean",
".lake/packages/lean4/src/lean/Lean/Util/Profile.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Check.lean"
] | [
{
"full_name": "Lean.Meta.SynthInstance.getMaxHeartbeats",
"code": "def getMaxHeartbeats (opts : Options) : Nat :=\n synthInstance.maxHeartbeats.get opts * 1000",
"start": [
36,
1
],
"end": [
37,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.Instance",
"code": "structure Instance where\n val : Expr\n synthOrder : Array Nat\n deriving Inhabited",
"start": [
39,
1
],
"end": [
42,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.GeneratorNode",
"code": "structure GeneratorNode where\n mvar : Expr\n key : Expr\n mctx : MetavarContext\n instances : Array Instance\n currInstanceIdx : Nat\n \n typeHasMVars : Bool\n deriving Inhabited",
"start": [
44,
1
],
"end": [
58,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.ConsumerNode",
"code": "structure ConsumerNode where\n mvar : Expr\n key : Expr\n mctx : MetavarContext\n subgoals : List Expr\n size : Nat deriving Inhabited",
"start": [
60,
1
],
"end": [
66,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.Waiter",
"code": "inductive Waiter where\n | consumerNode : ConsumerNode β Waiter\n | root : Waiter",
"start": [
68,
1
],
"end": [
70,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.Waiter.isRoot",
"code": "def Waiter.isRoot : Waiter β Bool\n | .consumerNode _ => false\n | .root => true",
"start": [
72,
1
],
"end": [
74,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.MkTableKey.State",
"code": "structure State where\n nextIdx : Nat := 0\n lmap : HashMap LMVarId Level := {}\n emap : HashMap MVarId Expr := {}\n mctx : MetavarContext",
"start": [
98,
1
],
"end": [
102,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.MkTableKey.M",
"code": "abbrev M := StateM State",
"start": [
104,
1
],
"end": [
104,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.MkTableKey.normLevel",
"code": "partial def normLevel (u : Level) : M Level := do\n if !u.hasMVar then\n return u\n else match u with\n | .succ v => return u.updateSucc! (β normLevel v)\n | .max v w => return u.updateMax! (β normLevel v) (β normLevel w)\n | .imax v w => return u.updateIMax! (β normLevel v) (β normLevel w)\n | .mvar mvarId =>\n if (β getMCtx).getLevelDepth mvarId != (β getMCtx).depth then\n return u\n else\n let s β get\n match (β get).lmap.find? mvarId with\n | some u' => pure u'\n | none =>\n let u' := mkLevelParam <| Name.mkNum `_tc s.nextIdx\n modify fun s => { s with nextIdx := s.nextIdx + 1, lmap := s.lmap.insert mvarId u' }\n return u'\n | u => return u",
"start": [
111,
1
],
"end": [
129,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.MkTableKey.normExpr",
"code": "partial def normExpr (e : Expr) : M Expr := do\n if !e.hasMVar then\n pure e\n else match e with\n | .const _ us => return e.updateConst! (β us.mapM normLevel)\n | .sort u => return e.updateSort! (β normLevel u)\n | .app f a => return e.updateApp! (β normExpr f) (β normExpr a)\n | .letE _ t v b _ => return e.updateLet! (β normExpr t) (β normExpr v) (β normExpr b)\n | .forallE _ d b _ => return e.updateForallE! (β normExpr d) (β normExpr b)\n | .lam _ d b _ => return e.updateLambdaE! (β normExpr d) (β normExpr b)\n | .mdata _ b => return e.updateMData! (β normExpr b)\n | .proj _ _ b => return e.updateProj! (β normExpr b)\n | .mvar mvarId =>\n if !(β mvarId.isAssignable) then\n return e\n else\n let s β get\n match s.emap.find? mvarId with\n | some e' => pure e'\n | none => do\n let e' := mkFVar { name := Name.mkNum `_tc s.nextIdx }\n modify fun s => { s with nextIdx := s.nextIdx + 1, emap := s.emap.insert mvarId e' }\n return e'\n | _ => return e",
"start": [
131,
1
],
"end": [
154,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.mkTableKey",
"code": "def mkTableKey [Monad m] [MonadMCtx m] (e : Expr) : m Expr := do\n let (r, s) := MkTableKey.normExpr e |>.run { mctx := (β getMCtx) }\n setMCtx s.mctx\n return r",
"start": [
158,
1
],
"end": [
162,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.Answer",
"code": "structure Answer where\n result : AbstractMVarsResult\n resultType : Expr\n size : Nat\n deriving Inhabited",
"start": [
164,
1
],
"end": [
168,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.TableEntry",
"code": "structure TableEntry where\n waiters : Array Waiter\n answers : Array Answer := #[]",
"start": [
170,
1
],
"end": [
172,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.Context",
"code": "structure Context where\n maxResultSize : Nat\n maxHeartbeats : Nat",
"start": [
174,
1
],
"end": [
176,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.State",
"code": "structure State where\n result? : Option AbstractMVarsResult := none\n generatorStack : Array GeneratorNode := #[]\n resumeStack : Array (ConsumerNode Γ Answer) := #[]\n tableEntries : HashMap Expr TableEntry := {}",
"start": [
178,
1
],
"end": [
189,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.SynthM",
"code": "abbrev SynthM := ReaderT Context $ StateRefT State MetaM",
"start": [
191,
1
],
"end": [
191,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.checkSystem",
"code": "def checkSystem : SynthM Unit := do\n Core.checkInterrupted\n Core.checkMaxHeartbeatsCore \"typeclass\" `synthInstance.maxHeartbeats (β read).maxHeartbeats",
"start": [
193,
1
],
"end": [
195,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.getInstances",
"code": "def getInstances (type : Expr) : MetaM (Array Instance) := do\n let localInstances β getLocalInstances\n forallTelescopeReducing type fun _ type => do\n let className? β isClass? type\n match className? with\n | none => throwError \"type class instance expected{indentExpr type}\"\n | some className =>\n let globalInstances β getGlobalInstancesIndex\n let result β globalInstances.getUnify type tcDtConfig\n let result := result.insertionSort fun eβ eβ => eβ.priority < eβ.priority\n let erasedInstances β getErasedInstances\n let mut result β result.filterMapM fun e => match e.val with\n | .const constName us =>\n if erasedInstances.contains constName then\n return none\n else\n return some {\n val := e.val.updateConst! (β us.mapM (fun _ => mkFreshLevelMVar))\n synthOrder := e.synthOrder\n }\n | _ => panic! \"global instance is not a constant\"\n for linst in localInstances do\n if linst.className == className then\n let synthOrder β forallTelescopeReducing (β inferType linst.fvar) fun xs _ => do\n if xs.isEmpty then return #[]\n let mut order := #[]\n for i in [:xs.size], x in xs do\n if (β getFVarLocalDecl x).binderInfo == .instImplicit then\n order := order.push i\n return order\n result := result.push { val := linst.fvar, synthOrder }\n trace[Meta.synthInstance.instances] result.map (Β·.val)\n return result",
"start": [
200,
1
],
"end": [
236,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.mkGeneratorNode?",
"code": "def mkGeneratorNode? (key mvar : Expr) : MetaM (Option GeneratorNode) := do\n let mvarType β inferType mvar\n let mvarType β instantiateMVars mvarType\n let instances β getInstances mvarType\n if instances.isEmpty then\n return none\n else\n let mctx β getMCtx\n return some {\n mvar, key, mctx, instances\n typeHasMVars := mvarType.hasMVar\n currInstanceIdx := instances.size\n }",
"start": [
238,
1
],
"end": [
250,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.newSubgoal",
"code": "def newSubgoal (mctx : MetavarContext) (key : Expr) (mvar : Expr) (waiter : Waiter) : SynthM Unit :=\n withMCtx mctx do withTraceNode' `Meta.synthInstance do\n match (β mkGeneratorNode? key mvar) with\n | none => pure ((), m!\"no instances for {key}\")\n | some node =>\n let entry : TableEntry := { waiters := #[waiter] }\n modify fun s =>\n { s with\n generatorStack := s.generatorStack.push node\n tableEntries := s.tableEntries.insert key entry }\n pure ((), m!\"new goal {key}\")",
"start": [
252,
1
],
"end": [
265,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.findEntry?",
"code": "def findEntry? (key : Expr) : SynthM (Option TableEntry) := do\n return (β get).tableEntries.find? key",
"start": [
267,
1
],
"end": [
268,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.getEntry",
"code": "def getEntry (key : Expr) : SynthM TableEntry := do\n match (β findEntry? key) with\n | none => panic! \"invalid key at synthInstance\"\n | some entry => pure entry",
"start": [
270,
1
],
"end": [
273,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.mkTableKeyFor",
"code": "def mkTableKeyFor (mctx : MetavarContext) (mvar : Expr) : SynthM Expr :=\n withMCtx mctx do\n let mvarType β inferType mvar\n let mvarType β instantiateMVars mvarType\n mkTableKey mvarType",
"start": [
275,
1
],
"end": [
284,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.SubgoalsResult",
"code": "structure SubgoalsResult where\n subgoals : List Expr\n instVal : Expr\n instTypeBody : Expr",
"start": [
286,
1
],
"end": [
295,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.getSubgoals",
"code": "def getSubgoals (lctx : LocalContext) (localInsts : LocalInstances) (xs : Array Expr) (inst : Instance) : MetaM SubgoalsResult := do\n let mut instVal := inst.val\n let mut instType β inferType instVal\n let mut mvars := #[]\n let mut subst := #[]\n repeat do\n if let .forallE _ d b _ := instType then\n let d := d.instantiateRev subst\n let mvar β mkFreshExprMVarAt lctx localInsts (β mkForallFVars xs d)\n subst := subst.push (mkAppN mvar xs)\n instVal := mkApp instVal (mkAppN mvar xs)\n instType := b\n mvars := mvars.push mvar\n else\n instType β whnf (instType.instantiateRev subst)\n instVal := instVal.instantiateRev subst\n subst := #[]\n unless instType.isForall do break\n return {\n instVal := instVal.instantiateRev subst\n instTypeBody := instType.instantiateRev subst\n subgoals := inst.synthOrder.map (mvars[Β·]!) |>.toList\n }",
"start": [
297,
1
],
"end": [
334,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.tryResolve",
"code": "def tryResolve (mvar : Expr) (inst : Instance) : MetaM (Option (MetavarContext Γ List Expr)) := do\n if (β isDiagnosticsEnabled) then\n if let .const declName _ := inst.val.getAppFn then\n recordInstance declName\n let mvarType β inferType mvar\n let lctx β getLCtx\n let localInsts β getLocalInstances\n forallTelescopeReducing mvarType fun xs mvarTypeBody => do\n let { subgoals, instVal, instTypeBody } β getSubgoals lctx localInsts xs inst\n withTraceNode `Meta.synthInstance.tryResolve (withMCtx (β getMCtx) do\n return m!\"{exceptOptionEmoji Β·} {β instantiateMVars mvarTypeBody} β {β instantiateMVars instTypeBody}\") do\n if (β isDefEq mvarTypeBody instTypeBody) then\n \n let instVal β mkLambdaFVars xs instVal (etaReduce := true)\n if (β isDefEq mvar instVal) then\n return some ((β getMCtx), subgoals)\n return none",
"start": [
336,
1
],
"end": [
372,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.tryAnswer",
"code": "def tryAnswer (mctx : MetavarContext) (mvar : Expr) (answer : Answer) : SynthM (Option MetavarContext) :=\n withMCtx mctx do\n let (_, _, val) β openAbstractMVarsResult answer.result\n if (β isDefEq mvar val) then\n return some (β getMCtx)\n else\n return none",
"start": [
374,
1
],
"end": [
383,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.wakeUp",
"code": "def wakeUp (answer : Answer) : Waiter β SynthM Unit\n | .root => do\n \n if answer.result.numMVars == 0 then\n modify fun s => { s with result? := answer.result }\n else\n let (_, _, answerExpr) β openAbstractMVarsResult answer.result\n trace[Meta.synthInstance] \"skip answer containing metavariables {answerExpr}\"\n | .consumerNode cNode =>\n modify fun s => { s with resumeStack := s.resumeStack.push (cNode, answer) }",
"start": [
385,
1
],
"end": [
398,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.isNewAnswer",
"code": "def isNewAnswer (oldAnswers : Array Answer) (answer : Answer) : Bool :=\n oldAnswers.all fun oldAnswer =>\n oldAnswer.resultType != answer.resultType",
"start": [
400,
1
],
"end": [
404,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.mkAnswer",
"code": "private def mkAnswer (cNode : ConsumerNode) : MetaM Answer :=\n withMCtx cNode.mctx do\n let val β instantiateMVars cNode.mvar\n trace[Meta.synthInstance.newAnswer] \"size: {cNode.size}, val: {val}\"\n let result β abstractMVars val let resultType β inferType result.expr\n return { result, resultType, size := cNode.size + 1 }",
"start": [
406,
1
],
"end": [
412,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.addAnswer",
"code": "def addAnswer (cNode : ConsumerNode) : SynthM Unit := do\n withMCtx cNode.mctx do\n if cNode.size β₯ (β read).maxResultSize then\n trace[Meta.synthInstance.answer] \"{crossEmoji} {β instantiateMVars (β inferType cNode.mvar)}{Format.line}(size: {cNode.size} β₯ {(β read).maxResultSize})\"\n else\n withTraceNode `Meta.synthInstance.answer\n (fun _ => return m!\"{checkEmoji} {β instantiateMVars (β inferType cNode.mvar)}\") do\n let answer β mkAnswer cNode\n let key := cNode.key\n let { waiters, answers } β getEntry key\n if isNewAnswer answers answer then\n let newEntry := { waiters, answers := answers.push answer }\n modify fun s => { s with tableEntries := s.tableEntries.insert key newEntry }\n waiters.forM (wakeUp answer)",
"start": [
414,
1
],
"end": [
432,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.hasUnusedArguments",
"code": "private def hasUnusedArguments : Expr β Bool\n | .forallE _ _ b _ => !b.hasLooseBVar 0 || hasUnusedArguments b\n | _ => false",
"start": [
434,
1
],
"end": [
441,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.removeUnusedArguments?",
"code": "private def removeUnusedArguments? (mctx : MetavarContext) (mvar : Expr) : MetaM (Option (Expr Γ Expr)) :=\n withMCtx mctx do\n let mvarType β instantiateMVars (β inferType mvar)\n if !hasUnusedArguments mvarType then\n return none\n else\n forallTelescope mvarType fun xs body => do\n let ys β xs.foldrM (init := []) fun x ys => do\n if body.containsFVar x.fvarId! then\n return x :: ys\n else if (β ys.anyM fun y => return (β inferType y).containsFVar x.fvarId!) then\n return x :: ys\n else\n return ys\n let ys := ys.toArray\n let mvarType' β mkForallFVars ys body\n withLocalDeclD `redf mvarType' fun f => do\n let transformer β mkLambdaFVars #[f] (β mkLambdaFVars xs (mkAppN f ys) (etaReduce := true)) (etaReduce := true)\n trace[Meta.synthInstance.unusedArgs] \"{mvarType}\\nhas unused arguments, reduced type{indentExpr mvarType'}\\nTransformer{indentExpr transformer}\"\n return some (mvarType', transformer)",
"start": [
443,
1
],
"end": [
484,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.consume",
"code": "def consume (cNode : ConsumerNode) : SynthM Unit := do\n \n let cNode := { cNode with\n subgoals := β withMCtx cNode.mctx do\n cNode.subgoals.filterM (not <$> Β·.mvarId!.isAssigned)\n }\n match cNode.subgoals with\n | [] => addAnswer cNode\n | mvar::_ =>\n let waiter := Waiter.consumerNode cNode\n let key β mkTableKeyFor cNode.mctx mvar\n let entry? β findEntry? key\n match entry? with\n | none =>\n match (β removeUnusedArguments? cNode.mctx mvar) with\n | none => newSubgoal cNode.mctx key mvar waiter\n | some (mvarType', transformer) =>\n let key' β withMCtx cNode.mctx <| mkTableKey mvarType'\n match (β findEntry? key') with\n | none =>\n let (mctx', mvar') β withMCtx cNode.mctx do\n let mvar' β mkFreshExprMVar mvarType'\n return (β getMCtx, mvar')\n newSubgoal mctx' key' mvar' (Waiter.consumerNode { cNode with mctx := mctx', subgoals := mvar'::cNode.subgoals })\n | some entry' =>\n let answers' β entry'.answers.mapM fun a => withMCtx cNode.mctx do\n let trAnswr := Expr.betaRev transformer #[β instantiateMVars a.result.expr]\n let trAnswrType β inferType trAnswr\n pure { a with result.expr := trAnswr, resultType := trAnswrType }\n modify fun s =>\n { s with\n resumeStack := answers'.foldl (fun s answer => s.push (cNode, answer)) s.resumeStack,\n tableEntries := s.tableEntries.insert key' { entry' with waiters := entry'.waiters.push waiter } }\n | some entry => modify fun s =>\n { s with\n resumeStack := entry.answers.foldl (fun s answer => s.push (cNode, answer)) s.resumeStack,\n tableEntries := s.tableEntries.insert key { entry with waiters := entry.waiters.push waiter } }",
"start": [
486,
1
],
"end": [
534,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.getTop",
"code": "def getTop : SynthM GeneratorNode :=\n return (β get).generatorStack.back",
"start": [
536,
1
],
"end": [
537,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.modifyTop",
"code": "@[inline] def modifyTop (f : GeneratorNode β GeneratorNode) : SynthM Unit :=\n modify fun s => { s with generatorStack := s.generatorStack.modify (s.generatorStack.size - 1) f }",
"start": [
539,
1
],
"end": [
540,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.generate",
"code": "def generate : SynthM Unit := do\n let gNode β getTop\n if gNode.currInstanceIdx == 0 then\n modify fun s => { s with generatorStack := s.generatorStack.pop }\n else\n let key := gNode.key\n let idx := gNode.currInstanceIdx - 1\n let inst := gNode.instances.get! idx\n let mctx := gNode.mctx\n let mvar := gNode.mvar\n \n if backward.synthInstance.canonInstances.get (β getOptions) then\n unless gNode.typeHasMVars do\n if let some entry := (β get).tableEntries.find? key then\n if entry.answers.any fun answer => answer.result.numMVars == 0 then\n \n modify fun s => { s with generatorStack := s.generatorStack.pop }\n return\n discard do withMCtx mctx do\n withTraceNode `Meta.synthInstance\n (return m!\"{exceptOptionEmoji Β·} apply {inst.val} to {β instantiateMVars (β inferType mvar)}\") do\n modifyTop fun gNode => { gNode with currInstanceIdx := idx }\n if let some (mctx, subgoals) β tryResolve mvar inst then\n consume { key, mvar, subgoals, mctx, size := 0 }\n return some ()\n return none",
"start": [
542,
1
],
"end": [
578,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.getNextToResume",
"code": "def getNextToResume : SynthM (ConsumerNode Γ Answer) := do\n let r := (β get).resumeStack.back\n modify fun s => { s with resumeStack := s.resumeStack.pop }\n return r",
"start": [
580,
1
],
"end": [
583,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.resume",
"code": "def resume : SynthM Unit := do\n let (cNode, answer) β getNextToResume\n match cNode.subgoals with\n | [] => panic! \"resume found no remaining subgoals\"\n | mvar::rest =>\n match (β tryAnswer cNode.mctx mvar answer) with\n | none => return ()\n | some mctx =>\n withMCtx mctx do\n let goal β inferType cNode.mvar\n let subgoal β inferType mvar\n withTraceNode `Meta.synthInstance.resume\n (fun _ => withMCtx cNode.mctx do\n return m!\"propagating {β instantiateMVars answer.resultType} to subgoal {β instantiateMVars subgoal} of {β instantiateMVars goal}\") do\n trace[Meta.synthInstance.resume] \"size: {cNode.size + answer.size}\"\n consume { key := cNode.key, mvar := cNode.mvar, subgoals := rest, mctx, size := cNode.size + answer.size }",
"start": [
585,
1
],
"end": [
603,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.step",
"code": "def step : SynthM Bool := do\n checkSystem\n let s β get\n if !s.resumeStack.isEmpty then\n resume\n return true\n else if !s.generatorStack.isEmpty then\n generate\n return true\n else\n return false",
"start": [
605,
1
],
"end": [
615,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.getResult",
"code": "def getResult : SynthM (Option AbstractMVarsResult) :=\n return (β get).result?",
"start": [
617,
1
],
"end": [
618,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.synth",
"code": "partial def synth : SynthM (Option AbstractMVarsResult) := do\n if (β step) then\n match (β getResult) with\n | none => synth\n | some result => return result\n else\n return none",
"start": [
620,
1
],
"end": [
626,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstance.main",
"code": "def main (type : Expr) (maxResultSize : Nat) : MetaM (Option AbstractMVarsResult) :=\n withCurrHeartbeats do\n let mvar β mkFreshExprMVar type\n let key β mkTableKey type\n let action : SynthM (Option AbstractMVarsResult) := do\n newSubgoal (β getMCtx) key mvar Waiter.root\n synth\n tryCatchRuntimeEx\n (action.run { maxResultSize := maxResultSize, maxHeartbeats := getMaxHeartbeats (β getOptions) } |>.run' {})\n fun ex =>\n if ex.isRuntime then\n throwError \"failed to synthesize{indentExpr type}\\n{ex.toMessageData}\\n{useDiagnosticMsg}\"\n else\n throw ex",
"start": [
628,
1
],
"end": [
641,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.preprocess",
"code": "private def preprocess (type : Expr) : MetaM Expr :=\n forallTelescopeReducing type fun xs type => do\n let type β whnf type\n mkForallFVars xs type",
"start": [
658,
1
],
"end": [
661,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.preprocessArgs",
"code": "private partial def preprocessArgs (type : Expr) (i : Nat) (args : Array Expr) (outParamsPos : Array Nat) : MetaM (Array Expr) := do\n if h : i < args.size then\n let type β whnf type\n match type with\n | .forallE _ d b _ => do\n let arg := args.get β¨i, hβ©\n \n let arg β if outParamsPos.contains i then mkFreshExprMVar d else pure arg\n let args := args.set β¨i, hβ© arg\n preprocessArgs (b.instantiate1 arg) (i+1) args outParamsPos\n | _ =>\n throwError \"type class resolution failed, insufficient number of arguments\" else\n return args",
"start": [
663,
1
],
"end": [
679,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.preprocessOutParam",
"code": "private def preprocessOutParam (type : Expr) : MetaM Expr :=\n forallTelescope type fun xs typeBody => do\n match typeBody.getAppFn with\n | c@(.const declName _) =>\n let env β getEnv\n if let some outParamsPos := getOutParamPositions? env declName then\n unless outParamsPos.isEmpty do\n let args := typeBody.getAppArgs\n let cType β inferType c\n let args β preprocessArgs cType 0 args outParamsPos\n return (β mkForallFVars xs (mkAppN c args))\n return type\n | _ =>\n return type",
"start": [
681,
1
],
"end": [
694,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.assignOutParams",
"code": "private def assignOutParams (type : Expr) (result : Expr) : MetaM Bool := do\n let resultType β inferType result\n \n let defEq β withDefault <| withAssignableSyntheticOpaque <| isDefEq type resultType\n unless defEq do\n trace[Meta.synthInstance] \"{crossEmoji} result type{indentExpr resultType}\\nis not definitionally equal to{indentExpr type}\"\n return defEq",
"start": [
701,
1
],
"end": [
709,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.applyAbstractResult?",
"code": "private def applyAbstractResult? (type : Expr) (abstResult? : Option AbstractMVarsResult) : MetaM (Option Expr) := do\n let some abstResult := abstResult? | return none\n let (_, _, result) β openAbstractMVarsResult abstResult\n unless (β assignOutParams type result) do return none\n let result β instantiateMVars result\n \n check result\n return some result",
"start": [
711,
1
],
"end": [
745,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.applyCachedAbstractResult?",
"code": "private def applyCachedAbstractResult? (type : Expr) (abstResult? : Option AbstractMVarsResult) : MetaM (Option Expr) := do\n let some abstResult := abstResult? | return none\n if abstResult.numMVars == 0 && abstResult.paramNames.isEmpty then\n \n unless (β assignOutParams type abstResult.expr) do\n return none\n return some abstResult.expr\n else\n applyAbstractResult? type abstResult?",
"start": [
747,
1
],
"end": [
763,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.cacheResult",
"code": "private def cacheResult (cacheKey : SynthInstanceCacheKey) (abstResult? : Option AbstractMVarsResult) (result? : Option Expr) : MetaM Unit := do\n match result? with\n | none => modify fun s => { s with cache.synthInstance := s.cache.synthInstance.insert cacheKey none }\n | some result =>\n let some abstResult := abstResult? | return ()\n if abstResult.numMVars == 0 && abstResult.paramNames.isEmpty then\n modify fun s => { s with cache.synthInstance := s.cache.synthInstance.insert cacheKey (some { expr := result, paramNames := #[], numMVars := 0 }) }\n else\n modify fun s => { s with cache.synthInstance := s.cache.synthInstance.insert cacheKey (some abstResult) }",
"start": [
765,
1
],
"end": [
776,
112
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.synthInstance?",
"code": "def synthInstance? (type : Expr) (maxResultSize? : Option Nat := none) : MetaM (Option Expr) := do profileitM Exception \"typeclass inference\" (β getOptions) (decl := type.getAppFn.constName?.getD .anonymous) do\n let opts β getOptions\n let maxResultSize := maxResultSize?.getD (synthInstance.maxSize.get opts)\n withTraceNode `Meta.synthInstance\n (return m!\"{exceptOptionEmoji Β·} {β instantiateMVars type}\") do\n withConfig (fun config => { config with isDefEqStuckEx := true, transparency := TransparencyMode.instances,\n foApprox := true, ctxApprox := true, constApprox := false, univApprox := false }) do\n withReader (fun ctx => { ctx with inTypeClassResolution := true }) do\n let localInsts β getLocalInstances\n let type β instantiateMVars type\n let type β preprocess type\n let cacheKey := { localInsts, type, synthPendingDepth := (β read).synthPendingDepth }\n match (β get).cache.synthInstance.find? cacheKey with\n | some abstResult? =>\n let result? β applyCachedAbstractResult? type abstResult?\n trace[Meta.synthInstance] \"result {result?} (cached)\"\n return result?\n | none =>\n let abstResult? β withNewMCtxDepth (allowLevelAssignments := true) do\n let normType β preprocessOutParam type\n SynthInstance.main normType maxResultSize\n let result? β applyAbstractResult? type abstResult?\n trace[Meta.synthInstance] \"result {result?}\"\n cacheResult cacheKey abstResult? result?\n return result?",
"start": [
778,
1
],
"end": [
802,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.trySynthInstance",
"code": "def trySynthInstance (type : Expr) (maxResultSize? : Option Nat := none) : MetaM (LOption Expr) := do\n catchInternalId isDefEqStuckExceptionId\n (toLOptionM <| synthInstance? type maxResultSize?)\n (fun _ => pure LOption.undef)",
"start": [
804,
1
],
"end": [
810,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwFailedToSynthesize",
"code": "def throwFailedToSynthesize (type : Expr) : MetaM Expr :=\n throwError \"failed to synthesize{indentExpr type}\\n{useDiagnosticMsg}\"",
"start": [
812,
1
],
"end": [
813,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.synthInstance",
"code": "def synthInstance (type : Expr) (maxResultSize? : Option Nat := none) : MetaM Expr :=\n catchInternalId isDefEqStuckExceptionId\n (do\n let result? β synthInstance? type maxResultSize?\n match result? with\n | some result => pure result\n | none => throwFailedToSynthesize type)\n (fun _ => throwFailedToSynthesize type)",
"start": [
815,
1
],
"end": [
822,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.synthPendingImp",
"code": "@[export lean_synth_pending]\nprivate def synthPendingImp (mvarId : MVarId) : MetaM Bool := withIncRecDepth <| mvarId.withContext do\n let mvarDecl β mvarId.getDecl\n match mvarDecl.kind with\n | .syntheticOpaque => return false\n | _ =>\n \n match (β isClass? mvarDecl.type) with\n | none =>\n return false\n | some _ =>\n let max := maxSynthPendingDepth.get (β getOptions)\n if (β read).synthPendingDepth > max then\n trace[Meta.synthPending] \"too many nested synthPending invocations\"\n recordSynthPendingFailure mvarDecl.type\n return false\n else\n withReader (fun ctx => { ctx with synthPendingDepth := ctx.synthPendingDepth + 1 }) do\n trace[Meta.synthPending] \"synthPending {mkMVar mvarId}\"\n let val? β catchInternalId isDefEqStuckExceptionId (synthInstance? mvarDecl.type (maxResultSize? := none)) (fun _ => pure none)\n match val? with\n | none =>\n return false\n | some val =>\n if (β mvarId.isAssigned) then\n return false\n else\n mvarId.assign val\n return true",
"start": [
824,
1
],
"end": [
853,
26
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/System/Promise.lean | [
".lake/packages/lean4/src/lean/Init/System/IO.lean"
] | [
{
"full_name": "IO.PromisePointed",
"code": "private opaque PromisePointed : NonemptyType.{0}",
"start": [
13,
1
],
"end": [
13,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.PromiseImpl",
"code": "private structure PromiseImpl (Ξ± : Type) : Type where\n prom : PromisePointed.type\n h : Nonempty Ξ±",
"start": [
15,
1
],
"end": [
17,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Promise",
"code": "def Promise (Ξ± : Type) : Type := PromiseImpl Ξ±",
"start": [
19,
1
],
"end": [
33,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Promise.new",
"code": "@[extern \"lean_io_promise_new\"]\nopaque Promise.new [Nonempty Ξ±] : BaseIO (Promise Ξ±)",
"start": [
38,
1
],
"end": [
40,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Promise.resolve",
"code": "@[extern \"lean_io_promise_resolve\"]\nopaque Promise.resolve (value : Ξ±) (promise : @& Promise Ξ±) : BaseIO Unit",
"start": [
42,
1
],
"end": [
48,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Promise.result",
"code": "@[extern \"lean_io_promise_result\"]\nopaque Promise.result (promise : Promise Ξ±) : Task Ξ± :=\n have : Nonempty Ξ± := promise.h\n Classical.choice inferInstance",
"start": [
50,
1
],
"end": [
58,
33
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Linter/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Options.lean"
] | [
{
"full_name": "Lean.Linter.getLinterAll",
"code": "def getLinterAll (o : Options) (defValue := linter.all.defValue) : Bool := o.get linter.all.name defValue",
"start": [
16,
1
],
"end": [
16,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Linter.getLinterValue",
"code": "def getLinterValue (opt : Lean.Option Bool) (o : Options) : Bool := o.get opt.name (getLinterAll o opt.defValue)",
"start": [
18,
1
],
"end": [
18,
113
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Attributes.lean | [
".lake/packages/lean4/src/lean/Lean/Elab/Util.lean"
] | [
{
"full_name": "Lean.Elab.Attribute",
"code": "structure Attribute where\n kind : AttributeKind := AttributeKind.global\n name : Name\n stx : Syntax := Syntax.missing\n deriving Inhabited",
"start": [
10,
1
],
"end": [
14,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.toAttributeKind",
"code": "def toAttributeKind (attrKindStx : Syntax) : MacroM AttributeKind := do\n if attrKindStx[0].isNone then\n return AttributeKind.global\n else if attrKindStx[0][0].getKind == ``Lean.Parser.Term.scoped then\n if (β Macro.getCurrNamespace).isAnonymous then\n throw <| Macro.Exception.error (β getRef) \"scoped attributes must be used inside namespaces\"\n return AttributeKind.scoped\n else\n return AttributeKind.local",
"start": [
24,
1
],
"end": [
37,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkAttrKindGlobal",
"code": "def mkAttrKindGlobal : Syntax :=\n mkNode ``Lean.Parser.Term.attrKind #[mkNullNode]",
"start": [
39,
1
],
"end": [
40,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.elabAttr",
"code": "def elabAttr [Monad m] [MonadEnv m] [MonadResolveName m] [MonadError m] [MonadMacroAdapter m] [MonadRecDepth m] [MonadTrace m] [MonadOptions m] [AddMessageContext m] [MonadLiftT IO m] (attrInstance : Syntax) : m Attribute := do\n \n let attrKind β liftMacroM <| toAttributeKind attrInstance[0]\n let attr := attrInstance[1]\n let attr β liftMacroM <| expandMacros attr\n let attrName β if attr.getKind == ``Parser.Attr.simple then\n pure attr[0].getId.eraseMacroScopes\n else match attr.getKind with\n | .str _ s => pure <| Name.mkSimple s\n | _ => throwErrorAt attr \"unknown attribute\"\n let .ok _impl := getAttributeImpl (β getEnv) attrName\n | throwError \"unknown attribute [{attrName}]\"\n \n return { kind := attrKind, name := attrName, stx := attr }",
"start": [
42,
1
],
"end": [
56,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.elabAttrs",
"code": "def elabAttrs [Monad m] [MonadEnv m] [MonadResolveName m] [MonadError m] [MonadMacroAdapter m] [MonadRecDepth m] [MonadTrace m] [MonadOptions m] [AddMessageContext m] [MonadLog m] [MonadLiftT IO m] (attrInstances : Array Syntax) : m (Array Attribute) := do\n let mut attrs := #[]\n for attr in attrInstances do\n try\n attrs := attrs.push (β withRef attr do elabAttr attr)\n catch ex =>\n logException ex\n return attrs",
"start": [
58,
1
],
"end": [
65,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.elabDeclAttrs",
"code": "def elabDeclAttrs [Monad m] [MonadEnv m] [MonadResolveName m] [MonadError m] [MonadMacroAdapter m] [MonadRecDepth m] [MonadTrace m] [MonadOptions m] [AddMessageContext m] [MonadLog m] [MonadLiftT IO m] (stx : Syntax) : m (Array Attribute) :=\n elabAttrs stx[1].getSepArgs",
"start": [
68,
1
],
"end": [
69,
30
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean | [
".lake/packages/lean4/src/lean/Lean/Structure.lean",
".lake/packages/lean4/src/lean/Lean/Util/Recognizers.lean",
".lake/packages/lean4/src/lean/Lean/Meta/SynthInstance.lean",
".lake/packages/lean4/src/lean/Lean/Meta/DecLevel.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Check.lean"
] | [
{
"full_name": "Lean.Meta.mkId",
"code": "def mkId (e : Expr) : MetaM Expr := do\n let type β inferType e\n let u β getLevel type\n return mkApp2 (mkConst ``id [u]) type e",
"start": [
15,
1
],
"end": [
19,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkExpectedTypeHint",
"code": "def mkExpectedTypeHint (e : Expr) (expectedType : Expr) : MetaM Expr := do\n let u β getLevel expectedType\n return mkApp2 (mkConst ``id [u]) expectedType e",
"start": [
21,
1
],
"end": [
26,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLetFun",
"code": "def mkLetFun (x : Expr) (v : Expr) (e : Expr) : MetaM Expr := do\n let f β mkLambdaFVars #[x] e\n let ety β inferType e\n let Ξ± β inferType x\n let Ξ² β mkLambdaFVars #[x] ety\n let u1 β getLevel Ξ±\n let u2 β getLevel ety\n return mkAppN (.const ``letFun [u1, u2]) #[Ξ±, Ξ², v, f]",
"start": [
28,
1
],
"end": [
39,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEq",
"code": "def mkEq (a b : Expr) : MetaM Expr := do\n let aType β inferType a\n let u β getLevel aType\n return mkApp3 (mkConst ``Eq [u]) aType a b",
"start": [
41,
1
],
"end": [
45,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHEq",
"code": "def mkHEq (a b : Expr) : MetaM Expr := do\n let aType β inferType a\n let bType β inferType b\n let u β getLevel aType\n return mkApp4 (mkConst ``HEq [u]) aType a bType b",
"start": [
47,
1
],
"end": [
52,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqHEq",
"code": "def mkEqHEq (a b : Expr) : MetaM Expr := do\n let aType β inferType a\n let bType β inferType b\n let u β getLevel aType\n if (β isDefEq aType bType) then\n return mkApp3 (mkConst ``Eq [u]) aType a b\n else\n return mkApp4 (mkConst ``HEq [u]) aType a bType b",
"start": [
54,
1
],
"end": [
64,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqRefl",
"code": "def mkEqRefl (a : Expr) : MetaM Expr := do\n let aType β inferType a\n let u β getLevel aType\n return mkApp2 (mkConst ``Eq.refl [u]) aType a",
"start": [
66,
1
],
"end": [
70,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHEqRefl",
"code": "def mkHEqRefl (a : Expr) : MetaM Expr := do\n let aType β inferType a\n let u β getLevel aType\n return mkApp2 (mkConst ``HEq.refl [u]) aType a",
"start": [
72,
1
],
"end": [
76,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAbsurd",
"code": "def mkAbsurd (e : Expr) (hp hnp : Expr) : MetaM Expr := do\n let p β inferType hp\n let u β getLevel e\n return mkApp4 (mkConst ``absurd [u]) p e hp hnp",
"start": [
78,
1
],
"end": [
82,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFalseElim",
"code": "def mkFalseElim (e : Expr) (h : Expr) : MetaM Expr := do\n let u β getLevel e\n return mkApp2 (mkConst ``False.elim [u]) e h",
"start": [
84,
1
],
"end": [
87,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.infer",
"code": "private def infer (h : Expr) : MetaM Expr := do\n let hType β inferType h\n whnfD hType",
"start": [
89,
1
],
"end": [
91,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.hasTypeMsg",
"code": "private def hasTypeMsg (e type : Expr) : MessageData :=\n m!\"{indentExpr e}\\nhas type{indentExpr type}\"",
"start": [
93,
1
],
"end": [
94,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwAppBuilderException",
"code": "private def throwAppBuilderException {Ξ±} (op : Name) (msg : MessageData) : MetaM Ξ± :=\n throwError \"AppBuilder for '{op}', {msg}\"",
"start": [
96,
1
],
"end": [
97,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqSymm",
"code": "def mkEqSymm (h : Expr) : MetaM Expr := do\n if h.isAppOf ``Eq.refl then\n return h\n else\n let hType β infer h\n match hType.eq? with\n | some (Ξ±, a, b) =>\n let u β getLevel Ξ±\n return mkApp4 (mkConst ``Eq.symm [u]) Ξ± a b h\n | none => throwAppBuilderException ``Eq.symm (\"equality proof expected\" ++ hasTypeMsg h hType)",
"start": [
99,
1
],
"end": [
109,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqTrans",
"code": "def mkEqTrans (hβ hβ : Expr) : MetaM Expr := do\n if hβ.isAppOf ``Eq.refl then\n return hβ\n else if hβ.isAppOf ``Eq.refl then\n return hβ\n else\n let hTypeβ β infer hβ\n let hTypeβ β infer hβ\n match hTypeβ.eq?, hTypeβ.eq? with\n | some (Ξ±, a, b), some (_, _, c) =>\n let u β getLevel Ξ±\n return mkApp6 (mkConst ``Eq.trans [u]) Ξ± a b c hβ hβ\n | none, _ => throwAppBuilderException ``Eq.trans (\"equality proof expected\" ++ hasTypeMsg hβ hTypeβ)\n | _, none => throwAppBuilderException ``Eq.trans (\"equality proof expected\" ++ hasTypeMsg hβ hTypeβ)",
"start": [
111,
1
],
"end": [
125,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqTrans?",
"code": "def mkEqTrans? (hβ? hβ? : Option Expr) : MetaM (Option Expr) :=\n match hβ?, hβ? with\n | none, none => return none\n | none, some h => return h\n | some h, none => return h\n | some hβ, some hβ => mkEqTrans hβ hβ",
"start": [
127,
1
],
"end": [
136,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHEqSymm",
"code": "def mkHEqSymm (h : Expr) : MetaM Expr := do\n if h.isAppOf ``HEq.refl then\n return h\n else\n let hType β infer h\n match hType.heq? with\n | some (Ξ±, a, Ξ², b) =>\n let u β getLevel Ξ±\n return mkApp5 (mkConst ``HEq.symm [u]) Ξ± Ξ² a b h\n | none =>\n throwAppBuilderException ``HEq.symm (\"heterogeneous equality proof expected\" ++ hasTypeMsg h hType)",
"start": [
138,
1
],
"end": [
149,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHEqTrans",
"code": "def mkHEqTrans (hβ hβ : Expr) : MetaM Expr := do\n if hβ.isAppOf ``HEq.refl then\n return hβ\n else if hβ.isAppOf ``HEq.refl then\n return hβ\n else\n let hTypeβ β infer hβ\n let hTypeβ β infer hβ\n match hTypeβ.heq?, hTypeβ.heq? with\n | some (Ξ±, a, Ξ², b), some (_, _, Ξ³, c) =>\n let u β getLevel Ξ±\n return mkApp8 (mkConst ``HEq.trans [u]) Ξ± Ξ² Ξ³ a b c hβ hβ\n | none, _ => throwAppBuilderException ``HEq.trans (\"heterogeneous equality proof expected\" ++ hasTypeMsg hβ hTypeβ)\n | _, none => throwAppBuilderException ``HEq.trans (\"heterogeneous equality proof expected\" ++ hasTypeMsg hβ hTypeβ)",
"start": [
151,
1
],
"end": [
165,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqOfHEq",
"code": "def mkEqOfHEq (h : Expr) : MetaM Expr := do\n let hType β infer h\n match hType.heq? with\n | some (Ξ±, a, Ξ², b) =>\n unless (β isDefEq Ξ± Ξ²) do\n throwAppBuilderException ``eq_of_heq m!\"heterogeneous equality types are not definitionally equal{indentExpr Ξ±}\\nis not definitionally equal to{indentExpr Ξ²}\"\n let u β getLevel Ξ±\n return mkApp4 (mkConst ``eq_of_heq [u]) Ξ± a b h\n | _ =>\n throwAppBuilderException ``eq_of_heq m!\"heterogeneous equality proof expected{indentExpr h}\"",
"start": [
167,
1
],
"end": [
177,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isRefl?",
"code": "def isRefl? (e : Expr) : Option Expr := do\n if e.isAppOfArity ``Eq.refl 2 then\n some e.appArg!\n else\n none",
"start": [
179,
1
],
"end": [
186,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.congrArg?",
"code": "def congrArg? (e : Expr) : MetaM (Option (Expr Γ Expr Γ Expr)) := do\n if e.isAppOfArity ``congrArg 6 then\n let #[Ξ±, _Ξ², _a, _b, f, h] := e.getAppArgs | unreachable!\n return some (Ξ±, f, h)\n if e.isAppOfArity ``congrFun 6 then\n let #[Ξ±, Ξ², _f, _g, h, a] := e.getAppArgs | unreachable!\n let Ξ±' β withLocalDecl `x .default Ξ± fun x => do\n mkForallFVars #[x] (Ξ².beta #[x])\n let f' β withLocalDecl `x .default Ξ±' fun f => do\n mkLambdaFVars #[f] (f.app a)\n return some (Ξ±', f', h)\n return none",
"start": [
188,
1
],
"end": [
203,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkCongrArg",
"code": "partial def mkCongrArg (f h : Expr) : MetaM Expr := do\n if let some a := isRefl? h then\n mkEqRefl (mkApp f a)\n else if let some (Ξ±, fβ, hβ) β congrArg? h then\n let f' β withLocalDecl `x .default Ξ± fun x => do\n mkLambdaFVars #[x] (f.beta #[fβ.beta #[x]])\n mkCongrArg f' hβ\n else\n let hType β infer h\n let fType β infer f\n match fType.arrow?, hType.eq? with\n | some (Ξ±, Ξ²), some (_, a, b) =>\n let u β getLevel Ξ±\n let v β getLevel Ξ²\n return mkApp6 (mkConst ``congrArg [u, v]) Ξ± Ξ² a b f h\n | none, _ => throwAppBuilderException ``congrArg (\"non-dependent function expected\" ++ hasTypeMsg f fType)\n | _, none => throwAppBuilderException ``congrArg (\"equality proof expected\" ++ hasTypeMsg h hType)",
"start": [
205,
1
],
"end": [
223,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkCongrFun",
"code": "def mkCongrFun (h a : Expr) : MetaM Expr := do\n if let some f := isRefl? h then\n mkEqRefl (mkApp f a)\n else if let some (Ξ±, fβ, hβ) β congrArg? h then\n let f' β withLocalDecl `x .default Ξ± fun x => do\n mkLambdaFVars #[x] (fβ.beta #[x, a])\n mkCongrArg f' hβ\n else\n let hType β infer h\n match hType.eq? with\n | some (Ο, f, g) => do\n let Ο β whnfD Ο\n match Ο with\n | Expr.forallE n Ξ± Ξ² _ =>\n let Ξ²' := Lean.mkLambda n BinderInfo.default Ξ± Ξ²\n let u β getLevel Ξ±\n let v β getLevel (mkApp Ξ²' a)\n return mkApp6 (mkConst ``congrFun [u, v]) Ξ± Ξ²' f g h a\n | _ => throwAppBuilderException ``congrFun (\"equality proof between functions expected\" ++ hasTypeMsg h hType)\n | _ => throwAppBuilderException ``congrFun (\"equality proof expected\" ++ hasTypeMsg h hType)",
"start": [
225,
1
],
"end": [
246,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkCongr",
"code": "def mkCongr (hβ hβ : Expr) : MetaM Expr := do\n if hβ.isAppOf ``Eq.refl then\n mkCongrArg hβ.appArg! hβ\n else if hβ.isAppOf ``Eq.refl then\n mkCongrFun hβ hβ.appArg!\n else\n let hTypeβ β infer hβ\n let hTypeβ β infer hβ\n match hTypeβ.eq?, hTypeβ.eq? with\n | some (Ο, f, g), some (Ξ±, a, b) =>\n let Ο β whnfD Ο\n match Ο.arrow? with\n | some (_, Ξ²) => do\n let u β getLevel Ξ±\n let v β getLevel Ξ²\n return mkApp8 (mkConst ``congr [u, v]) Ξ± Ξ² f g a b hβ hβ\n | _ => throwAppBuilderException ``congr (\"non-dependent function expected\" ++ hasTypeMsg hβ hTypeβ)\n | none, _ => throwAppBuilderException ``congr (\"equality proof expected\" ++ hasTypeMsg hβ hTypeβ)\n | _, none => throwAppBuilderException ``congr (\"equality proof expected\" ++ hasTypeMsg hβ hTypeβ)",
"start": [
248,
1
],
"end": [
267,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppMFinal",
"code": "private def mkAppMFinal (methodName : Name) (f : Expr) (args : Array Expr) (instMVars : Array MVarId) : MetaM Expr := do\n instMVars.forM fun mvarId => do\n let mvarDecl β mvarId.getDecl\n let mvarVal β synthInstance mvarDecl.type\n mvarId.assign mvarVal\n let result β instantiateMVars (mkAppN f args)\n if (β hasAssignableMVar result) then throwAppBuilderException methodName (\"result contains metavariables\" ++ indentExpr result)\n return result",
"start": [
269,
1
],
"end": [
276,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppMArgs",
"code": "private partial def mkAppMArgs (f : Expr) (fType : Expr) (xs : Array Expr) : MetaM Expr :=\n let rec loop (type : Expr) (i : Nat) (j : Nat) (args : Array Expr) (instMVars : Array MVarId) : MetaM Expr := do\n if i >= xs.size then\n mkAppMFinal `mkAppM f args instMVars\n else match type with\n | Expr.forallE n d b bi =>\n let d := d.instantiateRevRange j args.size args\n match bi with\n | BinderInfo.implicit =>\n let mvar β mkFreshExprMVar d MetavarKind.natural n\n loop b i j (args.push mvar) instMVars\n | BinderInfo.strictImplicit =>\n let mvar β mkFreshExprMVar d MetavarKind.natural n\n loop b i j (args.push mvar) instMVars\n | BinderInfo.instImplicit =>\n let mvar β mkFreshExprMVar d MetavarKind.synthetic n\n loop b i j (args.push mvar) (instMVars.push mvar.mvarId!)\n | _ =>\n let x := xs[i]!\n let xType β inferType x\n if (β isDefEq d xType) then\n loop b (i+1) j (args.push x) instMVars\n else\n throwAppTypeMismatch (mkAppN f args) x\n | type =>\n let type := type.instantiateRevRange j args.size args\n let type β whnfD type\n if type.isForall then\n loop type i args.size args instMVars\n else\n throwAppBuilderException `mkAppM m!\"too many explicit arguments provided to{indentExpr f}\\narguments{indentD xs}\"\n loop fType 0 0 #[] #[]",
"start": [
278,
1
],
"end": [
309,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFun",
"code": "private def mkFun (constName : Name) : MetaM (Expr Γ Expr) := do\n let cinfo β getConstInfo constName\n let us β cinfo.levelParams.mapM fun _ => mkFreshLevelMVar\n let f := mkConst constName us\n let fType β instantiateTypeLevelParams cinfo us\n return (f, fType)",
"start": [
311,
1
],
"end": [
316,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withAppBuilderTrace",
"code": "private def withAppBuilderTrace [ToMessageData Ξ±] [ToMessageData Ξ²]\n (f : Ξ±) (xs : Ξ²) (k : MetaM Expr) : MetaM Expr :=\n let emoji | .ok .. => checkEmoji | .error .. => crossEmoji\n withTraceNode `Meta.appBuilder (return m!\"{emoji Β·} f: {f}, xs: {xs}\") do\n try\n let res β k\n trace[Meta.appBuilder.result] res\n pure res\n catch ex =>\n trace[Meta.appBuilder.error] ex.toMessageData\n throw ex",
"start": [
318,
1
],
"end": [
328,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppM",
"code": "def mkAppM (constName : Name) (xs : Array Expr) : MetaM Expr := do\n withAppBuilderTrace constName xs do withNewMCtxDepth do\n let (f, fType) β mkFun constName\n mkAppMArgs f fType xs",
"start": [
330,
1
],
"end": [
342,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppM'",
"code": "def mkAppM' (f : Expr) (xs : Array Expr) : MetaM Expr := do\n let fType β inferType f\n withAppBuilderTrace f xs do withNewMCtxDepth do\n mkAppMArgs f fType xs",
"start": [
344,
1
],
"end": [
348,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppOptMAux",
"code": "private partial def mkAppOptMAux (f : Expr) (xs : Array (Option Expr)) : Nat β Array Expr β Nat β Array MVarId β Expr β MetaM Expr\n | i, args, j, instMVars, Expr.forallE n d b bi => do\n let d := d.instantiateRevRange j args.size args\n if h : i < xs.size then\n match xs.get β¨i, hβ© with\n | none =>\n match bi with\n | BinderInfo.instImplicit => do\n let mvar β mkFreshExprMVar d MetavarKind.synthetic n\n mkAppOptMAux f xs (i+1) (args.push mvar) j (instMVars.push mvar.mvarId!) b\n | _ => do\n let mvar β mkFreshExprMVar d MetavarKind.natural n\n mkAppOptMAux f xs (i+1) (args.push mvar) j instMVars b\n | some x =>\n let xType β inferType x\n if (β isDefEq d xType) then\n mkAppOptMAux f xs (i+1) (args.push x) j instMVars b\n else\n throwAppTypeMismatch (mkAppN f args) x\n else\n mkAppMFinal `mkAppOptM f args instMVars\n | i, args, j, instMVars, type => do\n let type := type.instantiateRevRange j args.size args\n let type β whnfD type\n if type.isForall then\n mkAppOptMAux f xs i args args.size instMVars type\n else if i == xs.size then\n mkAppMFinal `mkAppOptM f args instMVars\n else do\n let xs : Array Expr := xs.foldl (fun r x? => match x? with | none => r | some x => r.push x) #[]\n throwAppBuilderException `mkAppOptM (\"too many arguments provided to\" ++ indentExpr f ++ Format.line ++ \"arguments\" ++ xs)",
"start": [
350,
1
],
"end": [
380,
129
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppOptM",
"code": "def mkAppOptM (constName : Name) (xs : Array (Option Expr)) : MetaM Expr := do\n withAppBuilderTrace constName xs do withNewMCtxDepth do\n let (f, fType) β mkFun constName\n mkAppOptMAux f xs 0 #[] 0 #[] fType",
"start": [
382,
1
],
"end": [
399,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAppOptM'",
"code": "def mkAppOptM' (f : Expr) (xs : Array (Option Expr)) : MetaM Expr := do\n let fType β inferType f\n withAppBuilderTrace f xs do withNewMCtxDepth do\n mkAppOptMAux f xs 0 #[] 0 #[] fType",
"start": [
401,
1
],
"end": [
405,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqNDRec",
"code": "def mkEqNDRec (motive h1 h2 : Expr) : MetaM Expr := do\n if h2.isAppOf ``Eq.refl then\n return h1\n else\n let h2Type β infer h2\n match h2Type.eq? with\n | none => throwAppBuilderException ``Eq.ndrec (\"equality proof expected\" ++ hasTypeMsg h2 h2Type)\n | some (Ξ±, a, b) =>\n let u2 β getLevel Ξ±\n let motiveType β infer motive\n match motiveType with\n | Expr.forallE _ _ (Expr.sort u1) _ =>\n return mkAppN (mkConst ``Eq.ndrec [u1, u2]) #[Ξ±, a, motive, h1, b, h2]\n | _ => throwAppBuilderException ``Eq.ndrec (\"invalid motive\" ++ indentExpr motive)",
"start": [
407,
1
],
"end": [
420,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqRec",
"code": "def mkEqRec (motive h1 h2 : Expr) : MetaM Expr := do\n if h2.isAppOf ``Eq.refl then\n return h1\n else\n let h2Type β infer h2\n match h2Type.eq? with\n | none => throwAppBuilderException ``Eq.rec (\"equality proof expected\" ++ indentExpr h2)\n | some (Ξ±, a, b) =>\n let u2 β getLevel Ξ±\n let motiveType β infer motive\n match motiveType with\n | Expr.forallE _ _ (Expr.forallE _ _ (Expr.sort u1) _) _ =>\n return mkAppN (mkConst ``Eq.rec [u1, u2]) #[Ξ±, a, motive, h1, b, h2]\n | _ =>\n throwAppBuilderException ``Eq.rec (\"invalid motive\" ++ indentExpr motive)",
"start": [
422,
1
],
"end": [
436,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqMP",
"code": "def mkEqMP (eqProof pr : Expr) : MetaM Expr :=\n mkAppM ``Eq.mp #[eqProof, pr]",
"start": [
438,
1
],
"end": [
439,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqMPR",
"code": "def mkEqMPR (eqProof pr : Expr) : MetaM Expr :=\n mkAppM ``Eq.mpr #[eqProof, pr]",
"start": [
441,
1
],
"end": [
442,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkNoConfusion",
"code": "def mkNoConfusion (target : Expr) (h : Expr) : MetaM Expr := do\n let type β inferType h\n let type β whnf type\n match type.eq? with\n | none => throwAppBuilderException `noConfusion (\"equality expected\" ++ hasTypeMsg h type)\n | some (Ξ±, a, b) =>\n let Ξ± β whnfD Ξ±\n matchConstInduct Ξ±.getAppFn (fun _ => throwAppBuilderException `noConfusion (\"inductive type expected\" ++ indentExpr Ξ±)) fun v us => do\n let u β getLevel target\n return mkAppN (mkConst (Name.mkStr v.name \"noConfusion\") (u :: us)) (Ξ±.getAppArgs ++ #[target, a, b, h])",
"start": [
444,
1
],
"end": [
453,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkPure",
"code": "def mkPure (monad : Expr) (e : Expr) : MetaM Expr :=\n mkAppOptM ``Pure.pure #[monad, none, none, e]",
"start": [
455,
1
],
"end": [
457,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkProjection",
"code": "partial def mkProjection (s : Expr) (fieldName : Name) : MetaM Expr := do\n let type β inferType s\n let type β whnf type\n match type.getAppFn with\n | Expr.const structName us =>\n let env β getEnv\n unless isStructure env structName do\n throwAppBuilderException `mkProjection (\"structure expected\" ++ hasTypeMsg s type)\n match getProjFnForField? env structName fieldName with\n | some projFn =>\n let params := type.getAppArgs\n return mkApp (mkAppN (mkConst projFn us) params) s\n | none =>\n let fields := getStructureFields env structName\n let r? β fields.findSomeM? fun fieldName' => do\n match isSubobjectField? env structName fieldName' with\n | none => pure none\n | some _ =>\n let parent β mkProjection s fieldName'\n (do let r β mkProjection parent fieldName; return some r)\n <|>\n pure none\n match r? with\n | some r => pure r\n | none => throwAppBuilderException `mkProjection (\"invalid field name '\" ++ toString fieldName ++ \"' for\" ++ hasTypeMsg s type)\n | _ => throwAppBuilderException `mkProjection (\"structure expected\" ++ hasTypeMsg s type)",
"start": [
459,
1
],
"end": [
487,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkListLitAux",
"code": "private def mkListLitAux (nil : Expr) (cons : Expr) : List Expr β Expr\n | [] => nil\n | x::xs => mkApp (mkApp cons x) (mkListLitAux nil cons xs)",
"start": [
489,
1
],
"end": [
491,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkListLit",
"code": "def mkListLit (type : Expr) (xs : List Expr) : MetaM Expr := do\n let u β getDecLevel type\n let nil := mkApp (mkConst ``List.nil [u]) type\n match xs with\n | [] => return nil\n | _ =>\n let cons := mkApp (mkConst ``List.cons [u]) type\n return mkListLitAux nil cons xs",
"start": [
493,
1
],
"end": [
500,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkArrayLit",
"code": "def mkArrayLit (type : Expr) (xs : List Expr) : MetaM Expr := do\n let u β getDecLevel type\n let listLit β mkListLit type xs\n return mkApp (mkApp (mkConst ``List.toArray [u]) type) listLit",
"start": [
502,
1
],
"end": [
505,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSorry",
"code": "def mkSorry (type : Expr) (synthetic : Bool) : MetaM Expr := do\n let u β getLevel type\n return mkApp2 (mkConst ``sorryAx [u]) type (toExpr synthetic)",
"start": [
507,
1
],
"end": [
509,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkDecide",
"code": "def mkDecide (p : Expr) : MetaM Expr :=\n mkAppOptM ``Decidable.decide #[p, none]",
"start": [
511,
1
],
"end": [
513,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkDecideProof",
"code": "def mkDecideProof (p : Expr) : MetaM Expr := do\n let decP β mkDecide p\n let decEqTrue β mkEq decP (mkConst ``Bool.true)\n let h β mkEqRefl (mkConst ``Bool.true)\n let h β mkExpectedTypeHint h decEqTrue\n mkAppM ``of_decide_eq_true #[h]",
"start": [
515,
1
],
"end": [
521,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLt",
"code": "def mkLt (a b : Expr) : MetaM Expr :=\n mkAppM ``LT.lt #[a, b]",
"start": [
523,
1
],
"end": [
525,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLe",
"code": "def mkLe (a b : Expr) : MetaM Expr :=\n mkAppM ``LE.le #[a, b]",
"start": [
527,
1
],
"end": [
529,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkDefault",
"code": "def mkDefault (Ξ± : Expr) : MetaM Expr :=\n mkAppOptM ``Inhabited.default #[Ξ±, none]",
"start": [
531,
1
],
"end": [
533,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkOfNonempty",
"code": "def mkOfNonempty (Ξ± : Expr) : MetaM Expr := do\n mkAppOptM ``Classical.ofNonempty #[Ξ±, none]",
"start": [
535,
1
],
"end": [
537,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSyntheticSorry",
"code": "def mkSyntheticSorry (type : Expr) : MetaM Expr :=\n return mkApp2 (mkConst ``sorryAx [β getLevel type]) type (mkConst ``Bool.true)",
"start": [
539,
1
],
"end": [
541,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFunExt",
"code": "def mkFunExt (h : Expr) : MetaM Expr :=\n mkAppM ``funext #[h]",
"start": [
543,
1
],
"end": [
545,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkPropExt",
"code": "def mkPropExt (h : Expr) : MetaM Expr :=\n mkAppM ``propext #[h]",
"start": [
547,
1
],
"end": [
549,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLetCongr",
"code": "def mkLetCongr (hβ hβ : Expr) : MetaM Expr :=\n mkAppM ``let_congr #[hβ, hβ]",
"start": [
551,
1
],
"end": [
553,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLetValCongr",
"code": "def mkLetValCongr (b h : Expr) : MetaM Expr :=\n mkAppM ``let_val_congr #[b, h]",
"start": [
555,
1
],
"end": [
557,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLetBodyCongr",
"code": "def mkLetBodyCongr (a h : Expr) : MetaM Expr :=\n mkAppM ``let_body_congr #[a, h]",
"start": [
559,
1
],
"end": [
561,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkOfEqTrue",
"code": "def mkOfEqTrue (h : Expr) : MetaM Expr :=\n mkAppM ``of_eq_true #[h]",
"start": [
563,
1
],
"end": [
565,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqTrue",
"code": "def mkEqTrue (h : Expr) : MetaM Expr :=\n mkAppM ``eq_true #[h]",
"start": [
567,
1
],
"end": [
569,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqFalse",
"code": "def mkEqFalse (h : Expr) : MetaM Expr :=\n mkAppM ``eq_false #[h]",
"start": [
571,
1
],
"end": [
576,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkEqFalse'",
"code": "def mkEqFalse' (h : Expr) : MetaM Expr :=\n mkAppM ``eq_false' #[h]",
"start": [
578,
1
],
"end": [
583,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkImpCongr",
"code": "def mkImpCongr (hβ hβ : Expr) : MetaM Expr :=\n mkAppM ``implies_congr #[hβ, hβ]",
"start": [
585,
1
],
"end": [
586,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkImpCongrCtx",
"code": "def mkImpCongrCtx (hβ hβ : Expr) : MetaM Expr :=\n mkAppM ``implies_congr_ctx #[hβ, hβ]",
"start": [
588,
1
],
"end": [
589,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkImpDepCongrCtx",
"code": "def mkImpDepCongrCtx (hβ hβ : Expr) : MetaM Expr :=\n mkAppM ``implies_dep_congr_ctx #[hβ, hβ]",
"start": [
591,
1
],
"end": [
592,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkForallCongr",
"code": "def mkForallCongr (h : Expr) : MetaM Expr :=\n mkAppM ``forall_congr #[h]",
"start": [
594,
1
],
"end": [
595,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMonad?",
"code": "def isMonad? (m : Expr) : MetaM (Option Expr) :=\n try\n let monadType β mkAppM `Monad #[m]\n let result β trySynthInstance monadType\n match result with\n | LOption.some inst => pure inst\n | _ => pure none\n catch _ =>\n pure none",
"start": [
597,
1
],
"end": [
606,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkNumeral",
"code": "def mkNumeral (type : Expr) (n : Nat) : MetaM Expr := do\n let u β getDecLevel type\n let inst β synthInstance (mkApp2 (mkConst ``OfNat [u]) type (mkRawNatLit n))\n return mkApp3 (mkConst ``OfNat.ofNat [u]) type (mkRawNatLit n) inst",
"start": [
608,
1
],
"end": [
612,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkBinaryOp",
"code": "private def mkBinaryOp (className : Name) (opName : Name) (a b : Expr) : MetaM Expr := do\n let aType β inferType a\n let u β getDecLevel aType\n let inst β synthInstance (mkApp3 (mkConst className [u, u, u]) aType aType aType)\n return mkApp6 (mkConst opName [u, u, u]) aType aType aType inst a b",
"start": [
614,
1
],
"end": [
624,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAdd",
"code": "def mkAdd (a b : Expr) : MetaM Expr := mkBinaryOp ``HAdd ``HAdd.hAdd a b",
"start": [
626,
1
],
"end": [
627,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSub",
"code": "def mkSub (a b : Expr) : MetaM Expr := mkBinaryOp ``HSub ``HSub.hSub a b",
"start": [
629,
1
],
"end": [
630,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkMul",
"code": "def mkMul (a b : Expr) : MetaM Expr := mkBinaryOp ``HMul ``HMul.hMul a b",
"start": [
632,
1
],
"end": [
633,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkBinaryRel",
"code": "private def mkBinaryRel (className : Name) (rName : Name) (a b : Expr) : MetaM Expr := do\n let aType β inferType a\n let u β getDecLevel aType\n let inst β synthInstance (mkApp (mkConst className [u]) aType)\n return mkApp4 (mkConst rName [u]) aType inst a b",
"start": [
635,
1
],
"end": [
645,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLE",
"code": "def mkLE (a b : Expr) : MetaM Expr := mkBinaryRel ``LE ``LE.le a b",
"start": [
647,
1
],
"end": [
648,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLT",
"code": "def mkLT (a b : Expr) : MetaM Expr := mkBinaryRel ``LT ``LT.lt a b",
"start": [
650,
1
],
"end": [
651,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkIffOfEq",
"code": "def mkIffOfEq (h : Expr) : MetaM Expr := do\n if h.isAppOfArity ``propext 3 then\n return h.appArg!\n else\n mkAppM ``Iff.of_eq #[h]",
"start": [
653,
1
],
"end": [
658,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAndIntroN",
"code": "def mkAndIntroN : Array Expr β MetaM Expr\n| #[] => return mkConst ``True.intro []\n| #[e] => return e\n| es => es.foldrM (start := es.size - 1) (fun a b => mkAppM ``And.intro #[a,b]) es.back",
"start": [
660,
1
],
"end": [
668,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkProjAndN",
"code": "def mkProjAndN (n i : Nat) (e : Expr) : Expr := Id.run do\n let mut value := e\n for _ in [:i] do\n value := mkProj ``And 1 value\n if i + 1 < n then\n value := mkProj ``And 0 value\n return value",
"start": [
671,
1
],
"end": [
678,
15
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/AutoBound.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Options.lean"
] | [
{
"full_name": "Lean.Elab.isValidAutoBoundSuffix",
"code": "private def isValidAutoBoundSuffix (s : String) : Bool :=\n s.toSubstring.drop 1 |>.all fun c => c.isDigit || isSubScriptAlnum c || c == '_' || c == '\\''",
"start": [
24,
1
],
"end": [
25,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.isValidAutoBoundImplicitName",
"code": "def isValidAutoBoundImplicitName (n : Name) (relaxed : Bool) : Bool :=\n match n with\n | .str .anonymous s => s.length > 0 && (relaxed || isValidAutoBoundSuffix s)\n | _ => false",
"start": [
41,
1
],
"end": [
44,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.isValidAutoBoundLevelName",
"code": "def isValidAutoBoundLevelName (n : Name) (relaxed : Bool) : Bool :=\n match n with\n | .str .anonymous s => s.length > 0 && (relaxed || (s.front.isLower && isValidAutoBoundSuffix s))\n | _ => false",
"start": [
46,
1
],
"end": [
49,
15
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Attributes.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean"
] | [
{
"full_name": "Lean.hasPPUsingAnonymousConstructorAttribute",
"code": "def hasPPUsingAnonymousConstructorAttribute (env : Environment) (declName : Name) : Bool :=\n ppUsingAnonymousConstructorAttr.hasTag env declName",
"start": [
23,
1
],
"end": [
27,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasPPNoDotAttribute",
"code": "def hasPPNoDotAttribute (env : Environment) (declName : Name) : Bool :=\n ppNoDotAttr.hasTag env declName",
"start": [
29,
1
],
"end": [
33,
34
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Options.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Options.lean"
] | [
{
"full_name": "Lean.getPPMaxSteps",
"code": "def getPPMaxSteps (o : Options) : Nat := o.get pp.maxSteps.name pp.maxSteps.defValue",
"start": [
223,
1
],
"end": [
223,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAll",
"code": "def getPPAll (o : Options) : Bool := o.get pp.all.name false",
"start": [
224,
1
],
"end": [
224,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPFunBinderTypes",
"code": "def getPPFunBinderTypes (o : Options) : Bool := o.get pp.funBinderTypes.name (getPPAll o)",
"start": [
225,
1
],
"end": [
225,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPPiBinderTypes",
"code": "def getPPPiBinderTypes (o : Options) : Bool := o.get pp.piBinderTypes.name pp.piBinderTypes.defValue",
"start": [
226,
1
],
"end": [
226,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPLetVarTypes",
"code": "def getPPLetVarTypes (o : Options) : Bool := o.get pp.letVarTypes.name (getPPAll o)",
"start": [
227,
1
],
"end": [
227,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPNumericTypes",
"code": "def getPPNumericTypes (o : Options) : Bool := o.get pp.numericTypes.name pp.numericTypes.defValue",
"start": [
228,
1
],
"end": [
228,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPNatLit",
"code": "def getPPNatLit (o : Options) : Bool := o.get pp.natLit.name (getPPNumericTypes o && !getPPAll o)",
"start": [
229,
1
],
"end": [
229,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPCoercions",
"code": "def getPPCoercions (o : Options) : Bool := o.get pp.coercions.name (!getPPAll o)",
"start": [
230,
1
],
"end": [
230,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPExplicit",
"code": "def getPPExplicit (o : Options) : Bool := o.get pp.explicit.name (getPPAll o)",
"start": [
231,
1
],
"end": [
231,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPNotation",
"code": "def getPPNotation (o : Options) : Bool := o.get pp.notation.name (!getPPAll o)",
"start": [
232,
1
],
"end": [
232,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPUnicodeFun",
"code": "def getPPUnicodeFun (o : Options) : Bool := o.get pp.unicode.fun.name false",
"start": [
233,
1
],
"end": [
233,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPMatch",
"code": "def getPPMatch (o : Options) : Bool := o.get pp.match.name (!getPPAll o)",
"start": [
234,
1
],
"end": [
234,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPFieldNotation",
"code": "def getPPFieldNotation (o : Options) : Bool := o.get pp.fieldNotation.name (!getPPAll o)",
"start": [
235,
1
],
"end": [
235,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPFieldNotationGeneralized",
"code": "def getPPFieldNotationGeneralized (o : Options) : Bool := o.get pp.fieldNotation.generalized.name pp.fieldNotation.generalized.defValue",
"start": [
236,
1
],
"end": [
236,
136
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPStructureInstances",
"code": "def getPPStructureInstances (o : Options) : Bool := o.get pp.structureInstances.name (!getPPAll o)",
"start": [
237,
1
],
"end": [
237,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPStructureInstancesFlatten",
"code": "def getPPStructureInstancesFlatten (o : Options) : Bool := o.get pp.structureInstances.flatten.name pp.structureInstances.flatten.defValue",
"start": [
238,
1
],
"end": [
238,
139
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPStructureInstanceType",
"code": "def getPPStructureInstanceType (o : Options) : Bool := o.get pp.structureInstanceTypes.name (getPPAll o)",
"start": [
239,
1
],
"end": [
239,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPTagAppFns",
"code": "def getPPTagAppFns (o : Options) : Bool := o.get pp.tagAppFns.name (getPPAll o)",
"start": [
240,
1
],
"end": [
240,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPUniverses",
"code": "def getPPUniverses (o : Options) : Bool := o.get pp.universes.name (getPPAll o)",
"start": [
241,
1
],
"end": [
241,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPFullNames",
"code": "def getPPFullNames (o : Options) : Bool := o.get pp.fullNames.name (getPPAll o)",
"start": [
242,
1
],
"end": [
242,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPPrivateNames",
"code": "def getPPPrivateNames (o : Options) : Bool := o.get pp.privateNames.name (getPPAll o)",
"start": [
243,
1
],
"end": [
243,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPInstantiateMVars",
"code": "def getPPInstantiateMVars (o : Options) : Bool := o.get pp.instantiateMVars.name pp.instantiateMVars.defValue",
"start": [
244,
1
],
"end": [
244,
110
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPMVars",
"code": "def getPPMVars (o : Options) : Bool := o.get pp.mvars.name pp.mvars.defValue",
"start": [
245,
1
],
"end": [
245,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPMVarsWithType",
"code": "def getPPMVarsWithType (o : Options) : Bool := o.get pp.mvars.withType.name pp.mvars.withType.defValue",
"start": [
246,
1
],
"end": [
246,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPBeta",
"code": "def getPPBeta (o : Options) : Bool := o.get pp.beta.name pp.beta.defValue",
"start": [
247,
1
],
"end": [
247,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPSafeShadowing",
"code": "def getPPSafeShadowing (o : Options) : Bool := o.get pp.safeShadowing.name pp.safeShadowing.defValue",
"start": [
248,
1
],
"end": [
248,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPProofs",
"code": "def getPPProofs (o : Options) : Bool := o.get pp.proofs.name (pp.proofs.defValue || getPPAll o)",
"start": [
249,
1
],
"end": [
249,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPProofsWithType",
"code": "def getPPProofsWithType (o : Options) : Bool := o.get pp.proofs.withType.name pp.proofs.withType.defValue",
"start": [
250,
1
],
"end": [
250,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPProofsThreshold",
"code": "def getPPProofsThreshold (o : Options) : Nat := o.get pp.proofs.threshold.name pp.proofs.threshold.defValue",
"start": [
251,
1
],
"end": [
251,
108
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPMotivesPi",
"code": "def getPPMotivesPi (o : Options) : Bool := o.get pp.motives.pi.name pp.motives.pi.defValue",
"start": [
252,
1
],
"end": [
252,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPMotivesNonConst",
"code": "def getPPMotivesNonConst (o : Options) : Bool := o.get pp.motives.nonConst.name pp.motives.nonConst.defValue",
"start": [
253,
1
],
"end": [
253,
109
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPMotivesAll",
"code": "def getPPMotivesAll (o : Options) : Bool := o.get pp.motives.all.name pp.motives.all.defValue",
"start": [
254,
1
],
"end": [
254,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPInstances",
"code": "def getPPInstances (o : Options) : Bool := o.get pp.instances.name pp.instances.defValue",
"start": [
255,
1
],
"end": [
255,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPInstanceTypes",
"code": "def getPPInstanceTypes (o : Options) : Bool := o.get pp.instanceTypes.name pp.instanceTypes.defValue",
"start": [
256,
1
],
"end": [
256,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPDeepTerms",
"code": "def getPPDeepTerms (o : Options) : Bool := o.get pp.deepTerms.name (pp.deepTerms.defValue || getPPAll o)",
"start": [
257,
1
],
"end": [
257,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPDeepTermsThreshold",
"code": "def getPPDeepTermsThreshold (o : Options) : Nat := o.get pp.deepTerms.threshold.name pp.deepTerms.threshold.defValue",
"start": [
258,
1
],
"end": [
258,
117
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/SubExpr.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean"
] | [
{
"full_name": "Lean.SubExpr.Pos",
"code": "def SubExpr.Pos := Nat",
"start": [
13,
1
],
"end": [
22,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.maxChildren",
"code": "def maxChildren := 4",
"start": [
26,
1
],
"end": [
26,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.typeCoord",
"code": "def typeCoord : Nat := maxChildren - 1",
"start": [
28,
1
],
"end": [
30,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.asNat",
"code": "def asNat : Pos β Nat := id",
"start": [
32,
1
],
"end": [
32,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.root",
"code": "def root : Pos := (1 : Nat)",
"start": [
34,
1
],
"end": [
35,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.isRoot",
"code": "def isRoot (p : Pos) : Bool := p.asNat < maxChildren",
"start": [
39,
1
],
"end": [
39,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.head",
"code": "def head (p : Pos) : Nat :=\n if p.isRoot then panic! \"already at top\"\n else p.asNat % maxChildren",
"start": [
41,
1
],
"end": [
44,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.tail",
"code": "def tail (p : Pos) : Pos :=\n if p.isRoot then panic! \"already at top\"\n else (p.asNat - p.head) / maxChildren",
"start": [
46,
1
],
"end": [
48,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.push",
"code": "def push (p : Pos) (c : Nat) : Pos :=\n if c >= maxChildren then panic! s!\"invalid coordinate {c}\"\n else p.asNat * maxChildren + c",
"start": [
50,
1
],
"end": [
52,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.foldl",
"code": "partial def foldl (f : Ξ± β Nat β Ξ±) (init : Ξ±) (p : Pos) : Ξ± :=\n if p.isRoot then init else f (foldl f init p.tail) p.head",
"start": [
56,
1
],
"end": [
58,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.foldr",
"code": "partial def foldr (f : Nat β Ξ± β Ξ±) (p : Pos) (init : Ξ±) : Ξ± :=\n if p.isRoot then init else foldr f p.tail (f p.head init)",
"start": [
60,
1
],
"end": [
62,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.foldlM",
"code": "partial def foldlM [Monad M] (f : Ξ± β Nat β M Ξ±) (init : Ξ±) (p : Pos) : M Ξ± :=\n have : Inhabited (M Ξ±) := inferInstance\n if p.isRoot then pure init else do foldlM f init p.tail >>= (f Β· p.head)",
"start": [
64,
1
],
"end": [
67,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.foldrM",
"code": "partial def foldrM [Monad M] (f : Nat β Ξ± β M Ξ±) (p : Pos) (init : Ξ±) : M Ξ± :=\n if p.isRoot then pure init else f p.head init >>= foldrM f p.tail",
"start": [
69,
1
],
"end": [
71,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.depth",
"code": "def depth (p : Pos) :=\n p.foldr (init := 0) fun _ => Nat.succ",
"start": [
73,
1
],
"end": [
74,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.all",
"code": "def all (pred : Nat β Bool) (p : Pos) : Bool :=\n OptionT.run (m := Id) (foldrM (fun n a => if pred n then pure a else failure) p ()) |>.isSome",
"start": [
76,
1
],
"end": [
78,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.append",
"code": "def append : Pos β Pos β Pos := foldl push",
"start": [
80,
1
],
"end": [
80,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.ofArray",
"code": "def ofArray (ps : Array Nat) : Pos :=\n ps.foldl push root",
"start": [
82,
1
],
"end": [
86,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.toArray",
"code": "def toArray (p : Pos) : Array Nat :=\n foldl Array.push #[] p",
"start": [
88,
1
],
"end": [
91,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushBindingDomain",
"code": "def pushBindingDomain (p : Pos) := p.push 0",
"start": [
93,
1
],
"end": [
93,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushBindingBody",
"code": "def pushBindingBody (p : Pos) := p.push 1",
"start": [
94,
1
],
"end": [
94,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushLetVarType",
"code": "def pushLetVarType (p : Pos) := p.push 0",
"start": [
95,
1
],
"end": [
95,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushLetValue",
"code": "def pushLetValue (p : Pos) := p.push 1",
"start": [
96,
1
],
"end": [
96,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushLetBody",
"code": "def pushLetBody (p : Pos) := p.push 2",
"start": [
97,
1
],
"end": [
97,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushAppFn",
"code": "def pushAppFn (p : Pos) := p.push 0",
"start": [
98,
1
],
"end": [
98,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushAppArg",
"code": "def pushAppArg (p : Pos) := p.push 1",
"start": [
99,
1
],
"end": [
99,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushProj",
"code": "def pushProj (p : Pos) := p.push 0",
"start": [
100,
1
],
"end": [
100,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushType",
"code": "def pushType (p : Pos) := p.push Pos.typeCoord",
"start": [
101,
1
],
"end": [
101,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushNaryFn",
"code": "def pushNaryFn (numArgs : Nat) (p : Pos) : Pos :=\n p.asNat * (maxChildren ^ numArgs)",
"start": [
103,
1
],
"end": [
104,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushNaryArg",
"code": "def pushNaryArg (numArgs argIdx : Nat) (p : Pos) : Pos :=\n show Nat from p.asNat * (maxChildren ^ (numArgs - argIdx)) + 1",
"start": [
106,
1
],
"end": [
107,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushNthBindingDomain",
"code": "def pushNthBindingDomain : (binderIdx : Nat) β Pos β Pos\n | 0, p => p.pushBindingDomain\n | (n+1), p => pushNthBindingDomain n p.pushBindingBody",
"start": [
109,
1
],
"end": [
111,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.pushNthBindingBody",
"code": "def pushNthBindingBody : (numBinders : Nat) β Pos β Pos\n | 0, p => p\n | (n+1), p => pushNthBindingBody n p.pushBindingBody",
"start": [
113,
1
],
"end": [
115,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.toString",
"code": "protected def toString (p : Pos) : String :=\n p.toArray.toList\n |>.map toString\n |> String.intercalate \"/\"\n |> (\"/\" ++ Β·)",
"start": [
117,
1
],
"end": [
121,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.ofStringCoord",
"code": "private def ofStringCoord : String β Except String Nat\n | \"0\" => ok 0 | \"1\" => ok 1 | \"2\" => ok 2 | \"3\" => ok 3\n | c => error s!\"Invalid coordinate {c}\"",
"start": [
124,
1
],
"end": [
126,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.fromString?",
"code": "protected def fromString? : String β Except String Pos\n | \"/\" => Except.ok Pos.root\n | s =>\n match String.splitOn s \"/\" with\n | \"\" :: tail => Pos.ofArray <$> tail.toArray.mapM ofStringCoord\n | ss => error s!\"malformed {ss}\"",
"start": [
129,
1
],
"end": [
134,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.Pos.fromString!",
"code": "protected def fromString! (s : String) : Pos :=\n match Pos.fromString? s with\n | .ok a => a\n | .error e => panic! e",
"start": [
136,
1
],
"end": [
139,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr",
"code": "structure SubExpr where\n \n expr : Expr\n \n pos : SubExpr.Pos\n deriving Inhabited",
"start": [
156,
1
],
"end": [
163,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.mkRoot",
"code": "def mkRoot (e : Expr) : SubExpr := β¨e, Pos.rootβ©",
"start": [
167,
1
],
"end": [
167,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.isRoot",
"code": "def isRoot (s : SubExpr) : Bool := s.pos.isRoot",
"start": [
169,
1
],
"end": [
170,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.PosMap",
"code": "abbrev PosMap (Ξ± : Type u) := RBMap Pos Ξ± compare",
"start": [
172,
1
],
"end": [
173,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.bindingBody!",
"code": "def bindingBody! : SubExpr β SubExpr\n | β¨.forallE _ _ b _, pβ© => β¨b, p.pushBindingBodyβ©\n | β¨.lam _ _ b _, pβ© => β¨b, p.pushBindingBodyβ©\n | _ => panic! \"subexpr is not a binder\"",
"start": [
175,
1
],
"end": [
178,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.bindingDomain!",
"code": "def bindingDomain! : SubExpr β SubExpr\n | β¨.forallE _ t _ _, pβ© => β¨t, p.pushBindingDomainβ©\n | β¨.lam _ t _ _, pβ© => β¨t, p.pushBindingDomainβ©\n | _ => panic! \"subexpr is not a binder\"",
"start": [
180,
1
],
"end": [
183,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.GoalLocation",
"code": "inductive GoalLocation where\n \n | hyp : FVarId β GoalLocation\n \n | hypType : FVarId β SubExpr.Pos β GoalLocation\n \n | hypValue : FVarId β SubExpr.Pos β GoalLocation\n \n | target : SubExpr.Pos β GoalLocation\n deriving FromJson, ToJson",
"start": [
190,
1
],
"end": [
200,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SubExpr.GoalsLocation",
"code": "structure GoalsLocation where\n \n mvarId : MVarId\n loc : GoalLocation\n deriving FromJson, ToJson",
"start": [
202,
1
],
"end": [
208,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.traverseAppWithPos",
"code": "def Expr.traverseAppWithPos {M} [Monad M] (visit : Pos β Expr β M Expr) (p : Pos) (e : Expr) : M Expr :=\n match e with\n | .app f a =>\n e.updateApp!\n <$> traverseAppWithPos visit p.pushAppFn f\n <*> visit p.pushAppArg a\n | e => visit p e",
"start": [
213,
1
],
"end": [
221,
19
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Tactic/Doc.lean | [
".lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Main.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Attr.lean",
".lake/packages/lean4/src/lean/Lean/DocString/Extension.lean",
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Extension.lean"
] | [
{
"full_name": "Lean.Parser.Tactic.Doc.isTactic",
"code": "def isTactic (env : Environment) (kind : Name) : Bool := Id.run do\n let some tactics := (Lean.Parser.parserExtension.getState env).categories.find? `tactic\n | return false\n for (tac, _) in tactics.kinds do\n if kind == tac then return true\n return false",
"start": [
20,
1
],
"end": [
26,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.alternativeOfTactic",
"code": "def alternativeOfTactic (env : Environment) (tac : Name) : Option Name :=\n match env.getModuleIdxFor? tac with\n | some modIdx =>\n match (tacticAlternativeExt.getModuleEntries env modIdx).binSearch (tac, .anonymous) (Name.quickLt Β·.1 Β·.1) with\n | some (_, val) => some val\n | none => none\n | none => tacticAlternativeExt.getState env |>.find? tac",
"start": [
42,
1
],
"end": [
52,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.aliases",
"code": "def aliases [Monad m] [MonadEnv m] (tac : Name) : m NameSet := do\n let env β getEnv\n let mut found := {}\n for (src, tgt) in tacticAlternativeExt.getState env do\n if tgt == tac then found := found.insert src\n for arr in tacticAlternativeExt.toEnvExtension.getState env |>.importedEntries do\n for (src, tgt) in arr do\n if tgt == tac then found := found.insert src\n pure found",
"start": [
54,
1
],
"end": [
65,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.tagInfo",
"code": "def tagInfo [Monad m] [MonadEnv m] (tag : Name) : m (Option (String Γ Option String)) := do\n let env β getEnv\n match env.getModuleIdxFor? tag with\n | some modIdx =>\n match (knownTacticTagExt.getModuleEntries env modIdx).binSearch (tag, default) (Name.quickLt Β·.1 Β·.1) with\n | some (_, val) => pure (some val)\n | none => pure none\n | none => pure (knownTacticTagExt.getState env |>.find? tag)",
"start": [
120,
1
],
"end": [
130,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.allTags",
"code": "def allTags [Monad m] [MonadEnv m] : m (List Name) := do\n let env β getEnv\n let mut found : NameSet := {}\n for (tag, _) in knownTacticTagExt.getState env do\n found := found.insert tag\n for arr in knownTacticTagExt.toEnvExtension.getState env |>.importedEntries do\n for (tag, _) in arr do\n found := found.insert tag\n pure (found.toArray.qsort (Β·.toString < Β·.toString) |>.toList)",
"start": [
132,
1
],
"end": [
141,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.allTagsWithInfo",
"code": "def allTagsWithInfo [Monad m] [MonadEnv m] : m (List (Name Γ String Γ Option String)) := do\n let env β getEnv\n let mut found : NameMap (String Γ Option String) := {}\n for (tag, info) in knownTacticTagExt.getState env do\n found := found.insert tag info\n for arr in knownTacticTagExt.toEnvExtension.getState env |>.importedEntries do\n for (tag, info) in arr do\n found := found.insert tag info\n let arr := found.fold (init := #[]) (fun arr k v => arr.push (k, v))\n pure (arr.qsort (Β·.1.toString < Β·.1.toString) |>.toList)",
"start": [
143,
1
],
"end": [
153,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.getTacticExtensions",
"code": "def getTacticExtensions (env : Environment) (tactic : Name) : Array String := Id.run do\n let mut extensions := #[]\n for modArr in tacticDocExtExt.toEnvExtension.getState env |>.importedEntries do\n if let some (_, strs) := modArr.binSearch (tactic, #[]) (Name.quickLt Β·.1 Β·.1) then\n extensions := extensions ++ strs\n if let some strs := tacticDocExtExt.getState env |>.find? tactic then\n extensions := extensions ++ strs\n pure extensions",
"start": [
242,
1
],
"end": [
251,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.getTacticExtensionString",
"code": "def getTacticExtensionString (env : Environment) (tactic : Name) : String := Id.run do\n let exts := getTacticExtensions env tactic\n if exts.size == 0 then \"\"\n else \"\\n\\nExtensions:\\n\\n\" ++ String.join (exts.toList.map bullet) |>.trimRight\nwhere\n indentLine (str: String) : String :=\n (if str.all (Β·.isWhitespace) then str else \" \" ++ str) ++ \"\\n\"\n bullet (str : String) : String :=\n let lines := str.splitOn \"\\n\"\n match lines with\n | [] => \"\"\n | [l] => \" * \" ++ l ++ \"\\n\\n\"\n | l::ls => \" * \" ++ l ++ \"\\n\" ++ String.join (ls.map indentLine) ++ \"\\n\\n\"",
"start": [
253,
1
],
"end": [
266,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.Doc.tacticDocsOnTactics",
"code": "def tacticDocsOnTactics : ParserAttributeHook where\n postAdd (catName declName : Name) (_builtIn : Bool) := do\n if catName == `tactic then\n return\n if alternativeOfTactic (β getEnv) declName |>.isSome then\n throwError m!\"'{declName}' is not a tactic\"\n if let some tags := tacticTagExt.getState (β getEnv) |>.find? declName then\n if !tags.isEmpty then\n throwError m!\"'{declName}' is not a tactic\"",
"start": [
273,
1
],
"end": [
287,
52
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Language/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Types.lean",
".lake/packages/lean4/src/lean/Lean/Message.lean",
".lake/packages/lean4/src/lean/Init/System/Promise.lean"
] | [
{
"full_name": "Lean.Language.Snapshot.Diagnostics",
"code": "structure Snapshot.Diagnostics where\n private mk ::\n \n msgLog : MessageLog\n \n interactiveDiagsRef? : Option (IO.Ref (Option Dynamic))\nderiving Inhabited",
"start": [
20,
1
],
"end": [
37,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.Snapshot.Diagnostics.empty",
"code": "def Snapshot.Diagnostics.empty : Snapshot.Diagnostics where\n msgLog := .empty\n interactiveDiagsRef? := none",
"start": [
39,
1
],
"end": [
43,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.Snapshot",
"code": "structure Snapshot where\n \n diagnostics : Snapshot.Diagnostics\n \n infoTree? : Option Elab.InfoTree := none\n \n isFatal := false\nderiving Inhabited",
"start": [
45,
1
],
"end": [
60,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask",
"code": "structure SnapshotTask (Ξ± : Type) where\n \n range? : Option String.Range\n \n task : Task Ξ±\nderiving Nonempty",
"start": [
62,
1
],
"end": [
74,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.ofIO",
"code": "def SnapshotTask.ofIO (range? : Option String.Range) (act : BaseIO Ξ±) : BaseIO (SnapshotTask Ξ±) := do\n return {\n range?\n task := (β BaseIO.asTask act)\n }",
"start": [
76,
1
],
"end": [
81,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.pure",
"code": "def SnapshotTask.pure (a : Ξ±) : SnapshotTask Ξ± where\n range? := none\n task := .pure a",
"start": [
83,
1
],
"end": [
87,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.cancel",
"code": "def SnapshotTask.cancel (t : SnapshotTask Ξ±) : BaseIO Unit :=\n IO.cancel t.task",
"start": [
89,
1
],
"end": [
93,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.map",
"code": "def SnapshotTask.map (t : SnapshotTask Ξ±) (f : Ξ± β Ξ²) (range? : Option String.Range := t.range?)\n (sync := false) : SnapshotTask Ξ² :=\n { range?, task := t.task.map (sync := sync) f }",
"start": [
95,
1
],
"end": [
98,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.bind",
"code": "def SnapshotTask.bind (t : SnapshotTask Ξ±) (act : Ξ± β SnapshotTask Ξ²)\n (range? : Option String.Range := t.range?) (sync := false) : SnapshotTask Ξ² :=\n { range?, task := t.task.bind (sync := sync) (act Β· |>.task) }",
"start": [
100,
1
],
"end": [
105,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.bindIO",
"code": "def SnapshotTask.bindIO (t : SnapshotTask Ξ±) (act : Ξ± β BaseIO (SnapshotTask Ξ²))\n (range? : Option String.Range := t.range?) (sync := false) : BaseIO (SnapshotTask Ξ²) :=\n return {\n range?\n task := (β BaseIO.bindTask (sync := sync) t.task fun a => (Β·.task) <$> (act a))\n }",
"start": [
107,
1
],
"end": [
115,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.get",
"code": "def SnapshotTask.get (t : SnapshotTask Ξ±) : Ξ± :=\n t.task.get",
"start": [
117,
1
],
"end": [
119,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTask.get?",
"code": "def SnapshotTask.get? (t : SnapshotTask Ξ±) : BaseIO (Option Ξ±) :=\n return if (β IO.hasFinished t.task) then some t.task.get else none",
"start": [
121,
1
],
"end": [
123,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SyntaxGuarded",
"code": "structure SyntaxGuarded (Ξ± : Type) where\n \n stx : Syntax\n \n val : Ξ±",
"start": [
125,
1
],
"end": [
132,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotBundle",
"code": "structure SnapshotBundle (Ξ± : Type) where\n \n old? : Option (SyntaxGuarded (SnapshotTask Ξ±))\n \n new : IO.Promise Ξ±",
"start": [
134,
1
],
"end": [
156,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.withAlwaysResolvedPromise",
"code": "def withAlwaysResolvedPromise [Monad m] [MonadLiftT BaseIO m] [MonadFinally m] [Inhabited Ξ±]\n (act : IO.Promise Ξ± β m Ξ²) : m Ξ² := do\n let p β IO.Promise.new\n try\n act p\n finally\n p.resolve default",
"start": [
158,
1
],
"end": [
170,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.withAlwaysResolvedPromises",
"code": "def withAlwaysResolvedPromises [Monad m] [MonadLiftT BaseIO m] [MonadFinally m] [Inhabited Ξ±]\n (count : Nat) (act : Array (IO.Promise Ξ±) β m Unit) : m Unit := do\n let ps β List.iota count |>.toArray.mapM fun _ => IO.Promise.new\n try\n act ps\n finally\n for p in ps do\n p.resolve default",
"start": [
172,
1
],
"end": [
186,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree",
"code": "inductive SnapshotTree where\n \n | mk (element : Snapshot) (children : Array (SnapshotTask SnapshotTree))\nderiving Inhabited",
"start": [
188,
1
],
"end": [
196,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree.element",
"code": "abbrev SnapshotTree.element : SnapshotTree β Snapshot\n | mk s _ => s",
"start": [
198,
1
],
"end": [
200,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree.children",
"code": "abbrev SnapshotTree.children : SnapshotTree β Array (SnapshotTask SnapshotTree)\n | mk _ children => children",
"start": [
201,
1
],
"end": [
203,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree.format",
"code": "partial def SnapshotTree.format : SnapshotTree β Format := go none\nwhere go range? s :=\n let range := match range? with\n | some range => f!\"{range.start}..{range.stop} \"\n | none => \"\"\n let element := f!\"{s.element.diagnostics.msgLog.unreported.size} diagnostics\"\n let children := Std.Format.prefixJoin .line <|\n s.children.toList.map fun c => go c.range? c.get\n .nestD f!\"β’ {range}{element}{children}\"",
"start": [
205,
1
],
"end": [
214,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.ToSnapshotTree",
"code": "class ToSnapshotTree (Ξ± : Type) where\n \n toSnapshotTree : Ξ± β SnapshotTree",
"start": [
216,
1
],
"end": [
221,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotLeaf",
"code": "structure SnapshotLeaf extends Snapshot\nderiving Nonempty, TypeName",
"start": [
229,
1
],
"end": [
231,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.DynamicSnapshot",
"code": "structure DynamicSnapshot where\n \n val : Dynamic\n \n tree : SnapshotTree",
"start": [
236,
1
],
"end": [
241,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.DynamicSnapshot.ofTyped",
"code": "def DynamicSnapshot.ofTyped [TypeName Ξ±] [ToSnapshotTree Ξ±] (val : Ξ±) : DynamicSnapshot where\n val := .mk val\n tree := ToSnapshotTree.toSnapshotTree val",
"start": [
246,
1
],
"end": [
249,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.DynamicSnapshot.toTyped?",
"code": "def DynamicSnapshot.toTyped? (Ξ± : Type) [TypeName Ξ±] (snap : DynamicSnapshot) :\n Option Ξ± :=\n snap.val.get? Ξ±",
"start": [
251,
1
],
"end": [
254,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree.forM",
"code": "@[specialize] partial def SnapshotTree.forM [Monad m] (s : SnapshotTree)\n (f : Snapshot β m PUnit) : m PUnit := do\n match s with\n | mk element children =>\n f element\n children.forM (Β·.get.forM f)",
"start": [
259,
1
],
"end": [
267,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.reportMessages",
"code": "def reportMessages (msgLog : MessageLog) (opts : Options) (json := false) : IO Unit := do\n if json then\n msgLog.forM (Β·.toJson <&> (Β·.compress) >>= IO.println)\n else\n msgLog.forM (Β·.toString (includeEndPos := printMessageEndPos.get opts) >>= IO.print)",
"start": [
276,
1
],
"end": [
281,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree.runAndReport",
"code": "def SnapshotTree.runAndReport (s : SnapshotTree) (opts : Options) (json := false) : IO Unit := do\n s.forM (reportMessages Β·.diagnostics.msgLog opts json)",
"start": [
283,
1
],
"end": [
289,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.SnapshotTree.getAll",
"code": "def SnapshotTree.getAll (s : SnapshotTree) : Array Snapshot :=\n s.forM (m := StateM _) (fun s => modify (Β·.push s)) |>.run #[] |>.2",
"start": [
291,
1
],
"end": [
293,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.ProcessingContext",
"code": "structure ProcessingContext extends Parser.InputContext",
"start": [
295,
1
],
"end": [
296,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.ProcessingT",
"code": "abbrev ProcessingT m := ReaderT ProcessingContext m",
"start": [
298,
1
],
"end": [
299,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.ProcessingM",
"code": "abbrev ProcessingM := ProcessingT BaseIO",
"start": [
300,
1
],
"end": [
301,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.Snapshot.Diagnostics.ofMessageLog",
"code": "def Snapshot.Diagnostics.ofMessageLog (msgLog : Lean.MessageLog) :\n BaseIO Snapshot.Diagnostics := do\n return { msgLog, interactiveDiagsRef? := some (β IO.mkRef none) }",
"start": [
306,
1
],
"end": [
312,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.diagnosticsOfHeaderError",
"code": "def diagnosticsOfHeaderError (msg : String) : ProcessingM Snapshot.Diagnostics := do\n let msgLog := MessageLog.empty.add {\n fileName := \"<input>\"\n pos := β¨1, 0β©\n endPos := (β read).fileMap.toPosition (β read).fileMap.source.endPos\n data := msg\n }\n Snapshot.Diagnostics.ofMessageLog msgLog",
"start": [
314,
1
],
"end": [
322,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Language.withHeaderExceptions",
"code": "def withHeaderExceptions (ex : Snapshot β Ξ±) (act : ProcessingT IO Ξ±) : ProcessingM Ξ± := do\n match (β (act (β read)).toBaseIO) with\n | .error e => return ex { diagnostics := (β diagnosticsOfHeaderError e.toString) }\n | .ok a => return a",
"start": [
324,
1
],
"end": [
330,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Language.mkIncrementalProcessor",
"code": "def Language.mkIncrementalProcessor (process : Option InitSnap β ProcessingM InitSnap) :\n BaseIO (Parser.InputContext β BaseIO InitSnap) := do\n let oldRef β IO.mkRef none\n return fun ictx => do\n let snap β process (β oldRef.get) { ictx with }\n oldRef.set (some snap)\n return snap",
"start": [
334,
1
],
"end": [
343,
16
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Linter/Deprecated.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/Linter/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Main.lean"
] | [
{
"full_name": "Lean.Linter.DeprecationEntry",
"code": "structure DeprecationEntry where\n newName? : Option Name := none\n text? : Option String := none\n since? : Option String := none\n deriving Inhabited",
"start": [
18,
1
],
"end": [
22,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Linter.isDeprecated",
"code": "def isDeprecated (env : Environment) (declName : Name) : Bool :=\n Option.isSome <| deprecatedAttr.getParam? env declName",
"start": [
37,
1
],
"end": [
38,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.isDeprecationWarning",
"code": "def _root_.Lean.MessageData.isDeprecationWarning (msg : MessageData) : Bool :=\n msg.hasTag (Β· == ``deprecatedAttr)",
"start": [
40,
1
],
"end": [
41,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Linter.getDeprecatedNewName",
"code": "def getDeprecatedNewName (env : Environment) (declName : Name) : Option Name := do\n (β deprecatedAttr.getParam? env declName).newName?",
"start": [
43,
1
],
"end": [
44,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Linter.checkDeprecated",
"code": "def checkDeprecated [Monad m] [MonadEnv m] [MonadLog m] [AddMessageContext m] [MonadOptions m] (declName : Name) : m Unit := do\n if getLinterValue linter.deprecated (β getOptions) then\n let some attr := deprecatedAttr.getParam? (β getEnv) declName | pure ()\n logWarning <| .tagged ``deprecatedAttr <| attr.text?.getD <|\n match attr.newName? with\n | none => s!\"`{declName}` has been deprecated\"\n | some newName => s!\"`{declName}` has been deprecated, use `{newName}` instead\"",
"start": [
46,
1
],
"end": [
52,
86
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/PreDefinition/WF/TerminationHint.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Term.lean"
] | [
{
"full_name": "Lean.Elab.WF.TerminationBy",
"code": "structure TerminationBy where\n ref : Syntax\n vars : TSyntaxArray [`ident, ``Lean.Parser.Term.hole]\n body : Term\n \n synthetic : Bool := false\n deriving Inhabited",
"start": [
15,
1
],
"end": [
27,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.DecreasingBy",
"code": "structure DecreasingBy where\n ref : Syntax\n tactic : TSyntax ``Lean.Parser.Tactic.tacticSeq\n deriving Inhabited",
"start": [
29,
1
],
"end": [
33,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.TerminationHints",
"code": "structure TerminationHints where\n ref : Syntax\n terminationBy?? : Option Syntax\n terminationBy? : Option TerminationBy\n decreasingBy? : Option DecreasingBy\n \n extraParams : Nat\n deriving Inhabited",
"start": [
35,
1
],
"end": [
53,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.TerminationHints.none",
"code": "def TerminationHints.none : TerminationHints := β¨.missing, .none, .none, .none, 0β©",
"start": [
55,
1
],
"end": [
55,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.TerminationHints.ensureNone",
"code": "def TerminationHints.ensureNone (hints : TerminationHints) (reason : String): CoreM Unit := do\n match hints.terminationBy??, hints.terminationBy?, hints.decreasingBy? with\n | .none, .none, .none => pure ()\n | .none, .none, .some dec_by =>\n logErrorAt dec_by.ref m!\"unused `decreasing_by`, function is {reason}\"\n | .some term_by?, .none, .none =>\n logErrorAt term_by? m!\"unused `termination_by?`, function is {reason}\"\n | .none, .some term_by, .none =>\n logErrorAt term_by.ref m!\"unused `termination_by`, function is {reason}\"\n | _, _, _ =>\n logErrorAt hints.ref m!\"unused termination hints, function is {reason}\"",
"start": [
57,
1
],
"end": [
68,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.TerminationHints.isNotNone",
"code": "def TerminationHints.isNotNone (hints : TerminationHints) : Bool :=\n hints.terminationBy??.isSome ||\n hints.terminationBy?.isSome ||\n hints.decreasingBy?.isSome",
"start": [
70,
1
],
"end": [
74,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.TerminationHints.rememberExtraParams",
"code": "def TerminationHints.rememberExtraParams (headerParams : Nat) (hints : TerminationHints)\n (value : Expr) : TerminationHints :=\n { hints with extraParams := value.getNumHeadLambdas - headerParams }",
"start": [
76,
1
],
"end": [
82,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.TerminationBy.checkVars",
"code": "def TerminationBy.checkVars (funName : Name) (extraParams : Nat) (tb : TerminationBy) : MetaM Unit := do\n unless tb.synthetic do\n if tb.vars.size > extraParams then\n let mut msg := m!\"{parameters tb.vars.size} bound in `termination_by`, but the body of \" ++\n m!\"{funName} only binds {parameters extraParams}.\"\n if let `($ident:ident) := tb.vars[0]! then\n if ident.getId.isSuffixOf funName then\n msg := msg ++ m!\" (Since Lean v4.6.0, the `termination_by` clause no longer \" ++\n \"expects the function name here.)\"\n throwErrorAt tb.ref msg\n where\n parameters : Nat β MessageData\n | 1 => \"one parameter\"\n | n => m!\"{n} parameters\"",
"start": [
84,
1
],
"end": [
101,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.WF.elabTerminationHints",
"code": "def elabTerminationHints {m} [Monad m] [MonadError m] (stx : TSyntax ``suffix) : m TerminationHints := do\n if let .missing := stx.raw then\n return { TerminationHints.none with ref := stx }\n match stx with\n | `(suffix| $[$t?]? $[$d?:decreasingBy]? ) => do\n let terminationBy?? : Option Syntax β if let some t := t? then match t with\n | `(terminationBy?|termination_by?) => pure (some t)\n | _ => pure none\n else pure none\n let terminationBy? : Option TerminationBy β if let some t := t? then match t with\n | `(terminationBy|termination_by => $_body) =>\n throwErrorAt t \"no extra parameters bounds, please omit the `=>`\"\n | `(terminationBy|termination_by $vars* => $body) => pure (some {ref := t, vars, body})\n | `(terminationBy|termination_by $body:term) => pure (some {ref := t, vars := #[], body})\n | `(terminationBy?|termination_by?) => pure none\n | _ => throwErrorAt t \"unexpected `termination_by` syntax\"\n else pure none\n let decreasingBy? β d?.mapM fun d => match d with\n | `(decreasingBy|decreasing_by $tactic) => pure {ref := d, tactic}\n | _ => throwErrorAt d \"unexpected `decreasing_by` syntax\"\n return { ref := stx, terminationBy??, terminationBy?, decreasingBy?, extraParams := 0 }\n | _ => throwErrorAt stx s!\"Unexpected Termination.suffix syntax: {stx} of kind {stx.raw.getKind}\"",
"start": [
105,
1
],
"end": [
128,
100
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/DeclModifiers.lean | [
".lake/packages/lean4/src/lean/Lean/Elab/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/Structure.lean"
] | [
{
"full_name": "Lean.Elab.checkNotAlreadyDeclared",
"code": "def checkNotAlreadyDeclared {m} [Monad m] [MonadEnv m] [MonadError m] [MonadInfoTree m] (declName : Name) : m Unit := do\n let env β getEnv\n let addInfo declName := do\n pushInfoLeaf <| .ofTermInfo {\n elaborator := .anonymous, lctx := {}, expectedType? := none\n stx := (β getRef)\n expr := (β mkConstWithLevelParams declName)\n }\n if env.contains declName then\n addInfo declName\n match privateToUserName? declName with\n | none => throwError \"'{declName}' has already been declared\"\n | some declName => throwError \"private declaration '{declName}' has already been declared\"\n if isReservedName env declName then\n throwError \"'{declName}' is a reserved name\"\n if env.contains (mkPrivateName env declName) then\n addInfo (mkPrivateName env declName)\n throwError \"a private declaration '{declName}' has already been declared\"\n match privateToUserName? declName with\n | none => pure ()\n | some declName =>\n if env.contains declName then\n addInfo declName\n throwError \"a non-private declaration '{declName}' has already been declared\"",
"start": [
12,
1
],
"end": [
40,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Visibility",
"code": "inductive Visibility where\n | regular | Β«protectedΒ» | Β«privateΒ»\n deriving Inhabited",
"start": [
42,
1
],
"end": [
45,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.RecKind",
"code": "inductive RecKind where\n | Β«partialΒ» | Β«nonrecΒ» | default\n deriving Inhabited",
"start": [
53,
1
],
"end": [
56,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers",
"code": "structure Modifiers where\n docString? : Option String := none\n visibility : Visibility := Visibility.regular\n isNoncomputable : Bool := false\n recKind : RecKind := RecKind.default\n isUnsafe : Bool := false\n attrs : Array Attribute := #[]\n deriving Inhabited",
"start": [
58,
1
],
"end": [
66,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers.isPrivate",
"code": "def Modifiers.isPrivate : Modifiers β Bool\n | { visibility := .private, .. } => true\n | _ => false",
"start": [
68,
1
],
"end": [
70,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers.isProtected",
"code": "def Modifiers.isProtected : Modifiers β Bool\n | { visibility := .protected, .. } => true\n | _ => false",
"start": [
72,
1
],
"end": [
74,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers.isPartial",
"code": "def Modifiers.isPartial : Modifiers β Bool\n | { recKind := .partial, .. } => true\n | _ => false",
"start": [
76,
1
],
"end": [
78,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers.isNonrec",
"code": "def Modifiers.isNonrec : Modifiers β Bool\n | { recKind := .nonrec, .. } => true\n | _ => false",
"start": [
80,
1
],
"end": [
82,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers.addAttr",
"code": "def Modifiers.addAttr (modifiers : Modifiers) (attr : Attribute) : Modifiers :=\n { modifiers with attrs := modifiers.attrs.push attr }",
"start": [
84,
1
],
"end": [
86,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Modifiers.filterAttrs",
"code": "def Modifiers.filterAttrs (modifiers : Modifiers) (p : Attribute β Bool) : Modifiers :=\n { modifiers with attrs := modifiers.attrs.filter p }",
"start": [
88,
1
],
"end": [
90,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.expandOptDocComment?",
"code": "def expandOptDocComment? [Monad m] [MonadError m] (optDocComment : Syntax) : m (Option String) :=\n match optDocComment.getOptional? with\n | none => return none\n | some s => match s[1] with\n | .atom _ val => return some (val.extract 0 (val.endPos - β¨2β©))\n | _ => throwErrorAt s \"unexpected doc string{indentD s[1]}\"",
"start": [
109,
1
],
"end": [
117,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.elabModifiers",
"code": "def elabModifiers (stx : Syntax) : m Modifiers := do\n let docCommentStx := stx[0]\n let attrsStx := stx[1]\n let visibilityStx := stx[2]\n let noncompStx := stx[3]\n let unsafeStx := stx[4]\n let recKind :=\n if stx[5].isNone then\n RecKind.default\n else if stx[5][0].getKind == ``Parser.Command.partial then\n RecKind.partial\n else\n RecKind.nonrec\n let docString? β match docCommentStx.getOptional? with\n | none => pure none\n | some s => pure (some (β getDocStringText β¨sβ©))\n let visibility β match visibilityStx.getOptional? with\n | none => pure Visibility.regular\n | some v =>\n let kind := v.getKind\n if kind == ``Parser.Command.private then pure Visibility.private\n else if kind == ``Parser.Command.protected then pure Visibility.protected\n else throwErrorAt v \"unexpected visibility modifier\"\n let attrs β match attrsStx.getOptional? with\n | none => pure #[]\n | some attrs => elabDeclAttrs attrs\n return {\n docString?, visibility, recKind, attrs,\n isUnsafe := !unsafeStx.isNone\n isNoncomputable := !noncompStx.isNone\n }",
"start": [
123,
1
],
"end": [
154,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.applyVisibility",
"code": "def applyVisibility (visibility : Visibility) (declName : Name) : m Name := do\n match visibility with\n | .private =>\n let declName := mkPrivateName (β getEnv) declName\n checkNotAlreadyDeclared declName\n return declName\n | .protected =>\n checkNotAlreadyDeclared declName\n modifyEnv fun env => addProtected env declName\n return declName\n | _ =>\n checkNotAlreadyDeclared declName\n pure declName",
"start": [
156,
1
],
"end": [
173,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.checkIfShadowingStructureField",
"code": "def checkIfShadowingStructureField (declName : Name) : m Unit := do\n match declName with\n | Name.str pre .. =>\n if isStructure (β getEnv) pre then\n let fieldNames := getStructureFieldsFlattened (β getEnv) pre\n for fieldName in fieldNames do\n if pre ++ fieldName == declName then\n throwError \"invalid declaration name '{declName}', structure '{pre}' has field '{fieldName}'\"\n | _ => pure ()",
"start": [
175,
1
],
"end": [
183,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkDeclName",
"code": "def mkDeclName (currNamespace : Name) (modifiers : Modifiers) (shortName : Name) : m (Name Γ Name) := do\n let mut shortName := shortName\n let mut currNamespace := currNamespace\n let view := extractMacroScopes shortName\n let name := view.name\n let isRootName := (`_root_).isPrefixOf name\n if name == `_root_ then\n throwError \"invalid declaration name `_root_`, `_root_` is a prefix used to refer to the 'root' namespace\"\n let declName := if isRootName then { view with name := name.replacePrefix `_root_ Name.anonymous }.review else currNamespace ++ shortName\n if isRootName then\n let .str p s := name | throwError \"invalid declaration name '{name}'\"\n shortName := Name.mkSimple s\n currNamespace := p.replacePrefix `_root_ Name.anonymous\n checkIfShadowingStructureField declName\n let declName β applyVisibility modifiers.visibility declName\n match modifiers.visibility with\n | Visibility.protected =>\n match currNamespace with\n | .str _ s => return (declName, Name.mkSimple s ++ shortName)\n | _ =>\n if shortName.isAtomic then\n throwError \"protected declarations must be in a namespace\"\n return (declName, shortName)\n | _ => return (declName, shortName)",
"start": [
185,
1
],
"end": [
208,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.expandDeclIdCore",
"code": "def expandDeclIdCore (declId : Syntax) : Name Γ Syntax :=\n if declId.isIdent then\n (declId.getId, mkNullNode)\n else\n let id := declId[0].getId\n let optUnivDeclStx := declId[1]\n (id, optUnivDeclStx)",
"start": [
210,
1
],
"end": [
223,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.ExpandDeclIdResult",
"code": "structure ExpandDeclIdResult where\n \n shortName : Name\n \n declName : Name\n \n levelNames : List Name",
"start": [
225,
1
],
"end": [
232,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.expandDeclId",
"code": "def expandDeclId (currNamespace : Name) (currLevelNames : List Name) (declId : Syntax) (modifiers : Modifiers) : m ExpandDeclIdResult := do\n let (shortName, optUnivDeclStx) := expandDeclIdCore declId\n let levelNames β if optUnivDeclStx.isNone then\n pure currLevelNames\n else\n let extraLevels := optUnivDeclStx[1].getArgs.getEvenElems\n extraLevels.foldlM\n (fun levelNames idStx =>\n let id := idStx.getId\n if levelNames.elem id then\n withRef idStx <| throwAlreadyDeclaredUniverseLevel id\n else\n pure (id :: levelNames))\n currLevelNames\n let (declName, shortName) β withRef declId <| mkDeclName currNamespace modifiers shortName\n addDocString' declName modifiers.docString?\n return { shortName := shortName, declName := declName, levelNames := levelNames }",
"start": [
234,
1
],
"end": [
261,
84
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Coe.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/SynthInstance.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Transform.lean"
] | [
{
"full_name": "Lean.Meta.isCoeDecl",
"code": "def isCoeDecl (env : Environment) (declName : Name) : Bool :=\n coeDeclAttr.hasTag env declName",
"start": [
16,
1
],
"end": [
21,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.expandCoe",
"code": "partial def expandCoe (e : Expr) : MetaM Expr :=\n withReducibleAndInstances do\n transform e fun e => do\n let f := e.getAppFn\n if f.isConst then\n let declName := f.constName!\n if isCoeDecl (β getEnv) declName then\n if let some e β unfoldDefinition? e then\n return .visit e.headBeta\n return .continue",
"start": [
23,
1
],
"end": [
33,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.coerceSimple?",
"code": "def coerceSimple? (expr expectedType : Expr) : MetaM (LOption Expr) := do\n let eType β inferType expr\n let u β getLevel eType\n let v β getLevel expectedType\n let coeTInstType := mkAppN (mkConst ``CoeT [u, v]) #[eType, expr, expectedType]\n match β trySynthInstance coeTInstType with\n | .some inst =>\n let result β expandCoe (mkAppN (mkConst ``CoeT.coe [u, v]) #[eType, expr, expectedType, inst])\n unless β isDefEq (β inferType result) expectedType do\n throwError \"could not coerce{indentExpr expr}\\nto{indentExpr expectedType}\\ncoerced expression has wrong type:{indentExpr result}\"\n return .some result\n | .undef => return .undef\n | .none => return .none",
"start": [
40,
1
],
"end": [
53,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.coerceToFunction?",
"code": "def coerceToFunction? (expr : Expr) : MetaM (Option Expr) := do\n let Ξ± β inferType expr\n let u β getLevel Ξ±\n let v β mkFreshLevelMVar\n let Ξ³ β mkFreshExprMVar (β mkArrow Ξ± (mkSort v))\n let .some inst β trySynthInstance (mkApp2 (.const ``CoeFun [u,v]) Ξ± Ξ³) | return none\n let expanded β expandCoe (mkApp4 (.const ``CoeFun.coe [u,v]) Ξ± Ξ³ inst expr)\n unless (β whnf (β inferType expanded)).isForall do\n throwError \"failed to coerce{indentExpr expr}\\nto a function, after applying `CoeFun.coe`, result is still not a function{indentExpr expanded}\\nthis is often due to incorrect `CoeFun` instances, the synthesized instance was{indentExpr inst}\"\n return expanded",
"start": [
55,
1
],
"end": [
66,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.coerceToSort?",
"code": "def coerceToSort? (expr : Expr) : MetaM (Option Expr) := do\n let Ξ± β inferType expr\n let u β getLevel Ξ±\n let v β mkFreshLevelMVar\n let Ξ² β mkFreshExprMVar (mkSort v)\n let .some inst β trySynthInstance (mkApp2 (.const ``CoeSort [u,v]) Ξ± Ξ²) | return none\n let expanded β expandCoe (mkApp4 (.const ``CoeSort.coe [u,v]) Ξ± Ξ² inst expr)\n unless (β whnf (β inferType expanded)).isSort do\n throwError \"failed to coerce{indentExpr expr}\\nto a type, after applying `CoeSort.coe`, result is still not a type{indentExpr expanded}\\nthis is often due to incorrect `CoeSort` instances, the synthesized instance was{indentExpr inst}\"\n return expanded",
"start": [
68,
1
],
"end": [
79,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isTypeApp?",
"code": "def isTypeApp? (type : Expr) : MetaM (Option (Expr Γ Expr)) := do\n let type β withReducible <| whnf type\n match type with\n | .app m Ξ± => return some ((β instantiateMVars m), (β instantiateMVars Ξ±))\n | _ => return none",
"start": [
81,
1
],
"end": [
86,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isMonadApp",
"code": "def isMonadApp (type : Expr) : MetaM Bool := do\n let some (m, _) β isTypeApp? type | return false\n return (β isMonad? m).isSome",
"start": [
88,
1
],
"end": [
94,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.coerceMonadLift?",
"code": "def coerceMonadLift? (e expectedType : Expr) : MetaM (Option Expr) := do\n let expectedType β instantiateMVars expectedType\n let eType β instantiateMVars (β inferType e)\n let some (n, Ξ²) β isTypeApp? expectedType | return none\n let some (m, Ξ±) β isTypeApp? eType | return none\n if (β isDefEq m n) then\n let some monadInst β isMonad? n | return none\n try expandCoe (β mkAppOptM ``Lean.Internal.coeM #[m, Ξ±, Ξ², none, monadInst, e]) catch _ => return none\n else if autoLift.get (β getOptions) then\n try\n let .forallE _ (.sort umβ) (.sort umβ) _ β whnf (β inferType m) | return none\n let .forallE _ (.sort unβ) (.sort unβ) _ β whnf (β inferType n) | return none\n let u β decLevel umβ\n let .true β isLevelDefEq u (β decLevel unβ) | return none\n let v β decLevel umβ\n let w β decLevel unβ\n let monadLiftType := mkAppN (.const ``MonadLiftT [u, v, w]) #[m, n]\n let .some monadLiftVal β trySynthInstance monadLiftType | return none\n let u_1 β getDecLevel Ξ±\n let u_2 β getDecLevel eType\n let u_3 β getDecLevel expectedType\n let eNew := mkAppN (Lean.mkConst ``liftM [u_1, u_2, u_3]) #[m, n, monadLiftVal, Ξ±, e]\n let eNewType β inferType eNew\n if (β isDefEq expectedType eNewType) then\n return some eNew else\n let some monadInst β isMonad? n | return none\n let u β getLevel Ξ±\n let v β getLevel Ξ²\n let coeTInstType := Lean.mkForall `a BinderInfo.default Ξ± <| mkAppN (mkConst ``CoeT [u, v]) #[Ξ±, mkBVar 0, Ξ²]\n let .some coeTInstVal β trySynthInstance coeTInstType | return none\n let eNew β expandCoe (mkAppN (Lean.mkConst ``Lean.Internal.liftCoeM [u_1, u_2, u_3]) #[m, n, Ξ±, Ξ², monadLiftVal, coeTInstVal, monadInst, e])\n let eNewType β inferType eNew\n unless (β isDefEq expectedType eNewType) do return none\n return some eNew catch _ =>\n \n return none\n else\n return none",
"start": [
96,
1
],
"end": [
197,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.coerce?",
"code": "def coerce? (expr expectedType : Expr) : MetaM (LOption Expr) := do\n if let some lifted β coerceMonadLift? expr expectedType then\n return .some lifted\n if (β whnfR expectedType).isForall then\n if let some fn β coerceToFunction? expr then\n if β isDefEq (β inferType fn) expectedType then\n return .some fn\n coerceSimple? expr expectedType",
"start": [
199,
1
],
"end": [
210,
34
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Level.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Level.lean",
".lake/packages/lean4/src/lean/Lean/Elab/AutoBound.lean",
".lake/packages/lean4/src/lean/Lean/Elab/Exception.lean",
".lake/packages/lean4/src/lean/Lean/Log.lean"
] | [
{
"full_name": "Lean.Elab.Level.Context",
"code": "structure Context where\n options : Options\n ref : Syntax\n autoBoundImplicit : Bool",
"start": [
14,
1
],
"end": [
17,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Level.State",
"code": "structure State where\n ngen : NameGenerator\n mctx : MetavarContext\n levelNames : List Name",
"start": [
19,
1
],
"end": [
22,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Level.LevelElabM",
"code": "abbrev LevelElabM := ReaderT Context (EStateM Exception State)",
"start": [
24,
1
],
"end": [
24,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Level.mkFreshLevelMVar",
"code": "def mkFreshLevelMVar : LevelElabM Level := do\n let mvarId β mkFreshLMVarId\n modify fun s => { s with mctx := s.mctx.addLevelMVarDecl mvarId }\n return mkLevelMVar mvarId",
"start": [
42,
1
],
"end": [
45,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Level.checkUniverseOffset",
"code": "private def checkUniverseOffset [Monad m] [MonadError m] [MonadOptions m] (n : Nat) : m Unit := do\n let max := maxUniverseOffset.get (β getOptions)\n unless n <= max do\n throwError \"maximum universe level offset threshold ({max}) has been reached, you can increase the limit using option `set_option maxUniverseOffset <limit>`, but you are probably misusing universe levels since offsets are usually small natural numbers\"",
"start": [
52,
1
],
"end": [
55,
257
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Level.elabLevel",
"code": "partial def elabLevel (stx : Syntax) : LevelElabM Level := withRef stx do\n let kind := stx.getKind\n if kind == ``Lean.Parser.Level.paren then\n elabLevel (stx.getArg 1)\n else if kind == ``Lean.Parser.Level.max then\n let args := stx.getArg 1 |>.getArgs\n args[:args.size - 1].foldrM (init := β elabLevel args.back) fun stx lvl =>\n return mkLevelMax' (β elabLevel stx) lvl\n else if kind == ``Lean.Parser.Level.imax then\n let args := stx.getArg 1 |>.getArgs\n args[:args.size - 1].foldrM (init := β elabLevel args.back) fun stx lvl =>\n return mkLevelIMax' (β elabLevel stx) lvl\n else if kind == ``Lean.Parser.Level.hole then\n mkFreshLevelMVar\n else if kind == numLitKind then\n match stx.isNatLit? with\n | some val => checkUniverseOffset val; return Level.ofNat val\n | none => throwIllFormedSyntax\n else if kind == identKind then\n let paramName := stx.getId\n unless (β get).levelNames.contains paramName do\n if (β read).autoBoundImplicit && isValidAutoBoundLevelName paramName (relaxedAutoImplicit.get (β read).options) then\n modify fun s => { s with levelNames := paramName :: s.levelNames }\n else\n throwError \"unknown universe level '{mkIdent paramName}'\"\n return mkLevelParam paramName\n else if kind == `Lean.Parser.Level.addLit then\n let lvl β elabLevel (stx.getArg 0)\n match stx.getArg 2 |>.isNatLit? with\n | some val => checkUniverseOffset val; return lvl.addOffset val\n | none => throwIllFormedSyntax\n else\n throwError \"unexpected universe level syntax kind\"",
"start": [
57,
1
],
"end": [
89,
55
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Config.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Elab.Term.setElabConfig",
"code": "def setElabConfig (cfg : Meta.Config) : Meta.Config :=\n { cfg with foApprox := true, ctxApprox := true, constApprox := false, quasiPatternApprox := false }",
"start": [
11,
1
],
"end": [
58,
102
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/FindLevelMVar.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.FindLevelMVar.Visitor",
"code": "abbrev Visitor := Option LMVarId β Option LMVarId",
"start": [
13,
1
],
"end": [
13,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FindLevelMVar.visit",
"code": "partial def visit (p : LMVarId β Bool) (e : Expr) : Visitor := fun s =>\n if s.isSome || !e.hasLevelMVar then s else main p e s",
"start": [
16,
3
],
"end": [
17,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FindLevelMVar.main",
"code": "partial def main (p : LMVarId β Bool) : Expr β Visitor\n | .sort l => visitLevel p l\n | .const _ ls => ls.foldr (init := id) fun l acc => visitLevel p l β acc\n | .forallE _ d b _ => visit p b β visit p d\n | .lam _ d b _ => visit p b β visit p d\n | .letE _ t v b _ => visit p b β visit p v β visit p t\n | .app f a => visit p a β visit p f\n | .mdata _ b => visit p b\n | .proj _ _ e => visit p e\n | _ => id",
"start": [
19,
3
],
"end": [
28,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FindLevelMVar.visitLevel",
"code": "partial def visitLevel (p : LMVarId β Bool) (l : Level) : Visitor := fun s =>\n if s.isSome || !l.hasMVar then s else mainLevel p l s",
"start": [
30,
3
],
"end": [
31,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FindLevelMVar.mainLevel",
"code": "partial def mainLevel (p : LMVarId β Bool) : Level β Visitor\n | .zero => id\n | .succ l => visitLevel p l\n | .max lβ lβ => visitLevel p lβ β visitLevel p lβ\n | .imax lβ lβ => visitLevel p lβ β visitLevel p lβ\n | .param _ => id\n | .mvar mvarId => fun s => if p mvarId then some mvarId else s",
"start": [
33,
3
],
"end": [
39,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.findLevelMVar?",
"code": "@[inline] def Expr.findLevelMVar? (e : Expr) (p : LMVarId β Bool) : Option LMVarId :=\n FindLevelMVar.main p e none",
"start": [
44,
1
],
"end": [
45,
30
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/FieldNotation.lean | [
".lake/packages/lean4/src/lean/Lean/Structure.lean",
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Options.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Attributes.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Delaborator.projInfo",
"code": "private def projInfo (c : Name) : MetaM (Name Γ Nat Γ Bool) := do\n let .str _ field := c | failure\n let field := Name.mkSimple field\n let env β getEnv\n let some info := env.getProjectionFnInfo? c | failure\n guard <| !info.fromClass\n let some (.ctorInfo cVal) := env.find? info.ctorName | failure\n let isParentProj := (isSubobjectField? env cVal.induct field).isSome\n return (field, info.numParams, isParentProj)",
"start": [
19,
1
],
"end": [
33,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.typeMatchesBaseName",
"code": "private def typeMatchesBaseName (type : Expr) (baseName : Name) : MetaM Bool := do\n if type.cleanupAnnotations.isAppOf baseName then\n return true\n else\n return (β whnfR type).isAppOf baseName",
"start": [
35,
1
],
"end": [
42,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.generalizedFieldInfo",
"code": "private def generalizedFieldInfo (c : Name) (args : Array Expr) : MetaM (Name Γ Nat) := do\n let .str _ field := c | failure\n let field := Name.mkSimple field\n let baseName := c.getPrefix\n guard <| !baseName.isAnonymous\n guard <| baseName != `Function\n let info β getConstInfo c\n forallBoundedTelescope info.type args.size fun params _ => do\n for i in [0:params.size] do\n let fvarId := params[i]!.fvarId!\n if (β fvarId.getUserName) == `motive then\n failure\n if (β typeMatchesBaseName (β fvarId.getType) baseName) then\n guard (β fvarId.getBinderInfo).isExplicit\n guard <| (β instantiateMVars <| β inferType args[i]!).consumeMData.isAppOf baseName\n return (field, i)\n else\n guard !(β fvarId.getBinderInfo).isExplicit\n failure",
"start": [
44,
1
],
"end": [
76,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.fieldNotationCandidate?",
"code": "def fieldNotationCandidate? (f : Expr) (args : Array Expr) (useGeneralizedFieldNotation : Bool) : MetaM (Option (Name Γ Nat)) := do\n let env β getEnv\n let .const c .. := f.consumeMData | return none\n if c.getPrefix.isAnonymous then return none\n if hasPPNoDotAttribute env c then\n return none\n try\n let (field, numParams, _) β projInfo c\n return (field, numParams)\n catch _ => pure ()\n if useGeneralizedFieldNotation then\n try\n guard !(β isProof f)\n return β generalizedFieldInfo c args\n catch _ => pure ()\n return none",
"start": [
78,
1
],
"end": [
102,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.parentProj?",
"code": "def parentProj? (explicit : Bool) (e : Expr) : MetaM (Option Name) := do\n unless e.isApp do return none\n try\n let .const c .. := e.getAppFn | failure\n let (field, numParams, isParentProj) β projInfo c\n if isParentProj && (!explicit || numParams == 0) && e.getAppNumArgs == numParams + 1 then\n return some field\n else\n return none\n catch _ =>\n return none",
"start": [
104,
1
],
"end": [
118,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isParentProj",
"code": "def isParentProj (explicit : Bool) (e : Expr) : MetaM Bool := do\n return (β parentProj? explicit e).isSome",
"start": [
120,
1
],
"end": [
125,
43
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/CollectLevelParams.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.CollectLevelParams.State",
"code": "structure State where\n visitedLevel : LevelSet := {}\n visitedExpr : ExprSet := {}\n params : Array Name := #[]",
"start": [
13,
1
],
"end": [
16,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.Visitor",
"code": "abbrev Visitor := State β State",
"start": [
20,
1
],
"end": [
20,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.visitLevel",
"code": "partial def visitLevel (u : Level) : Visitor := fun s =>\n if !u.hasParam || s.visitedLevel.contains u then s\n else collect u { s with visitedLevel := s.visitedLevel.insert u }",
"start": [
23,
3
],
"end": [
25,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.collect",
"code": "partial def collect : Level β Visitor\n | .succ v => visitLevel v\n | .max u v => visitLevel v β visitLevel u\n | .imax u v => visitLevel v β visitLevel u\n | .param n => fun s => { s with params := s.params.push n }\n | _ => id",
"start": [
27,
3
],
"end": [
32,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.visitLevels",
"code": "def visitLevels (us : List Level) : Visitor :=\n fun s => us.foldl (fun s u => visitLevel u s) s",
"start": [
35,
1
],
"end": [
36,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.visitExpr",
"code": "partial def visitExpr (e : Expr) : Visitor := fun s =>\n if !e.hasLevelParam then s\n else if s.visitedExpr.contains e then s\n else main e { s with visitedExpr := s.visitedExpr.insert e }",
"start": [
39,
3
],
"end": [
42,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.main",
"code": "partial def main : Expr β Visitor\n | .proj _ _ s => visitExpr s\n | .forallE _ d b _ => visitExpr b β visitExpr d\n | .lam _ d b _ => visitExpr b β visitExpr d\n | .letE _ t v b _ => visitExpr b β visitExpr v β visitExpr t\n | .app f a => visitExpr a β visitExpr f\n | .mdata _ b => visitExpr b\n | .const _ us => visitLevels us\n | .sort u => visitLevel u\n | _ => id",
"start": [
44,
3
],
"end": [
53,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.State.getUnusedLevelParam",
"code": "partial def State.getUnusedLevelParam (s : CollectLevelParams.State) (pre : Name := `v) : Level :=\n let v := mkLevelParam pre;\n if s.visitedLevel.contains v then\n let rec loop (i : Nat) :=\n let v := mkLevelParam (pre.appendIndexAfter i);\n if s.visitedLevel.contains v then loop (i+1) else v\n loop 1\n else\n v",
"start": [
56,
1
],
"end": [
64,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.collectLevelParams",
"code": "def collectLevelParams (s : CollectLevelParams.State) (e : Expr) : CollectLevelParams.State :=\n CollectLevelParams.main e s",
"start": [
68,
1
],
"end": [
69,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CollectLevelParams.State.collect",
"code": "def CollectLevelParams.State.collect (s : CollectLevelParams.State) (e : Expr) : CollectLevelParams.State :=\n collectLevelParams s e",
"start": [
71,
1
],
"end": [
72,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/ReplaceLevel.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.Level.replace",
"code": "partial def replace (f? : Level β Option Level) (u : Level) : Level :=\n match f? u with\n | some v => v\n | none => match u with\n | max vβ vβ => mkLevelMax' (replace f? vβ) (replace f? vβ)\n | imax vβ vβ => mkLevelIMax' (replace f? vβ) (replace f? vβ)\n | succ v => mkLevelSucc (replace f? v)\n | _ => u",
"start": [
12,
1
],
"end": [
19,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.cacheSize",
"code": "abbrev cacheSize : USize := 8192 - 1",
"start": [
27,
1
],
"end": [
27,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.State",
"code": "structure State where\n keys : Array Expr results : Array Expr",
"start": [
29,
1
],
"end": [
31,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.ReplaceM",
"code": "abbrev ReplaceM := StateM State",
"start": [
33,
1
],
"end": [
33,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.cache",
"code": "unsafe def cache (i : USize) (key : Expr) (result : Expr) : ReplaceM Expr := do\n modify fun s => { keys := s.keys.uset i key lcProof, results := s.results.uset i result lcProof };\n pure result",
"start": [
35,
1
],
"end": [
37,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.replaceUnsafeM",
"code": "unsafe def replaceUnsafeM (f? : Level β Option Level) (size : USize) (e : Expr) : ReplaceM Expr := do\n let rec visit (e : Expr) := do\n let c β get\n let h := ptrAddrUnsafe e\n let i := h % size\n if ptrAddrUnsafe (c.keys.uget i lcProof) == h then\n pure <| c.results.uget i lcProof\n else match e with\n | Expr.forallE _ d b _ => cache i e <| e.updateForallE! (β visit d) (β visit b)\n | Expr.lam _ d b _ => cache i e <| e.updateLambdaE! (β visit d) (β visit b)\n | Expr.mdata _ b => cache i e <| e.updateMData! (β visit b)\n | Expr.letE _ t v b _ => cache i e <| e.updateLet! (β visit t) (β visit v) (β visit b)\n | Expr.app f a => cache i e <| e.updateApp! (β visit f) (β visit a)\n | Expr.proj _ _ b => cache i e <| e.updateProj! (β visit b)\n | Expr.sort u => cache i e <| e.updateSort! (u.replace f?)\n | Expr.const _ us => cache i e <| e.updateConst! (us.map (Level.replace f?))\n | e => pure e\n visit e",
"start": [
39,
1
],
"end": [
56,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.initCache",
"code": "unsafe def initCache : State :=\n { keys := mkArray cacheSize.toNat (cast lcProof ()), results := mkArray cacheSize.toNat default }",
"start": [
58,
1
],
"end": [
60,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceLevelImpl.replaceUnsafe",
"code": "unsafe def replaceUnsafe (f? : Level β Option Level) (e : Expr) : Expr :=\n (replaceUnsafeM f? cacheSize e).run' initCache",
"start": [
62,
1
],
"end": [
63,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.replaceLevel",
"code": "@[implemented_by ReplaceLevelImpl.replaceUnsafe]\npartial def replaceLevel (f? : Level β Option Level) : Expr β Expr\n | e@(Expr.forallE _ d b _) => let d := replaceLevel f? d; let b := replaceLevel f? b; e.updateForallE! d b\n | e@(Expr.lam _ d b _) => let d := replaceLevel f? d; let b := replaceLevel f? b; e.updateLambdaE! d b\n | e@(Expr.mdata _ b) => let b := replaceLevel f? b; e.updateMData! b\n | e@(Expr.letE _ t v b _) => let t := replaceLevel f? t; let v := replaceLevel f? v; let b := replaceLevel f? b; e.updateLet! t v b\n | e@(Expr.app f a) => let f := replaceLevel f? f; let a := replaceLevel f? a; e.updateApp! f a\n | e@(Expr.proj _ _ b) => let b := replaceLevel f? b; e.updateProj! b\n | e@(Expr.sort u) => e.updateSort! (u.replace f?)\n | e@(Expr.const _ us) => e.updateConst! (us.map (Level.replace f?))\n | e => e",
"start": [
67,
1
],
"end": [
77,
36
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/FindMVar.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.FindMVar.Visitor",
"code": "abbrev Visitor := Option MVarId β Option MVarId",
"start": [
13,
1
],
"end": [
13,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FindMVar.visit",
"code": "partial def visit (p : MVarId β Bool) (e : Expr) : Visitor := fun s =>\n if s.isSome || !e.hasExprMVar then s else main p e s",
"start": [
16,
3
],
"end": [
17,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FindMVar.main",
"code": "partial def main (p : MVarId β Bool) : Expr β Visitor\n | Expr.proj _ _ e => visit p e\n | Expr.forallE _ d b _ => visit p b β visit p d\n | Expr.lam _ d b _ => visit p b β visit p d\n | Expr.letE _ t v b _ => visit p b β visit p v β visit p t\n | Expr.app f a => visit p a β visit p f\n | Expr.mdata _ b => visit p b\n | Expr.mvar mvarId => fun s => if s.isNone && p mvarId then some mvarId else s\n | _ => id",
"start": [
19,
3
],
"end": [
27,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.findMVar?",
"code": "@[inline] def Expr.findMVar? (e : Expr) (p : MVarId β Bool) : Option MVarId :=\n FindMVar.main p e none",
"start": [
32,
1
],
"end": [
33,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/SubExpr.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean",
".lake/packages/lean4/src/lean/Lean/SubExpr.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Delaborator.OptionsPerPos",
"code": "abbrev OptionsPerPos := RBMap SubExpr.Pos Options compare",
"start": [
19,
1
],
"end": [
19,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.getExpr",
"code": "def getExpr : m Expr := return (β readThe SubExpr).expr",
"start": [
34,
1
],
"end": [
34,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.getPos",
"code": "def getPos : m Pos := return (β readThe SubExpr).pos",
"start": [
35,
1
],
"end": [
35,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.descend",
"code": "def descend (child : Expr) (childIdx : Nat) (x : m Ξ±) : m Ξ± :=\n withTheReader SubExpr (fun cfg => { cfg with expr := child, pos := cfg.pos.push childIdx }) x",
"start": [
37,
1
],
"end": [
38,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withAppFn",
"code": "def withAppFn (x : m Ξ±) : m Ξ± := do descend (β getExpr).appFn! 0 x",
"start": [
40,
1
],
"end": [
40,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withAppArg",
"code": "def withAppArg (x : m Ξ±) : m Ξ± := do descend (β getExpr).appArg! 1 x",
"start": [
41,
1
],
"end": [
41,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withType",
"code": "def withType (x : m Ξ±) : m Ξ± := do\n descend (β Meta.inferType (β getExpr)) Pos.typeCoord x",
"start": [
43,
1
],
"end": [
44,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withAppFnArgs",
"code": "partial def withAppFnArgs (xf : m Ξ±) (xa : Ξ± β m Ξ±) : m Ξ± := do\n if (β getExpr).isApp then\n let acc β withAppFn (withAppFnArgs xf xa)\n withAppArg (xa acc)\n else xf",
"start": [
46,
1
],
"end": [
54,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withBoundedAppFnArgs",
"code": "def withBoundedAppFnArgs (maxArgs : Nat) (xf : m Ξ±) (xa : Ξ± β m Ξ±) : m Ξ± := do\n match maxArgs, (β getExpr) with\n | maxArgs' + 1, .app .. =>\n let acc β withAppFn (withBoundedAppFnArgs maxArgs' xf xa)\n withAppArg (xa acc)\n | _, _ => xf",
"start": [
56,
1
],
"end": [
66,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withBoundedAppFn",
"code": "def withBoundedAppFn (maxArgs : Nat) (xf : m Ξ±) : m Ξ± := do\n let e β getExpr\n let numArgs := min maxArgs e.getAppNumArgs\n let newPos := (β getPos).pushNaryFn numArgs\n withTheReader SubExpr (fun cfg => { cfg with expr := e.getBoundedAppFn numArgs, pos := newPos }) xf",
"start": [
68,
1
],
"end": [
76,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withBindingDomain",
"code": "def withBindingDomain (x : m Ξ±) : m Ξ± := do descend (β getExpr).bindingDomain! 0 x",
"start": [
78,
1
],
"end": [
78,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withBindingBody'",
"code": "def withBindingBody' (n : Name) (v : Expr β m Ξ²) (x : Ξ² β m Ξ±) : m Ξ± := do\n let e β getExpr\n Meta.withLocalDecl n e.binderInfo e.bindingDomain! fun fvar => do\n let b β v fvar\n descend (e.bindingBody!.instantiate1 fvar) 1 (x b)",
"start": [
80,
1
],
"end": [
90,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withBindingBody",
"code": "def withBindingBody (n : Name) (x : m Ξ±) : m Ξ± :=\n withBindingBody' n (fun _ => pure ()) (fun _ => x)",
"start": [
92,
1
],
"end": [
97,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withProj",
"code": "def withProj (x : m Ξ±) : m Ξ± := do\n let Expr.proj _ _ e β getExpr | unreachable!\n descend e 0 x",
"start": [
99,
1
],
"end": [
101,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withMDataExpr",
"code": "def withMDataExpr (x : m Ξ±) : m Ξ± := do\n let Expr.mdata _ e β getExpr | unreachable!\n withTheReader SubExpr (fun ctx => { ctx with expr := e }) x",
"start": [
103,
1
],
"end": [
105,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withLetVarType",
"code": "def withLetVarType (x : m Ξ±) : m Ξ± := do\n let Expr.letE _ t _ _ _ β getExpr | unreachable!\n descend t 0 x",
"start": [
107,
1
],
"end": [
109,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withLetValue",
"code": "def withLetValue (x : m Ξ±) : m Ξ± := do\n let Expr.letE _ _ v _ _ β getExpr | unreachable!\n descend v 1 x",
"start": [
111,
1
],
"end": [
113,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withLetBody",
"code": "def withLetBody (x : m Ξ±) : m Ξ± := do\n let Expr.letE n t v b _ β getExpr | unreachable!\n Meta.withLetDecl n t v fun fvar =>\n let b := b.instantiate1 fvar\n descend b 2 x",
"start": [
115,
1
],
"end": [
119,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withNaryFn",
"code": "def withNaryFn (x : m Ξ±) : m Ξ± := do\n let e β getExpr\n let newPos := (β getPos).pushNaryFn e.getAppNumArgs\n withTheReader SubExpr (fun cfg => { cfg with expr := e.getAppFn, pos := newPos }) x",
"start": [
121,
1
],
"end": [
124,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.withNaryArg",
"code": "def withNaryArg (argIdx : Nat) (x : m Ξ±) : m Ξ± := do\n let e β getExpr\n let args := e.getAppArgs\n let newPos := (β getPos).pushNaryArg args.size argIdx\n withTheReader SubExpr (fun cfg => { cfg with expr := args[argIdx]!, pos := newPos }) x",
"start": [
126,
1
],
"end": [
130,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.HoleIterator",
"code": "structure HoleIterator where\n curr : Nat := 2\n top : Nat := Pos.maxChildren\n deriving Inhabited",
"start": [
134,
1
],
"end": [
137,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.HoleIterator.toPos",
"code": "def HoleIterator.toPos (iter : HoleIterator) : Pos :=\n iter.curr",
"start": [
145,
1
],
"end": [
146,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.HoleIterator.next",
"code": "def HoleIterator.next (iter : HoleIterator) : HoleIterator :=\n if (iter.curr+1) == iter.top then\n β¨2*iter.top, Pos.maxChildren*iter.topβ©\n else β¨iter.curr+1, iter.topβ©",
"start": [
148,
1
],
"end": [
151,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.SubExpr.nextExtraPos",
"code": "def nextExtraPos : m Pos := do\n let iter β getThe HoleIterator\n let pos := iter.toPos\n modifyThe HoleIterator HoleIterator.next\n return pos",
"start": [
153,
1
],
"end": [
163,
13
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Module.lean | [
".lake/packages/lean4/src/lean/Lean/Message.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Command.lean"
] | [
{
"full_name": "Lean.Parser.Module.prelude",
"code": "def Β«preludeΒ» := leading_parser \"prelude\"",
"start": [
14,
1
],
"end": [
14,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Module.import",
"code": "def Β«importΒ» := leading_parser \"import \" >> optional \"runtime\" >> identWithPartialTrailingDot",
"start": [
15,
1
],
"end": [
15,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Module.header",
"code": "def header := leading_parser optional (Β«preludeΒ» >> ppLine) >> many (Β«importΒ» >> ppLine) >> ppLine",
"start": [
16,
1
],
"end": [
16,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Module.module",
"code": "@[run_builtin_parser_attribute_hooks]\ndef module := leading_parser header >> many (commandParser >> ppLine >> ppLine)",
"start": [
17,
1
],
"end": [
22,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Module.updateTokens",
"code": "def updateTokens (tokens : TokenTable) : TokenTable :=\n match addParserTokens tokens header.info with\n | Except.ok tables => tables\n | Except.error _ => unreachable!",
"start": [
24,
1
],
"end": [
27,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ModuleParserState",
"code": "structure ModuleParserState where\n pos : String.Pos := 0\n recovering : Bool := false\n deriving Inhabited",
"start": [
31,
1
],
"end": [
34,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkErrorMessage",
"code": "private partial def mkErrorMessage (c : InputContext) (pos : String.Pos) (stk : SyntaxStack) (e : Parser.Error) : Message := Id.run do\n let mut pos := pos\n let mut endPos? := none\n let mut e := e\n unless e.unexpectedTk.isMissing do\n if let some r := e.unexpectedTk.getRange? then\n pos := r.start\n endPos? := some r.stop\n let unexpected := match e.unexpectedTk with\n | .ident .. => \"unexpected identifier\"\n | .atom _ v => s!\"unexpected token '{v}'\"\n | _ => \"unexpected token\" e := { e with unexpected }\n if let some trailing := lastTrailing stk then\n if trailing.stopPos == pos then\n pos := trailing.startPos\n { fileName := c.fileName\n pos := c.fileMap.toPosition pos\n endPos := c.fileMap.toPosition <$> endPos?\n keepFullRange := true\n data := toString e }\nwhere\n lastTrailing (s : SyntaxStack) : Option Substring :=\n s.toSubarray.findSomeRevM? (m := Id) fun stx =>\n if let .original (trailing := trailing) .. := stx.getTailInfo then pure (some trailing)\n else none",
"start": [
36,
1
],
"end": [
65,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.parseHeader",
"code": "def parseHeader (inputCtx : InputContext) : IO (Syntax Γ ModuleParserState Γ MessageLog) := do\n let dummyEnv β mkEmptyEnvironment\n let p := andthenFn whitespace Module.header.fn\n let tokens := Module.updateTokens (getTokenTable dummyEnv)\n let s := p.run inputCtx { env := dummyEnv, options := {} } tokens (mkParserState inputCtx.input)\n let stx := if s.stxStack.isEmpty then .missing else s.stxStack.back\n let mut messages : MessageLog := {}\n for (pos, stk, err) in s.allErrors do\n messages := messages.add <| mkErrorMessage inputCtx pos stk err\n pure (stx, {pos := s.pos, recovering := s.hasError}, messages)",
"start": [
67,
1
],
"end": [
76,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkEOI",
"code": "private def mkEOI (pos : String.Pos) : Syntax :=\n let atom := mkAtom (SourceInfo.original \"\".toSubstring pos \"\".toSubstring pos) \"\"\n mkNode ``Command.eoi #[atom]",
"start": [
78,
1
],
"end": [
80,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isTerminalCommand",
"code": "def isTerminalCommand (s : Syntax) : Bool :=\n s.isOfKind ``Command.exit || s.isOfKind ``Command.import || s.isOfKind ``Command.eoi",
"start": [
82,
1
],
"end": [
83,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.consumeInput",
"code": "private def consumeInput (inputCtx : InputContext) (pmctx : ParserModuleContext) (pos : String.Pos) : String.Pos :=\n let s : ParserState := { cache := initCacheForInput inputCtx.input, pos := pos }\n let s := tokenFn [] |>.run inputCtx pmctx (getTokenTable pmctx.env) s\n match s.errorMsg with\n | some _ => pos + ' '\n | none => s.pos",
"start": [
85,
1
],
"end": [
90,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.topLevelCommandParserFn",
"code": "def topLevelCommandParserFn : ParserFn :=\n commandParser.fn",
"start": [
92,
1
],
"end": [
93,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.parseCommand",
"code": "partial def parseCommand (inputCtx : InputContext) (pmctx : ParserModuleContext) (mps : ModuleParserState) (messages : MessageLog) : Syntax Γ ModuleParserState Γ MessageLog := Id.run do\n let mut pos := mps.pos\n let mut recovering := mps.recovering\n let mut messages := messages\n let mut stx := Syntax.missing repeat\n if inputCtx.input.atEnd pos then\n stx := mkEOI pos\n break\n let pos' := pos\n let p := andthenFn whitespace topLevelCommandParserFn\n let s := p.run inputCtx pmctx (getTokenTable pmctx.env) { cache := initCacheForInput inputCtx.input, pos }\n for (rpos, rstk, recovered) in s.recoveredErrors do\n messages := messages.add <| mkErrorMessage inputCtx rpos rstk recovered\n pos := s.pos\n if recovering && !s.stxStack.isEmpty && s.stxStack.back.isAntiquot then\n continue\n match s.errorMsg with\n | none =>\n stx := s.stxStack.back\n recovering := false\n break\n | some errorMsg =>\n if pos == pos' then\n pos := consumeInput inputCtx pmctx pos\n \n let ignore := s.stxStack.isEmpty || s.stxStack.back.getPos?.isNone\n unless recovering && ignore do\n messages := messages.add <| mkErrorMessage inputCtx s.pos s.stxStack errorMsg\n recovering := true\n if ignore then\n continue\n else\n stx := s.stxStack.back\n break\n return (stx, { pos, recovering }, messages)",
"start": [
95,
1
],
"end": [
135,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.testParseModuleAux",
"code": "partial def testParseModuleAux (env : Environment) (inputCtx : InputContext) (s : ModuleParserState) (msgs : MessageLog) (stxs : Array Syntax) : IO (Array Syntax) :=\n let rec parse (state : ModuleParserState) (msgs : MessageLog) (stxs : Array Syntax) :=\n match parseCommand inputCtx { env := env, options := {} } state msgs with\n | (stx, state, msgs) =>\n if isTerminalCommand stx then\n if !msgs.hasUnreported then\n pure stxs\n else do\n msgs.forM fun msg => msg.toString >>= IO.println\n throw (IO.userError \"failed to parse file\")\n else\n parse state msgs (stxs.push stx)\n parse s msgs stxs",
"start": [
139,
1
],
"end": [
151,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.testParseModule",
"code": "def testParseModule (env : Environment) (fname contents : String) : IO (TSyntax ``Parser.Module.module) := do\n let inputCtx := mkInputContext contents fname\n let (header, state, messages) β parseHeader inputCtx\n let cmds β testParseModuleAux env inputCtx state messages #[]\n let stx := mkNode `Lean.Parser.Module.module #[header, mkListNode cmds]\n pure β¨stx.raw.updateLeadingβ©",
"start": [
153,
1
],
"end": [
158,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.testParseFile",
"code": "def testParseFile (env : Environment) (fname : System.FilePath) : IO (TSyntax ``Parser.Module.module) := do\n let contents β IO.FS.readFile fname\n testParseModule env fname.toString contents",
"start": [
160,
1
],
"end": [
162,
46
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Tactic.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Term.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Tactic/Doc.lean"
] | [
{
"full_name": "Lean.Parser.Tactic.unknown",
"code": "@[builtin_tactic_parser] def Β«unknownΒ» := leading_parser\n withPosition (ident >> errorAtSavedPos \"unknown tactic\" true)",
"start": [
24,
1
],
"end": [
25,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.nestedTactic",
"code": "@[builtin_tactic_parser] def nestedTactic := tacticSeqBracketed",
"start": [
27,
1
],
"end": [
27,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.matchRhs",
"code": "def matchRhs := Term.hole <|> Term.syntheticHole <|> tacticSeq",
"start": [
29,
1
],
"end": [
29,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.matchAlts",
"code": "def matchAlts := Term.matchAlts (rhsParser := matchRhs)",
"start": [
30,
1
],
"end": [
30,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.match",
"code": "@[builtin_tactic_parser] def Β«matchΒ» := leading_parser:leadPrec\n \"match \" >> optional Term.generalizingParam >>\n optional Term.motive >> sepBy1 Term.matchDiscr \", \" >>\n \" with \" >> ppDedent matchAlts",
"start": [
32,
1
],
"end": [
48,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.introMatch",
"code": "@[builtin_tactic_parser] def introMatch := leading_parser\n nonReservedSymbol \"intro\" >> matchAlts",
"start": [
50,
1
],
"end": [
68,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.decide",
"code": "@[builtin_tactic_parser] def decide := leading_parser\n nonReservedSymbol \"decide\"",
"start": [
70,
1
],
"end": [
126,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Tactic.nativeDecide",
"code": "@[builtin_tactic_parser] def nativeDecide := leading_parser\n nonReservedSymbol \"native_decide\"",
"start": [
128,
1
],
"end": [
142,
36
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Syntax.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Command.lean"
] | [
{
"full_name": "Lean.Parser.precedenceParser",
"code": "@[inline] def precedenceParser (rbp : Nat := 0) : Parser :=\n categoryParser `prec rbp",
"start": [
20,
1
],
"end": [
21,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.syntaxParser",
"code": "@[inline] def syntaxParser (rbp : Nat := 0) : Parser :=\n categoryParser `stx rbp",
"start": [
23,
1
],
"end": [
24,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.precedence",
"code": "def Β«precedenceΒ» := leading_parser\n \":\" >> precedenceParser maxPrec",
"start": [
26,
1
],
"end": [
27,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.optPrecedence",
"code": "def optPrecedence := optional (atomic Β«precedenceΒ»)",
"start": [
28,
1
],
"end": [
28,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.numPrec",
"code": "@[builtin_prec_parser] def numPrec := checkPrec maxPrec >> numLit",
"start": [
31,
1
],
"end": [
31,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.paren",
"code": "@[builtin_syntax_parser] def paren := leading_parser\n \"(\" >> withoutPosition (many1 syntaxParser) >> \")\"",
"start": [
33,
1
],
"end": [
34,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.cat",
"code": "@[builtin_syntax_parser] def cat := leading_parser\n ident >> optPrecedence",
"start": [
35,
1
],
"end": [
36,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.unary",
"code": "@[builtin_syntax_parser] def unary := leading_parser\n ident >> checkNoWsBefore >> \"(\" >> withoutPosition (many1 syntaxParser) >> \")\"",
"start": [
37,
1
],
"end": [
38,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.binary",
"code": "@[builtin_syntax_parser] def binary := leading_parser\n ident >> checkNoWsBefore >> \"(\" >> withoutPosition (many1 syntaxParser >> \", \" >> many1 syntaxParser) >> \")\"",
"start": [
39,
1
],
"end": [
40,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.sepBy",
"code": "@[builtin_syntax_parser] def sepBy := leading_parser\n \"sepBy(\" >> withoutPosition (many1 syntaxParser >> \", \" >> strLit >>\n optional (\", \" >> many1 syntaxParser) >> optional (\", \" >> nonReservedSymbol \"allowTrailingSep\")) >> \")\"",
"start": [
41,
1
],
"end": [
43,
109
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.sepBy1",
"code": "@[builtin_syntax_parser] def sepBy1 := leading_parser\n \"sepBy1(\" >> withoutPosition (many1 syntaxParser >> \", \" >> strLit >>\n optional (\", \" >> many1 syntaxParser) >> optional (\", \" >> nonReservedSymbol \"allowTrailingSep\")) >> \")\"",
"start": [
44,
1
],
"end": [
46,
109
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.atom",
"code": "@[builtin_syntax_parser] def atom := leading_parser\n strLit",
"start": [
47,
1
],
"end": [
48,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Syntax.nonReserved",
"code": "@[builtin_syntax_parser] def nonReserved := leading_parser\n \"&\" >> strLit",
"start": [
49,
1
],
"end": [
50,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.namedName",
"code": "def namedName := leading_parser\n atomic (\" (\" >> nonReservedSymbol \"name\") >> \" := \" >> ident >> \")\"",
"start": [
56,
1
],
"end": [
57,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optNamedName",
"code": "def optNamedName := optional namedName",
"start": [
58,
1
],
"end": [
58,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.prefix",
"code": "def Β«prefixΒ» := leading_parser \"prefix\"",
"start": [
60,
1
],
"end": [
60,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.infix",
"code": "def Β«infixΒ» := leading_parser \"infix\"",
"start": [
61,
1
],
"end": [
61,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.infixl",
"code": "def Β«infixlΒ» := leading_parser \"infixl\"",
"start": [
62,
1
],
"end": [
62,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.infixr",
"code": "def Β«infixrΒ» := leading_parser \"infixr\"",
"start": [
63,
1
],
"end": [
63,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.postfix",
"code": "def Β«postfixΒ» := leading_parser \"postfix\"",
"start": [
64,
1
],
"end": [
64,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.mixfixKind",
"code": "def mixfixKind := Β«prefixΒ» <|> Β«infixΒ» <|> Β«infixlΒ» <|> Β«infixrΒ» <|> Β«postfixΒ»",
"start": [
65,
1
],
"end": [
65,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.mixfix",
"code": "@[builtin_command_parser] def Β«mixfixΒ» := leading_parser\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >> mixfixKind >>\n precedence >> optNamedName >> optNamedPrio >> ppSpace >> strLit >> darrow >> termParser",
"start": [
66,
1
],
"end": [
68,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.identPrec",
"code": "def identPrec := leading_parser ident >> optPrecedence",
"start": [
71,
1
],
"end": [
71,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.optKind",
"code": "def optKind : Parser := optional (\" (\" >> nonReservedSymbol \"kind\" >> \":=\" >> ident >> \")\")",
"start": [
73,
1
],
"end": [
73,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.notationItem",
"code": "def notationItem := ppSpace >> withAntiquot (mkAntiquot \"notationItem\" decl_name%) (strLit <|> identPrec)",
"start": [
75,
1
],
"end": [
75,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.notation",
"code": "@[builtin_command_parser] def Β«notationΒ» := leading_parser\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >>\n \"notation\" >> optPrecedence >> optNamedName >> optNamedPrio >> many notationItem >> darrow >> termParser",
"start": [
76,
1
],
"end": [
78,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.macro_rules",
"code": "@[builtin_command_parser] def Β«macro_rulesΒ» := suppressInsideQuot <| leading_parser\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >>\n \"macro_rules\" >> optKind >> Term.matchAlts",
"start": [
79,
1
],
"end": [
81,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.syntax",
"code": "@[builtin_command_parser] def Β«syntaxΒ» := leading_parser\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >>\n \"syntax \" >> optPrecedence >> optNamedName >> optNamedPrio >> many1 (ppSpace >> syntaxParser argPrec) >> \" : \" >> ident",
"start": [
82,
1
],
"end": [
84,
122
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.syntaxAbbrev",
"code": "@[builtin_command_parser] def syntaxAbbrev := leading_parser\n optional docComment >> \"syntax \" >> ident >> \" := \" >> many1 syntaxParser",
"start": [
85,
1
],
"end": [
86,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.catBehaviorBoth",
"code": "def catBehaviorBoth := leading_parser nonReservedSymbol \"both\"",
"start": [
87,
1
],
"end": [
87,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.catBehaviorSymbol",
"code": "def catBehaviorSymbol := leading_parser nonReservedSymbol \"symbol\"",
"start": [
88,
1
],
"end": [
88,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.catBehavior",
"code": "def catBehavior := optional (\" (\" >> nonReservedSymbol \"behavior\" >> \" := \" >> (catBehaviorBoth <|> catBehaviorSymbol) >> \")\")",
"start": [
89,
1
],
"end": [
89,
127
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.syntaxCat",
"code": "@[builtin_command_parser] def syntaxCat := leading_parser\n optional docComment >> \"declare_syntax_cat \" >> ident >> catBehavior",
"start": [
90,
1
],
"end": [
91,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.macroArg",
"code": "def macroArg := leading_parser\n optional (atomic (ident >> checkNoWsBefore \"no space before ':'\" >> \":\")) >> syntaxParser argPrec",
"start": [
92,
1
],
"end": [
93,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.macroRhs",
"code": "def macroRhs : Parser := leading_parser withPosition termParser",
"start": [
94,
1
],
"end": [
94,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.macroTail",
"code": "def macroTail := leading_parser atomic (\" : \" >> ident) >> darrow >> macroRhs",
"start": [
95,
1
],
"end": [
95,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.macro",
"code": "@[builtin_command_parser] def Β«macroΒ» := leading_parser suppressInsideQuot <|\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >>\n \"macro\" >> optPrecedence >> optNamedName >> optNamedPrio >> many1 (ppSpace >> macroArg) >> macroTail",
"start": [
96,
1
],
"end": [
98,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.elab_rules",
"code": "@[builtin_command_parser] def Β«elab_rulesΒ» := leading_parser suppressInsideQuot <|\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >>\n \"elab_rules\" >> optKind >> optional (\" : \" >> ident) >> optional (\" <= \" >> ident) >> Term.matchAlts",
"start": [
99,
1
],
"end": [
101,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.elabArg",
"code": "def elabArg := macroArg",
"start": [
102,
1
],
"end": [
102,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.elabTail",
"code": "def elabTail := leading_parser atomic (\" : \" >> ident >> optional (\" <= \" >> ident)) >> darrow >> withPosition termParser",
"start": [
103,
1
],
"end": [
103,
122
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.elab",
"code": "@[builtin_command_parser] def Β«elabΒ» := leading_parser suppressInsideQuot <|\n optional docComment >> optional Term.Β«attributesΒ» >> Term.attrKind >>\n \"elab\" >> optPrecedence >> optNamedName >> optNamedPrio >> many1 (ppSpace >> elabArg) >> elabTail",
"start": [
104,
1
],
"end": [
106,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Command.binderPredicate",
"code": "@[builtin_command_parser] def binderPredicate := leading_parser\n optional docComment >> optional Term.attributes >> optional Term.attrKind >>\n \"binder_predicate\" >> optNamedName >> optNamedPrio >> ppSpace >> ident >> many (ppSpace >> macroArg) >> \" => \" >> termParser",
"start": [
108,
1
],
"end": [
116,
128
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Term.lean | [
".lake/packages/lean4/src/lean/Lean/Elab/Config.lean",
".lake/packages/lean4/src/lean/Lean/ReservedNameAction.lean",
".lake/packages/lean4/src/lean/Lean/Elab/Level.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Coe.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean",
".lake/packages/lean4/src/lean/Lean/Elab/DeclModifiers.lean",
".lake/packages/lean4/src/lean/Lean/Elab/PreDefinition/WF/TerminationHint.lean",
".lake/packages/lean4/src/lean/Lean/Linter/Deprecated.lean",
".lake/packages/lean4/src/lean/Lean/Language/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Meta/CollectMVars.lean"
] | [
{
"full_name": "Lean.Elab.Term.SavedContext",
"code": "structure SavedContext where\n declName? : Option Name\n options : Options\n openDecls : List OpenDecl\n macroStack : MacroStack\n errToSorry : Bool\n levelNames : List Name",
"start": [
22,
1
],
"end": [
29,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.SyntheticMVarKind",
"code": "inductive SyntheticMVarKind where\n \n | typeClass (extraErrorMsg? : Option MessageData)\n \n | coe (header? : Option String) (expectedType : Expr) (e : Expr) (f? : Option Expr)\n \n | tactic (tacticCode : Syntax) (ctx : SavedContext)\n \n | postponed (ctx : SavedContext)\n deriving Inhabited",
"start": [
31,
1
],
"end": [
48,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.extraMsgToMsg",
"code": "def extraMsgToMsg (extraErrorMsg? : Option MessageData) : MessageData :=\n if let some msg := extraErrorMsg? then m!\"\\n{msg}\" else .nil",
"start": [
50,
1
],
"end": [
54,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.SyntheticMVarDecl",
"code": "structure SyntheticMVarDecl where\n stx : Syntax\n kind : SyntheticMVarKind\n deriving Inhabited",
"start": [
63,
1
],
"end": [
66,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.MVarErrorKind",
"code": "inductive MVarErrorKind where\n \n | implicitArg (ctx : Expr)\n \n | hole\n \n | custom (msgData : MessageData)\n deriving Inhabited",
"start": [
68,
1
],
"end": [
79,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.MVarErrorInfo",
"code": "structure MVarErrorInfo where\n mvarId : MVarId\n ref : Syntax\n kind : MVarErrorKind\n deriving Inhabited",
"start": [
87,
1
],
"end": [
94,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.LetRecToLift",
"code": "structure LetRecToLift where\n ref : Syntax\n fvarId : FVarId\n attrs : Array Attribute\n shortDeclName : Name\n declName : Name\n lctx : LocalContext\n localInstances : LocalInstances\n type : Expr\n val : Expr\n mvarId : MVarId\n termination : WF.TerminationHints\n deriving Inhabited",
"start": [
96,
1
],
"end": [
112,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.State",
"code": "structure State where\n levelNames : List Name := []\n syntheticMVars : MVarIdMap SyntheticMVarDecl := {}\n pendingMVars : List MVarId := {}\n \n mvarErrorInfos : List MVarErrorInfo := []\n \n mvarArgNames : MVarIdMap Name := {}\n letRecsToLift : List LetRecToLift := []\n deriving Inhabited",
"start": [
114,
1
],
"end": [
136,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.SavedState",
"code": "structure SavedState where\n meta : Meta.SavedState\n Β«elabΒ» : State\n deriving Nonempty",
"start": [
138,
1
],
"end": [
144,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.State",
"code": "structure State where\n goals : List MVarId\n deriving Inhabited",
"start": [
150,
1
],
"end": [
155,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.Snapshot",
"code": "structure Snapshot where\n core : Core.State\n meta : Meta.State\n term : Term.State\n tactic : Tactic.State\n stx : Syntax",
"start": [
157,
1
],
"end": [
168,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.CacheKey",
"code": "structure CacheKey where\n mvarId : MVarId pos : String.Pos\n deriving BEq, Hashable, Inhabited",
"start": [
170,
1
],
"end": [
176,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.Cache",
"code": "structure Cache where\n pre : PHashMap CacheKey Snapshot := {}\n post : PHashMap CacheKey Snapshot := {}\n deriving Inhabited",
"start": [
178,
1
],
"end": [
184,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.SavedState",
"code": "structure SavedState where\n term : Term.SavedState\n tactic : State",
"start": [
189,
1
],
"end": [
191,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticFinished",
"code": "structure TacticFinished where\n \n state? : Option SavedState\nderiving Inhabited",
"start": [
193,
1
],
"end": [
197,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticParsedSnapshotData",
"code": "structure TacticParsedSnapshotData extends Language.Snapshot where\n \n stx : Syntax\n \n finished : Task TacticFinished\nderiving Inhabited",
"start": [
199,
1
],
"end": [
205,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticParsedSnapshot",
"code": "inductive TacticParsedSnapshot where\n | mk (data : TacticParsedSnapshotData) (next : Array (SnapshotTask TacticParsedSnapshot))\nderiving Inhabited",
"start": [
207,
1
],
"end": [
210,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticParsedSnapshot.data",
"code": "abbrev TacticParsedSnapshot.data : TacticParsedSnapshot β TacticParsedSnapshotData\n | .mk data _ => data",
"start": [
211,
1
],
"end": [
212,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticParsedSnapshot.next",
"code": "abbrev TacticParsedSnapshot.next : TacticParsedSnapshot β Array (SnapshotTask TacticParsedSnapshot)\n | .mk _ next => next",
"start": [
213,
1
],
"end": [
216,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.Context",
"code": "structure Context where\n declName? : Option Name := none\n \n auxDeclToFullName : FVarIdMap Name := {}\n macroStack : MacroStack := []\n \n mayPostpone : Bool := true\n \n errToSorry : Bool := true\n \n autoBoundImplicit : Bool := false\n autoBoundImplicits : PArray Expr := {}\n \n autoBoundImplicitForbidden : Name β Bool := fun _ => false\n \n sectionVars : NameMap Name := {}\n \n sectionFVars : NameMap Expr := {}\n \n implicitLambda : Bool := true\n \n heedElabAsElim : Bool := true\n \n isNoncomputableSection : Bool := false\n \n ignoreTCFailures : Bool := false\n \n inPattern : Bool := false\n \n tacticCache? : Option (IO.Ref Tactic.Cache) := none\n \n tacSnap? : Option (Language.SnapshotBundle Tactic.TacticParsedSnapshot) := none\n \n saveRecAppSyntax : Bool := true\n \n holesAsSyntheticOpaque : Bool := false",
"start": [
226,
1
],
"end": [
299,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.TermElabM",
"code": "abbrev TermElabM := ReaderT Context $ StateRefT State MetaM",
"start": [
301,
1
],
"end": [
301,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.TermElab",
"code": "abbrev TermElab := Syntax β Option Expr β TermElabM Expr",
"start": [
302,
1
],
"end": [
302,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.saveState",
"code": "protected def saveState : TermElabM SavedState :=\n return { meta := (β Meta.saveState), Β«elabΒ» := (β get) }",
"start": [
318,
1
],
"end": [
319,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.SavedState.restore",
"code": "def SavedState.restore (s : SavedState) (restoreInfo : Bool := false) : TermElabM Unit := do\n let traceState β getTraceState let infoState β getInfoState s.meta.restore\n set s.elab\n setTraceState traceState\n unless restoreInfo do\n setInfoState infoState",
"start": [
321,
1
],
"end": [
328,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withRestoreOrSaveFull",
"code": "@[specialize, inherit_doc Core.withRestoreOrSaveFull]\ndef withRestoreOrSaveFull (reusableResult? : Option (Ξ± Γ SavedState)) (act : TermElabM Ξ±) :\n TermElabM (Ξ± Γ SavedState) := do\n if let some (_, state) := reusableResult? then\n set state.elab\n let reusableResult? := reusableResult?.map (fun (val, state) => (val, state.meta))\n let (a, meta) β controlAt MetaM fun runInBase => do\n Meta.withRestoreOrSaveFull reusableResult? <| runInBase act\n return (a, { meta, Β«elabΒ» := (β get) })",
"start": [
330,
1
],
"end": [
338,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withNarrowedTacticReuse",
"code": "def withNarrowedTacticReuse [Monad m] [MonadWithReaderOf Context m]\n [MonadOptions m] [MonadRef m] (split : Syntax β Syntax Γ Syntax) (act : Syntax β m Ξ±)\n (stx : Syntax) : m Ξ± := do\n let (outer, inner) := split stx\n let opts β getOptions\n withTheReader Term.Context (fun ctx => { ctx with tacSnap? := ctx.tacSnap?.map fun tacSnap =>\n { tacSnap with old? := tacSnap.old?.bind fun old => do\n let (oldOuter, oldInner) := split old.stx\n guard <| outer.eqWithInfoAndTraceReuse opts oldOuter\n return { old with stx := oldInner }\n }\n }) do\n withRef inner do\n act inner",
"start": [
344,
1
],
"end": [
369,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withNarrowedArgTacticReuse",
"code": "def withNarrowedArgTacticReuse [Monad m] [MonadWithReaderOf Context m]\n [MonadOptions m] [MonadRef m] (argIdx : Nat) (act : Syntax β m Ξ±) (stx : Syntax) : m Ξ± :=\n withNarrowedTacticReuse (fun stx => (mkNullNode stx.getArgs[:argIdx], stx[argIdx])) act stx",
"start": [
371,
1
],
"end": [
382,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutTacticIncrementality",
"code": "def withoutTacticIncrementality [Monad m] [MonadWithReaderOf Context m] [MonadOptions m]\n (cond : Bool) (act : m Ξ±) : m Ξ± := do\n let opts β getOptions\n withTheReader Term.Context (fun ctx => { ctx with tacSnap? := ctx.tacSnap?.filter fun tacSnap => Id.run do\n if let some old := tacSnap.old? then\n if cond && opts.getBool `trace.Elab.reuse then\n dbg_trace \"reuse stopped: guard failed at {old.stx}\"\n return !cond\n }) act",
"start": [
384,
1
],
"end": [
398,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutTacticReuse",
"code": "def withoutTacticReuse [Monad m] [MonadWithReaderOf Context m] [MonadOptions m]\n (cond : Bool) (act : m Ξ±) : m Ξ± := do\n let opts β getOptions\n withTheReader Term.Context (fun ctx => { ctx with tacSnap? := ctx.tacSnap?.map fun tacSnap =>\n { tacSnap with old? := tacSnap.old?.filter fun old => Id.run do\n if cond && opts.getBool `trace.Elab.reuse then\n dbg_trace \"reuse stopped: guard failed at {old.stx}\"\n return !cond }\n }) act",
"start": [
400,
1
],
"end": [
409,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.TermElabResult",
"code": "abbrev TermElabResult (Ξ± : Type) := EStateM.Result Exception SavedState Ξ±",
"start": [
411,
1
],
"end": [
411,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.observing",
"code": "def observing (x : TermElabM Ξ±) : TermElabM (TermElabResult Ξ±) := do\n let s β saveState\n try\n let e β x\n let sNew β saveState\n s.restore (restoreInfo := true)\n return EStateM.Result.ok e sNew\n catch\n | ex@(.error ..) =>\n let sNew β saveState\n s.restore (restoreInfo := true)\n return .error ex sNew\n | ex@(.internal id _) =>\n if id == postponeExceptionId then\n s.restore (restoreInfo := true)\n throw ex",
"start": [
413,
1
],
"end": [
435,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.applyResult",
"code": "def applyResult (result : TermElabResult Ξ±) : TermElabM Ξ± := do\n match result with\n | .ok a r => r.restore (restoreInfo := true); return a\n | .error ex r => r.restore (restoreInfo := true); throw ex",
"start": [
437,
1
],
"end": [
443,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.commitIfDidNotPostpone",
"code": "def commitIfDidNotPostpone (x : TermElabM Ξ±) : TermElabM Ξ± := do\n let r β observing x\n applyResult r",
"start": [
445,
1
],
"end": [
452,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.getLevelNames",
"code": "def getLevelNames : TermElabM (List Name) :=\n return (β get).levelNames",
"start": [
454,
1
],
"end": [
458,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.getFVarLocalDecl!",
"code": "def getFVarLocalDecl! (fvar : Expr) : TermElabM LocalDecl := do\n match (β getLCtx).find? fvar.fvarId! with\n | some d => pure d\n | none => unreachable!",
"start": [
460,
1
],
"end": [
467,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutSavingRecAppSyntax",
"code": "def withoutSavingRecAppSyntax (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withReader (fun ctx => { ctx with saveRecAppSyntax := false }) x",
"start": [
477,
1
],
"end": [
481,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkTermElabAttributeUnsafe",
"code": "unsafe def mkTermElabAttributeUnsafe (ref : Name) : IO (KeyedDeclsAttribute TermElab) :=\n mkElabAttribute TermElab `builtin_term_elab `term_elab `Lean.Parser.Term `Lean.Elab.Term.TermElab \"term\" ref",
"start": [
483,
1
],
"end": [
484,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkTermElabAttribute",
"code": "@[implemented_by mkTermElabAttributeUnsafe]\nopaque mkTermElabAttribute (ref : Name) : IO (KeyedDeclsAttribute TermElab)",
"start": [
486,
1
],
"end": [
487,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.LVal",
"code": "inductive LVal where\n | fieldIdx (ref : Syntax) (i : Nat)\n \n | fieldName (ref : Syntax) (name : String) (suffix? : Option Name) (fullRef : Syntax)",
"start": [
491,
1
],
"end": [
501,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.LVal.getRef",
"code": "def LVal.getRef : LVal β Syntax\n | .fieldIdx ref _ => ref\n | .fieldName ref .. => ref",
"start": [
503,
1
],
"end": [
505,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.LVal.isFieldName",
"code": "def LVal.isFieldName : LVal β Bool\n | .fieldName .. => true\n | _ => false",
"start": [
507,
1
],
"end": [
509,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.getDeclName?",
"code": "def getDeclName? : TermElabM (Option Name) := return (β read).declName?",
"start": [
516,
1
],
"end": [
517,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.getLetRecsToLift",
"code": "def getLetRecsToLift : TermElabM (List LetRecToLift) := return (β get).letRecsToLift",
"start": [
518,
1
],
"end": [
519,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.getMVarDecl",
"code": "def getMVarDecl (mvarId : MVarId) : TermElabM MetavarDecl := return (β getMCtx).getDecl mvarId",
"start": [
520,
1
],
"end": [
521,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withDeclName",
"code": "def withDeclName (name : Name) (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withReader (fun ctx => { ctx with declName? := name }) <| withSaveParentDeclInfoContext x",
"start": [
526,
1
],
"end": [
528,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.setLevelNames",
"code": "def setLevelNames (levelNames : List Name) : TermElabM Unit :=\n modify fun s => { s with levelNames := levelNames }",
"start": [
530,
1
],
"end": [
532,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withLevelNames",
"code": "def withLevelNames (levelNames : List Name) (x : TermElabM Ξ±) : TermElabM Ξ± := do\n let levelNamesSaved β getLevelNames\n setLevelNames levelNames\n try x finally setLevelNames levelNamesSaved",
"start": [
534,
1
],
"end": [
538,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withAuxDecl",
"code": "def withAuxDecl (shortDeclName : Name) (type : Expr) (declName : Name) (k : Expr β TermElabM Ξ±) : TermElabM Ξ± :=\n withLocalDecl shortDeclName .default (kind := .auxDecl) type fun x =>\n withReader (fun ctx => { ctx with auxDeclToFullName := ctx.auxDeclToFullName.insert x.fvarId! declName }) do\n k x",
"start": [
540,
1
],
"end": [
547,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutErrToSorryImp",
"code": "def withoutErrToSorryImp (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withReader (fun ctx => { ctx with errToSorry := false }) x",
"start": [
549,
1
],
"end": [
550,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutErrToSorry",
"code": "def withoutErrToSorry [MonadFunctorT TermElabM m] : m Ξ± β m Ξ± :=\n monadMap (m := TermElabM) withoutErrToSorryImp",
"start": [
552,
1
],
"end": [
557,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutHeedElabAsElimImp",
"code": "def withoutHeedElabAsElimImp (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withReader (fun ctx => { ctx with heedElabAsElim := false }) x",
"start": [
559,
1
],
"end": [
560,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutHeedElabAsElim",
"code": "def withoutHeedElabAsElim [MonadFunctorT TermElabM m] : m Ξ± β m Ξ± :=\n monadMap (m := TermElabM) withoutHeedElabAsElimImp",
"start": [
562,
1
],
"end": [
568,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutModifyingElabMetaStateWithInfo",
"code": "def withoutModifyingElabMetaStateWithInfo (x : TermElabM Ξ±) : TermElabM Ξ± := do\n let s β get\n let sMeta β getThe Meta.State\n try\n withSaveInfoContext x\n finally\n set s\n set sMeta",
"start": [
570,
1
],
"end": [
584,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutModifyingStateWithInfoAndMessagesImpl",
"code": "private def withoutModifyingStateWithInfoAndMessagesImpl (x : TermElabM Ξ±) : TermElabM Ξ± := do\n let saved β saveState\n try\n withSaveInfoContext x\n finally\n let saved := { saved with meta.core.infoState := (β getInfoState), meta.core.messages := (β getThe Core.State).messages }\n restoreState saved",
"start": [
586,
1
],
"end": [
595,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.throwErrorIfErrors",
"code": "def throwErrorIfErrors : TermElabM Unit := do\n if (β MonadLog.hasErrors) then\n throwError \"Error(s)\"",
"start": [
597,
1
],
"end": [
600,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.traceAtCmdPos",
"code": "def traceAtCmdPos (cls : Name) (msg : Unit β MessageData) : TermElabM Unit :=\n withRef Syntax.missing <| trace cls msg",
"start": [
602,
1
],
"end": [
603,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.ppGoal",
"code": "def ppGoal (mvarId : MVarId) : TermElabM Format :=\n Meta.ppGoal mvarId",
"start": [
605,
1
],
"end": [
606,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.liftLevelM",
"code": "def liftLevelM (x : LevelElabM Ξ±) : TermElabM Ξ± := do\n let ctx β read\n let mctx β getMCtx\n let ngen β getNGen\n let lvlCtx : Level.Context := { options := (β getOptions), ref := (β getRef), autoBoundImplicit := ctx.autoBoundImplicit }\n match (x lvlCtx).run { ngen := ngen, mctx := mctx, levelNames := (β getLevelNames) } with\n | .ok a newS => setMCtx newS.mctx; setNGen newS.ngen; setLevelNames newS.levelNames; pure a\n | .error ex _ => throw ex",
"start": [
610,
1
],
"end": [
617,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabLevel",
"code": "def elabLevel (stx : Syntax) : TermElabM Level :=\n liftLevelM <| Level.elabLevel stx",
"start": [
619,
1
],
"end": [
620,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withPushMacroExpansionStack",
"code": "def withPushMacroExpansionStack (beforeStx afterStx : Syntax) (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withReader (fun ctx => { ctx with macroStack := { before := beforeStx, after := afterStx } :: ctx.macroStack }) x",
"start": [
622,
1
],
"end": [
624,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withMacroExpansion",
"code": "def withMacroExpansion (beforeStx afterStx : Syntax) (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withMacroExpansionInfo beforeStx afterStx do\n withPushMacroExpansionStack beforeStx afterStx x",
"start": [
626,
1
],
"end": [
629,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerSyntheticMVar",
"code": "def registerSyntheticMVar (stx : Syntax) (mvarId : MVarId) (kind : SyntheticMVarKind) : TermElabM Unit := do\n modify fun s => { s with syntheticMVars := s.syntheticMVars.insert mvarId { stx, kind }, pendingMVars := mvarId :: s.pendingMVars }",
"start": [
631,
1
],
"end": [
635,
134
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerSyntheticMVarWithCurrRef",
"code": "def registerSyntheticMVarWithCurrRef (mvarId : MVarId) (kind : SyntheticMVarKind) : TermElabM Unit := do\n registerSyntheticMVar (β getRef) mvarId kind",
"start": [
637,
1
],
"end": [
638,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerMVarErrorInfo",
"code": "def registerMVarErrorInfo (mvarErrorInfo : MVarErrorInfo) : TermElabM Unit :=\n modify fun s => { s with mvarErrorInfos := mvarErrorInfo :: s.mvarErrorInfos }",
"start": [
640,
1
],
"end": [
641,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerMVarErrorHoleInfo",
"code": "def registerMVarErrorHoleInfo (mvarId : MVarId) (ref : Syntax) : TermElabM Unit :=\n registerMVarErrorInfo { mvarId, ref, kind := .hole }",
"start": [
643,
1
],
"end": [
644,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerMVarErrorImplicitArgInfo",
"code": "def registerMVarErrorImplicitArgInfo (mvarId : MVarId) (ref : Syntax) (app : Expr) : TermElabM Unit := do\n registerMVarErrorInfo { mvarId, ref, kind := .implicitArg app }",
"start": [
646,
1
],
"end": [
647,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerMVarErrorCustomInfo",
"code": "def registerMVarErrorCustomInfo (mvarId : MVarId) (ref : Syntax) (msgData : MessageData) : TermElabM Unit := do\n registerMVarErrorInfo { mvarId, ref, kind := .custom msgData }",
"start": [
649,
1
],
"end": [
650,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerCustomErrorIfMVar",
"code": "def registerCustomErrorIfMVar (e : Expr) (ref : Syntax) (msgData : MessageData) : TermElabM Unit :=\n match e.getAppFn with\n | Expr.mvar mvarId => registerMVarErrorCustomInfo mvarId ref msgData\n | _ => pure ()",
"start": [
652,
1
],
"end": [
655,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.registerMVarArgName",
"code": "def registerMVarArgName (mvarId : MVarId) (argName : Name) : TermElabM Unit :=\n modify fun s => { s with mvarArgNames := s.mvarArgNames.insert mvarId argName }",
"start": [
657,
1
],
"end": [
658,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.throwMVarError",
"code": "def throwMVarError (m : MessageData) : TermElabM Ξ± := do\n if (β MonadLog.hasErrors) then\n throwAbortTerm\n else\n throwError m",
"start": [
660,
1
],
"end": [
669,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.MVarErrorInfo.logError",
"code": "def MVarErrorInfo.logError (mvarErrorInfo : MVarErrorInfo) (extraMsg? : Option MessageData) : TermElabM Unit := do\n match mvarErrorInfo.kind with\n | MVarErrorKind.implicitArg app => do\n let app β instantiateMVars app\n let msg β addArgName \"don't know how to synthesize implicit argument\"\n let msg := msg ++ m!\"{indentExpr app.setAppPPExplicitForExposingMVars}\" ++ Format.line ++ \"context:\" ++ Format.line ++ MessageData.ofGoal mvarErrorInfo.mvarId\n logErrorAt mvarErrorInfo.ref (appendExtra msg)\n | MVarErrorKind.hole => do\n let msg β addArgName \"don't know how to synthesize placeholder\" \" for argument\"\n let msg := msg ++ Format.line ++ \"context:\" ++ Format.line ++ MessageData.ofGoal mvarErrorInfo.mvarId\n logErrorAt mvarErrorInfo.ref (MessageData.tagged `Elab.synthPlaceholder <| appendExtra msg)\n | MVarErrorKind.custom msg =>\n logErrorAt mvarErrorInfo.ref (appendExtra msg)\nwhere\n \n addArgName (msg : MessageData) (extra : String := \"\") : TermElabM MessageData := do\n match (β get).mvarArgNames.find? mvarErrorInfo.mvarId with\n | none => return msg\n | some argName => return if argName.hasMacroScopes then msg else msg ++ extra ++ m!\" '{argName}'\"\n\n appendExtra (msg : MessageData) : MessageData :=\n match extraMsg? with\n | none => msg\n | some extraMsg => msg ++ extraMsg",
"start": [
671,
1
],
"end": [
695,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.logUnassignedUsingErrorInfos",
"code": "def logUnassignedUsingErrorInfos (pendingMVarIds : Array MVarId) (extraMsg? : Option MessageData := none) : TermElabM Bool := do\n if pendingMVarIds.isEmpty then\n return false\n else\n let hasOtherErrors β MonadLog.hasErrors\n let mut hasNewErrors := false\n let mut alreadyVisited : MVarIdSet := {}\n let mut errors : Array MVarErrorInfo := #[]\n for mvarErrorInfo in (β get).mvarErrorInfos do\n let mvarId := mvarErrorInfo.mvarId\n unless alreadyVisited.contains mvarId do\n alreadyVisited := alreadyVisited.insert mvarId\n \n let mvarDeps β getMVars (mkMVar mvarId)\n if mvarDeps.any pendingMVarIds.contains then do\n unless hasOtherErrors do\n errors := errors.push mvarErrorInfo\n hasNewErrors := true\n for error in errors do\n error.mvarId.withContext do\n error.logError extraMsg?\n return hasNewErrors",
"start": [
697,
1
],
"end": [
728,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.ensureNoUnassignedMVars",
"code": "def ensureNoUnassignedMVars (decl : Declaration) : TermElabM Unit := do\n let pendingMVarIds β getMVarsAtDecl decl\n if (β logUnassignedUsingErrorInfos pendingMVarIds) then\n throwAbortCommand",
"start": [
730,
1
],
"end": [
734,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutPostponing",
"code": "def withoutPostponing (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withReader (fun ctx => { ctx with mayPostpone := false }) x",
"start": [
736,
1
],
"end": [
740,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkExplicitBinder",
"code": "def mkExplicitBinder (ident : Syntax) (type : Syntax) : Syntax :=\n mkNode ``Lean.Parser.Term.explicitBinder #[mkAtom \"(\", mkNullNode #[ident], mkNullNode #[mkAtom \":\", type], mkNullNode, mkAtom \")\"]",
"start": [
742,
1
],
"end": [
744,
134
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.levelMVarToParam",
"code": "def levelMVarToParam (e : Expr) (except : LMVarId β Bool := fun _ => false) : TermElabM Expr := do\n let levelNames β getLevelNames\n let r := (β getMCtx).levelMVarToParam (fun n => levelNames.elem n) except e `u 1\n setLevelNames (r.newParamNames.reverse.toList ++ levelNames)\n setMCtx r.mctx\n return r.expr",
"start": [
746,
1
],
"end": [
755,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkFreshBinderName",
"code": "def mkFreshBinderName [Monad m] [MonadQuotation m] : m Name :=\n withFreshMacroScope <| MonadQuotation.addMacroScope `x",
"start": [
757,
1
],
"end": [
761,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkFreshIdent",
"code": "def mkFreshIdent [Monad m] [MonadQuotation m] (ref : Syntax) (canonical := false) : m Ident :=\n return mkIdentFrom ref (β mkFreshBinderName) canonical",
"start": [
763,
1
],
"end": [
768,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.applyAttributesCore",
"code": "private def applyAttributesCore\n (declName : Name) (attrs : Array Attribute)\n (applicationTime? : Option AttributeApplicationTime) : TermElabM Unit := do profileitM Exception \"attribute application\" (β getOptions) do\n \n unless declName == .anonymous do\n for attr in attrs do\n withRef attr.stx do withLogging do\n let env β getEnv\n match getAttributeImpl env attr.name with\n | Except.error errMsg => throwError errMsg\n | Except.ok attrImpl =>\n let runAttr := attrImpl.add declName attr.stx attr.kind\n let runAttr := do\n let elaborator := attrImpl.ref\n if (β getInfoState).enabled && (β getEnv).contains elaborator then\n withInfoContext (mkInfo := return .ofCommandInfo { elaborator, stx := attr.stx }) do\n try runAttr\n finally if attr.stx[0].isIdent || attr.stx[0].isAtom then\n pushInfoLeaf <| .ofCommandInfo { elaborator, stx := attr.stx[0] }\n else\n runAttr\n match applicationTime? with\n | none => runAttr\n | some applicationTime =>\n if applicationTime == attrImpl.applicationTime then\n runAttr",
"start": [
770,
1
],
"end": [
801,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.applyAttributesAt",
"code": "def applyAttributesAt (declName : Name) (attrs : Array Attribute) (applicationTime : AttributeApplicationTime) : TermElabM Unit :=\n applyAttributesCore declName attrs applicationTime",
"start": [
803,
1
],
"end": [
805,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.applyAttributes",
"code": "def applyAttributes (declName : Name) (attrs : Array Attribute) : TermElabM Unit :=\n applyAttributesCore declName attrs none",
"start": [
807,
1
],
"end": [
808,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkTypeMismatchError",
"code": "def mkTypeMismatchError (header? : Option String) (e : Expr) (eType : Expr) (expectedType : Expr) : TermElabM MessageData := do\n let header : MessageData := match header? with\n | some header => m!\"{header} \"\n | none => m!\"type mismatch{indentExpr e}\\n\"\n return m!\"{header}{β mkHasTypeButIsExpectedMsg eType expectedType}\"",
"start": [
810,
1
],
"end": [
814,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.throwTypeMismatchError",
"code": "def throwTypeMismatchError (header? : Option String) (expectedType : Expr) (eType : Expr) (e : Expr)\n (f? : Option Expr := none) (_extraMsg? : Option MessageData := none) : TermElabM Ξ± := do\n \n let extraMsg := Format.nil\n \n match f? with\n | none => throwError \"{β mkTypeMismatchError header? e eType expectedType}{extraMsg}\"\n | some f => Meta.throwAppTypeMismatch f e",
"start": [
816,
1
],
"end": [
835,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutMacroStackAtErr",
"code": "def withoutMacroStackAtErr (x : TermElabM Ξ±) : TermElabM Ξ± :=\n withTheReader Core.Context (fun (ctx : Core.Context) => { ctx with options := pp.macroStack.set ctx.options false }) x",
"start": [
837,
1
],
"end": [
838,
121
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.ContainsPendingMVar.M",
"code": "abbrev M := MonadCacheT Expr Unit (OptionT MetaM)",
"start": [
842,
1
],
"end": [
842,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.ContainsPendingMVar.visit",
"code": "partial def visit (e : Expr) : M Unit := do\n checkCache e fun _ => do\n match e with\n | .forallE _ d b _ => visit d; visit b\n | .lam _ d b _ => visit d; visit b\n | .letE _ t v b _ => visit t; visit v; visit b\n | .app f a => visit f; visit a\n | .mdata _ b => visit b\n | .proj _ _ b => visit b\n | .fvar fvarId .. =>\n match (β fvarId.getDecl) with\n | .cdecl .. => return ()\n | .ldecl (value := v) .. => visit v\n | .mvar mvarId .. =>\n let e' β instantiateMVars e\n if e' != e then\n visit e'\n else\n match (β getDelayedMVarAssignment? mvarId) with\n | some d => visit (mkMVar d.mvarIdPending)\n | none => failure\n | _ => return ()",
"start": [
844,
1
],
"end": [
866,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.containsPendingMVar",
"code": "def containsPendingMVar (e : Expr) : MetaM Bool := do\n match (β ContainsPendingMVar.visit e |>.run.run) with\n | some _ => return false\n | none => return true",
"start": [
870,
1
],
"end": [
874,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.synthesizeInstMVarCore",
"code": "def synthesizeInstMVarCore (instMVar : MVarId) (maxResultSize? : Option Nat := none) (extraErrorMsg? : Option MessageData := none): TermElabM Bool := do\n let extraErrorMsg := extraMsgToMsg extraErrorMsg?\n let instMVarDecl β getMVarDecl instMVar\n let type := instMVarDecl.type\n let type β instantiateMVars type\n let result β trySynthInstance type maxResultSize?\n match result with\n | LOption.some val =>\n if (β instMVar.isAssigned) then\n let oldVal β instantiateMVars (mkMVar instMVar)\n unless (β isDefEq oldVal val) do\n if (β containsPendingMVar oldVal <||> containsPendingMVar val) then\n \n return false let oldValType β inferType oldVal\n let valType β inferType val\n unless (β isDefEq oldValType valType) do\n throwError \"synthesized type class instance type is not definitionally equal to expected type, synthesized{indentExpr val}\\nhas type{indentExpr valType}\\nexpected{indentExpr oldValType}{extraErrorMsg}\"\n throwError \"synthesized type class instance is not definitionally equal to expression inferred by typing rules, synthesized{indentExpr val}\\ninferred{indentExpr oldVal}{extraErrorMsg}\"\n else\n unless (β isDefEq (mkMVar instMVar) val) do\n throwError \"failed to assign synthesized type class instance{indentExpr val}{extraErrorMsg}\"\n return true\n | .undef => return false | .none =>\n if (β read).ignoreTCFailures then\n return false\n else\n throwError \"failed to synthesize{indentExpr type}{extraErrorMsg}\\n{useDiagnosticMsg}\"",
"start": [
876,
1
],
"end": [
932,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkCoe",
"code": "def mkCoe (expectedType : Expr) (e : Expr) (f? : Option Expr := none) (errorMsgHeader? : Option String := none) : TermElabM Expr := do\n withTraceNode `Elab.coe (fun _ => return m!\"adding coercion for {e} : {β inferType e} =?= {expectedType}\") do\n try\n withoutMacroStackAtErr do\n match β coerce? e expectedType with\n | .some eNew => return eNew\n | .none => failure\n | .undef =>\n let mvarAux β mkFreshExprMVar expectedType MetavarKind.syntheticOpaque\n registerSyntheticMVarWithCurrRef mvarAux.mvarId! (.coe errorMsgHeader? expectedType e f?)\n return mvarAux\n catch\n | .error _ msg => throwTypeMismatchError errorMsgHeader? expectedType (β inferType e) e f? msg\n | _ => throwTypeMismatchError errorMsgHeader? expectedType (β inferType e) e f?",
"start": [
934,
1
],
"end": [
947,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.ensureHasType",
"code": "def ensureHasType (expectedType? : Option Expr) (e : Expr)\n (errorMsgHeader? : Option String := none) (f? : Option Expr := none) : TermElabM Expr := do\n let some expectedType := expectedType? | return e\n if (β isDefEq (β inferType e) expectedType) then\n return e\n else\n mkCoe expectedType e f? errorMsgHeader?",
"start": [
949,
1
],
"end": [
960,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkSyntheticSorryFor",
"code": "private def mkSyntheticSorryFor (expectedType? : Option Expr) : TermElabM Expr := do\n let expectedType β match expectedType? with\n | none => mkFreshTypeMVar\n | some expectedType => pure expectedType\n mkSyntheticSorry expectedType",
"start": [
962,
1
],
"end": [
970,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.exceptionToSorry",
"code": "def exceptionToSorry (ex : Exception) (expectedType? : Option Expr) : TermElabM Expr := do\n let syntheticSorry β mkSyntheticSorryFor expectedType?\n logException ex\n pure syntheticSorry",
"start": [
972,
1
],
"end": [
979,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.tryPostpone",
"code": "def tryPostpone : TermElabM Unit := do\n if (β read).mayPostpone then\n throwPostpone",
"start": [
981,
1
],
"end": [
984,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isMVarApp",
"code": "def isMVarApp (e : Expr) : TermElabM Bool :=\n return (β whnfR e).getAppFn.isMVar",
"start": [
986,
1
],
"end": [
988,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.tryPostponeIfMVar",
"code": "def tryPostponeIfMVar (e : Expr) : TermElabM Unit := do\n if (β isMVarApp e) then\n tryPostpone",
"start": [
990,
1
],
"end": [
993,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.tryPostponeIfNoneOrMVar",
"code": "def tryPostponeIfNoneOrMVar (e? : Option Expr) : TermElabM Unit :=\n match e? with\n | some e => tryPostponeIfMVar e\n | none => tryPostpone",
"start": [
995,
1
],
"end": [
999,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.tryPostponeIfHasMVars?",
"code": "def tryPostponeIfHasMVars? (expectedType? : Option Expr) : TermElabM (Option Expr) := do\n tryPostponeIfNoneOrMVar expectedType?\n let some expectedType := expectedType? | return none\n let expectedType β instantiateMVars expectedType\n if expectedType.hasExprMVar then\n tryPostpone\n return none\n return some expectedType",
"start": [
1001,
1
],
"end": [
1012,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.tryPostponeIfHasMVars",
"code": "def tryPostponeIfHasMVars (expectedType? : Option Expr) (msg : String) : TermElabM Expr := do\n let some expectedType β tryPostponeIfHasMVars? expectedType? |\n throwError \"{msg}, expected type contains metavariables{indentD expectedType?}\"\n return expectedType",
"start": [
1014,
1
],
"end": [
1021,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withExpectedType",
"code": "def withExpectedType (expectedType? : Option Expr) (x : Expr β TermElabM Expr) : TermElabM Expr := do\n tryPostponeIfNoneOrMVar expectedType?\n let some expectedType β pure expectedType?\n | throwError \"expected type must be known\"\n x expectedType",
"start": [
1023,
1
],
"end": [
1027,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.saveContext",
"code": "def saveContext : TermElabM SavedContext :=\n return {\n macroStack := (β read).macroStack\n declName? := (β read).declName?\n options := (β getOptions)\n openDecls := (β getOpenDecls)\n errToSorry := (β read).errToSorry\n levelNames := (β get).levelNames\n }",
"start": [
1029,
1
],
"end": [
1040,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withSavedContext",
"code": "def withSavedContext (savedCtx : SavedContext) (x : TermElabM Ξ±) : TermElabM Ξ± := do\n withReader (fun ctx => { ctx with declName? := savedCtx.declName?, macroStack := savedCtx.macroStack, errToSorry := savedCtx.errToSorry }) <|\n withTheReader Core.Context (fun ctx => { ctx with options := savedCtx.options, openDecls := savedCtx.openDecls }) <|\n withLevelNames savedCtx.levelNames x",
"start": [
1042,
1
],
"end": [
1048,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.postponeElabTermCore",
"code": "private def postponeElabTermCore (stx : Syntax) (expectedType? : Option Expr) : TermElabM Expr := do\n trace[Elab.postpone] \"{stx} : {expectedType?}\"\n let mvar β mkFreshExprMVar expectedType? MetavarKind.syntheticOpaque\n registerSyntheticMVar stx mvar.mvarId! (SyntheticMVarKind.postponed (β saveContext))\n return mvar",
"start": [
1050,
1
],
"end": [
1059,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.getSyntheticMVarDecl?",
"code": "def getSyntheticMVarDecl? (mvarId : MVarId) : TermElabM (Option SyntheticMVarDecl) :=\n return (β get).syntheticMVars.find? mvarId",
"start": [
1061,
1
],
"end": [
1062,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkSaveInfoAnnotation",
"code": "def mkSaveInfoAnnotation (e : Expr) : Expr :=\n if e.isMVar then\n mkAnnotation `save_info e\n else\n e",
"start": [
1064,
1
],
"end": [
1085,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isSaveInfoAnnotation?",
"code": "def isSaveInfoAnnotation? (e : Expr) : Option Expr :=\n annotation? `save_info e",
"start": [
1087,
1
],
"end": [
1088,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.removeSaveInfoAnnotation",
"code": "partial def removeSaveInfoAnnotation (e : Expr) : Expr :=\n match isSaveInfoAnnotation? e with\n | some e => removeSaveInfoAnnotation e\n | _ => e",
"start": [
1090,
1
],
"end": [
1093,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isTacticOrPostponedHole?",
"code": "def isTacticOrPostponedHole? (e : Expr) : TermElabM (Option MVarId) := do\n match e with\n | Expr.mvar mvarId =>\n match (β getSyntheticMVarDecl? mvarId) with\n | some { kind := .tactic .., .. } => return mvarId\n | some { kind := .postponed .., .. } => return mvarId\n | _ => return none\n | _ => pure none",
"start": [
1095,
1
],
"end": [
1107,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkTermInfo",
"code": "def mkTermInfo (elaborator : Name) (stx : Syntax) (e : Expr) (expectedType? : Option Expr := none) (lctx? : Option LocalContext := none) (isBinder := false) : TermElabM (Sum Info MVarId) := do\n match (β isTacticOrPostponedHole? e) with\n | some mvarId => return Sum.inr mvarId\n | none =>\n let e := removeSaveInfoAnnotation e\n return Sum.inl <| Info.ofTermInfo { elaborator, lctx := lctx?.getD (β getLCtx), expr := e, stx, expectedType?, isBinder }",
"start": [
1109,
1
],
"end": [
1114,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.addTermInfo",
"code": "def addTermInfo (stx : Syntax) (e : Expr) (expectedType? : Option Expr := none)\n (lctx? : Option LocalContext := none) (elaborator := Name.anonymous)\n (isBinder := false) (force := false) : TermElabM Expr := do\n if (β read).inPattern && !force then\n return mkPatternWithRef e stx\n else\n withInfoContext' (pure ()) (fun _ => mkTermInfo elaborator stx e expectedType? lctx? isBinder) |> discard\n return e",
"start": [
1116,
1
],
"end": [
1138,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.addTermInfo'",
"code": "def addTermInfo' (stx : Syntax) (e : Expr) (expectedType? : Option Expr := none) (lctx? : Option LocalContext := none) (elaborator := Name.anonymous) (isBinder := false) : TermElabM Unit :=\n discard <| addTermInfo stx e expectedType? lctx? elaborator isBinder",
"start": [
1140,
1
],
"end": [
1141,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withInfoContext'",
"code": "def withInfoContext' (stx : Syntax) (x : TermElabM Expr) (mkInfo : Expr β TermElabM (Sum Info MVarId)) : TermElabM Expr := do\n if (β read).inPattern then\n let e β x\n return mkPatternWithRef e stx\n else\n Elab.withInfoContext' x mkInfo",
"start": [
1143,
1
],
"end": [
1148,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.postponeElabTerm",
"code": "def postponeElabTerm (stx : Syntax) (expectedType? : Option Expr) : TermElabM Expr := do\n withInfoContext' stx (mkInfo := mkTermInfo .anonymous (expectedType? := expectedType?) stx) do\n postponeElabTermCore stx expectedType?",
"start": [
1150,
1
],
"end": [
1157,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabUsingElabFnsAux",
"code": "private def elabUsingElabFnsAux (s : SavedState) (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone : Bool)\n : List (KeyedDeclsAttribute.AttributeEntry TermElab) β TermElabM Expr\n | [] => do throwError \"unexpected syntax{indentD stx}\"\n | (elabFn::elabFns) =>\n try\n withInfoContext' stx (mkInfo := mkTermInfo elabFn.declName (expectedType? := expectedType?) stx)\n (try\n elabFn.value stx expectedType?\n catch ex => match ex with\n | .error .. =>\n if (β read).errToSorry then\n exceptionToSorry ex expectedType?\n else\n throw ex\n | .internal id _ =>\n if (β read).errToSorry && id == abortTermExceptionId then\n exceptionToSorry ex expectedType?\n else if id == unsupportedSyntaxExceptionId then\n throw ex else if catchExPostpone && id == postponeExceptionId then\n \n s.restore\n postponeElabTermCore stx expectedType?\n else\n throw ex)\n catch ex => match ex with\n | .internal id _ =>\n if id == unsupportedSyntaxExceptionId then\n s.restore elabUsingElabFnsAux s stx expectedType? catchExPostpone elabFns\n else\n throw ex\n | _ => throw ex",
"start": [
1159,
1
],
"end": [
1208,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabUsingElabFns",
"code": "private def elabUsingElabFns (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone : Bool) : TermElabM Expr := do\n let s β saveState\n let k := stx.getKind\n match termElabAttribute.getEntries (β getEnv) k with\n | [] => throwError \"elaboration function for '{k}' has not been implemented{indentD stx}\"\n | elabFns => elabUsingElabFnsAux s stx expectedType? catchExPostpone elabFns",
"start": [
1210,
1
],
"end": [
1215,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isExplicit",
"code": "private def isExplicit (stx : Syntax) : Bool :=\n match stx with\n | `(@$_) => true\n | _ => false",
"start": [
1222,
1
],
"end": [
1225,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isExplicitApp",
"code": "private def isExplicitApp (stx : Syntax) : Bool :=\n stx.getKind == ``Lean.Parser.Term.app && isExplicit stx[0]",
"start": [
1227,
1
],
"end": [
1228,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isLambdaWithImplicit",
"code": "private def isLambdaWithImplicit (stx : Syntax) : Bool :=\n match stx with\n | `(fun $binders* => $_) => binders.raw.any fun b => b.isOfKind ``Lean.Parser.Term.implicitBinder || b.isOfKind `Lean.Parser.Term.instBinder\n | _ => false",
"start": [
1230,
1
],
"end": [
1236,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.dropTermParens",
"code": "private partial def dropTermParens : Syntax β Syntax := fun stx =>\n match stx with\n | `(($stx)) => dropTermParens stx\n | _ => stx",
"start": [
1238,
1
],
"end": [
1241,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isHole",
"code": "private def isHole (stx : Syntax) : Bool :=\n match stx with\n | `(_) => true\n | `(? _) => true\n | `(? $_:ident) => true\n | _ => false",
"start": [
1243,
1
],
"end": [
1248,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isTacticBlock",
"code": "private def isTacticBlock (stx : Syntax) : Bool :=\n match stx with\n | `(by $_:tacticSeq) => true\n | _ => false",
"start": [
1250,
1
],
"end": [
1253,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isNoImplicitLambda",
"code": "private def isNoImplicitLambda (stx : Syntax) : Bool :=\n match stx with\n | `(no_implicit_lambda% $_:term) => true\n | _ => false",
"start": [
1255,
1
],
"end": [
1258,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isTypeAscription",
"code": "private def isTypeAscription (stx : Syntax) : Bool :=\n match stx with\n | `(($_ : $[$_]?)) => true\n | _ => false",
"start": [
1260,
1
],
"end": [
1263,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.hasNoImplicitLambdaAnnotation",
"code": "def hasNoImplicitLambdaAnnotation (type : Expr) : Bool :=\n annotation? `noImplicitLambda type |>.isSome",
"start": [
1265,
1
],
"end": [
1266,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkNoImplicitLambdaAnnotation",
"code": "def mkNoImplicitLambdaAnnotation (type : Expr) : Expr :=\n if hasNoImplicitLambdaAnnotation type then\n type\n else\n mkAnnotation `noImplicitLambda type",
"start": [
1268,
1
],
"end": [
1272,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.blockImplicitLambda",
"code": "def blockImplicitLambda (stx : Syntax) : Bool :=\n let stx := dropTermParens stx\n isExplicit stx || isExplicitApp stx || isLambdaWithImplicit stx || isHole stx || isTacticBlock stx ||\n isNoImplicitLambda stx || isTypeAscription stx",
"start": [
1274,
1
],
"end": [
1279,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.resolveLocalName",
"code": "def resolveLocalName (n : Name) : TermElabM (Option (Expr Γ List String)) := do\n let lctx β getLCtx\n let auxDeclToFullName := (β read).auxDeclToFullName\n let currNamespace β getCurrNamespace\n let view := extractMacroScopes n\n \n let matchLocalDecl? (localDecl : LocalDecl) (givenName : Name) : Option LocalDecl := do\n guard (localDecl.userName == givenName)\n return localDecl\n \n let matchAuxRecDecl? (localDecl : LocalDecl) (fullDeclName : Name) (givenNameView : MacroScopesView) : Option LocalDecl := do\n let fullDeclView := extractMacroScopes fullDeclName\n \n let fullDeclView := { fullDeclView with name := (privateToUserName? fullDeclView.name).getD fullDeclView.name }\n let fullDeclName := fullDeclView.review\n let localDeclNameView := extractMacroScopes localDecl.userName\n \n if currNamespace.isPrefixOf fullDeclName then\n \n guard (localDeclNameView.isSuffixOf givenNameView)\n guard (givenNameView.isSuffixOf fullDeclView)\n return localDecl\n else\n \n let rec go (ns : Name) : Option LocalDecl := do\n if { givenNameView with name := ns ++ givenNameView.name }.review == fullDeclName then\n return localDecl\n match ns with\n | .str pre .. => go pre\n | _ => failure\n return (β go currNamespace)\n \n let findLocalDecl? (givenNameView : MacroScopesView) (skipAuxDecl : Bool) : Option LocalDecl :=\n let givenName := givenNameView.review\n let localDecl? := lctx.decls.findSomeRev? fun localDecl? => do\n let localDecl β localDecl?\n if localDecl.isAuxDecl then\n guard (not skipAuxDecl)\n if let some fullDeclName := auxDeclToFullName.find? localDecl.fvarId then\n matchAuxRecDecl? localDecl fullDeclName givenNameView\n else\n matchLocalDecl? localDecl givenName\n else\n matchLocalDecl? localDecl givenName\n if localDecl?.isSome || skipAuxDecl then\n localDecl?\n else\n lctx.decls.findSomeRev? fun localDecl? => do\n let localDecl β localDecl?\n guard localDecl.isAuxDecl\n matchLocalDecl? localDecl givenName\n \n let rec loop (n : Name) (projs : List String) (globalDeclFound : Bool) := do\n let givenNameView := { view with name := n }\n let mut globalDeclFoundNext := globalDeclFound\n unless globalDeclFound do\n let r β resolveGlobalName givenNameView.review\n let r := r.filter fun (_, fieldList) => fieldList.isEmpty\n unless r.isEmpty do\n globalDeclFoundNext := true\n \n match findLocalDecl? givenNameView (skipAuxDecl := globalDeclFound && not projs.isEmpty) with\n | some decl => return some (decl.toExpr, projs)\n | none => match n with\n | .str pre s => loop pre (s::projs) globalDeclFoundNext\n | _ => return none\n loop view.name [] (globalDeclFound := false)",
"start": [
1281,
1
],
"end": [
1442,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isLocalIdent?",
"code": "def isLocalIdent? (stx : Syntax) : TermElabM (Option Expr) :=\n match stx with\n | Syntax.ident _ _ val _ => do\n let r? β resolveLocalName val\n match r? with\n | some (fvar, []) => return some fvar\n | _ => return none\n | _ => return none",
"start": [
1444,
1
],
"end": [
1452,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.UseImplicitLambdaResult",
"code": "inductive UseImplicitLambdaResult where\n | no\n | yes (expectedType : Expr)\n | postpone",
"start": [
1454,
1
],
"end": [
1457,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.useImplicitLambda",
"code": "private def useImplicitLambda (stx : Syntax) (expectedType? : Option Expr) : TermElabM UseImplicitLambdaResult := do\n if blockImplicitLambda stx then\n return .no\n let some expectedType := expectedType? | return .no\n if hasNoImplicitLambdaAnnotation expectedType then\n return .no\n let expectedType β whnfForall expectedType\n let .forallE _ _ _ c := expectedType | return .no\n unless c.isImplicit || c.isInstImplicit do\n return .no\n if let some x β isLocalIdent? stx then\n if (β isMVarApp (β inferType x)) then\n \n return .postpone\n return .yes expectedType",
"start": [
1459,
1
],
"end": [
1501,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.decorateErrorMessageWithLambdaImplicitVars",
"code": "private def decorateErrorMessageWithLambdaImplicitVars (ex : Exception) (impFVars : Array Expr) : TermElabM Exception := do\n match ex with\n | .error ref msg =>\n if impFVars.isEmpty then\n return Exception.error ref msg\n else\n let mut msg := m!\"{msg}\\nthe following variables have been introduced by the implicit lambda feature\"\n for impFVar in impFVars do\n let auxMsg := m!\"{impFVar} : {β inferType impFVar}\"\n let auxMsg β addMessageContext auxMsg\n msg := m!\"{msg}{indentD auxMsg}\"\n msg := m!\"{msg}\\nyou can disable implicit lambdas using `@` or writing a lambda expression with `\\{}` or `[]` binder annotations.\"\n return Exception.error ref msg\n | _ => return ex",
"start": [
1503,
1
],
"end": [
1516,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabImplicitLambdaAux",
"code": "private def elabImplicitLambdaAux (stx : Syntax) (catchExPostpone : Bool) (expectedType : Expr) (impFVars : Array Expr) : TermElabM Expr := do\n let body β elabUsingElabFns stx expectedType catchExPostpone\n try\n let body β ensureHasType expectedType body\n let r β mkLambdaFVars impFVars body\n trace[Elab.implicitForall] r\n return r\n catch ex =>\n throw (β decorateErrorMessageWithLambdaImplicitVars ex impFVars)",
"start": [
1518,
1
],
"end": [
1526,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabImplicitLambda",
"code": "private partial def elabImplicitLambda (stx : Syntax) (catchExPostpone : Bool) (type : Expr) : TermElabM Expr :=\n loop type #[]\nwhere\n loop (type : Expr) (fvars : Array Expr) : TermElabM Expr := do\n match (β whnfForall type) with\n | .forallE n d b c =>\n if c.isExplicit then\n elabImplicitLambdaAux stx catchExPostpone type fvars\n else withFreshMacroScope do\n let n β MonadQuotation.addMacroScope n\n withLocalDecl n c d fun fvar => do\n let type := b.instantiate1 fvar\n loop type (fvars.push fvar)\n | _ =>\n elabImplicitLambdaAux stx catchExPostpone type fvars",
"start": [
1528,
1
],
"end": [
1542,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabTermAux",
"code": "private partial def elabTermAux (expectedType? : Option Expr) (catchExPostpone : Bool) (implicitLambda : Bool) : Syntax β TermElabM Expr\n | .missing => mkSyntheticSorryFor expectedType?\n | stx => withFreshMacroScope <| withIncRecDepth do\n withTraceNode `Elab.step (fun _ => return m!\"expected type: {expectedType?}, term\\n{stx}\")\n (tag := stx.getKind.toString) do\n checkSystem \"elaborator\"\n let env β getEnv\n let result β match (β liftMacroM (expandMacroImpl? env stx)) with\n | some (decl, stxNew?) =>\n let stxNew β liftMacroM <| liftExcept stxNew?\n withInfoContext' stx (mkInfo := mkTermInfo decl (expectedType? := expectedType?) stx) <|\n withMacroExpansion stx stxNew <|\n withRef stxNew <|\n elabTermAux expectedType? catchExPostpone implicitLambda stxNew\n | _ =>\n let useImplicitResult β if implicitLambda && (β read).implicitLambda then useImplicitLambda stx expectedType? else pure .no\n match useImplicitResult with\n | .yes expectedType => elabImplicitLambda stx catchExPostpone expectedType\n | .no => elabUsingElabFns stx expectedType? catchExPostpone\n | .postpone =>\n \n if (β read).mayPostpone then\n if catchExPostpone then\n postponeElabTerm stx expectedType?\n else\n throwPostpone\n else\n elabUsingElabFns stx expectedType? catchExPostpone\n trace[Elab.step.result] result\n pure result",
"start": [
1544,
1
],
"end": [
1577,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.addDotCompletionInfo",
"code": "def addDotCompletionInfo (stx : Syntax) (e : Expr) (expectedType? : Option Expr) : TermElabM Unit := do\n addCompletionInfo <| CompletionInfo.dot { expr := e, stx, lctx := (β getLCtx), elaborator := .anonymous, expectedType? } (expectedType? := expectedType?)",
"start": [
1579,
1
],
"end": [
1581,
156
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabTerm",
"code": "def elabTerm (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) (implicitLambda := true) : TermElabM Expr :=\n withRef stx <| elabTermAux expectedType? catchExPostpone implicitLambda stx",
"start": [
1583,
1
],
"end": [
1601,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabTermEnsuringType",
"code": "def elabTermEnsuringType (stx : Syntax) (expectedType? : Option Expr) (catchExPostpone := true) (implicitLambda := true) (errorMsgHeader? : Option String := none) : TermElabM Expr := do\n let e β elabTerm stx expectedType? catchExPostpone implicitLambda\n try\n withRef stx <| ensureHasType expectedType? e errorMsgHeader?\n catch ex =>\n if (β read).errToSorry && ex matches .error .. then\n exceptionToSorry ex expectedType?\n else\n throw ex",
"start": [
1603,
1
],
"end": [
1618,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.commitIfNoErrors?",
"code": "def commitIfNoErrors? (x : TermElabM Ξ±) : TermElabM (Option Ξ±) := do\n let saved β saveState\n Core.resetMessageLog\n try\n let a β x\n if (β MonadLog.hasErrors) then\n restoreState saved\n return none\n else\n Core.setMessageLog (saved.meta.core.messages ++ (β Core.getMessageLog))\n return a\n catch _ =>\n restoreState saved\n return none",
"start": [
1620,
1
],
"end": [
1634,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.adaptExpander",
"code": "def adaptExpander (exp : Syntax β TermElabM Syntax) : TermElab := fun stx expectedType? => do\n let stx' β exp stx\n withMacroExpansion stx stx' <| elabTerm stx' expectedType?",
"start": [
1636,
1
],
"end": [
1639,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkInstMVar",
"code": "def mkInstMVar (type : Expr) (extraErrorMsg? : Option MessageData := none) : TermElabM Expr := do\n let mvar β mkFreshExprMVar type MetavarKind.synthetic\n let mvarId := mvar.mvarId!\n unless (β synthesizeInstMVarCore mvarId (extraErrorMsg? := extraErrorMsg?)) do\n registerSyntheticMVarWithCurrRef mvarId (.typeClass extraErrorMsg?)\n return mvar",
"start": [
1641,
1
],
"end": [
1651,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.ensureType",
"code": "def ensureType (e : Expr) : TermElabM Expr := do\n if (β isType e) then\n return e\n else\n let eType β inferType e\n let u β mkFreshLevelMVar\n if (β isDefEq eType (mkSort u)) then\n return e\n else if let some coerced β coerceToSort? e then\n return coerced\n else\n if (β instantiateMVars e).hasSyntheticSorry then\n throwAbortTerm\n throwError \"type expected, got\\n ({β instantiateMVars e} : {β instantiateMVars eType})\"",
"start": [
1653,
1
],
"end": [
1669,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.elabType",
"code": "def elabType (stx : Syntax) : TermElabM Expr := do\n let u β mkFreshLevelMVar\n let type β elabTerm stx (mkSort u)\n withRef stx <| ensureType type",
"start": [
1671,
1
],
"end": [
1675,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withAutoBoundImplicit",
"code": "partial def withAutoBoundImplicit (k : TermElabM Ξ±) : TermElabM Ξ± := do\n let flag := autoImplicit.get (β getOptions)\n if flag then\n withReader (fun ctx => { ctx with autoBoundImplicit := flag, autoBoundImplicits := {} }) do\n let rec loop (s : SavedState) : TermElabM Ξ± := withIncRecDepth do\n checkSystem \"auto-implicit\"\n try\n k\n catch\n | ex => match isAutoBoundImplicitLocalException? ex with\n | some n =>\n s.restore (restoreInfo := true)\n withLocalDecl n .implicit (β mkFreshTypeMVar) fun x =>\n withReader (fun ctx => { ctx with autoBoundImplicits := ctx.autoBoundImplicits.push x } ) do\n loop (β saveState)\n | none => throw ex\n loop (β saveState)\n else\n k",
"start": [
1677,
1
],
"end": [
1699,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withoutAutoBoundImplicit",
"code": "def withoutAutoBoundImplicit (k : TermElabM Ξ±) : TermElabM Ξ± := do\n withReader (fun ctx => { ctx with autoBoundImplicit := false, autoBoundImplicits := {} }) k",
"start": [
1701,
1
],
"end": [
1702,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.withAutoBoundImplicitForbiddenPred",
"code": "partial def withAutoBoundImplicitForbiddenPred (p : Name β Bool) (x : TermElabM Ξ±) : TermElabM Ξ± := do\n withReader (fun ctx => { ctx with autoBoundImplicitForbidden := fun n => p n || ctx.autoBoundImplicitForbidden n }) x",
"start": [
1704,
1
],
"end": [
1705,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.collectUnassignedMVars",
"code": "partial def collectUnassignedMVars (type : Expr) (init : Array Expr := #[]) (except : MVarId β Bool := fun _ => false)\n : TermElabM (Array Expr) := do\n let mvarIds β getMVars type\n if mvarIds.isEmpty then\n return init\n else\n go mvarIds.toList init init\nwhere\n go (mvarIds : List MVarId) (result visited : Array Expr) : TermElabM (Array Expr) := do\n match mvarIds with\n | [] => return result\n | mvarId :: mvarIds => do\n let visited := visited.push (mkMVar mvarId)\n if (β mvarId.isAssigned) then\n go mvarIds result visited\n else if result.contains (mkMVar mvarId) || except mvarId then\n go mvarIds result visited\n else\n let mvarType := (β getMVarDecl mvarId).type\n let mvarIdsNew β getMVars mvarType\n let mvarIdsNew := mvarIdsNew.filter fun mvarId => !visited.contains (mkMVar mvarId)\n if mvarIdsNew.isEmpty then\n go mvarIds (result.push (mkMVar mvarId)) visited\n else\n go (mvarIdsNew.toList ++ mvarId :: mvarIds) result visited",
"start": [
1707,
1
],
"end": [
1734,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.addAutoBoundImplicits",
"code": "def addAutoBoundImplicits (xs : Array Expr) : TermElabM (Array Expr) := do\n let autos := (β read).autoBoundImplicits\n go autos.toList #[]\nwhere\n go (todo : List Expr) (autos : Array Expr) : TermElabM (Array Expr) := do\n match todo with\n | [] =>\n for auto in autos do\n if auto.isFVar then\n let localDecl β auto.fvarId!.getDecl\n for x in xs do\n if (β localDeclDependsOn localDecl x.fvarId!) then\n throwError \"invalid auto implicit argument '{auto}', it depends on explicitly provided argument '{x}'\"\n return autos ++ xs\n | auto :: todo =>\n let autos β collectUnassignedMVars (β inferType auto) autos\n go todo (autos.push auto)",
"start": [
1736,
1
],
"end": [
1761,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.addAutoBoundImplicits'",
"code": "def addAutoBoundImplicits' (xs : Array Expr) (type : Expr) (k : Array Expr β Expr β TermElabM Ξ±) : TermElabM Ξ± := do\n let xs β addAutoBoundImplicits xs\n if xs.all (Β·.isFVar) then\n k xs type\n else\n forallBoundedTelescope (β mkForallFVars xs type) xs.size fun xs type => k xs type",
"start": [
1763,
1
],
"end": [
1774,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkAuxName",
"code": "def mkAuxName (suffix : Name) : TermElabM Name := do\n match (β read).declName? with\n | none => throwError \"auxiliary declaration cannot be created when declaration name is not available\"\n | some declName => Lean.mkAuxName (declName ++ suffix) 1",
"start": [
1776,
1
],
"end": [
1779,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.isLetRecAuxMVar",
"code": "def isLetRecAuxMVar (mvarId : MVarId) : TermElabM Bool := do\n trace[Elab.letrec] \"mvarId: {mkMVar mvarId} letrecMVars: {(β get).letRecsToLift.map (mkMVar $ Β·.mvarId)}\"\n let mvarId β getDelayedMVarRoot mvarId\n trace[Elab.letrec] \"mvarId root: {mkMVar mvarId}\"\n return (β get).letRecsToLift.any (Β·.mvarId == mvarId)",
"start": [
1783,
1
],
"end": [
1789,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkConst",
"code": "def mkConst (constName : Name) (explicitLevels : List Level := []) : TermElabM Expr := do\n Linter.checkDeprecated constName let cinfo β getConstInfo constName\n if explicitLevels.length > cinfo.levelParams.length then\n throwError \"too many explicit universe levels for '{constName}'\"\n else\n let numMissingLevels := cinfo.levelParams.length - explicitLevels.length\n let us β mkFreshLevelMVars numMissingLevels\n return Lean.mkConst constName (explicitLevels ++ us)",
"start": [
1791,
1
],
"end": [
1803,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.mkConsts",
"code": "private def mkConsts (candidates : List (Name Γ List String)) (explicitLevels : List Level) : TermElabM (List (Expr Γ List String)) := do\n candidates.foldlM (init := []) fun result (declName, projs) => do\n let const β mkConst declName explicitLevels\n return (const, projs) :: result",
"start": [
1805,
1
],
"end": [
1809,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.resolveName",
"code": "def resolveName (stx : Syntax) (n : Name) (preresolved : List Syntax.Preresolved) (explicitLevels : List Level) (expectedType? : Option Expr := none) : TermElabM (List (Expr Γ List String)) := do\n addCompletionInfo <| CompletionInfo.id stx stx.getId (danglingDot := false) (β getLCtx) expectedType?\n if let some (e, projs) β resolveLocalName n then\n unless explicitLevels.isEmpty do\n throwError \"invalid use of explicit universe parameters, '{e}' is a local\"\n return [(e, projs)]\n let preresolved := preresolved.filterMap fun\n | .decl n projs => some (n, projs)\n | _ => none\n let ctx β read\n if let some (e, projs) := preresolved.findSome? fun (n, projs) => ctx.sectionFVars.find? n |>.map (Β·, projs) then\n return [(e, projs)] if preresolved.isEmpty then\n process (β realizeGlobalName n)\n else\n process preresolved\nwhere\n process (candidates : List (Name Γ List String)) : TermElabM (List (Expr Γ List String)) := do\n if candidates.isEmpty then\n if (β read).autoBoundImplicit &&\n !(β read).autoBoundImplicitForbidden n &&\n isValidAutoBoundImplicitName n (relaxedAutoImplicit.get (β getOptions)) then\n throwAutoBoundImplicitLocal n\n else\n throwError \"unknown identifier '{Lean.mkConst n}'\"\n mkConsts candidates explicitLevels",
"start": [
1811,
1
],
"end": [
1837,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.resolveName'",
"code": "def resolveName' (ident : Syntax) (explicitLevels : List Level) (expectedType? : Option Expr := none) : TermElabM (List (Expr Γ Syntax Γ List Syntax)) := do\n match ident with\n | .ident _ _ n preresolved =>\n let r β resolveName ident n preresolved explicitLevels expectedType?\n r.mapM fun (c, fields) => do\n let ids := ident.identComponents (nFields? := fields.length)\n return (c, ids.head!, ids.tail!)\n | _ => throwError \"identifier expected\"",
"start": [
1839,
1
],
"end": [
1850,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.resolveId?",
"code": "def resolveId? (stx : Syntax) (kind := \"term\") (withInfo := false) : TermElabM (Option Expr) := withRef stx do\n match stx with\n | .ident _ _ val preresolved =>\n let rs β try resolveName stx val preresolved [] catch _ => pure []\n let rs := rs.filter fun β¨_, projsβ© => projs.isEmpty\n let fs := rs.map fun (f, _) => f\n match fs with\n | [] => return none\n | [f] =>\n let f β if withInfo then addTermInfo stx f else pure f\n return some f\n | _ => throwError \"ambiguous {kind}, use fully qualified name, possible interpretations {fs}\"\n | _ => throwError \"identifier expected\"",
"start": [
1852,
1
],
"end": [
1864,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.TermElabM.run",
"code": "def TermElabM.run (x : TermElabM Ξ±) (ctx : Context := {}) (s : State := {}) : MetaM (Ξ± Γ State) :=\n withConfig setElabConfig (x ctx |>.run s)",
"start": [
1867,
1
],
"end": [
1868,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.TermElabM.run'",
"code": "@[inline] def TermElabM.run' (x : TermElabM Ξ±) (ctx : Context := {}) (s : State := {}) : MetaM Ξ± :=\n (Β·.1) <$> x.run ctx s",
"start": [
1870,
1
],
"end": [
1871,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.TermElabM.toIO",
"code": "def TermElabM.toIO (x : TermElabM Ξ±)\n (ctxCore : Core.Context) (sCore : Core.State)\n (ctxMeta : Meta.Context) (sMeta : Meta.State)\n (ctx : Context) (s : State) : IO (Ξ± Γ Core.State Γ Meta.State Γ State) := do\n let ((a, s), sCore, sMeta) β (x.run ctx s).toIO ctxCore sCore ctxMeta sMeta\n return (a, sCore, sMeta, s)",
"start": [
1873,
1
],
"end": [
1878,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.universeConstraintsCheckpoint",
"code": "def universeConstraintsCheckpoint (x : TermElabM Ξ±) : TermElabM Ξ± := do\n let a β x\n discard <| processPostponed (mayPostpone := true) (exceptionOnFailure := true)\n return a",
"start": [
1887,
1
],
"end": [
1894,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.expandDeclId",
"code": "def expandDeclId (currNamespace : Name) (currLevelNames : List Name) (declId : Syntax) (modifiers : Modifiers) : TermElabM ExpandDeclIdResult := do\n let r β Elab.expandDeclId currNamespace currLevelNames declId modifiers\n if (β read).sectionVars.contains r.shortName then\n throwError \"invalid declaration name '{r.shortName}', there is a section variable with the same name\"\n return r",
"start": [
1896,
1
],
"end": [
1900,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.exprToSyntax",
"code": "def exprToSyntax (e : Expr) : TermElabM Term := withFreshMacroScope do\n let result β `(?m)\n let eType β inferType e\n let mvar β elabTerm result eType\n mvar.mvarId!.assign e\n return result",
"start": [
1902,
1
],
"end": [
1916,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.withoutModifyingStateWithInfoAndMessages",
"code": "def withoutModifyingStateWithInfoAndMessages [MonadControlT TermElabM m] [Monad m] (x : m Ξ±) : m Ξ± := do\n controlAt TermElabM fun runInBase => withoutModifyingStateWithInfoAndMessagesImpl <| runInBase x",
"start": [
1921,
1
],
"end": [
1922,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.addBuiltinIncrementalElab",
"code": "def addBuiltinIncrementalElab (decl : Name) : IO Unit := do\n builtinIncrementalElabs.modify fun s => s.insert decl",
"start": [
1937,
1
],
"end": [
1938,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.isIncrementalElab",
"code": "def isIncrementalElab [Monad m] [MonadEnv m] [MonadLiftT IO m] (decl : Name) : m Bool :=\n (return (β builtinIncrementalElabs.get (m := IO)).contains decl) <||>\n (return incrementalAttr.hasTag (β getEnv) decl)",
"start": [
1952,
1
],
"end": [
1955,
50
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/SubExpr.lean",
".lake/packages/lean4/src/lean/Lean/Elab/Config.lean",
".lake/packages/lean4/src/lean/Lean/Util/FindMVar.lean",
".lake/packages/lean4/src/lean/Lean/Util/ReplaceLevel.lean",
".lake/packages/lean4/src/lean/Lean/Util/CollectLevelParams.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Options.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/FieldNotation.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean",
".lake/packages/lean4/src/lean/Lean/Meta/SynthInstance.lean",
".lake/packages/lean4/src/lean/Lean/Util/FindLevelMVar.lean",
".lake/packages/lean4/src/lean/Lean/Meta/CtorRecognizer.lean"
] | [
{
"full_name": "Lean.getPPAnalyze",
"code": "def getPPAnalyze (o : Options) : Bool := o.get pp.analyze.name pp.analyze.defValue",
"start": [
108,
1
],
"end": [
108,
110
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeCheckInstances",
"code": "def getPPAnalyzeCheckInstances (o : Options) : Bool := o.get pp.analyze.checkInstances.name pp.analyze.checkInstances.defValue",
"start": [
109,
1
],
"end": [
109,
140
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTypeAscriptions",
"code": "def getPPAnalyzeTypeAscriptions (o : Options) : Bool := o.get pp.analyze.typeAscriptions.name pp.analyze.typeAscriptions.defValue",
"start": [
110,
1
],
"end": [
110,
142
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTrustSubst",
"code": "def getPPAnalyzeTrustSubst (o : Options) : Bool := o.get pp.analyze.trustSubst.name pp.analyze.trustSubst.defValue",
"start": [
111,
1
],
"end": [
111,
132
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTrustOfNat",
"code": "def getPPAnalyzeTrustOfNat (o : Options) : Bool := o.get pp.analyze.trustOfNat.name pp.analyze.trustOfNat.defValue",
"start": [
112,
1
],
"end": [
112,
132
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTrustOfScientific",
"code": "def getPPAnalyzeTrustOfScientific (o : Options) : Bool := o.get pp.analyze.trustOfScientific.name pp.analyze.trustOfScientific.defValue",
"start": [
113,
1
],
"end": [
113,
146
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTrustId",
"code": "def getPPAnalyzeTrustId (o : Options) : Bool := o.get pp.analyze.trustId.name pp.analyze.trustId.defValue",
"start": [
114,
1
],
"end": [
114,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTrustSubtypeMk",
"code": "def getPPAnalyzeTrustSubtypeMk (o : Options) : Bool := o.get pp.analyze.trustSubtypeMk.name pp.analyze.trustSubtypeMk.defValue",
"start": [
115,
1
],
"end": [
115,
140
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeTrustKnownFOType2TypeHOFuns",
"code": "def getPPAnalyzeTrustKnownFOType2TypeHOFuns (o : Options) : Bool := o.get pp.analyze.trustKnownFOType2TypeHOFuns.name pp.analyze.trustKnownFOType2TypeHOFuns.defValue",
"start": [
116,
1
],
"end": [
116,
166
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeOmitMax",
"code": "def getPPAnalyzeOmitMax (o : Options) : Bool := o.get pp.analyze.omitMax.name pp.analyze.omitMax.defValue",
"start": [
117,
1
],
"end": [
117,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeKnowsType",
"code": "def getPPAnalyzeKnowsType (o : Options) : Bool := o.get pp.analyze.knowsType.name pp.analyze.knowsType.defValue",
"start": [
118,
1
],
"end": [
118,
130
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalyzeExplicitHoles",
"code": "def getPPAnalyzeExplicitHoles (o : Options) : Bool := o.get pp.analyze.explicitHoles.name pp.analyze.explicitHoles.defValue",
"start": [
119,
1
],
"end": [
119,
138
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisSkip",
"code": "def getPPAnalysisSkip (o : Options) : Bool := o.get `pp.analysis.skip false",
"start": [
121,
1
],
"end": [
121,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisHole",
"code": "def getPPAnalysisHole (o : Options) : Bool := o.get `pp.analysis.hole false",
"start": [
122,
1
],
"end": [
122,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisNamedArg",
"code": "def getPPAnalysisNamedArg (o : Options) : Bool := o.get `pp.analysis.namedArg false",
"start": [
123,
1
],
"end": [
123,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisLetVarType",
"code": "def getPPAnalysisLetVarType (o : Options) : Bool := o.get `pp.analysis.letVarType false",
"start": [
124,
1
],
"end": [
124,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisNeedsType",
"code": "def getPPAnalysisNeedsType (o : Options) : Bool := o.get `pp.analysis.needsType false",
"start": [
125,
1
],
"end": [
125,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisBlockImplicit",
"code": "def getPPAnalysisBlockImplicit (o : Options) : Bool := o.get `pp.analysis.blockImplicit false",
"start": [
126,
1
],
"end": [
126,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getPPAnalysisNoDot",
"code": "def getPPAnalysisNoDot (o : Options) : Bool := o.get `pp.analysis.noDot false",
"start": [
127,
1
],
"end": [
127,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.returnsPi",
"code": "def returnsPi (motive : Expr) : MetaM Bool := do\n lambdaTelescope motive fun _ b => return b.isForall",
"start": [
131,
1
],
"end": [
132,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isNonConstFun",
"code": "def isNonConstFun (motive : Expr) : MetaM Bool := do\n match motive with\n | Expr.lam _ _ b _ => isNonConstFun b\n | _ => return motive.hasLooseBVars",
"start": [
134,
1
],
"end": [
137,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isSimpleHOFun",
"code": "def isSimpleHOFun (motive : Expr) : MetaM Bool :=\n return not (β returnsPi motive) && not (β isNonConstFun motive)",
"start": [
139,
1
],
"end": [
140,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isType2Type",
"code": "def isType2Type (motive : Expr) : MetaM Bool := do\n match β inferType motive with\n | Expr.forallE _ (Expr.sort ..) (Expr.sort ..) .. => return true\n | _ => return false",
"start": [
142,
1
],
"end": [
145,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isFOLike",
"code": "def isFOLike (motive : Expr) : MetaM Bool := do\n let f := motive.getAppFn\n return f.isFVar || f.isConst",
"start": [
147,
1
],
"end": [
149,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isIdLike",
"code": "def isIdLike (arg : Expr) : Bool :=\n match arg with\n | Expr.lam _ _ (Expr.bvar ..) .. => true\n | _ => false",
"start": [
151,
1
],
"end": [
155,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isStructureInstance",
"code": "def isStructureInstance (e : Expr) : MetaM Bool := do\n match (β isConstructorApp? e) with\n | some s => return isStructure (β getEnv) s.induct\n | none => return false",
"start": [
157,
1
],
"end": [
160,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.hasMVarAtCurrDepth",
"code": "partial def hasMVarAtCurrDepth (e : Expr) : MetaM Bool := do\n let mctx β getMCtx\n return Option.isSome <| e.findMVar? fun mvarId =>\n match mctx.findDecl? mvarId with\n | some mdecl => mdecl.depth == mctx.depth\n | _ => false",
"start": [
164,
1
],
"end": [
169,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.hasLevelMVarAtCurrDepth",
"code": "partial def hasLevelMVarAtCurrDepth (e : Expr) : MetaM Bool := do\n let mctx β getMCtx\n return Option.isSome <| e.findLevelMVar? fun mvarId =>\n mctx.findLevelDepth? mvarId == some mctx.depth",
"start": [
171,
1
],
"end": [
174,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.valUnknown",
"code": "private def valUnknown (e : Expr) : MetaM Bool := do\n hasMVarAtCurrDepth (β instantiateMVars e)",
"start": [
176,
1
],
"end": [
177,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.typeUnknown",
"code": "private def typeUnknown (e : Expr) : MetaM Bool := do\n valUnknown (β inferType e)",
"start": [
179,
1
],
"end": [
180,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.isHBinOp",
"code": "def isHBinOp (e : Expr) : Bool := Id.run do\n if e.getAppNumArgs != 6 then return false\n let f := e.getAppFn\n if !f.isConst then return false\n\n let ops := #[\n `HOr.hOr, `HXor.hXor, `HAnd.hAnd,\n `HAppend.hAppend, `HOrElse.hOrElse, `HAndThen.hAndThen,\n `HAdd.hAdd, `HSub.hSub, `HMul.hMul, `HDiv.hDiv, `HMod.hMod,\n `HShiftLeft.hShiftLeft, `HShiftRight]\n ops.any fun op => op == f.constName!",
"start": [
182,
1
],
"end": [
196,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.replaceLPsWithVars",
"code": "def replaceLPsWithVars (e : Expr) : MetaM Expr := do\n if !e.hasLevelParam then return e\n let lps := collectLevelParams {} e |>.params\n let mut replaceMap : HashMap Name Level := {}\n for lp in lps do replaceMap := replaceMap.insert lp (β mkFreshLevelMVar)\n return e.replaceLevel fun\n | Level.param n .. => replaceMap.find! n\n | l => if !l.hasParam then some l else none",
"start": [
198,
1
],
"end": [
205,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.isDefEqAssigning",
"code": "def isDefEqAssigning (t s : Expr) : MetaM Bool := do\n withReader (fun ctx => { ctx with config := { ctx.config with assignSyntheticOpaque := true }}) $\n Meta.isDefEq t s",
"start": [
207,
1
],
"end": [
209,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.checkpointDefEq",
"code": "def checkpointDefEq (t s : Expr) : MetaM Bool := do\n Meta.checkpointDefEq (mayPostpone := false) do\n isDefEqAssigning t s",
"start": [
211,
1
],
"end": [
213,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.isHigherOrder",
"code": "def isHigherOrder (type : Expr) : MetaM Bool := do\n forallTelescopeReducing type fun xs b => return xs.size > 0 && b.isSort",
"start": [
215,
1
],
"end": [
216,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.isFunLike",
"code": "def isFunLike (e : Expr) : MetaM Bool := do\n forallTelescopeReducing (β inferType e) fun xs _ => return xs.size > 0",
"start": [
218,
1
],
"end": [
219,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.isSubstLike",
"code": "def isSubstLike (e : Expr) : Bool :=\n e.isAppOfArity ``Eq.ndrec 6 || e.isAppOfArity ``Eq.rec 6",
"start": [
221,
1
],
"end": [
222,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.nameNotRoundtrippable",
"code": "def nameNotRoundtrippable (n : Name) : Bool :=\n n.hasMacroScopes || isPrivateName n || containsNum n\nwhere\n containsNum\n | Name.str p .. => containsNum p\n | Name.num .. => true\n | Name.anonymous => false",
"start": [
224,
1
],
"end": [
230,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.mvarName",
"code": "def mvarName (mvar : Expr) : MetaM Name :=\n return (β mvar.mvarId!.getDecl).userName",
"start": [
232,
1
],
"end": [
233,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.containsBadMax",
"code": "def containsBadMax : Level β Bool\n | Level.succ u .. => containsBadMax u\n | Level.max u v .. => (u.hasParam && v.hasParam) || containsBadMax u || containsBadMax v\n | Level.imax u v .. => (u.hasParam && v.hasParam) || containsBadMax u || containsBadMax v\n | _ => false",
"start": [
235,
1
],
"end": [
239,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.Context",
"code": "structure Context where\n knowsType : Bool\n knowsLevel : Bool inBottomUp : Bool := false\n parentIsApp : Bool := false\n subExpr : SubExpr\n deriving Inhabited",
"start": [
243,
1
],
"end": [
249,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.State",
"code": "structure State where\n annotations : OptionsPerPos := {}\n postponed : Array (Expr Γ Expr) := #[]",
"start": [
251,
1
],
"end": [
253,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.AnalyzeM",
"code": "abbrev AnalyzeM := ReaderT Context (StateRefT State MetaM)",
"start": [
255,
1
],
"end": [
255,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.tryUnify",
"code": "def tryUnify (eβ eβ : Expr) : AnalyzeM Unit := do\n try\n let r β isDefEqAssigning eβ eβ\n if !r then modify fun s => { s with postponed := s.postponed.push (eβ, eβ) }\n pure ()\n catch _ =>\n modify fun s => { s with postponed := s.postponed.push (eβ, eβ) }",
"start": [
263,
1
],
"end": [
269,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.inspectOutParams",
"code": "partial def inspectOutParams (arg mvar : Expr) : AnalyzeM Unit := do\n let argType β inferType arg let mvarType β inferType mvar\n let fType β inferType argType.getAppFn let mType β inferType mvarType.getAppFn\n inspectAux fType mType 0 argType.getAppArgs mvarType.getAppArgs\nwhere\n inspectAux (fType mType : Expr) (i : Nat) (args mvars : Array Expr) := do\n let fType β whnf fType\n let mType β whnf mType\n if not (i < args.size) then return ()\n match fType, mType with\n | Expr.forallE _ fd fb _, Expr.forallE _ _ mb _ => do\n if fd.isOutParam then\n tryUnify (args[i]!) (mvars[i]!)\n inspectAux (fb.instantiate1 args[i]!) (mb.instantiate1 mvars[i]!) (i+1) args mvars\n | _, _ => return ()",
"start": [
271,
1
],
"end": [
289,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.isTrivialBottomUp",
"code": "partial def isTrivialBottomUp (e : Expr) : AnalyzeM Bool := do\n let opts β getOptions\n return e.isFVar\n || e.isConst || e.isMVar || e.isRawNatLit || e.isStringLit || e.isSort\n || (getPPAnalyzeTrustOfNat opts && e.isAppOfArity ``OfNat.ofNat 3)\n || (getPPAnalyzeTrustOfScientific opts && e.isAppOfArity ``OfScientific.ofScientific 5)",
"start": [
291,
1
],
"end": [
296,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.canBottomUp",
"code": "partial def canBottomUp (e : Expr) (mvar? : Option Expr := none) (fuel : Nat := 10) : AnalyzeM Bool := do\n match fuel with\n | 0 => return false\n | fuel + 1 =>\n if β isTrivialBottomUp e then return true\n let f := e.getAppFn\n if !f.isConst && !f.isFVar then return false\n let args := e.getAppArgs\n let fType β replaceLPsWithVars (β inferType e.getAppFn)\n let (mvars, bInfos, resultType) β forallMetaBoundedTelescope fType e.getAppArgs.size\n for i in [:mvars.size] do\n if bInfos[i]! == BinderInfo.instImplicit then\n inspectOutParams args[i]! mvars[i]!\n else if bInfos[i]! == BinderInfo.default then\n if β isTrivialBottomUp args[i]! then tryUnify args[i]! mvars[i]!\n else if β typeUnknown mvars[i]! <&&> canBottomUp args[i]! (some mvars[i]!) fuel then tryUnify args[i]! mvars[i]!\n if β (pure (isHBinOp e) <&&> (valUnknown mvars[0]! <||> valUnknown mvars[1]!)) then tryUnify mvars[0]! mvars[1]!\n if mvar?.isSome then tryUnify resultType (β inferType mvar?.get!)\n return !(β valUnknown resultType)",
"start": [
298,
1
],
"end": [
319,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.withKnowing",
"code": "def withKnowing (knowsType knowsLevel : Bool) (x : AnalyzeM Ξ±) : AnalyzeM Ξ± := do\n withReader (fun ctx => { ctx with knowsType := knowsType, knowsLevel := knowsLevel }) x",
"start": [
321,
1
],
"end": [
322,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.checkKnowsType",
"code": "def checkKnowsType : AnalyzeM Unit := do\n if not (β read).knowsType then\n throw $ Exception.internal analyzeFailureId",
"start": [
326,
1
],
"end": [
328,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.annotateBoolAt",
"code": "def annotateBoolAt (n : Name) (pos : Pos) : AnalyzeM Unit := do\n let opts := (β get).annotations.findD pos {} |>.setBool n true\n trace[pp.analyze.annotate] \"{pos} {n}\"\n modify fun s => { s with annotations := s.annotations.insert pos opts }",
"start": [
330,
1
],
"end": [
333,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.annotateBool",
"code": "def annotateBool (n : Name) : AnalyzeM Unit := do\n annotateBoolAt n (β getPos)",
"start": [
335,
1
],
"end": [
336,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.App.Context",
"code": "structure App.Context where\n f : Expr\n fType : Expr\n args : Array Expr\n mvars : Array Expr\n bInfos : Array BinderInfo\n forceRegularApp : Bool",
"start": [
338,
1
],
"end": [
344,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.App.State",
"code": "structure App.State where\n bottomUps : Array Bool\n higherOrders : Array Bool\n funBinders : Array Bool\n provideds : Array Bool\n namedArgs : Array Name := #[]",
"start": [
346,
1
],
"end": [
351,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.AnalyzeAppM",
"code": "abbrev AnalyzeAppM := ReaderT App.Context (StateT App.State AnalyzeM)",
"start": [
353,
1
],
"end": [
353,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.analyze",
"code": "partial def analyze (parentIsApp : Bool := false) : AnalyzeM Unit := do\n checkSystem \"Delaborator.topDownAnalyze\"\n trace[pp.analyze] \"{(β read).knowsType}.{(β read).knowsLevel}\"\n let e β getExpr\n let opts β getOptions\n if β (pure !e.isAtomic) <&&> pure !(getPPProofs opts) <&&> (try Meta.isProof e catch _ => pure false) then\n if getPPProofsWithType opts then\n withType $ withKnowing true true $ analyze\n return ()\n else\n withReader (fun ctx => { ctx with parentIsApp := parentIsApp }) do\n match (β getExpr) with\n | Expr.app .. => analyzeApp\n | Expr.forallE .. => analyzePi\n | Expr.lam .. => analyzeLam\n | Expr.const .. => analyzeConst\n | Expr.sort .. => analyzeSort\n | Expr.proj .. => analyzeProj\n | Expr.fvar .. => analyzeFVar\n | Expr.mdata .. => analyzeMData\n | Expr.letE .. => analyzeLet\n | Expr.lit .. => pure ()\n | Expr.mvar .. => pure ()\n | Expr.bvar .. => pure ()\n where\n analyzeApp := do\n let mut willKnowType := (β read).knowsType\n if !(β read).knowsType && !(β canBottomUp (β getExpr)) then\n annotateBool `pp.analysis.needsType\n withType $ withKnowing true false $ analyze\n willKnowType := true\n\n else if β (pure !(β read).knowsType <||> pure (β read).inBottomUp) <&&> isStructureInstance (β getExpr) then\n withType do\n annotateBool `pp.structureInstanceTypes\n withKnowing true false $ analyze\n willKnowType := true\n\n withKnowing willKnowType true $ analyzeAppStaged (β getExpr).getAppFn (β getExpr).getAppArgs\n\n analyzeAppStaged (f : Expr) (args : Array Expr) : AnalyzeM Unit := do\n let fType β replaceLPsWithVars (β inferType f)\n let (mvars, bInfos, resultType) β forallMetaBoundedTelescope fType args.size\n let rest := args.extract mvars.size args.size\n let args := args.shrink mvars.size\n\n if (β read).knowsType then tryUnify (β inferType (mkAppN f args)) resultType\n\n if getPPFieldNotation (β getOptions) then\n if let some (_, idx) β fieldNotationCandidate? f args (getPPFieldNotationGeneralized (β getOptions)) then\n if idx < args.size then\n withKnowing false false do\n if !(β canBottomUp args[idx]!) then\n annotateBool `pp.analysis.noDot\n else\n annotateBool `pp.analysis.noDot\n\n let forceRegularApp : Bool :=\n (getPPAnalyzeTrustSubst (β getOptions) && isSubstLike (β getExpr))\n || (getPPAnalyzeTrustSubtypeMk (β getOptions) && (β getExpr).isAppOfArity ``Subtype.mk 4)\n\n analyzeAppStagedCore { f, fType, args, mvars, bInfos, forceRegularApp } |>.run' {\n bottomUps := mkArray args.size false,\n higherOrders := mkArray args.size false,\n provideds := mkArray args.size false,\n funBinders := mkArray args.size false\n }\n\n if not rest.isEmpty then\n if !args.isEmpty then\n analyzeAppStaged (mkAppN f args) rest\n\n maybeAddBlockImplicit : AnalyzeM Unit := do\n if !(β read).parentIsApp then\n let type β inferType (β getExpr)\n if type.isForall && type.bindingInfo! == BinderInfo.implicit then\n annotateBool `pp.analysis.blockImplicit\n\n analyzeConst : AnalyzeM Unit := do\n let Expr.const _ ls .. β getExpr | unreachable!\n if !(β read).knowsLevel && !ls.isEmpty then\n unless getPPAnalyzeOmitMax (β getOptions) && ls.any containsBadMax do\n annotateBool `pp.universes\n maybeAddBlockImplicit\n\n analyzePi : AnalyzeM Unit := do\n withBindingDomain $ withKnowing true false analyze\n withBindingBody Name.anonymous analyze\n\n analyzeLam : AnalyzeM Unit := do\n if !(β read).knowsType then annotateBool `pp.funBinderTypes\n withBindingDomain $ withKnowing true false analyze\n withBindingBody Name.anonymous analyze\n\n analyzeLet : AnalyzeM Unit := do\n let Expr.letE _ _ v _ .. β getExpr | unreachable!\n if !(β canBottomUp v) then\n annotateBool `pp.analysis.letVarType\n withLetVarType $ withKnowing true false analyze\n withLetValue $ withKnowing true true analyze\n else\n withReader (fun ctx => { ctx with inBottomUp := true }) do\n withLetValue $ withKnowing true true analyze\n\n withLetBody analyze\n\n analyzeSort : AnalyzeM Unit := pure ()\n analyzeProj : AnalyzeM Unit := withProj analyze\n analyzeFVar : AnalyzeM Unit := maybeAddBlockImplicit\n analyzeMData : AnalyzeM Unit := withMDataExpr analyze",
"start": [
357,
3
],
"end": [
472,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.TopDownAnalyze.analyzeAppStagedCore",
"code": "partial def analyzeAppStagedCore : AnalyzeAppM Unit := do\n collectBottomUps\n checkOutParams\n collectHigherOrders\n hBinOpHeuristic\n collectTrivialBottomUps\n discard <| processPostponed (mayPostpone := true)\n applyFunBinderHeuristic\n analyzeFn\n for i in [:(β read).args.size] do analyzeArg i\n maybeSetExplicit\n\n where\n collectBottomUps := do\n let { args, mvars, bInfos, ..} β read\n for target in [fun _ => none, fun i => some mvars[i]!] do\n for i in [:args.size] do\n if bInfos[i]! == BinderInfo.default then\n if β typeUnknown mvars[i]! <&&> canBottomUp args[i]! (target i) then\n tryUnify args[i]! mvars[i]!\n modify fun s => { s with bottomUps := s.bottomUps.set! i true }\n\n checkOutParams := do\n let { args, mvars, bInfos, ..} β read\n for i in [:args.size] do\n if bInfos[i]! == BinderInfo.instImplicit then inspectOutParams args[i]! mvars[i]!\n\n collectHigherOrders := do\n let { args, mvars, bInfos, ..} β read\n for i in [:args.size] do\n if not (bInfos[i]! == BinderInfo.implicit || bInfos[i]! == BinderInfo.strictImplicit) then continue\n if not (β isHigherOrder (β inferType args[i]!)) then continue\n if getPPAnalyzeTrustId (β getOptions) && isIdLike args[i]! then continue\n\n if getPPAnalyzeTrustKnownFOType2TypeHOFuns (β getOptions) && not (β valUnknown mvars[i]!)\n && (β isType2Type (args[i]!)) && (β isFOLike (args[i]!)) then continue\n\n tryUnify args[i]! mvars[i]!\n modify fun s => { s with higherOrders := s.higherOrders.set! i true }\n\n hBinOpHeuristic := do\n let { mvars, ..} β read\n if β (pure (isHBinOp (β getExpr)) <&&> (valUnknown mvars[0]! <||> valUnknown mvars[1]!)) then\n tryUnify mvars[0]! mvars[1]!\n\n collectTrivialBottomUps := do\n let { args, mvars, bInfos, ..} β read\n for i in [:args.size] do\n if bInfos[i]! == BinderInfo.default then\n if β valUnknown mvars[i]! <&&> isTrivialBottomUp args[i]! then\n tryUnify args[i]! mvars[i]!\n modify fun s => { s with bottomUps := s.bottomUps.set! i true }\n\n applyFunBinderHeuristic := do\n let { args, mvars, bInfos, .. } β read\n\n let rec core (argIdx : Nat) (mvarType : Expr) : AnalyzeAppM Bool := do\n match β getExpr, mvarType with\n | Expr.lam .., Expr.forallE _ t b .. =>\n let mut annotated := false\n for i in [:argIdx] do\n if β pure (bInfos[i]! == BinderInfo.implicit) <&&> valUnknown mvars[i]! <&&> withNewMCtxDepth (checkpointDefEq t mvars[i]!) then\n annotateBool `pp.funBinderTypes\n tryUnify args[i]! mvars[i]!\n annotated := true\n break\n let annotatedBody β withBindingBody Name.anonymous (core argIdx b)\n return annotated || annotatedBody\n\n | _, _ => return false\n\n for i in [:args.size] do\n if bInfos[i]! == BinderInfo.default then\n let b β withNaryArg i (core i (β inferType mvars[i]!))\n if b then modify fun s => { s with funBinders := s.funBinders.set! i true }\n\n analyzeFn := do\n let {f, fType, forceRegularApp ..} β read\n if !f.isApp then withKnowing false (forceRegularApp || !(β hasLevelMVarAtCurrDepth (β instantiateMVars fType))) $ withNaryFn (analyze (parentIsApp := true))\n\n annotateNamedArg (n : Name) : AnalyzeAppM Unit := do\n annotateBool `pp.analysis.namedArg\n modify fun s => { s with namedArgs := s.namedArgs.push n }\n\n analyzeArg (i : Nat) := do\n let { f, args, mvars, bInfos, forceRegularApp ..} β read\n let { bottomUps, higherOrders, funBinders, ..} β get\n let arg := args[i]!\n let argType β inferType arg\n\n let processNaturalImplicit : AnalyzeAppM Unit := do\n if (β valUnknown mvars[i]! <||> pure higherOrders[i]!) && !forceRegularApp then\n annotateNamedArg (β mvarName mvars[i]!)\n modify fun s => { s with provideds := s.provideds.set! i true }\n else\n annotateBool `pp.analysis.skip\n\n withNaryArg (f.getAppNumArgs + i) do\n withTheReader Context (fun ctx => { ctx with inBottomUp := ctx.inBottomUp || bottomUps[i]! }) do\n\n match bInfos[i]! with\n | BinderInfo.default =>\n if β pure (getPPAnalyzeExplicitHoles (β getOptions)) <&&> pure !(β valUnknown mvars[i]!) <&&> pure !(β readThe Context).inBottomUp <&&> pure !(β isFunLike arg) <&&> pure !funBinders[i]! <&&> checkpointDefEq mvars[i]! arg then\n annotateBool `pp.analysis.hole\n else\n modify fun s => { s with provideds := s.provideds.set! i true }\n\n | BinderInfo.implicit => processNaturalImplicit\n | BinderInfo.strictImplicit => processNaturalImplicit\n\n | BinderInfo.instImplicit =>\n let mut provided := true\n if !getPPInstances (β getOptions) then\n annotateBool `pp.analysis.skip\n provided := false\n else if getPPAnalyzeCheckInstances (β getOptions) then\n let instResult β try trySynthInstance argType catch _ => pure LOption.undef\n match instResult with\n | LOption.some inst =>\n if β checkpointDefEq inst arg then annotateBool `pp.analysis.skip; provided := false\n else annotateNamedArg (β mvarName mvars[i]!)\n | _ => annotateNamedArg (β mvarName mvars[i]!)\n else annotateBool `pp.analysis.skip; provided := false\n modify fun s => { s with provideds := s.provideds.set! i provided }\n if (β get).provideds[i]! then withKnowing (not (β typeUnknown mvars[i]!)) true analyze\n tryUnify mvars[i]! args[i]!\n\n maybeSetExplicit := do\n let { f, args, bInfos, ..} β read\n if (β get).namedArgs.any nameNotRoundtrippable then\n annotateBool `pp.explicit\n for i in [:args.size] do\n if !(β get).provideds[i]! then\n withNaryArg (f.getAppNumArgs + i) do annotateBool `pp.analysis.hole\n if bInfos[i]! == BinderInfo.instImplicit && getPPInstanceTypes (β getOptions) then\n withType (withKnowing true false analyze)",
"start": [
474,
3
],
"end": [
616,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.topDownAnalyze",
"code": "def topDownAnalyze (e : Expr) : MetaM OptionsPerPos := do\n let sβ β get\n withTraceNode `pp.analyze (fun _ => return e) do\n withReader (fun ctx => { ctx with config := Elab.Term.setElabConfig ctx.config }) do\n let Ο : AnalyzeM OptionsPerPos := do withNewMCtxDepth analyze; pure (β get).annotations\n try\n let knowsType := getPPAnalyzeKnowsType (β getOptions)\n Ο { knowsType := knowsType, knowsLevel := knowsType, subExpr := mkRoot e }\n |>.run' { : TopDownAnalyze.State }\n catch e =>\n trace[pp.analyze.error] \"failed {e.toMessageData}\"\n pure {}\n finally set sβ",
"start": [
624,
1
],
"end": [
636,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/ForEachExprWhere.lean | [
".lake/packages/lean4/src/lean/Lean/Util/MonadCache.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.ForEachExprWhere.cacheSize",
"code": "abbrev cacheSize : USize := 8192 - 1",
"start": [
20,
1
],
"end": [
20,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ForEachExprWhere.State",
"code": "structure State where\n \n visited : Array Expr \n checked : HashSet Expr",
"start": [
22,
1
],
"end": [
31,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ForEachExprWhere.initCache",
"code": "unsafe def initCache : State := {\n visited := mkArray cacheSize.toNat (cast lcProof ())\n checked := {}\n}",
"start": [
33,
1
],
"end": [
36,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ForEachExprWhere.ForEachM",
"code": "abbrev ForEachM {Ο : Type} (m : Type β Type) [STWorld Ο m] := StateRefT' Ο State m",
"start": [
38,
1
],
"end": [
38,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ForEachExprWhere.visited",
"code": "unsafe def visited (e : Expr) : ForEachM m Bool := do\n let s β get\n let h := ptrAddrUnsafe e\n let i := h % cacheSize\n let k := s.visited.uget i lcProof\n if ptrAddrUnsafe k == h then\n return true\n else\n modify fun s => { s with visited := s.visited.uset i e lcProof }\n return false",
"start": [
42,
1
],
"end": [
51,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ForEachExprWhere.checked",
"code": "def checked (e : Expr) : ForEachM m Bool := do\n if (β get).checked.contains e then\n return true\n else\n modify fun s => { s with checked := s.checked.insert e }\n return false",
"start": [
53,
1
],
"end": [
58,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ForEachExprWhere.visit",
"code": "unsafe def visit (p : Expr β Bool) (f : Expr β m Unit) (e : Expr) (stopWhenVisited : Bool := false) : m Unit := do\n go e |>.run' initCache\nwhere\n go (e : Expr) : StateRefT' Ο State m Unit := do\n unless (β visited e) do\n if p e then\n unless (β checked e) do\n f e\n if stopWhenVisited then\n return ()\n match e with\n | .forallE _ d b _ => go d; go b\n | .lam _ d b _ => go d; go b\n | .letE _ t v b _ => go t; go v; go b\n | .app f a => go f; go a\n | .mdata _ b => go b\n | .proj _ _ b => go b\n | _ => return ()",
"start": [
60,
1
],
"end": [
78,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.forEachWhere",
"code": "@[implemented_by ForEachExprWhere.visit]\nopaque Expr.forEachWhere {Ο : Type} {m : Type β Type} [STWorld Ο m] [MonadLiftT (ST Ο) m] [Monad m] (p : Expr β Bool) (f : Expr β m Unit) (e : Expr) (stopWhenVisited : Bool := false) : m Unit",
"start": [
82,
1
],
"end": [
88,
192
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Level.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Term.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Tactic/Doc.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Syntax.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Tactic.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Do.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Module.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Command.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.mkAntiquot.parenthesizer",
"code": "@[export lean_mk_antiquot_parenthesizer]\ndef mkAntiquot.parenthesizer (name : String) (kind : SyntaxNodeKind) (anonymous := true) (isPseudoKind := true) : Parenthesizer :=\n Parser.mkAntiquot.parenthesizer name kind anonymous isPseudoKind",
"start": [
63,
1
],
"end": [
65,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.ident.parenthesizer",
"code": "@[builtin_parenthesizer ident] def ident.parenthesizer : Parenthesizer := Parser.Term.ident.parenthesizer",
"start": [
69,
1
],
"end": [
69,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.numLit.parenthesizer",
"code": "@[builtin_parenthesizer num] def numLit.parenthesizer : Parenthesizer := Parser.Term.num.parenthesizer",
"start": [
70,
1
],
"end": [
70,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.scientificLit.parenthesizer",
"code": "@[builtin_parenthesizer scientific] def scientificLit.parenthesizer : Parenthesizer := Parser.Term.scientific.parenthesizer",
"start": [
71,
1
],
"end": [
71,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.charLit.parenthesizer",
"code": "@[builtin_parenthesizer char] def charLit.parenthesizer : Parenthesizer := Parser.Term.char.parenthesizer",
"start": [
72,
1
],
"end": [
72,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.strLit.parenthesizer",
"code": "@[builtin_parenthesizer str] def strLit.parenthesizer : Parenthesizer := Parser.Term.str.parenthesizer",
"start": [
73,
1
],
"end": [
73,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Parenthesizer.interpretParserDescr",
"code": "@[export lean_pretty_printer_parenthesizer_interpret_parser_descr]\nunsafe def interpretParserDescr : ParserDescr β CoreM Parenthesizer\n | ParserDescr.const n => getConstAlias parenthesizerAliasesRef n\n | ParserDescr.unary n d => return (β getUnaryAlias parenthesizerAliasesRef n) (β interpretParserDescr d)\n | ParserDescr.binary n dβ dβ => return (β getBinaryAlias parenthesizerAliasesRef n) (β interpretParserDescr dβ) (β interpretParserDescr dβ)\n | ParserDescr.node k prec d => return leadingNode.parenthesizer k prec (β interpretParserDescr d)\n | ParserDescr.nodeWithAntiquot n k d => return withAntiquot.parenthesizer (mkAntiquot.parenthesizer' n k (anonymous := true)) <|\n node.parenthesizer k (β interpretParserDescr d)\n | ParserDescr.sepBy p sep psep trail => return sepBy.parenthesizer (β interpretParserDescr p) sep (β interpretParserDescr psep) trail\n | ParserDescr.sepBy1 p sep psep trail => return sepBy1.parenthesizer (β interpretParserDescr p) sep (β interpretParserDescr psep) trail\n | ParserDescr.trailingNode k prec lhsPrec d => return trailingNode.parenthesizer k prec lhsPrec (β interpretParserDescr d)\n | ParserDescr.symbol tk => return symbol.parenthesizer tk\n | ParserDescr.nonReservedSymbol tk includeIdent => return nonReservedSymbol.parenthesizer tk includeIdent\n | ParserDescr.parser constName => combinatorParenthesizerAttribute.runDeclFor constName\n | ParserDescr.cat catName prec => return categoryParser.parenthesizer catName prec",
"start": [
77,
1
],
"end": [
91,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.mkAntiquot.formatter",
"code": "@[export lean_mk_antiquot_formatter]\ndef mkAntiquot.formatter (name : String) (kind : SyntaxNodeKind) (anonymous := true) (isPseudoKind := true) : Formatter :=\n Parser.mkAntiquot.formatter name kind anonymous isPseudoKind",
"start": [
97,
1
],
"end": [
99,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.ident.formatter",
"code": "@[builtin_formatter ident] def ident.formatter : Formatter := Parser.Term.ident.formatter",
"start": [
101,
1
],
"end": [
101,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.numLit.formatter",
"code": "@[builtin_formatter num] def numLit.formatter : Formatter := Parser.Term.num.formatter",
"start": [
102,
1
],
"end": [
102,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.scientificLit.formatter",
"code": "@[builtin_formatter scientific] def scientificLit.formatter : Formatter := Parser.Term.scientific.formatter",
"start": [
103,
1
],
"end": [
103,
108
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.charLit.formatter",
"code": "@[builtin_formatter char] def charLit.formatter : Formatter := Parser.Term.char.formatter",
"start": [
104,
1
],
"end": [
104,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.strLit.formatter",
"code": "@[builtin_formatter str] def strLit.formatter : Formatter := Parser.Term.str.formatter",
"start": [
105,
1
],
"end": [
105,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Formatter.interpretParserDescr",
"code": "@[export lean_pretty_printer_formatter_interpret_parser_descr]\nunsafe def interpretParserDescr : ParserDescr β CoreM Formatter\n | ParserDescr.const n => getConstAlias formatterAliasesRef n\n | ParserDescr.unary n d => return (β getUnaryAlias formatterAliasesRef n) (β interpretParserDescr d)\n | ParserDescr.binary n dβ dβ => return (β getBinaryAlias formatterAliasesRef n) (β interpretParserDescr dβ) (β interpretParserDescr dβ)\n | ParserDescr.node k _ d => return node.formatter k (β interpretParserDescr d)\n | ParserDescr.nodeWithAntiquot n k d => return withAntiquot.formatter (mkAntiquot.formatter' n k (anonymous := true)) <|\n node.formatter k (β interpretParserDescr d)\n | ParserDescr.sepBy p sep psep trail => return sepBy.formatter (β interpretParserDescr p) sep (β interpretParserDescr psep) trail\n | ParserDescr.sepBy1 p sep psep trail => return sepBy1.formatter (β interpretParserDescr p) sep (β interpretParserDescr psep) trail\n | ParserDescr.trailingNode k prec lhsPrec d => return trailingNode.formatter k prec lhsPrec (β interpretParserDescr d)\n | ParserDescr.symbol tk => return symbol.formatter tk\n | ParserDescr.nonReservedSymbol tk _ => return nonReservedSymbol.formatter tk\n | ParserDescr.parser constName => combinatorFormatterAttribute.runDeclFor constName\n | ParserDescr.cat catName _ => return categoryParser.formatter catName",
"start": [
109,
1
],
"end": [
123,
95
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/SubExpr.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Options.lean",
".lake/packages/lean4/src/lean/Lean/Elab/Term.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Delaborator.Context",
"code": "structure Context where\n optionsPerPos : OptionsPerPos\n currNamespace : Name\n openDecls : List OpenDecl\n inPattern : Bool := false subExpr : SubExpr\n \n depth : Nat := 0",
"start": [
38,
1
],
"end": [
45,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.State",
"code": "structure State where\n \n steps : Nat := 0\n \n infos : PosMap Info := {}\n \n holeIter : SubExpr.HoleIterator := {}",
"start": [
47,
1
],
"end": [
55,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.DelabM",
"code": "abbrev DelabM := ReaderT Context (StateRefT State MetaM)",
"start": [
61,
1
],
"end": [
61,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.Delab",
"code": "abbrev Delab := DelabM Term",
"start": [
62,
1
],
"end": [
62,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.orElse",
"code": "@[inline] protected def orElse (dβ : DelabM Ξ±) (dβ : Unit β DelabM Ξ±) : DelabM Ξ± := do\n catchInternalId delabFailureId dβ fun _ => dβ ()",
"start": [
67,
1
],
"end": [
68,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.failure",
"code": "protected def failure : DelabM Ξ± :=\n throw $ Exception.internal delabFailureId",
"start": [
70,
1
],
"end": [
71,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.mkDelabAttribute",
"code": "unsafe def mkDelabAttribute : IO (KeyedDeclsAttribute Delab) :=\n KeyedDeclsAttribute.init {\n builtinName := `builtin_delab,\n name := `delab,\n descr := \"Register a delaborator.\n\n [delab k] registers a declaration of type `Lean.PrettyPrinter.Delaborator.Delab` for the `Lean.Expr`\n constructor `k`. Multiple delaborators for a single constructor are tried in turn until\n the first success. If the term to be delaborated is an application of a constant `c`,\n elaborators for `app.c` are tried first; this is also done for `Expr.const`s (\\\"nullary applications\\\")\n to reduce special casing. If the term is an `Expr.mdata` with a single key `k`, `mdata.k`\n is tried first.\",\n valueTypeName := `Lean.PrettyPrinter.Delaborator.Delab\n evalKey := fun _ stx => do\n let stx β Attribute.Builtin.getIdent stx\n let kind := stx.getId\n if (β Elab.getInfoState).enabled && kind.getRoot == `app then\n let c := kind.replacePrefix `app .anonymous\n if (β getEnv).contains c then\n Elab.addConstInfo stx c none\n pure kind\n } `Lean.PrettyPrinter.Delaborator.delabAttribute",
"start": [
102,
1
],
"end": [
123,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabAttribute",
"code": "@[builtin_init mkDelabAttribute] opaque delabAttribute : KeyedDeclsAttribute Delab",
"start": [
124,
1
],
"end": [
124,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.getExprKind",
"code": "def getExprKind : DelabM Name := do\n let e β getExpr\n pure $ match e with\n | Expr.bvar _ => `bvar\n | Expr.fvar _ => `fvar\n | Expr.mvar _ => `mvar\n | Expr.sort _ => `sort\n | Expr.const c _ =>\n `app ++ c\n | Expr.app fn _ => match fn.getAppFn with\n | Expr.const c _ => `app ++ c\n | _ => `app\n | Expr.lam _ _ _ _ => `lam\n | Expr.forallE _ _ _ _ => `forallE\n | Expr.letE _ _ _ _ _ => `letE\n | Expr.lit _ => `lit\n | Expr.mdata m _ => match m.entries with\n | [(key, _)] => `mdata ++ key\n | _ => `mdata\n | Expr.proj _ _ _ => `proj",
"start": [
126,
1
],
"end": [
146,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.getOptionsAtCurrPos",
"code": "def getOptionsAtCurrPos : DelabM Options := do\n let ctx β read\n let mut opts β getOptions\n if let some opts' := ctx.optionsPerPos.find? (β getPos) then\n for (k, v) in opts' do\n opts := opts.insert k v\n return opts",
"start": [
148,
1
],
"end": [
154,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.getPPOption",
"code": "def getPPOption (opt : Options β Ξ±) : DelabM Ξ± := do\n return opt (β getOptionsAtCurrPos)",
"start": [
156,
1
],
"end": [
158,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.whenPPOption",
"code": "def whenPPOption (opt : Options β Bool) (d : Delab) : Delab := do\n let b β getPPOption opt\n if b then d else failure",
"start": [
160,
1
],
"end": [
162,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.whenNotPPOption",
"code": "def whenNotPPOption (opt : Options β Bool) (d : Delab) : Delab := do\n let b β getPPOption opt\n if b then failure else d",
"start": [
164,
1
],
"end": [
166,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withOptionAtCurrPos",
"code": "def withOptionAtCurrPos (k : Name) (v : DataValue) (x : DelabM Ξ±) : DelabM Ξ± := do\n let pos β getPos\n withReader\n (fun ctx =>\n let opts' := ctx.optionsPerPos.find? pos |>.getD {} |>.insert k v\n { ctx with optionsPerPos := ctx.optionsPerPos.insert pos opts' })\n x",
"start": [
168,
1
],
"end": [
175,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.annotatePos",
"code": "def annotatePos (pos : Pos) (stx : Term) : Term :=\n β¨stx.raw.setInfo (SourceInfo.synthetic β¨posβ© β¨posβ©)β©",
"start": [
177,
1
],
"end": [
178,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.annotateCurPos",
"code": "def annotateCurPos (stx : Term) : Delab :=\n return annotatePos (β getPos) stx",
"start": [
180,
1
],
"end": [
181,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.addTermInfo",
"code": "def addTermInfo (pos : Pos) (stx : Syntax) (e : Expr) (isBinder : Bool := false) : DelabM Unit := do\n let info := Info.ofTermInfo <| β mkTermInfo stx e isBinder\n modify fun s => { s with infos := s.infos.insert pos info }\nwhere\n mkTermInfo stx e isBinder := return {\n elaborator := `Delab,\n stx := stx,\n lctx := (β getLCtx),\n expectedType? := none,\n expr := e,\n isBinder := isBinder\n }",
"start": [
183,
1
],
"end": [
194,
3
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.addFieldInfo",
"code": "def addFieldInfo (pos : Pos) (projName fieldName : Name) (stx : Syntax) (val : Expr) : DelabM Unit := do\n let info := Info.ofFieldInfo <| β mkFieldInfo projName fieldName stx val\n modify fun s => { s with infos := s.infos.insert pos info }\nwhere\n mkFieldInfo projName fieldName stx val := return {\n projName := projName,\n fieldName := fieldName,\n lctx := (β getLCtx),\n val := val,\n stx := stx\n }",
"start": [
196,
1
],
"end": [
206,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.annotateTermInfo",
"code": "def annotateTermInfo (stx : Term) : Delab := do\n let stx β annotateCurPos stx\n addTermInfo (β getPos) stx (β getExpr)\n pure stx",
"start": [
208,
1
],
"end": [
215,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withAnnotateTermInfo",
"code": "def withAnnotateTermInfo (d : Delab) : Delab := do\n let stx β d\n annotateTermInfo stx",
"start": [
217,
1
],
"end": [
223,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.getUnusedName",
"code": "def getUnusedName (suggestion : Name) (body : Expr) : DelabM Name := do\n let suggestion := if suggestion.isAnonymous then `a else suggestion\n let suggestion := suggestion.eraseMacroScopes\n let lctx β getLCtx\n if !lctx.usesUserName suggestion then\n return suggestion\n else if (β getPPOption getPPSafeShadowing) && !bodyUsesSuggestion lctx suggestion then\n return suggestion\n else\n return lctx.getUnusedName suggestion\nwhere\n bodyUsesSuggestion (lctx : LocalContext) (suggestion' : Name) : Bool :=\n Option.isSome <| body.find? fun\n | Expr.fvar fvarId =>\n match lctx.find? fvarId with\n | none => false\n | some decl => decl.userName == suggestion'\n | _ => false",
"start": [
225,
1
],
"end": [
244,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.mkAnnotatedIdent",
"code": "def mkAnnotatedIdent (n : Name) (e : Expr) : DelabM Ident := do\n let pos β nextExtraPos\n let stx : Syntax := annotatePos pos (mkIdent n)\n addTermInfo pos stx e\n return β¨stxβ©",
"start": [
246,
1
],
"end": [
253,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withBindingBodyUnusedName",
"code": "def withBindingBodyUnusedName {Ξ±} (d : Syntax β DelabM Ξ±) : DelabM Ξ± := do\n let n β getUnusedName (β getExpr).bindingName! (β getExpr).bindingBody!\n withBindingBody' n (mkAnnotatedIdent n) (d Β·)",
"start": [
255,
1
],
"end": [
262,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.OmissionReason",
"code": "inductive OmissionReason\n | deep\n | proof\n | maxSteps",
"start": [
264,
1
],
"end": [
267,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.OmissionReason.toString",
"code": "def OmissionReason.toString : OmissionReason β String\n | deep => \"Term omitted due to its depth (see option `pp.deepTerms`).\"\n | proof => \"Proof omitted (see option `pp.proofs`).\"\n | maxSteps => \"Term omitted due to reaching the maximum number of steps allowed for pretty printing this expression (see option `pp.maxSteps`).\"",
"start": [
269,
1
],
"end": [
272,
147
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.addOmissionInfo",
"code": "def addOmissionInfo (pos : Pos) (stx : Syntax) (e : Expr) (reason : OmissionReason) : DelabM Unit := do\n let info := Info.ofOmissionInfo <| β mkOmissionInfo stx e\n modify fun s => { s with infos := s.infos.insert pos info }\nwhere\n mkOmissionInfo stx e := return {\n toTermInfo := β addTermInfo.mkTermInfo stx e (isBinder := false)\n reason := reason.toString\n }",
"start": [
274,
1
],
"end": [
281,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withIncDepth",
"code": "def withIncDepth (act : DelabM Ξ±) : DelabM Ξ± := fun ctx =>\n act { ctx with depth := ctx.depth + 1 }",
"start": [
283,
1
],
"end": [
289,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.isShallowExpression",
"code": "def isShallowExpression (threshold : Nat) (e : Expr) : Bool :=\n let threshold := min 254 threshold\n e.approxDepth.toNat β€ threshold",
"start": [
291,
1
],
"end": [
302,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.shouldOmitExpr",
"code": "def shouldOmitExpr (e : Expr) : DelabM Bool := do\n if e.isAtomic then\n return false\n\n if (β getPPOption getPPDeepTerms) then\n return false\n\n let depth := (β read).depth\n let depthThreshold β getPPOption getPPDeepTermsThreshold\n let depthExcess := depth - depthThreshold\n let threshold := depthThreshold/4 - depthExcess\n\n return depthExcess > 0 && !isShallowExpression threshold e",
"start": [
304,
1
],
"end": [
326,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.shouldOmitProof",
"code": "def shouldOmitProof (e : Expr) : DelabM Bool := do\n if e.isAtomic then\n return false\n\n if (β getPPOption getPPProofs) then\n return false\n\n unless (β try Meta.isProof e catch _ => pure false) do\n return false\n\n return !isShallowExpression (β getPPOption getPPProofsThreshold) e",
"start": [
328,
1
],
"end": [
347,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.omission",
"code": "def omission (reason : OmissionReason) : Delab := do\n let stx β `(β―)\n let stx β annotateCurPos stx\n addOmissionInfo (β getPos) stx (β getExpr) reason\n pure stx",
"start": [
349,
1
],
"end": [
357,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabFor",
"code": "partial def delabFor : Name β Delab\n | Name.anonymous => failure\n | k =>\n (do annotateTermInfo (β (delabAttribute.getValues (β getEnv) k).firstM id))\n <|> if k.isAtomic then failure else delabFor k.getRoot",
"start": [
359,
1
],
"end": [
364,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delab",
"code": "partial def delab : Delab := do\n checkSystem \"delab\"\n\n if (β get).steps β₯ (β getPPOption getPPMaxSteps) then\n return β omission .maxSteps\n modify fun s => {s with steps := s.steps + 1}\n\n let e β getExpr\n\n if β shouldOmitExpr e then\n return β omission .deep\n\n if β shouldOmitProof e then\n let pf β omission .proof\n if β getPPOption getPPProofsWithType then\n let stx β withType delab\n return β annotateCurPos (β `(($pf : $stx)))\n else\n return pf\n\n let k β getExprKind\n let stx β withIncDepth <| delabFor k <|> (liftM $ show MetaM _ from throwError \"don't know how to delaborate '{k}'\")\n if β getPPOption getPPAnalyzeTypeAscriptions <&&> getPPOption getPPAnalysisNeedsType <&&> pure !e.isMData then\n let typeStx β withType delab\n `(($stx : $typeStx)) >>= annotateCurPos\n else\n return stx",
"start": [
366,
1
],
"end": [
392,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.mkAppUnexpanderAttribute",
"code": "unsafe def mkAppUnexpanderAttribute : IO (KeyedDeclsAttribute Unexpander) :=\n KeyedDeclsAttribute.init {\n name := `app_unexpander,\n descr := \"Register an unexpander for applications of a given constant.\n\n[app_unexpander c] registers a `Lean.PrettyPrinter.Unexpander` for applications of the constant `c`. The unexpander is\npassed the result of pre-pretty printing the application *without* implicitly passed arguments. If `pp.explicit` is set\nto true or `pp.notation` is set to false, it will not be called at all.\",\n valueTypeName := `Lean.PrettyPrinter.Unexpander\n evalKey := fun _ stx => do\n Elab.realizeGlobalConstNoOverloadWithInfo (β Attribute.Builtin.getIdent stx)\n } `Lean.PrettyPrinter.Delaborator.appUnexpanderAttribute",
"start": [
394,
1
],
"end": [
405,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.appUnexpanderAttribute",
"code": "@[builtin_init mkAppUnexpanderAttribute] opaque appUnexpanderAttribute : KeyedDeclsAttribute Unexpander",
"start": [
406,
1
],
"end": [
406,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "delabCore",
"code": "def delabCore (e : Expr) (optionsPerPos : OptionsPerPos := {}) (delab : DelabM Ξ±) :\n MetaM (Ξ± Γ PosMap Elab.Info) := do\n \n let e β Meta.erasePatternRefAnnotations e\n trace[PrettyPrinter.delab.input] \"{Std.format e}\"\n let mut opts β getOptions\n if pp.proofs.get? opts == none &&\n !e.isConst then\n try if β Meta.isProof e then opts := pp.proofs.set opts true\n catch _ => pure ()\n withOptions (fun _ => opts) do\n let e β if getPPInstantiateMVars opts then instantiateMVars e else pure e\n let e β if getPPBeta opts then Core.betaReduce e else pure e\n let optionsPerPos β\n if !getPPAll opts && getPPAnalyze opts && optionsPerPos.isEmpty then\n topDownAnalyze e\n else pure optionsPerPos\n let (stx, {infos := infos, ..}) β catchInternalId Delaborator.delabFailureId\n (delab\n { optionsPerPos := optionsPerPos\n currNamespace := (β getCurrNamespace)\n openDecls := (β getOpenDecls)\n subExpr := SubExpr.mkRoot e\n inPattern := opts.getInPattern }\n |>.run { : Delaborator.State })\n (fun _ => unreachable!)\n return (stx, infos)",
"start": [
413,
1
],
"end": [
442,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "delab",
"code": "def delab (e : Expr) (optionsPerPos : OptionsPerPos := {}) : MetaM Term := do\n let (stx, _) β delabCore e optionsPerPos Delaborator.delab\n return stx",
"start": [
444,
1
],
"end": [
447,
13
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/CoeAttr.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Meta/FunInfo.lean"
] | [
{
"full_name": "Lean.Meta.CoeFnType",
"code": "inductive CoeFnType\n \n | coe\n \n | coeFun\n \n | coeSort\n deriving Inhabited, Repr, DecidableEq",
"start": [
26,
1
],
"end": [
34,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.CoeFnInfo",
"code": "structure CoeFnInfo where\n \n numArgs : Nat\n \n coercee : Nat\n \n type : CoeFnType\n deriving Inhabited, Repr",
"start": [
43,
1
],
"end": [
51,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getCoeFnInfo?",
"code": "def getCoeFnInfo? (fn : Name) : CoreM (Option CoeFnInfo) :=\n return (coeExt.getState (β getEnv)).find? fn",
"start": [
65,
1
],
"end": [
67,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.registerCoercion",
"code": "def registerCoercion (name : Name) (info : Option CoeFnInfo := none) : MetaM Unit := do\n let info β match info with | some info => pure info | none => do\n let fnInfo β getFunInfo (β mkConstWithLevelParams name)\n let some coercee := fnInfo.paramInfo.findIdx? (Β·.binderInfo.isExplicit)\n | throwError \"{name} has no explicit arguments\"\n pure { numArgs := coercee + 1, coercee, type := .coe }\n modifyEnv fun env => coeExt.addEntry env (name, info)",
"start": [
69,
1
],
"end": [
76,
56
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Util.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/PPGoal.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Util/ForEachExprWhere.lean"
] | [
{
"full_name": "Lean.MVarId.getTag",
"code": "def _root_.Lean.MVarId.getTag (mvarId : MVarId) : MetaM Name :=\n return (β mvarId.getDecl).userName",
"start": [
14,
1
],
"end": [
16,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarTag",
"code": "@[deprecated MVarId.getTag (since := \"2022-07-15\")]\ndef getMVarTag (mvarId : MVarId) : MetaM Name :=\n mvarId.getTag",
"start": [
18,
1
],
"end": [
20,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.setTag",
"code": "def _root_.Lean.MVarId.setTag (mvarId : MVarId) (tag : Name) : MetaM Unit := do\n modify fun s => { s with mctx := s.mctx.setMVarUserName mvarId tag }",
"start": [
22,
1
],
"end": [
23,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setMVarTag",
"code": "@[deprecated MVarId.setTag (since := \"2022-07-15\")]\ndef setMVarTag (mvarId : MVarId) (tag : Name) : MetaM Unit := do\n mvarId.setTag tag",
"start": [
25,
1
],
"end": [
27,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.appendTag",
"code": "def appendTag (tag : Name) (suffix : Name) : Name :=\n tag.modifyBase (Β· ++ suffix.eraseMacroScopes)",
"start": [
29,
1
],
"end": [
30,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.appendTagSuffix",
"code": "def appendTagSuffix (mvarId : MVarId) (suffix : Name) : MetaM Unit := do\n let tag β mvarId.getTag\n mvarId.setTag (appendTag tag suffix)",
"start": [
32,
1
],
"end": [
34,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprSyntheticOpaqueMVar",
"code": "def mkFreshExprSyntheticOpaqueMVar (type : Expr) (tag : Name := Name.anonymous) : MetaM Expr :=\n mkFreshExprMVar type MetavarKind.syntheticOpaque tag",
"start": [
36,
1
],
"end": [
37,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwTacticEx",
"code": "def throwTacticEx (tacticName : Name) (mvarId : MVarId) (msg? : Option MessageData := none) : MetaM Ξ± :=\n match msg? with\n | none => throwError \"tactic '{tacticName}' failed\\n{mvarId}\"\n | some msg => throwError \"tactic '{tacticName}' failed, {msg}\\n{mvarId}\"",
"start": [
39,
1
],
"end": [
42,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwNestedTacticEx",
"code": "def throwNestedTacticEx {Ξ±} (tacticName : Name) (ex : Exception) : MetaM Ξ± := do\n throwError \"tactic '{tacticName}' failed, nested error:\\n{ex.toMessageData}\"",
"start": [
44,
1
],
"end": [
45,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.checkNotAssigned",
"code": "def _root_.Lean.MVarId.checkNotAssigned (mvarId : MVarId) (tacticName : Name) : MetaM Unit := do\n if (β mvarId.isAssigned) then\n throwTacticEx tacticName mvarId \"metavariable has already been assigned\"",
"start": [
47,
1
],
"end": [
50,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkNotAssigned",
"code": "@[deprecated MVarId.checkNotAssigned (since := \"2022-07-15\")]\ndef checkNotAssigned (mvarId : MVarId) (tacticName : Name) : MetaM Unit := do\n mvarId.checkNotAssigned tacticName",
"start": [
52,
1
],
"end": [
54,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.getType",
"code": "def _root_.Lean.MVarId.getType (mvarId : MVarId) : MetaM Expr :=\n return (β mvarId.getDecl).type",
"start": [
56,
1
],
"end": [
58,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarType",
"code": "@[deprecated MVarId.getType (since := \"2022-07-15\")]\ndef getMVarType (mvarId : MVarId) : MetaM Expr :=\n mvarId.getType",
"start": [
60,
1
],
"end": [
62,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.getType'",
"code": "def _root_.Lean.MVarId.getType' (mvarId : MVarId) : MetaM Expr := do\n instantiateMVars (β whnf (β mvarId.getType))",
"start": [
64,
1
],
"end": [
70,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarType'",
"code": "@[deprecated MVarId.getType' (since := \"2022-07-15\")]\ndef getMVarType' (mvarId : MVarId) : MetaM Expr := do\n mvarId.getType'",
"start": [
72,
1
],
"end": [
74,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.admit",
"code": "def _root_.Lean.MVarId.admit (mvarId : MVarId) (synthetic := true) : MetaM Unit :=\n mvarId.withContext do\n mvarId.checkNotAssigned `admit\n let mvarType β mvarId.getType\n let val β mkSorry mvarType synthetic\n mvarId.assign val",
"start": [
78,
1
],
"end": [
84,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.admit",
"code": "@[deprecated MVarId.admit (since := \"2022-07-15\")]\ndef admit (mvarId : MVarId) (synthetic := true) : MetaM Unit :=\n mvarId.admit synthetic",
"start": [
86,
1
],
"end": [
88,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.headBetaType",
"code": "def _root_.Lean.MVarId.headBetaType (mvarId : MVarId) : MetaM Unit := do\n mvarId.setType (β mvarId.getType).headBeta",
"start": [
90,
1
],
"end": [
92,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.headBetaMVarType",
"code": "@[deprecated MVarId.headBetaType (since := \"2022-07-15\")]\ndef headBetaMVarType (mvarId : MVarId) : MetaM Unit := do\n mvarId.headBetaType",
"start": [
94,
1
],
"end": [
96,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.getNondepPropHyps",
"code": "def _root_.Lean.MVarId.getNondepPropHyps (mvarId : MVarId) : MetaM (Array FVarId) :=\n let removeDeps (e : Expr) (candidates : FVarIdHashSet) : MetaM FVarIdHashSet := do\n let e β instantiateMVars e\n let visit : StateRefT FVarIdHashSet MetaM FVarIdHashSet := do\n e.forEachWhere Expr.isFVar fun e => modify fun s => s.erase e.fvarId!\n get\n visit |>.run' candidates\n mvarId.withContext do\n let mut candidates : FVarIdHashSet := {}\n for localDecl in (β getLCtx) do\n unless localDecl.isImplementationDetail do\n candidates β removeDeps localDecl.type candidates\n match localDecl.value? with\n | none => pure ()\n | some value => candidates β removeDeps value candidates\n if (β isProp localDecl.type) && !localDecl.hasValue then\n candidates := candidates.insert localDecl.fvarId\n candidates β removeDeps (β mvarId.getType) candidates\n if candidates.isEmpty then\n return #[]\n else\n let mut result := #[]\n for localDecl in (β getLCtx) do\n if candidates.contains localDecl.fvarId then\n result := result.push localDecl.fvarId\n return result",
"start": [
98,
1
],
"end": [
124,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getNondepPropHyps",
"code": "@[deprecated MVarId.getNondepPropHyps (since := \"2022-07-15\")]\ndef getNondepPropHyps (mvarId : MVarId) : MetaM (Array FVarId) :=\n mvarId.getNondepPropHyps",
"start": [
126,
1
],
"end": [
128,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.saturate",
"code": "partial def saturate (mvarId : MVarId) (x : MVarId β MetaM (Option (List MVarId))) : MetaM (List MVarId) := do\n let (_, r) β go mvarId |>.run #[]\n return r.toList\nwhere\n go (mvarId : MVarId) : StateRefT (Array MVarId) MetaM Unit :=\n withIncRecDepth do\n match (β x mvarId) with\n | none => modify fun s => s.push mvarId\n | some mvarIds => mvarIds.forM go",
"start": [
130,
1
],
"end": [
138,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.exactlyOne",
"code": "def exactlyOne (mvarIds : List MVarId) (msg : MessageData := \"unexpected number of goals\") : MetaM MVarId :=\n match mvarIds with\n | [mvarId] => return mvarId\n | _ => throwError msg",
"start": [
140,
1
],
"end": [
143,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ensureAtMostOne",
"code": "def ensureAtMostOne (mvarIds : List MVarId) (msg : MessageData := \"unexpected number of goals\") : MetaM (Option MVarId) :=\n match mvarIds with\n | [] => return none\n | [mvarId] => return some mvarId\n | _ => throwError msg",
"start": [
145,
1
],
"end": [
149,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getPropHyps",
"code": "def getPropHyps : MetaM (Array FVarId) := do\n let mut result := #[]\n for localDecl in (β getLCtx) do\n unless localDecl.isImplementationDetail do\n if (β isProp localDecl.type) then\n result := result.push localDecl.fvarId\n return result",
"start": [
151,
1
],
"end": [
158,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.inferInstance",
"code": "def _root_.Lean.MVarId.inferInstance (mvarId : MVarId) : MetaM Unit := mvarId.withContext do\n mvarId.checkNotAssigned `infer_instance\n let synthVal β synthInstance (β mvarId.getType)\n unless (β isDefEq (mkMVar mvarId) synthVal) do\n throwTacticEx `infer_instance mvarId \"`infer_instance` tactic failed to assign instance\"",
"start": [
160,
1
],
"end": [
164,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.TacticResultCNM",
"code": "inductive TacticResultCNM where\n | closed\n | noChange\n | modified (mvarId : MVarId)",
"start": [
166,
1
],
"end": [
169,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isSubsingleton",
"code": "def _root_.Lean.MVarId.isSubsingleton (g : MVarId) : MetaM Bool := do\n try\n discard <| synthInstance (β mkAppM ``Subsingleton #[β g.getType])\n return true\n catch _ =>\n return false",
"start": [
172,
1
],
"end": [
178,
17
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array/Mem.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Linear.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/List/BasicAux.lean"
] | [
{
"full_name": "Array.Mem",
"code": "structure Mem (a : Ξ±) (as : Array Ξ±) : Prop where\n val : a β as.data",
"start": [
13,
1
],
"end": [
17,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.sizeOf_lt_of_mem",
"code": "theorem sizeOf_lt_of_mem [SizeOf Ξ±] {as : Array Ξ±} (h : a β as) : sizeOf a < sizeOf as",
"start": [
22,
1
],
"end": [
24,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.sizeOf_get",
"code": "@[simp] theorem sizeOf_get [SizeOf Ξ±] (as : Array Ξ±) (i : Fin as.size) : sizeOf (as.get i) < sizeOf as",
"start": [
26,
1
],
"end": [
28,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.sizeOf_getElem",
"code": "@[simp] theorem sizeOf_getElem [SizeOf Ξ±] (as : Array Ξ±) (i : Nat) (h : i < as.size) :\n sizeOf (as[i]'h) < sizeOf as",
"start": [
30,
1
],
"end": [
31,
49
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Builtins.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/SubExpr.lean",
".lake/packages/lean4/src/lean/Lean/Meta/CoeAttr.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Parser.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Attributes.lean"
] | [
{
"full_name": "Lean.PrettyPrinter.Delaborator.withTypeAscription",
"code": "def withTypeAscription (d : Delab) (cond : Bool := true) : DelabM Term := do\n let stx β d\n if cond then\n let stx β annotateCurPos stx\n let typeStx β withType delab\n `(($stx : $typeStx))\n else\n return stx",
"start": [
20,
1
],
"end": [
30,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.maybeAddBlockImplicit",
"code": "def maybeAddBlockImplicit (identLike : Syntax) : DelabM Syntax := do\n if β getPPOption getPPAnalysisBlockImplicit then `(@$identLike) else pure identLike",
"start": [
32,
1
],
"end": [
36,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabFVar",
"code": "@[builtin_delab fvar]\ndef delabFVar : Delab := do\n let Expr.fvar fvarId β getExpr | unreachable!\n try\n let l β fvarId.getDecl\n maybeAddBlockImplicit (mkIdent l.userName)\n catch _ =>\n maybeAddBlockImplicit <| mkIdent (fvarId.name.replacePrefix `_uniq `_fvar)",
"start": [
38,
1
],
"end": [
46,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabBVar",
"code": "@[builtin_delab bvar]\ndef delabBVar : Delab := do\n let Expr.bvar idx β getExpr | unreachable!\n pure $ mkIdent $ Name.mkSimple $ \"#\" ++ toString idx",
"start": [
49,
1
],
"end": [
52,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabMVar",
"code": "@[builtin_delab mvar]\ndef delabMVar : Delab := do\n let Expr.mvar n β getExpr | unreachable!\n withTypeAscription (cond := β getPPOption getPPMVarsWithType) do\n if β getPPOption getPPMVars then\n let mvarDecl β n.getDecl\n let n :=\n match mvarDecl.userName with\n | .anonymous => n.name.replacePrefix `_uniq `m\n | n => n\n `(?$(mkIdent n))\n else\n `(?_)",
"start": [
54,
1
],
"end": [
66,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabSort",
"code": "@[builtin_delab sort]\ndef delabSort : Delab := do\n let Expr.sort l β getExpr | unreachable!\n match l with\n | Level.zero => `(Prop)\n | Level.succ .zero => `(Type)\n | _ =>\n let mvars β getPPOption getPPMVars\n match l.dec with\n | some l' => `(Type $(Level.quote l' (prec := max_prec) (mvars := mvars)))\n | none => `(Sort $(Level.quote l (prec := max_prec) (mvars := mvars)))",
"start": [
68,
1
],
"end": [
78,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabConst",
"code": "def delabConst : Delab := do\n let Expr.const cβ ls β getExpr | unreachable!\n let cβ := if (β getPPOption getPPPrivateNames) then cβ else (privateToUserName? cβ).getD cβ\n\n let mut c β unresolveNameGlobal cβ (fullNames := β getPPOption getPPFullNames)\n let stx β if ls.isEmpty || !(β getPPOption getPPUniverses) then\n if (β getLCtx).usesUserName c then\n if c == cβ && !(β read).inPattern then\n c := `_root_ ++ c\n else\n c := cβ\n pure <| mkIdent c\n else\n let mvars β getPPOption getPPMVars\n `($(mkIdent c).{$[$(ls.toArray.map (Level.quote Β· (prec := 0) (mvars := mvars)))],*})\n\n let stx β maybeAddBlockImplicit stx\n if (β getPPOption getPPTagAppFns) then\n annotateTermInfo stx\n else\n return stx",
"start": [
80,
1
],
"end": [
108,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withMDataOptions",
"code": "def withMDataOptions [Inhabited Ξ±] (x : DelabM Ξ±) : DelabM Ξ± := do\n match β getExpr with\n | Expr.mdata m .. =>\n let mut posOpts := (β read).optionsPerPos\n let pos β getPos\n for (k, v) in m do\n if (`pp).isPrefixOf k then\n let opts := posOpts.find? pos |>.getD {}\n posOpts := posOpts.insert pos (opts.insert k v)\n withReader ({ Β· with optionsPerPos := posOpts }) $ withMDataExpr x\n | _ => x",
"start": [
110,
1
],
"end": [
120,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withMDatasOptions",
"code": "partial def withMDatasOptions [Inhabited Ξ±] (x : DelabM Ξ±) : DelabM Ξ± := do\n if (β getExpr).isMData then withMDataOptions (withMDatasOptions x) else x",
"start": [
122,
1
],
"end": [
123,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.ParamKind",
"code": "structure ParamKind where\n \n name : Name\n \n bInfo : BinderInfo\n \n defVal : Option Expr := none\n \n isAutoParam : Bool := false\n deriving Inhabited",
"start": [
125,
1
],
"end": [
137,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.ParamKind.isRegularExplicit",
"code": "def ParamKind.isRegularExplicit (param : ParamKind) : Bool :=\n param.bInfo.isExplicit && !param.isAutoParam && param.defVal.isNone",
"start": [
139,
1
],
"end": [
143,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.getParamKinds",
"code": "def getParamKinds (f : Expr) (args : Array Expr) : MetaM (Array ParamKind) := do\n try\n let mut result : Array ParamKind := Array.mkEmpty args.size\n let mut fnType β inferType f\n let mut j := 0\n for i in [0:args.size] do\n unless fnType.isForall do\n fnType β withTransparency .all <| whnf (fnType.instantiateRevRange j i args)\n j := i\n let .forallE n t b bi := fnType | failure\n let defVal := t.getOptParamDefault? |>.map (Β·.instantiateRevRange j i args)\n result := result.push { name := n, bInfo := bi, defVal, isAutoParam := t.isAutoParam }\n fnType := b\n fnType := fnType.instantiateRevRange j args.size args\n forallTelescopeReducing fnType fun xs _ => do\n xs.foldlM (init := result) fun result x => do\n let l β x.fvarId!.getDecl\n pure <| result.push { name := l.userName, bInfo := l.binderInfo, defVal := l.type.getOptParamDefault?, isAutoParam := l.type.isAutoParam }\n catch _ => pure #[]",
"start": [
145,
1
],
"end": [
180,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.shouldShowMotive",
"code": "def shouldShowMotive (motive : Expr) (opts : Options) : MetaM Bool := do\n pure (getPPMotivesAll opts)\n <||> (pure (getPPMotivesPi opts) <&&> returnsPi motive)\n <||> (pure (getPPMotivesNonConst opts) <&&> isNonConstFun motive)",
"start": [
182,
1
],
"end": [
185,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.unexpandStructureInstance",
"code": "def unexpandStructureInstance (stx : Syntax) : Delab := whenPPOption getPPStructureInstances do\n let env β getEnv\n let e β getExpr\n let some s β isConstructorApp? e | failure\n guard <| isStructure env s.induct\n \n let fieldNames := getStructureFields env s.induct\n let mut fields := #[]\n guard $ fieldNames.size == stx[1].getNumArgs\n if hasPPUsingAnonymousConstructorAttribute env s.induct then\n return β withTypeAscription (cond := (β withType <| getPPOption getPPStructureInstanceType)) do\n `(β¨$[$(stx[1].getArgs)],*β©)\n let args := e.getAppArgs\n let fieldVals := args.extract s.numParams args.size\n for idx in [:fieldNames.size] do\n let fieldName := fieldNames[idx]!\n if (β getPPOption getPPStructureInstancesFlatten) && (Lean.isSubobjectField? env s.induct fieldName).isSome then\n match stx[1][idx] with\n | `({ $fields',* $[: $_]?}) =>\n fields := fields ++ fields'.getElems\n continue\n | _ => pure ()\n let fieldId := mkIdent fieldName\n let fieldPos β nextExtraPos\n let fieldId := annotatePos fieldPos fieldId\n addFieldInfo fieldPos (s.induct ++ fieldName) fieldName fieldId fieldVals[idx]!\n let field β `(structInstField|$fieldId:ident := $(stx[1][idx]))\n fields := fields.push field\n let tyStx β withType do\n if (β getPPOption getPPStructureInstanceType) then delab >>= pure β some else pure none\n `({ $fields,* $[: $tyStx]? })",
"start": [
187,
1
],
"end": [
224,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.appFieldNotationCandidate?",
"code": "def appFieldNotationCandidate? : DelabM (Option (Nat Γ Name)) := do\n let e β getExpr\n unless e.isApp do return none\n let some (field, idx) β fieldNotationCandidate? e.getAppFn e.getAppArgs (β getPPOption getPPFieldNotationGeneralized)\n | return none\n unless idx < e.getAppNumArgs do return none\n \n let obj := e.getArg! idx\n if obj.isRawNatLit || obj.isAppOfArity ``OfNat.ofNat 3 || obj.isAppOfArity ``OfScientific.ofScientific 5 then\n return none\n return (idx, field)",
"start": [
226,
1
],
"end": [
245,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withoutParentProjections",
"code": "private partial def withoutParentProjections (explicit : Bool) (d : DelabM Ξ±) : DelabM Ξ± := do\n if β try isParentProj explicit (β getExpr) catch _ => pure false then\n withAppArg <| withoutParentProjections explicit d\n else\n d",
"start": [
247,
1
],
"end": [
258,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.stripParentProjections",
"code": "private partial def stripParentProjections (s : Term) : DelabM Term :=\n match s with\n | `($x.$f:ident) => do\n if let some field β try parentProj? false (β getExpr) catch _ => pure none then\n if f.getId == field then\n withAppArg <| stripParentProjections x\n else\n return s\n else\n return s\n | _ => return s",
"start": [
263,
1
],
"end": [
274,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.needsExplicit",
"code": "def needsExplicit (f : Expr) (numArgs : Nat) (paramKinds : Array ParamKind) : Bool :=\n if paramKinds.size == 0 && 0 < numArgs && f matches .const _ [] then\n false\n else\n paramKinds.size < numArgs\n || paramKinds[:numArgs].any (fun param => !param.bInfo.isExplicit)\n || (numArgs < paramKinds.size && paramKinds[numArgs]!.bInfo matches .implicit | .instImplicit)\n || paramKinds[numArgs:].any (fun param => param.bInfo.isExplicit && !param.isRegularExplicit)",
"start": [
276,
1
],
"end": [
294,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabAppExplicitCore",
"code": "def delabAppExplicitCore (fieldNotation : Bool) (numArgs : Nat) (delabHead : (insertExplicit : Bool) β Delab) (paramKinds : Array ParamKind) : Delab := do\n let insertExplicit := needsExplicit ((β getExpr).getBoundedAppFn numArgs) numArgs paramKinds\n let fieldNotation β pure (fieldNotation && !insertExplicit) <&&> getPPOption getPPFieldNotation\n <&&> not <$> getPPOption getPPAnalysisNoDot\n <&&> withBoundedAppFn numArgs do pure (β getExpr).consumeMData.isConst <&&> not <$> withMDatasOptions (getPPOption getPPAnalysisBlockImplicit <|> getPPOption getPPUniverses)\n let field? β if fieldNotation then appFieldNotationCandidate? else pure none\n let (fnStx, _, argStxs) β withBoundedAppFnArgs numArgs\n (do return (β delabHead insertExplicit, paramKinds.toList, Array.mkEmpty numArgs))\n (fun β¨fnStx, paramKinds, argStxsβ© => do\n let isInstImplicit := paramKinds.head? |>.map (Β·.bInfo == .instImplicit) |>.getD false\n let argStx β if some argStxs.size = field?.map Prod.fst then\n withoutParentProjections (explicit := true) delab\n else if β getPPOption getPPAnalysisHole then `(_)\n else if isInstImplicit == true then\n withTypeAscription (cond := β getPPOption getPPInstanceTypes) do\n if β getPPOption getPPInstances then delab else `(_)\n else delab\n pure (fnStx, paramKinds.tailD [], argStxs.push argStx))\n if let some (idx, field) := field? then\n let obj := argStxs[idx]!\n let mut head : Term β `($obj.$(mkIdent field))\n if idx == 0 then\n head β withBoundedAppFn (numArgs - 1) <| annotateTermInfo head\n return Syntax.mkApp head (argStxs.eraseIdx idx)\n else\n return Syntax.mkApp fnStx argStxs",
"start": [
296,
1
],
"end": [
330,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.AppImplicitArg",
"code": "inductive AppImplicitArg\n \n | skip\n \n | regular (s : Term)\n \n | named (s : TSyntax ``Parser.Term.namedArgument)\n deriving Inhabited",
"start": [
332,
1
],
"end": [
340,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.AppImplicitArg.canUnexpand",
"code": "def AppImplicitArg.canUnexpand : AppImplicitArg β Bool\n | .regular .. | .skip => true\n | .named .. => false",
"start": [
342,
1
],
"end": [
345,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.AppImplicitArg.syntax?",
"code": "def AppImplicitArg.syntax? : AppImplicitArg β Option Syntax\n | .skip => none\n | .regular s => s\n | .named s => s",
"start": [
347,
1
],
"end": [
351,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabAppImplicitCore",
"code": "def delabAppImplicitCore (unexpand : Bool) (numArgs : Nat) (delabHead : Delab) (paramKinds : Array ParamKind) : Delab := do\n let unexpand β pure unexpand\n <&&> withBoundedAppFn numArgs do pure (β getExpr).consumeMData.isConst <&&> not <$> withMDatasOptions (getPPOption getPPUniverses)\n let field? β\n if β pure unexpand <&&> getPPOption getPPFieldNotation <&&> not <$> getPPOption getPPAnalysisNoDot then\n appFieldNotationCandidate?\n else\n pure none\n let (fnStx, args) β\n withBoundedAppFnArgs numArgs\n (do return ((β delabHead), Array.mkEmpty numArgs))\n (fun (fnStx, args) => do\n let idx := args.size\n let arg β mkArg (numArgs - idx - 1) paramKinds[idx]!\n return (fnStx, args.push arg))\n\n if β pure unexpand <&&> getPPOption getPPNotation then\n if let some stx β (some <$> tryAppUnexpanders fnStx args) <|> pure none then\n return stx\n\n let stx := Syntax.mkApp fnStx (args.filterMap (Β·.syntax?))\n\n if β pure (unexpand && args.all (Β·.canUnexpand)) <&&> getPPOption getPPStructureInstances then\n if let some stx β (some <$> unexpandStructureInstance stx) <|> pure none then\n return stx\n\n if let some (fieldIdx, field) := field? then\n if fieldIdx < args.size then\n let obj? : Option Term β do\n let arg := args[fieldIdx]!\n if let .regular s := arg then\n withNaryArg fieldIdx <| some <$> stripParentProjections s\n else\n pure none\n if let some obj := obj? then\n let isFirst := args[0:fieldIdx].all (Β· matches .skip)\n let args' := args.set! fieldIdx .skip\n let mut head : Term β `($obj.$(mkIdent field))\n if isFirst then\n let objArity := args'.findIdx? (fun a => !(a matches .skip)) |>.getD args'.size\n head β withBoundedAppFn (numArgs - objArity) <| annotateTermInfo <| head\n return Syntax.mkApp head (args'.filterMap (Β·.syntax?))\n\n return stx\nwhere\n mkNamedArg (name : Name) : DelabM AppImplicitArg :=\n return .named <| β `(Parser.Term.namedArgument| ($(mkIdent name) := $(β delab)))\n \n mkArg (remainingArgs : Nat) (param : ParamKind) : DelabM AppImplicitArg := do\n let arg β getExpr\n if β getPPOption getPPAnalysisSkip then return .skip\n else if β getPPOption getPPAnalysisHole then return .regular (β `(_))\n else if β getPPOption getPPAnalysisNamedArg then\n mkNamedArg param.name\n else if param.defVal.isSome && remainingArgs == 0 && param.defVal.get! == arg then\n return .skip\n else if param.bInfo.isExplicit then\n return .regular (β delab)\n else if β pure (param.name == `motive) <&&> shouldShowMotive arg (β getOptions) then\n mkNamedArg param.name\n else\n return .skip\n \n tryUnexpand (fs : List Unexpander) (stx : Syntax) : DelabM Syntax := do\n let ref β getRef\n fs.firstM fun f =>\n match f stx |>.run ref |>.run () with\n | EStateM.Result.ok stx _ => return stx\n | _ => failure\n \n tryAppUnexpanders (fnStx : Term) (args : Array AppImplicitArg) : Delab := do\n let .const c _ := (β getExpr).getAppFn.consumeMData | unreachable!\n let fs := appUnexpanderAttribute.getValues (β getEnv) c\n if fs.isEmpty then failure\n let rec go (i : Nat) (implicitArgs : Nat) (argStxs : Array Syntax) : DelabM Term := do\n match i with\n | 0 =>\n let stx β tryUnexpand fs fnStx\n return Syntax.mkApp (β annotateTermInfo stx) (args.filterMap (Β·.syntax?))\n | i' + 1 =>\n if args[i']!.syntax?.isSome then\n (do let stx β tryUnexpand fs <| Syntax.mkApp fnStx argStxs\n let argStxs' := args.extract i args.size |>.filterMap (Β·.syntax?)\n return Syntax.mkApp (β annotateTermInfo stx) argStxs')\n <|> withBoundedAppFn (implicitArgs + 1) (go i' 0 argStxs.pop)\n else\n go i' (implicitArgs + 1) argStxs\n let maxUnexpand := args.findIdx? (!Β·.canUnexpand) |>.getD args.size\n withBoundedAppFn (args.size - maxUnexpand) <|\n go maxUnexpand 0 (args.extract 0 maxUnexpand |>.filterMap (Β·.syntax?))",
"start": [
353,
1
],
"end": [
471,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.useAppExplicit",
"code": "def useAppExplicit (numArgs : Nat) (paramKinds : Array ParamKind) : DelabM Bool := do\n if β getPPOption getPPExplicit then return true\n\n if β withBoundedAppFn numArgs <| withMDatasOptions <| getPPOption getPPAnalysisBlockImplicit then\n return true\n\n if paramKinds.size < numArgs then return true\n\n if numArgs < paramKinds.size then\n let nextParam := paramKinds[numArgs]!\n\n if nextParam.bInfo matches .implicit | .instImplicit then return true\n\n if paramKinds[numArgs:].any fun param => param.bInfo.isExplicit && !param.isRegularExplicit then return true\n\n return false",
"start": [
473,
1
],
"end": [
499,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabAppCore",
"code": "def delabAppCore (maxArgs : Nat) (delabHead : (insertExplicit : Bool) β Delab) (unexpand : Bool) : Delab := do\n let tagAppFn β getPPOption getPPTagAppFns\n let delabHead' (insertExplicit : Bool) : Delab := withOptionAtCurrPos `pp.tagAppFns tagAppFn (delabHead insertExplicit)\n let e β getExpr\n let fn := e.getBoundedAppFn maxArgs\n let args := e.getBoundedAppArgs maxArgs\n let paramKinds β getParamKinds fn args\n if (β useAppExplicit args.size paramKinds) then\n delabAppExplicitCore (fieldNotation := unexpand && !tagAppFn) args.size delabHead' paramKinds\n else\n delabAppImplicitCore (unexpand := unexpand) args.size (delabHead' false) paramKinds",
"start": [
501,
1
],
"end": [
521,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabApp",
"code": "@[builtin_delab app]\ndef delabApp : Delab := do\n let delabAppFn (insertExplicit : Bool) : Delab := do\n let stx β if (β getExpr).consumeMData.isConst then withMDatasOptions delabConst else delab\n if insertExplicit && !stx.raw.isOfKind ``Lean.Parser.Term.explicit then `(@$stx) else pure stx\n delabAppCore (β getExpr).getAppNumArgs delabAppFn (unexpand := true)",
"start": [
523,
1
],
"end": [
531,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.withOverApp",
"code": "def withOverApp (arity : Nat) (x : Delab) : Delab := do\n let n := (β getExpr).getAppNumArgs\n guard <| n β₯ arity\n if n == arity then\n x\n else\n let delabHead (insertExplicit : Bool) : Delab := do\n guard <| !insertExplicit\n withAnnotateTermInfo x\n delabAppCore (n - arity) delabHead (unexpand := false)",
"start": [
533,
1
],
"end": [
565,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.AppMatchState",
"code": "structure AppMatchState where\n info : MatcherInfo\n \n matcherTy : SubExpr\n \n motive : Option (Term Γ Expr) := none\n \n motiveNamed : Bool := false\n \n discrs : Array Term := #[]\n \n hNames? : Array (Option Name) := #[]\n \n alts : Array SubExpr := #[]\n \n varNames : Array (Array Name) := #[]\n \n rhss : Array Term := #[]",
"start": [
567,
1
],
"end": [
589,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.skippingBinders",
"code": "private partial def skippingBinders {Ξ±} (numParams : Nat) (hNames : Array Name) (x : Array Name β DelabM Ξ±) : DelabM Ξ± := do\n loop 0 #[]\nwhere\n loop (i : Nat) (varNames : Array Name) : DelabM Ξ± := do\n let rec visitLambda : DelabM Ξ± := do\n let varName := (β getExpr).bindingName!.eraseMacroScopes\n if numParams - hNames.size β€ i then\n let varName := hNames[i + hNames.size - numParams]!\n withBindingBody varName do\n loop (i + 1) (varNames.push varName)\n else if varNames.contains varName then\n let varName := (β getLCtx).getUnusedName varName\n withBindingBody varName do\n loop (i + 1) (varNames.push varName)\n else\n withBindingBodyUnusedName fun id => do\n loop (i + 1) (varNames.push id.getId)\n if i < numParams then\n let e β getExpr\n if e.isLambda then\n visitLambda\n else\n let e β forallTelescopeReducing (β inferType e) fun xs _ => do\n if xs.size == 1 && (β inferType xs[0]!).isConstOf ``Unit then\n mkLambdaFVars xs (mkApp e (mkConst ``Unit.unit))\n else\n mkLambdaFVars xs (mkAppN e xs)\n withTheReader SubExpr (fun ctx => { ctx with expr := e }) visitLambda\n else x varNames",
"start": [
591,
1
],
"end": [
631,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabAppMatch",
"code": "@[builtin_delab app]\npartial def delabAppMatch : Delab := whenPPOption getPPNotation <| whenPPOption getPPMatch do\n let Expr.const c us := (β getExpr).getAppFn | failure\n let some info β getMatcherInfo? c | failure\n withOverApp info.arity do\n let st : AppMatchState β withBoundedAppFnArgs (1 + info.numDiscrs + info.numAlts)\n (do\n let params := (β getExpr).getAppArgs\n let matcherTy : SubExpr :=\n { expr := β instantiateForall (β instantiateTypeLevelParams (β getConstInfo c) us) params\n pos := (β getPos).pushType }\n guard <| β isDefEq matcherTy.expr (β inferType (β getExpr))\n return { info, matcherTy })\n (fun st => do\n if st.motive.isNone then\n let lamMotive β getExpr\n let piMotive β lambdaTelescope lamMotive fun xs body => mkForallFVars xs body\n let piStx β withTheReader SubExpr (fun cfg => { cfg with expr := piMotive }) delab\n let named β getPPOption getPPAnalysisNamedArg\n return { st with motive := (piStx, lamMotive), motiveNamed := named }\n else if st.discrs.size < st.info.numDiscrs then\n return { st with discrs := st.discrs.push (β delab) }\n else if st.alts.size < st.info.numAlts then\n return { st with alts := st.alts.push (β readThe SubExpr) }\n else\n panic! \"impossible, number of arguments does not match arity\")\n\n let st β withDummyBinders (st.info.discrInfos.map (Β·.hName?)) (β getExpr) fun hNames? => do\n let hNames := hNames?.filterMap id\n let mut st := {st with hNames? := hNames?}\n for i in [0:st.alts.size] do\n st β withTheReader SubExpr (fun _ => st.alts[i]!) do\n skippingBinders st.info.altNumParams[i]! hNames fun varNames => do\n let rhs β delab\n return { st with rhss := st.rhss.push rhs, varNames := st.varNames.push varNames }\n return st\n\n if st.rhss.isEmpty then\n `(nomatch $(st.discrs),*)\n else\n let pats β withReader (fun ctx => { ctx with inPattern := true, subExpr := st.matcherTy }) do\n forallTelescopeReducing (β getExpr) fun afterParams _ => do\n let alts := Array.ofSubarray afterParams[1 + st.discrs.size:]\n alts.mapIdxM fun idx alt => do\n let altTy β inferType alt\n withTheReader SubExpr (fun ctx =>\n { ctx with expr := altTy, pos := ctx.pos.pushNthBindingDomain (1 + st.discrs.size + idx) }) do\n usingNames st.varNames[idx]! <|\n withAppFnArgs (pure #[]) fun pats => return pats.push (β delab)\n let discrs β (st.hNames?.zip st.discrs).mapM fun (hName?, discr) =>\n match hName? with\n | none => `(matchDiscr| $discr:term)\n | some hName => `(matchDiscr| $(mkIdent hName) : $discr)\n let (piStx, lamMotive) := st.motive.get!\n let opts β getOptions\n if β pure st.motiveNamed <||> shouldShowMotive lamMotive opts then\n `(match (motive := $piStx) $[$discrs:matchDiscr],* with $[| $pats,* => $st.rhss]*)\n else\n `(match $[$discrs:matchDiscr],* with $[| $pats,* => $st.rhss]*)\nwhere\n \n withDummyBinders {Ξ± : Type} (hNames? : Array (Option Name)) (body : Expr)\n (m : Array (Option Name) β DelabM Ξ±) (acc : Array (Option Name) := #[]) : DelabM Ξ± := do\n let i := acc.size\n if i < hNames?.size then\n if let some name := hNames?[i]! then\n let n' β getUnusedName name body\n withLocalDecl n' .default (.sort levelZero) (kind := .implDetail) fun _ =>\n withDummyBinders hNames? body m (acc.push n')\n else\n withDummyBinders hNames? body m (acc.push none)\n else\n m acc\n\n usingNames {Ξ±} (varNames : Array Name) (x : DelabM Ξ±) (i : Nat := 0) : DelabM Ξ± :=\n if i < varNames.size then\n withBindingBody varNames[i]! <| usingNames varNames x (i+1)\n else\n x",
"start": [
633,
1
],
"end": [
741,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabLetFun",
"code": "@[builtin_delab app.letFun]\ndef delabLetFun : Delab := whenPPOption getPPNotation <| withOverApp 4 do\n let e β getExpr\n guard <| e.getAppNumArgs == 4\n let Expr.lam n _ b _ := e.appArg! | failure\n let n β getUnusedName n b\n let stxV β withAppFn <| withAppArg delab\n let (stxN, stxB) β withAppArg <| withBindingBody' n (mkAnnotatedIdent n) fun stxN => return (stxN, β delab)\n if β getPPOption getPPLetVarTypes <||> getPPOption getPPAnalysisLetVarType then\n let stxT β SubExpr.withNaryArg 0 delab\n `(let_fun $stxN : $stxT := $stxV; $stxB)\n else\n `(let_fun $stxN := $stxV; $stxB)",
"start": [
743,
1
],
"end": [
758,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabMData",
"code": "@[builtin_delab mdata]\ndef delabMData : Delab := do\n if let some _ := inaccessible? (β getExpr) then\n let s β withMDataExpr delab\n if (β read).inPattern then\n `(.($s)) else\n return s\n else if let some _ := isLHSGoal? (β getExpr) then\n withMDataExpr <| withAppFn <| withAppArg <| delab\n else\n withMDataOptions delab",
"start": [
760,
1
],
"end": [
771,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.hasIdent",
"code": "partial def hasIdent (id : Name) : Syntax β Bool\n | Syntax.ident _ _ id' _ => id == id'\n | Syntax.node _ _ args => args.any (hasIdent id)\n | _ => false",
"start": [
773,
1
],
"end": [
781,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.shouldGroupWithNext",
"code": "private def shouldGroupWithNext : DelabM Bool := do\n let e β getExpr\n let ppEType β getPPOption (getPPBinderTypes e)\n let go (e' : Expr) := do\n let ppE'Type β withBindingBody `_ $ getPPOption (getPPBinderTypes e)\n pure $ e.binderInfo == e'.binderInfo &&\n e.bindingDomain! == e'.bindingDomain! &&\n e'.binderInfo != BinderInfo.instImplicit &&\n ppEType == ppE'Type &&\n (e'.binderInfo != BinderInfo.default || ppE'Type)\n match e with\n | Expr.lam _ _ e'@(Expr.lam _ _ _ _) _ => go e'\n | Expr.forallE _ _ e'@(Expr.forallE _ _ _ _) _ => go e'\n | _ => pure false\nwhere\n getPPBinderTypes (e : Expr) :=\n if e.isForall then getPPPiBinderTypes else getPPFunBinderTypes",
"start": [
783,
1
],
"end": [
807,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabBinders",
"code": "private partial def delabBinders (delabGroup : Array Syntax β Syntax β Delab) : optParam (Array Syntax) #[] β Delab\n | curNames => do\n if β shouldGroupWithNext then\n withBindingBodyUnusedName fun stxN => delabBinders delabGroup (curNames.push stxN)\n else\n let (stx, stxN) β withBindingBodyUnusedName fun stxN => return (β delab, stxN)\n delabGroup (curNames.push stxN) stx",
"start": [
809,
1
],
"end": [
820,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabLam",
"code": "@[builtin_delab lam]\ndef delabLam : Delab :=\n delabBinders fun curNames stxBody => do\n let e β getExpr\n let stxT β withBindingDomain delab\n let ppTypes β getPPOption getPPFunBinderTypes\n let usedDownstream := curNames.any (fun n => hasIdent n.getId stxBody)\n\n let blockImplicitLambda := true\n \n\n if !blockImplicitLambda then\n pure stxBody\n else\n let defaultCase (_ : Unit) : Delab := do\n if ppTypes then\n let stxCurNames β\n if curNames.size > 1 then\n `($(curNames.get! 0) $(curNames.eraseIdx 0)*)\n else\n pure $ curNames.get! 0;\n `(funBinder| ($stxCurNames : $stxT))\n else\n pure curNames.back let group β match e.binderInfo, ppTypes with\n | BinderInfo.default, _ => defaultCase ()\n | BinderInfo.implicit, true => `(funBinder| {$curNames* : $stxT})\n | BinderInfo.implicit, false => `(funBinder| {$curNames*})\n | BinderInfo.strictImplicit, true => `(funBinder| β¦$curNames* : $stxTβ¦)\n | BinderInfo.strictImplicit, false => `(funBinder| β¦$curNames*β¦)\n | BinderInfo.instImplicit, _ =>\n if usedDownstream then `(funBinder| [$curNames.back : $stxT]) else `(funBinder| [$stxT])\n let (binders, stxBody) :=\n match stxBody with\n | `(fun $binderGroups* => $stxBody) => (#[group] ++ binderGroups, stxBody)\n | _ => (#[group], stxBody)\n if β getPPOption getPPUnicodeFun then\n `(fun $binders* β¦ $stxBody)\n else\n `(fun $binders* => $stxBody)",
"start": [
822,
1
],
"end": [
876,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabForallBinders",
"code": "private partial def delabForallBinders (delabGroup : Array Syntax β Bool β Syntax β Delab) (curNames : Array Syntax := #[]) (curDep := false) : Delab := do\n let dep := !(β getExpr).isArrow\n if !curNames.isEmpty && dep != curDep then\n delabGroup curNames curDep (β delab)\n else\n let curDep := dep\n if β shouldGroupWithNext then\n withBindingBodyUnusedName fun stxN => delabForallBinders delabGroup (curNames.push stxN) curDep\n else\n let (stx, stxN) β withBindingBodyUnusedName fun stxN => return (β delab, stxN)\n delabGroup (curNames.push stxN) curDep stx",
"start": [
878,
1
],
"end": [
896,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabForall",
"code": "@[builtin_delab forallE]\ndef delabForall : Delab := do\n delabForallBinders fun curNames dependent stxBody => do\n let e β getExpr\n let prop β try isProp e catch _ => pure false\n let stxT β withBindingDomain delab\n let group β match e.binderInfo with\n | BinderInfo.implicit => `(bracketedBinderF|{$curNames* : $stxT})\n | BinderInfo.strictImplicit => `(bracketedBinderF|β¦$curNames* : $stxTβ¦)\n | BinderInfo.instImplicit => `(bracketedBinderF|[$curNames.back : $stxT])\n | _ =>\n if dependent then\n if prop && !(β getPPOption getPPPiBinderTypes) then\n return β `(β $curNames:ident*, $stxBody)\n else\n `(bracketedBinderF|($curNames* : $stxT))\n else\n return β curNames.foldrM (fun _ stxBody => `($stxT β $stxBody)) stxBody\n if prop then\n match stxBody with\n | `(β $groups*, $stxBody) => `(β $group $groups*, $stxBody)\n | _ => `(β $group, $stxBody)\n else\n `($group:bracketedBinder β $stxBody)",
"start": [
898,
1
],
"end": [
923,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabLetE",
"code": "@[builtin_delab letE]\ndef delabLetE : Delab := do\n let Expr.letE n t v b _ β getExpr | unreachable!\n let n β getUnusedName n b\n let stxV β descend v 1 delab\n let (stxN, stxB) β withLetDecl n t v fun fvar => do\n let b := b.instantiate1 fvar\n return (β mkAnnotatedIdent n fvar, β descend b 2 delab)\n if β getPPOption getPPLetVarTypes <||> getPPOption getPPAnalysisLetVarType then\n let stxT β descend t 0 delab\n `(let $stxN : $stxT := $stxV; $stxB)\n else `(let $stxN := $stxV; $stxB)",
"start": [
925,
1
],
"end": [
936,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabChar",
"code": "@[builtin_delab app.Char.ofNat]\ndef delabChar : Delab := do\n let e β getExpr\n guard <| e.getAppNumArgs == 1\n let .lit (.natVal n) := e.appArg! | failure\n return quote (Char.ofNat n)",
"start": [
938,
1
],
"end": [
943,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabLit",
"code": "@[builtin_delab lit]\ndef delabLit : Delab := do\n let Expr.lit l β getExpr | unreachable!\n match l with\n | Literal.natVal n =>\n if β getPPOption getPPNatLit then\n `(nat_lit $(quote n))\n else\n return quote n\n | Literal.strVal s => return quote s",
"start": [
945,
1
],
"end": [
954,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabOfNatCore",
"code": "def delabOfNatCore (showType : Bool := false) : Delab := do\n let .app (.app (.app (.const ``OfNat.ofNat ..) _) (.lit (.natVal n))) _ β getExpr | failure\n let stx β annotateTermInfo <| quote n\n if showType then\n let ty β withNaryArg 0 delab\n `(($stx : $ty))\n else\n return stx",
"start": [
956,
1
],
"end": [
966,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabNegIntCore",
"code": "def delabNegIntCore (showType : Bool := false) : Delab := do\n guard <| (β getExpr).isAppOfArity ``Neg.neg 3\n let n β withAppArg delabOfNatCore\n let stx β annotateTermInfo (β `(- $n))\n if showType then\n let ty β withNaryArg 0 delab\n `(($stx : $ty))\n else\n return stx",
"start": [
968,
1
],
"end": [
979,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabDivRatCore",
"code": "def delabDivRatCore (showType : Bool := false) : Delab := do\n let e β getExpr\n guard <| e.isAppOfArity ``HDiv.hDiv 6\n guard <| e.getArg! 0 == e.getArg! 1\n guard <| e.getArg! 0 == e.getArg! 2\n let p β withAppFn <| withAppArg <| (delabOfNatCore <|> delabNegIntCore)\n let q β withAppArg <| delabOfNatCore\n let stx β annotateTermInfo (β `($p / $q))\n if showType then\n let ty β withNaryArg 0 delab\n `(($stx : $ty))\n else\n return stx",
"start": [
981,
1
],
"end": [
998,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabOfNat",
"code": "@[builtin_delab app.OfNat.ofNat]\ndef delabOfNat : Delab := whenPPOption getPPCoercions <| withOverApp 3 do\n delabOfNatCore (showType := (β getPPOption getPPNumericTypes))",
"start": [
1000,
1
],
"end": [
1006,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabNeg",
"code": "@[builtin_delab app.Neg.neg]\ndef delabNeg : Delab := whenPPOption getPPCoercions do\n delabNegIntCore (showType := (β getPPOption getPPNumericTypes))",
"start": [
1008,
1
],
"end": [
1014,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabHDiv",
"code": "@[builtin_delab app.HDiv.hDiv]\ndef delabHDiv : Delab := whenPPOption getPPCoercions do\n delabDivRatCore (showType := (β getPPOption getPPNumericTypes))",
"start": [
1016,
1
],
"end": [
1023,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabOfScientific",
"code": "@[builtin_delab app.OfScientific.ofScientific]\ndef delabOfScientific : Delab := whenPPOption getPPCoercions <| withOverApp 5 do\n let expr β getExpr\n guard <| expr.getAppNumArgs == 5\n let .lit (.natVal m) β pure (expr.getArg! 2) | failure\n let .lit (.natVal e) β pure (expr.getArg! 4) | failure\n let s β match expr.getArg! 3 with\n | Expr.const ``Bool.true _ => pure true\n | Expr.const ``Bool.false _ => pure false\n | _ => failure\n let str := toString m\n if s && e == str.length then\n return Syntax.mkScientificLit (\"0.\" ++ str)\n else if s && e < str.length then\n let mStr := str.extract 0 β¨str.length - eβ©\n let eStr := str.extract β¨str.length - eβ© β¨str.lengthβ©\n return Syntax.mkScientificLit (mStr ++ \".\" ++ eStr)\n else\n return Syntax.mkScientificLit (str ++ \"e\" ++ (if s then \"-\" else \"\") ++ toString e)",
"start": [
1026,
1
],
"end": [
1044,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabProj",
"code": "@[builtin_delab proj]\ndef delabProj : Delab := do\n let Expr.proj _ idx _ β getExpr | unreachable!\n let e β withProj delab\n let idx := Syntax.mkLit fieldIdxKind (toString (idx + 1));\n `($(e).$idx:fieldIdx)",
"start": [
1046,
1
],
"end": [
1059,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.coeDelaborator",
"code": "@[builtin_delab app]\ndef coeDelaborator : Delab := whenPPOption getPPCoercions do\n let e β getExpr\n let .const declName _ := e.getAppFn | failure\n let some info β Meta.getCoeFnInfo? declName | failure\n let n := e.getAppNumArgs\n withOverApp info.numArgs do\n match info.type with\n | .coe => `(β$(β withNaryArg info.coercee delab))\n | .coeFun =>\n if n = info.numArgs then\n `(β$(β withNaryArg info.coercee delab))\n else\n withNaryArg info.coercee delab\n | .coeSort => `(β₯$(β withNaryArg info.coercee delab))",
"start": [
1061,
1
],
"end": [
1080,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabDIte",
"code": "@[builtin_delab app.dite]\ndef delabDIte : Delab := whenPPOption getPPNotation <| withOverApp 5 do\n guard $ (β getExpr).getAppNumArgs == 5\n let c β withAppFn $ withAppFn $ withAppFn $ withAppArg delab\n let (t, h) β withAppFn $ withAppArg $ delabBranch none\n let (e, _) β withAppArg $ delabBranch h\n `(if $(mkIdent h):ident : $c then $t else $e)\nwhere\n delabBranch (h? : Option Name) : DelabM (Syntax Γ Name) := do\n let e β getExpr\n guard e.isLambda\n let h β match h? with\n | some h => return (β withBindingBody h delab, h)\n | none => withBindingBodyUnusedName fun h => do\n return (β delab, h.getId)",
"start": [
1082,
1
],
"end": [
1097,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabCond",
"code": "@[builtin_delab app.cond]\ndef delabCond : Delab := whenPPOption getPPNotation <| withOverApp 4 do\n guard $ (β getExpr).getAppNumArgs == 4\n let c β withAppFn $ withAppFn $ withAppArg delab\n let t β withAppFn $ withAppArg delab\n let e β withAppArg delab\n `(bif $c then $t else $e)",
"start": [
1099,
1
],
"end": [
1105,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabNamedPattern",
"code": "@[builtin_delab app.namedPattern]\ndef delabNamedPattern : Delab := do\n guard (β read).inPattern\n guard $ (β getExpr).getAppNumArgs == 4\n let x β withAppFn $ withAppFn $ withAppArg delab\n let p β withAppFn $ withAppArg delab\n let h β withAppArg delab\n guard x.raw.isIdent\n `($x:ident@$h:ident:$p:term)",
"start": [
1107,
1
],
"end": [
1117,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabSigmaCore",
"code": "def delabSigmaCore (sigma : Bool) : Delab := whenPPOption getPPNotation do\n guard $ (β getExpr).getAppNumArgs == 2\n guard $ (β getExpr).appArg!.isLambda\n withAppArg do\n let Ξ± β withBindingDomain delab\n let bodyExpr := (β getExpr).bindingBody!\n withBindingBodyUnusedName fun n => do\n let b β delab\n if bodyExpr.hasLooseBVars then\n if sigma then `(($n:ident : $Ξ±) Γ $b) else `(($n:ident : $Ξ±) Γ' $b)\n else\n if sigma then `((_ : $Ξ±) Γ $b) else `((_ : $Ξ±) Γ' $b)",
"start": [
1120,
1
],
"end": [
1131,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabSigma",
"code": "@[builtin_delab app.Sigma]\ndef delabSigma : Delab := delabSigmaCore (sigma := true)",
"start": [
1133,
1
],
"end": [
1134,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabPSigma",
"code": "@[builtin_delab app.PSigma]\ndef delabPSigma : Delab := delabSigmaCore (sigma := false)",
"start": [
1136,
1
],
"end": [
1137,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabDoElems",
"code": "partial def delabDoElems : DelabM (List Syntax) := do\n let e β getExpr\n if e.isAppOfArity ``Bind.bind 6 then\n let Ξ± := e.getAppArgs[2]!\n let ma β withAppFn $ withAppArg delab\n withAppArg do\n match (β getExpr) with\n | Expr.lam _ _ body _ =>\n withBindingBodyUnusedName fun n => do\n if body.hasLooseBVars then\n prependAndRec `(doElem|let $n:term β $ma:term)\n else if Ξ±.isConstOf ``Unit || Ξ±.isConstOf ``PUnit then\n prependAndRec `(doElem|$ma:term)\n else\n prependAndRec `(doElem|let _ β $ma:term)\n | _ => failure\n else if e.isLet then\n let Expr.letE n t v b _ β getExpr | unreachable!\n let n β getUnusedName n b\n let stxT β descend t 0 delab\n let stxV β descend v 1 delab\n withLetDecl n t v fun fvar =>\n let b := b.instantiate1 fvar\n descend b 2 $\n prependAndRec `(doElem|let $(mkIdent n) : $stxT := $stxV)\n else if e.isLetFun then\n let stxT β withNaryArg 0 delab\n let stxV β withNaryArg 2 delab\n withAppArg do\n match (β getExpr) with\n | Expr.lam .. =>\n withBindingBodyUnusedName fun n => do\n prependAndRec `(doElem|have $n:term : $stxT := $stxV)\n | _ => failure\n else\n let stx β delab\n return [β `(doElem|$stx:term)]\n where\n prependAndRec x : DelabM _ := List.cons <$> x <*> delabDoElems",
"start": [
1139,
1
],
"end": [
1179,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabDo",
"code": "@[builtin_delab app.Bind.bind]\ndef delabDo : Delab := whenPPOption getPPNotation do\n guard <| (β getExpr).isAppOfArity ``Bind.bind 6\n let elems β delabDoElems\n let items β elems.toArray.mapM (`(doSeqItem|$(Β·):doElem))\n `(do $items:doSeqItem*)",
"start": [
1181,
1
],
"end": [
1186,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.reifyName",
"code": "def reifyName : Expr β DelabM Name\n | .const ``Lean.Name.anonymous .. => return Name.anonymous\n | .app (.app (.const ``Lean.Name.str ..) n) (.lit (.strVal s)) => return (β reifyName n).mkStr s\n | .app (.app (.const ``Lean.Name.num ..) n) (.lit (.natVal i)) => return (β reifyName n).mkNum i\n | _ => failure",
"start": [
1188,
1
],
"end": [
1192,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabNameMkStr",
"code": "@[builtin_delab app.Lean.Name.str]\ndef delabNameMkStr : Delab := whenPPOption getPPNotation do\n let n β reifyName (β getExpr)\n return mkNode ``Lean.Parser.Term.quotedName #[Syntax.mkNameLit s!\"`{n}\"]",
"start": [
1194,
1
],
"end": [
1198,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabNameMkNum",
"code": "@[builtin_delab app.Lean.Name.num]\ndef delabNameMkNum : Delab := delabNameMkStr",
"start": [
1200,
1
],
"end": [
1201,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.declSigWithId",
"code": "@[run_builtin_parser_attribute_hooks]\ndef declSigWithId := leading_parser termParser maxPrec >> declSig",
"start": [
1204,
1
],
"end": [
1206,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.evalSyntaxConstantUnsafe",
"code": "private unsafe def evalSyntaxConstantUnsafe (env : Environment) (opts : Options) (constName : Name) : ExceptT String Id Syntax :=\n env.evalConstCheck Syntax opts ``Syntax constName",
"start": [
1208,
1
],
"end": [
1209,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.evalSyntaxConstant",
"code": "@[implemented_by evalSyntaxConstantUnsafe]\nprivate opaque evalSyntaxConstant (env : Environment) (opts : Options) (constName : Name) : ExceptT String Id Syntax := throw \"\"",
"start": [
1211,
1
],
"end": [
1212,
129
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.Delaborator.delabConstWithSignature",
"code": "partial def delabConstWithSignature (universes : Bool := true) : Delab := do\n let e β getExpr\n let idStx β descend e 0 <|\n withOptions (pp.universes.set Β· universes |> (pp.fullNames.set Β· true)) <|\n delabConst\n descend (β inferType e) 1 <|\n delabParams {} idStx #[]\nwhere\n \n delabTy : DelabM Term := withOptions (pp.piBinderTypes.set Β· true) delab\n \n delabParams (bindingNames : NameSet) (idStx : Ident) (groups : TSyntaxArray ``bracketedBinder) := do\n let e β getExpr\n if e.isForall && e.binderInfo.isInstImplicit && e.bindingName!.hasMacroScopes then\n let group β withBindingDomain do `(bracketedBinderF|[$(β delabTy)])\n withBindingBody e.bindingName! <| delabParams bindingNames idStx (groups.push group)\n else if e.isForall && !e.bindingName!.hasMacroScopes && !bindingNames.contains e.bindingName! then\n delabParamsAux bindingNames idStx groups #[]\n else\n let type β delabTy\n `(declSigWithId| $idStx:ident $groups* : $type)\n \n delabParamsAux (bindingNames : NameSet) (idStx : Ident) (groups : TSyntaxArray ``bracketedBinder) (curIds : Array Ident) := do\n let e@(.forallE n d e' i) β getExpr | unreachable!\n let bindingNames := bindingNames.insert n\n let stxN := mkIdent n\n let curIds := curIds.push β¨stxNβ©\n if shouldGroupWithNext bindingNames e e' then\n withBindingBody n <| delabParamsAux bindingNames idStx groups curIds\n else\n let group β withBindingDomain do\n match i with\n | .implicit => `(bracketedBinderF|{$curIds* : $(β delabTy)})\n | .strictImplicit => `(bracketedBinderF|β¦$curIds* : $(β delabTy)β¦)\n | .instImplicit => `(bracketedBinderF|[$stxN : $(β delabTy)])\n | _ =>\n if d.isOptParam then\n `(bracketedBinderF|($curIds* : $(β withAppFn <| withAppArg delabTy) := $(β withAppArg delabTy)))\n else if let some (.const tacticDecl _) := d.getAutoParamTactic? then\n let tacticSyntax β ofExcept <| evalSyntaxConstant (β getEnv) (β getOptions) tacticDecl\n `(bracketedBinderF|($curIds* : $(β withAppFn <| withAppArg delabTy) := by $tacticSyntax))\n else\n `(bracketedBinderF|($curIds* : $(β delabTy)))\n withBindingBody n <| delabParams bindingNames idStx (groups.push group)\n \n shouldGroupWithNext (bindingNames : NameSet) (e e' : Expr) : Bool :=\n e'.isForall &&\n !e'.bindingName!.hasMacroScopes &&\n !bindingNames.contains e'.bindingName! &&\n e.binderInfo == e'.binderInfo &&\n e.bindingDomain! == e'.bindingDomain! &&\n e'.binderInfo != BinderInfo.instImplicit",
"start": [
1214,
1
],
"end": [
1293,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/ReduceEval.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Offset.lean"
] | [
{
"full_name": "Lean.Meta.ReduceEval",
"code": "class ReduceEval (Ξ± : Type) where\n reduceEval : Expr β MetaM Ξ±",
"start": [
13,
1
],
"end": [
14,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.reduceEval",
"code": "def reduceEval [ReduceEval Ξ±] (e : Expr) : MetaM Ξ± :=\n withAtLeastTransparency TransparencyMode.default $\n ReduceEval.reduceEval e",
"start": [
16,
1
],
"end": [
18,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwFailedToEval",
"code": "private def throwFailedToEval (e : Expr) : MetaM Ξ± :=\n throwError \"reduceEval: failed to evaluate argument{indentExpr e}\"",
"start": [
20,
1
],
"end": [
21,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.evalName",
"code": "private partial def evalName (e : Expr) : MetaM Name := do\n let e β whnf e\n let Expr.const c _ β pure e.getAppFn | throwFailedToEval e\n let nargs := e.getAppNumArgs\n if c == ``Lean.Name.anonymous && nargs == 0 then pure Name.anonymous\n else if c == ``Lean.Name.str && nargs == 2 then do\n let n β evalName $ e.getArg! 0\n let s β reduceEval $ e.getArg! 1\n pure $ Name.mkStr n s\n else if c == ``Lean.Name.num && nargs == 2 then do\n let n β evalName $ e.getArg! 0\n let u β reduceEval $ e.getArg! 1\n pure $ Name.mkNum n u\n else\n throwFailedToEval e",
"start": [
43,
1
],
"end": [
57,
24
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Clear.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Util.lean"
] | [
{
"full_name": "Lean.MVarId.clear",
"code": "def _root_.Lean.MVarId.clear (mvarId : MVarId) (fvarId : FVarId) : MetaM MVarId :=\n mvarId.withContext do\n mvarId.checkNotAssigned `clear\n let lctx β getLCtx\n unless lctx.contains fvarId do\n throwTacticEx `clear mvarId m!\"unknown variable '{mkFVar fvarId}'\"\n let tag β mvarId.getTag\n lctx.forM fun localDecl => do\n unless localDecl.fvarId == fvarId do\n if (β localDeclDependsOn localDecl fvarId) then\n throwTacticEx `clear mvarId m!\"variable '{localDecl.toExpr}' depends on '{mkFVar fvarId}'\"\n let mvarDecl β mvarId.getDecl\n if (β exprDependsOn mvarDecl.type fvarId) then\n throwTacticEx `clear mvarId m!\"target depends on '{mkFVar fvarId}'\"\n let lctx := lctx.erase fvarId\n let localInsts β getLocalInstances\n let localInsts := match localInsts.findIdx? fun localInst => localInst.fvar.fvarId! == fvarId with\n | none => localInsts\n | some idx => localInsts.eraseIdx idx\n let newMVar β mkFreshExprMVarAt lctx localInsts mvarDecl.type MetavarKind.syntheticOpaque tag\n mvarId.assign newMVar\n pure newMVar.mvarId!",
"start": [
11,
1
],
"end": [
35,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.clear",
"code": "@[deprecated MVarId.clear (since := \"2022-07-15\")]\ndef clear (mvarId : MVarId) (fvarId : FVarId) : MetaM MVarId :=\n mvarId.clear fvarId",
"start": [
38,
1
],
"end": [
40,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.tryClear",
"code": "def _root_.Lean.MVarId.tryClear (mvarId : MVarId) (fvarId : FVarId) : MetaM MVarId :=\n mvarId.clear fvarId <|> pure mvarId",
"start": [
42,
1
],
"end": [
47,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.tryClear",
"code": "@[deprecated MVarId.tryClear (since := \"2022-07-15\")]\ndef tryClear (mvarId : MVarId) (fvarId : FVarId) : MetaM MVarId :=\n mvarId.tryClear fvarId",
"start": [
49,
1
],
"end": [
51,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.tryClearMany",
"code": "def _root_.Lean.MVarId.tryClearMany (mvarId : MVarId) (fvarIds : Array FVarId) : MetaM MVarId := do\n fvarIds.foldrM (init := mvarId) fun fvarId mvarId => mvarId.tryClear fvarId",
"start": [
53,
1
],
"end": [
57,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.tryClearMany",
"code": "@[deprecated MVarId.tryClearMany (since := \"2022-07-15\")]\ndef tryClearMany (mvarId : MVarId) (fvarIds : Array FVarId) : MetaM MVarId := do\n mvarId.tryClearMany fvarIds",
"start": [
59,
1
],
"end": [
61,
30
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array/DecidableEq.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean",
".lake/packages/lean4/src/lean/Init/ByCases.lean"
] | [
{
"full_name": "Array.eq_of_isEqvAux",
"code": "theorem eq_of_isEqvAux [DecidableEq Ξ±] (a b : Array Ξ±) (hsz : a.size = b.size) (i : Nat) (hi : i β€ a.size) (heqv : Array.isEqvAux a b hsz (fun x y => x = y) i) (j : Nat) (low : i β€ j) (high : j < a.size) : a[j] = b[j]'(hsz βΈ high)",
"start": [
12,
1
],
"end": [
24,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.eq_of_isEqv",
"code": "theorem eq_of_isEqv [DecidableEq Ξ±] (a b : Array Ξ±) : Array.isEqv a b (fun x y => x = y) β a = b",
"start": [
27,
1
],
"end": [
34,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.isEqvAux_self",
"code": "theorem isEqvAux_self [DecidableEq Ξ±] (a : Array Ξ±) (i : Nat) : Array.isEqvAux a a rfl (fun x y => x = y) i = true",
"start": [
36,
1
],
"end": [
42,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.isEqv_self",
"code": "theorem isEqv_self [DecidableEq Ξ±] (a : Array Ξ±) : Array.isEqv a a (fun x y => x = y) = true",
"start": [
44,
1
],
"end": [
45,
30
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array/Lemmas.lean | [
".lake/packages/lean4/src/lean/Init/TacticsExtra.lean",
".lake/packages/lean4/src/lean/Init/Data/Fin/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/MinMax.lean",
".lake/packages/lean4/src/lean/Init/Data/List/Lemmas.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/Mem.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/Lemmas.lean"
] | [
{
"full_name": "Array.singleton_def",
"code": "@[simp] theorem singleton_def (v : Ξ±) : singleton v = #[v]",
"start": [
24,
1
],
"end": [
24,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.toArray_data",
"code": "@[simp] theorem toArray_data : (a : Array Ξ±) β a.data.toArray = a",
"start": [
26,
1
],
"end": [
27,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.data_length",
"code": "@[simp] theorem data_length {l : Array Ξ±} : l.data.length = l.size",
"start": [
29,
1
],
"end": [
29,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mkEmpty_eq",
"code": "@[simp] theorem mkEmpty_eq (Ξ± n) : @mkEmpty Ξ± n = #[]",
"start": [
31,
1
],
"end": [
31,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_toArray",
"code": "@[simp] theorem size_toArray (as : List Ξ±) : as.toArray.size = as.length",
"start": [
33,
1
],
"end": [
33,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_mk",
"code": "@[simp] theorem size_mk (as : List Ξ±) : (Array.mk as).size = as.length",
"start": [
35,
1
],
"end": [
35,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_eq_data_getElem",
"code": "theorem getElem_eq_data_getElem (a : Array Ξ±) (h : i < a.size) : a[i] = a.data[i]",
"start": [
37,
1
],
"end": [
38,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_eq_data_get",
"code": "@[deprecated getElem_eq_data_getElem (since := \"2024-06-12\")]\ntheorem getElem_eq_data_get (a : Array Ξ±) (h : i < a.size) : a[i] = a.data.get β¨i, hβ©",
"start": [
40,
1
],
"end": [
42,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldlM_eq_foldlM_data.aux",
"code": "theorem foldlM_eq_foldlM_data.aux [Monad m]\n (f : Ξ² β Ξ± β m Ξ²) (arr : Array Ξ±) (i j) (H : arr.size β€ i + j) (b) :\n foldlM.loop f arr arr.size (Nat.le_refl _) i j b = (arr.data.drop j).foldlM f b",
"start": [
44,
1
],
"end": [
54,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldlM_eq_foldlM_data",
"code": "theorem foldlM_eq_foldlM_data [Monad m]\n (f : Ξ² β Ξ± β m Ξ²) (init : Ξ²) (arr : Array Ξ±) :\n arr.foldlM f init = arr.data.foldlM f init",
"start": [
56,
1
],
"end": [
59,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldl_eq_foldl_data",
"code": "theorem foldl_eq_foldl_data (f : Ξ² β Ξ± β Ξ²) (init : Ξ²) (arr : Array Ξ±) :\n arr.foldl f init = arr.data.foldl f init",
"start": [
61,
1
],
"end": [
63,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldrM_eq_reverse_foldlM_data.aux",
"code": "theorem foldrM_eq_reverse_foldlM_data.aux [Monad m]\n (f : Ξ± β Ξ² β m Ξ²) (arr : Array Ξ±) (init : Ξ²) (i h) :\n (arr.data.take i).reverse.foldlM (fun x y => f y x) init = foldrM.fold f arr 0 i h init",
"start": [
65,
1
],
"end": [
71,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldrM_eq_reverse_foldlM_data",
"code": "theorem foldrM_eq_reverse_foldlM_data [Monad m] (f : Ξ± β Ξ² β m Ξ²) (init : Ξ²) (arr : Array Ξ±) :\n arr.foldrM f init = arr.data.reverse.foldlM (fun x y => f y x) init",
"start": [
73,
1
],
"end": [
78,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldrM_eq_foldrM_data",
"code": "theorem foldrM_eq_foldrM_data [Monad m]\n (f : Ξ± β Ξ² β m Ξ²) (init : Ξ²) (arr : Array Ξ±) :\n arr.foldrM f init = arr.data.foldrM f init",
"start": [
80,
1
],
"end": [
83,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldr_eq_foldr_data",
"code": "theorem foldr_eq_foldr_data (f : Ξ± β Ξ² β Ξ²) (init : Ξ²) (arr : Array Ξ±) :\n arr.foldr f init = arr.data.foldr f init",
"start": [
85,
1
],
"end": [
87,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.push_data",
"code": "@[simp] theorem push_data (arr : Array Ξ±) (a : Ξ±) : (arr.push a).data = arr.data ++ [a]",
"start": [
89,
1
],
"end": [
90,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldrM_push",
"code": "theorem foldrM_push [Monad m] (f : Ξ± β Ξ² β m Ξ²) (init : Ξ²) (arr : Array Ξ±) (a : Ξ±) :\n (arr.push a).foldrM f init = f a init >>= arr.foldrM f",
"start": [
92,
1
],
"end": [
94,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldrM_push'",
"code": "@[simp] theorem foldrM_push' [Monad m] (f : Ξ± β Ξ² β m Ξ²) (init : Ξ²) (arr : Array Ξ±) (a : Ξ±) :\n (arr.push a).foldrM f init (start := arr.size + 1) = f a init >>= arr.foldrM f",
"start": [
96,
1
],
"end": [
98,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldr_push",
"code": "theorem foldr_push (f : Ξ± β Ξ² β Ξ²) (init : Ξ²) (arr : Array Ξ±) (a : Ξ±) :\n (arr.push a).foldr f init = arr.foldr f (f a init)",
"start": [
100,
1
],
"end": [
101,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldr_push'",
"code": "@[simp] theorem foldr_push' (f : Ξ± β Ξ² β Ξ²) (init : Ξ²) (arr : Array Ξ±) (a : Ξ±) :\n (arr.push a).foldr f init (start := arr.size + 1) = arr.foldr f (f a init)",
"start": [
103,
1
],
"end": [
104,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.toListAppend_eq",
"code": "@[simp] theorem toListAppend_eq (arr : Array Ξ±) (l) : arr.toListAppend l = arr.data ++ l",
"start": [
106,
1
],
"end": [
107,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.toList_eq",
"code": "@[simp] theorem toList_eq (arr : Array Ξ±) : arr.toList = arr.data",
"start": [
109,
1
],
"end": [
110,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.toListRev",
"code": "@[inline] def toListRev (arr : Array Ξ±) : List Ξ± := arr.foldl (fun l t => t :: l) []",
"start": [
112,
1
],
"end": [
113,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.toListRev_eq",
"code": "@[simp] theorem toListRev_eq (arr : Array Ξ±) : arr.toListRev = arr.data.reverse",
"start": [
115,
1
],
"end": [
116,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_push_lt",
"code": "theorem get_push_lt (a : Array Ξ±) (x : Ξ±) (i : Nat) (h : i < a.size) :\n have : i < (a.push x).size := by simp [*, Nat.lt_succ_of_le, Nat.le_of_lt]\n (a.push x)[i] = a[i]",
"start": [
118,
1
],
"end": [
121,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_push_eq",
"code": "@[simp] theorem get_push_eq (a : Array Ξ±) (x : Ξ±) : (a.push x)[a.size] = x",
"start": [
123,
1
],
"end": [
125,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_push",
"code": "theorem get_push (a : Array Ξ±) (x : Ξ±) (i : Nat) (h : i < (a.push x).size) :\n (a.push x)[i] = if h : i < a.size then a[i] else x",
"start": [
127,
1
],
"end": [
132,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mapM_eq_foldlM",
"code": "theorem mapM_eq_foldlM [Monad m] [LawfulMonad m] (f : Ξ± β m Ξ²) (arr : Array Ξ±) :\n arr.mapM f = arr.foldlM (fun bs a => bs.push <$> f a) #[]",
"start": [
134,
1
],
"end": [
146,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.map_data",
"code": "@[simp] theorem map_data (f : Ξ± β Ξ²) (arr : Array Ξ±) : (arr.map f).data = arr.data.map f",
"start": [
148,
1
],
"end": [
153,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_map",
"code": "@[simp] theorem size_map (f : Ξ± β Ξ²) (arr : Array Ξ±) : (arr.map f).size = arr.size",
"start": [
155,
1
],
"end": [
157,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.pop_data",
"code": "@[simp] theorem pop_data (arr : Array Ξ±) : arr.pop.data = arr.data.dropLast",
"start": [
159,
1
],
"end": [
159,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.append_eq_append",
"code": "@[simp] theorem append_eq_append (arr arr' : Array Ξ±) : arr.append arr' = arr ++ arr'",
"start": [
161,
1
],
"end": [
161,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.append_data",
"code": "@[simp] theorem append_data (arr arr' : Array Ξ±) :\n (arr ++ arr').data = arr.data ++ arr'.data",
"start": [
163,
1
],
"end": [
167,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.appendList_eq_append",
"code": "@[simp] theorem appendList_eq_append\n (arr : Array Ξ±) (l : List Ξ±) : arr.appendList l = arr ++ l",
"start": [
169,
1
],
"end": [
170,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.appendList_data",
"code": "@[simp] theorem appendList_data (arr : Array Ξ±) (l : List Ξ±) :\n (arr ++ l).data = arr.data ++ l",
"start": [
172,
1
],
"end": [
175,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.appendList_nil",
"code": "@[simp] theorem appendList_nil (arr : Array Ξ±) : arr ++ ([] : List Ξ±) = arr",
"start": [
177,
1
],
"end": [
177,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.appendList_cons",
"code": "@[simp] theorem appendList_cons (arr : Array Ξ±) (a : Ξ±) (l : List Ξ±) :\n arr ++ (a :: l) = arr.push a ++ l",
"start": [
179,
1
],
"end": [
180,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldl_data_eq_bind",
"code": "theorem foldl_data_eq_bind (l : List Ξ±) (acc : Array Ξ²)\n (F : Array Ξ² β Ξ± β Array Ξ²) (G : Ξ± β List Ξ²)\n (H : β acc a, (F acc a).data = acc.data ++ G a) :\n (l.foldl F acc).data = acc.data ++ l.bind G",
"start": [
182,
1
],
"end": [
186,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldl_data_eq_map",
"code": "theorem foldl_data_eq_map (l : List Ξ±) (acc : Array Ξ²) (G : Ξ± β Ξ²) :\n (l.foldl (fun acc a => acc.push (G a)) acc).data = acc.data ++ l.map G",
"start": [
188,
1
],
"end": [
190,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_uset",
"code": "theorem size_uset (a : Array Ξ±) (v i h) : (uset a i v h).size = a.size",
"start": [
192,
1
],
"end": [
192,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.anyM_eq_anyM_loop",
"code": "theorem anyM_eq_anyM_loop [Monad m] (p : Ξ± β m Bool) (as : Array Ξ±) (start stop) :\n anyM p as start stop = anyM.loop p as (min stop as.size) (Nat.min_le_right ..) start",
"start": [
194,
1
],
"end": [
196,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.anyM_stop_le_start",
"code": "theorem anyM_stop_le_start [Monad m] (p : Ξ± β m Bool) (as : Array Ξ±) (start stop)\n (h : min stop as.size β€ start) : anyM p as start stop = pure false",
"start": [
198,
1
],
"end": [
200,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_def",
"code": "theorem mem_def (a : Ξ±) (as : Array Ξ±) : a β as β a β as.data",
"start": [
202,
1
],
"end": [
203,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_eq_getElem",
"code": "@[simp] theorem get_eq_getElem (a : Array Ξ±) (i : Fin _) : a.get i = a[i.1]",
"start": [
207,
1
],
"end": [
207,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_lt",
"code": "theorem getElem?_lt\n (a : Array Ξ±) {i : Nat} (h : i < a.size) : a[i]? = some (a[i])",
"start": [
209,
1
],
"end": [
210,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_ge",
"code": "theorem getElem?_ge\n (a : Array Ξ±) {i : Nat} (h : i β₯ a.size) : a[i]? = none",
"start": [
212,
1
],
"end": [
213,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_eq_getElem?",
"code": "@[simp] theorem get?_eq_getElem? (a : Array Ξ±) (i : Nat) : a.get? i = a[i]?",
"start": [
215,
1
],
"end": [
215,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_len_le",
"code": "theorem getElem?_len_le (a : Array Ξ±) {i : Nat} (h : a.size β€ i) : a[i]? = none",
"start": [
217,
1
],
"end": [
218,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getD_get?",
"code": "theorem getD_get? (a : Array Ξ±) (i : Nat) (d : Ξ±) :\n Option.getD a[i]? d = if p : i < a.size then a[i]'p else d",
"start": [
220,
1
],
"end": [
226,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getD_eq_get?",
"code": "@[simp] theorem getD_eq_get? (a : Array Ξ±) (n d) : a.getD n d = (a[n]?).getD d",
"start": [
228,
1
],
"end": [
229,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get!_eq_getD",
"code": "theorem get!_eq_getD [Inhabited Ξ±] (a : Array Ξ±) : a.get! n = a.getD n default",
"start": [
231,
1
],
"end": [
231,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get!_eq_getElem?",
"code": "@[simp] theorem get!_eq_getElem? [Inhabited Ξ±] (a : Array Ξ±) (i : Nat) : a.get! i = (a.get? i).getD default",
"start": [
233,
1
],
"end": [
234,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_set_eq",
"code": "@[simp] theorem getElem_set_eq (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) {j : Nat}\n (eq : i.val = j) (p : j < (a.set i v).size) :\n (a.set i v)[j]'p = v",
"start": [
238,
1
],
"end": [
241,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_set_ne",
"code": "@[simp] theorem getElem_set_ne (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) {j : Nat} (pj : j < (a.set i v).size)\n (h : i.val β j) : (a.set i v)[j]'pj = a[j]'(size_set a i v βΈ pj)",
"start": [
243,
1
],
"end": [
245,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_set",
"code": "theorem getElem_set (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) (j : Nat)\n (h : j < (a.set i v).size) :\n (a.set i v)[j]'h = if i = j then v else a[j]'(size_set a i v βΈ h)",
"start": [
247,
1
],
"end": [
250,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_set_eq",
"code": "@[simp] theorem getElem?_set_eq (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) :\n (a.set i v)[i.1]? = v",
"start": [
252,
1
],
"end": [
253,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_set_ne",
"code": "@[simp] theorem getElem?_set_ne (a : Array Ξ±) (i : Fin a.size) {j : Nat} (v : Ξ±)\n (ne : i.val β j) : (a.set i v)[j]? = a[j]?",
"start": [
255,
1
],
"end": [
257,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.set!_is_setD",
"code": "@[simp] theorem set!_is_setD : @set! = @setD",
"start": [
261,
1
],
"end": [
261,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_setD",
"code": "@[simp] theorem size_setD (a : Array Ξ±) (index : Nat) (val : Ξ±) :\n (Array.setD a index val).size = a.size",
"start": [
263,
1
],
"end": [
268,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_setD_eq",
"code": "@[simp] theorem getElem_setD_eq (a : Array Ξ±) {i : Nat} (v : Ξ±) (h : _) :\n (setD a i v)[i]'h = v",
"start": [
270,
1
],
"end": [
273,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_setD_eq",
"code": "@[simp]\ntheorem getElem?_setD_eq (a : Array Ξ±) {i : Nat} (p : i < a.size) (v : Ξ±) : (a.setD i v)[i]? = some v",
"start": [
275,
1
],
"end": [
277,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getD_get?_setD",
"code": "@[simp] theorem getD_get?_setD (a : Array Ξ±) (i : Nat) (v d : Ξ±) :\n Option.getD (setD a i v)[i]? d = if i < a.size then v else d",
"start": [
279,
1
],
"end": [
283,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_ofFn_go",
"code": "@[simp] theorem size_ofFn_go {n} (f : Fin n β Ξ±) (i acc) :\n (ofFn.go f i acc).size = acc.size + (n - i)",
"start": [
287,
1
],
"end": [
298,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_ofFn",
"code": "@[simp] theorem size_ofFn (f : Fin n β Ξ±) : (ofFn f).size = n",
"start": [
300,
1
],
"end": [
300,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_ofFn_go",
"code": "theorem getElem_ofFn_go (f : Fin n β Ξ±) (i) {acc k}\n (hki : k < n) (hin : i β€ n) (hi : i = acc.size)\n (hacc : β j, β hj : j < acc.size, acc[j] = f β¨j, Nat.lt_of_lt_of_le hj (hi βΈ hin)β©) :\n haveI : acc.size + (n - acc.size) = n := Nat.add_sub_cancel' (hi βΈ hin)\n (ofFn.go f i acc)[k]'(by simp [*]) = f β¨k, hkiβ©",
"start": [
302,
1
],
"end": [
318,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_ofFn",
"code": "@[simp] theorem getElem_ofFn (f : Fin n β Ξ±) (i : Nat) (h) :\n (ofFn f)[i] = f β¨i, size_ofFn f βΈ hβ©",
"start": [
320,
1
],
"end": [
322,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mkArray_data",
"code": "@[simp] theorem mkArray_data (n : Nat) (v : Ξ±) : (mkArray n v).data = List.replicate n v",
"start": [
324,
1
],
"end": [
326,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_mkArray",
"code": "@[simp] theorem getElem_mkArray (n : Nat) (v : Ξ±) (h : i < (mkArray n v).size) :\n (mkArray n v)[i] = v",
"start": [
328,
1
],
"end": [
329,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_data",
"code": "theorem mem_data {a : Ξ±} {l : Array Ξ±} : a β l.data β a β l",
"start": [
331,
1
],
"end": [
333,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.not_mem_nil",
"code": "theorem not_mem_nil (a : Ξ±) : Β¬ a β #[]",
"start": [
335,
1
],
"end": [
335,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_mem",
"code": "theorem getElem?_mem {l : Array Ξ±} {i : Fin l.size} : l[i] β l",
"start": [
337,
1
],
"end": [
341,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_fin_eq_data_get",
"code": "theorem getElem_fin_eq_data_get (a : Array Ξ±) (i : Fin _) : a[i] = a.data.get i",
"start": [
343,
1
],
"end": [
343,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.ugetElem_eq_getElem",
"code": "@[simp] theorem ugetElem_eq_getElem (a : Array Ξ±) {i : USize} (h : i.toNat < a.size) :\n a[i] = a[i.toNat]",
"start": [
345,
1
],
"end": [
346,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_eq_getElem",
"code": "theorem getElem?_eq_getElem (a : Array Ξ±) (i : Nat) (h : i < a.size) : a[i]? = a[i]",
"start": [
348,
1
],
"end": [
349,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_len_le",
"code": "theorem get?_len_le (a : Array Ξ±) (i : Nat) (h : a.size β€ i) : a[i]? = none",
"start": [
351,
1
],
"end": [
352,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_mem_data",
"code": "theorem getElem_mem_data (a : Array Ξ±) (h : i < a.size) : a[i] β a.data",
"start": [
354,
1
],
"end": [
355,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem?_eq_data_get?",
"code": "theorem getElem?_eq_data_get? (a : Array Ξ±) (i : Nat) : a[i]? = a.data.get? i",
"start": [
357,
1
],
"end": [
358,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_eq_data_get?",
"code": "theorem get?_eq_data_get? (a : Array Ξ±) (i : Nat) : a.get? i = a.data.get? i",
"start": [
360,
1
],
"end": [
361,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get!_eq_get?",
"code": "theorem get!_eq_get? [Inhabited Ξ±] (a : Array Ξ±) : a.get! n = (a.get? n).getD default",
"start": [
363,
1
],
"end": [
364,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.back_eq_back?",
"code": "@[simp] theorem back_eq_back? [Inhabited Ξ±] (a : Array Ξ±) : a.back = a.back?.getD default",
"start": [
366,
1
],
"end": [
367,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.back?_push",
"code": "@[simp] theorem back?_push (a : Array Ξ±) : (a.push x).back? = some x",
"start": [
369,
1
],
"end": [
370,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.back_push",
"code": "theorem back_push [Inhabited Ξ±] (a : Array Ξ±) : (a.push x).back = x",
"start": [
372,
1
],
"end": [
372,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_push_lt",
"code": "theorem get?_push_lt (a : Array Ξ±) (x : Ξ±) (i : Nat) (h : i < a.size) :\n (a.push x)[i]? = some a[i]",
"start": [
374,
1
],
"end": [
376,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_push_eq",
"code": "theorem get?_push_eq (a : Array Ξ±) (x : Ξ±) : (a.push x)[a.size]? = some x",
"start": [
378,
1
],
"end": [
379,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_push",
"code": "theorem get?_push {a : Array Ξ±} : (a.push x)[i]? = if i = a.size then some x else a[i]?",
"start": [
381,
1
],
"end": [
394,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_size",
"code": "@[simp] theorem get?_size {a : Array Ξ±} : a[a.size]? = none",
"start": [
396,
1
],
"end": [
397,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.data_set",
"code": "@[simp] theorem data_set (a : Array Ξ±) (i v) : (a.set i v).data = a.data.set i.1 v",
"start": [
399,
1
],
"end": [
399,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_set_eq",
"code": "theorem get_set_eq (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) :\n (a.set i v)[i.1] = v",
"start": [
401,
1
],
"end": [
403,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_set_eq",
"code": "theorem get?_set_eq (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) :\n (a.set i v)[i.1]? = v",
"start": [
405,
1
],
"end": [
406,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_set_ne",
"code": "@[simp] theorem get?_set_ne (a : Array Ξ±) (i : Fin a.size) {j : Nat} (v : Ξ±)\n (h : i.1 β j) : (a.set i v)[j]? = a[j]?",
"start": [
408,
1
],
"end": [
410,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_set",
"code": "theorem get?_set (a : Array Ξ±) (i : Fin a.size) (j : Nat) (v : Ξ±) :\n (a.set i v)[j]? = if i.1 = j then some v else a[j]?",
"start": [
412,
1
],
"end": [
414,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_set",
"code": "theorem get_set (a : Array Ξ±) (i : Fin a.size) (j : Nat) (hj : j < a.size) (v : Ξ±) :\n (a.set i v)[j]'(by simp [*]) = if i = j then v else a[j]",
"start": [
416,
1
],
"end": [
418,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_set_ne",
"code": "@[simp] theorem get_set_ne (a : Array Ξ±) (i : Fin a.size) {j : Nat} (v : Ξ±) (hj : j < a.size)\n (h : i.1 β j) : (a.set i v)[j]'(by simp [*]) = a[j]",
"start": [
420,
1
],
"end": [
422,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_setD",
"code": "theorem getElem_setD (a : Array Ξ±) (i : Nat) (v : Ξ±) (h : i < (setD a i v).size) :\n (setD a i v)[i] = v",
"start": [
424,
1
],
"end": [
427,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.set_set",
"code": "theorem set_set (a : Array Ξ±) (i : Fin a.size) (v v' : Ξ±) :\n (a.set i v).set β¨i, by simp [i.2]β© v' = a.set i v'",
"start": [
429,
1
],
"end": [
430,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.fin_cast_val",
"code": "private theorem fin_cast_val (e : n = n') (i : Fin n) : e βΈ i = β¨i.1, e βΈ i.2β©",
"start": [
432,
1
],
"end": [
432,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.swap_def",
"code": "theorem swap_def (a : Array Ξ±) (i j : Fin a.size) :\n a.swap i j = (a.set i (a.get j)).set β¨j.1, by simp [j.2]β© (a.get i)",
"start": [
434,
1
],
"end": [
436,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.data_swap",
"code": "theorem data_swap (a : Array Ξ±) (i j : Fin a.size) :\n (a.swap i j).data = (a.data.set i (a.get j)).set j (a.get i)",
"start": [
438,
1
],
"end": [
439,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get?_swap",
"code": "theorem get?_swap (a : Array Ξ±) (i j : Fin a.size) (k : Nat) : (a.swap i j)[k]? =\n if j = k then some a[i.1] else if i = k then some a[j.1] else a[k]?",
"start": [
441,
1
],
"end": [
443,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.swapAt_def",
"code": "@[simp] theorem swapAt_def (a : Array Ξ±) (i : Fin a.size) (v : Ξ±) :\n a.swapAt i v = (a[i.1], a.set i v)",
"start": [
445,
1
],
"end": [
446,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.swapAt!_def",
"code": "theorem swapAt!_def (a : Array Ξ±) (i : Nat) (v : Ξ±) (h : i < a.size) :\n a.swapAt! i v = (a[i], a.set β¨i, hβ© v)",
"start": [
449,
1
],
"end": [
450,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.data_pop",
"code": "@[simp] theorem data_pop (a : Array Ξ±) : a.pop.data = a.data.dropLast",
"start": [
452,
1
],
"end": [
452,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.pop_empty",
"code": "@[simp] theorem pop_empty : (#[] : Array Ξ±).pop = #[]",
"start": [
454,
1
],
"end": [
454,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.pop_push",
"code": "@[simp] theorem pop_push (a : Array Ξ±) : (a.push x).pop = a",
"start": [
456,
1
],
"end": [
456,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_pop",
"code": "@[simp] theorem getElem_pop (a : Array Ξ±) (i : Nat) (hi : i < a.pop.size) :\n a.pop[i] = a[i]'(Nat.lt_of_lt_of_le (a.size_pop βΈ hi) (Nat.sub_le _ _))",
"start": [
458,
1
],
"end": [
460,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.eq_empty_of_size_eq_zero",
"code": "theorem eq_empty_of_size_eq_zero {as : Array Ξ±} (h : as.size = 0) : as = #[]",
"start": [
462,
1
],
"end": [
465,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.eq_push_pop_back_of_size_ne_zero",
"code": "theorem eq_push_pop_back_of_size_ne_zero [Inhabited Ξ±] {as : Array Ξ±} (h : as.size β 0) :\n as = as.pop.push as.back",
"start": [
467,
1
],
"end": [
477,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.eq_push_of_size_ne_zero",
"code": "theorem eq_push_of_size_ne_zero {as : Array Ξ±} (h : as.size β 0) :\n β (bs : Array Ξ±) (c : Ξ±), as = bs.push c",
"start": [
479,
1
],
"end": [
482,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_eq_length_data",
"code": "theorem size_eq_length_data (as : Array Ξ±) : as.size = as.data.length",
"start": [
484,
1
],
"end": [
484,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_swap!",
"code": "@[simp] theorem size_swap! (a : Array Ξ±) (i j) :\n (a.swap! i j).size = a.size",
"start": [
486,
1
],
"end": [
487,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_reverse",
"code": "@[simp] theorem size_reverse (a : Array Ξ±) : a.reverse.size = a.size",
"start": [
489,
1
],
"end": [
497,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_range",
"code": "@[simp] theorem size_range {n : Nat} : (range n).size = n",
"start": [
499,
1
],
"end": [
506,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.reverse_data",
"code": "@[simp] theorem reverse_data (a : Array Ξ±) : a.reverse.data = a.data.reverse",
"start": [
509,
1
],
"end": [
548,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldl_induction",
"code": "theorem foldl_induction\n {as : Array Ξ±} (motive : Nat β Ξ² β Prop) {init : Ξ²} (h0 : motive 0 init) {f : Ξ² β Ξ± β Ξ²}\n (hf : β i : Fin as.size, β b, motive i.1 b β motive (i.1 + 1) (f b as[i])) :\n motive as.size (as.foldl f init)",
"start": [
554,
1
],
"end": [
566,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.foldr_induction",
"code": "theorem foldr_induction\n {as : Array Ξ±} (motive : Nat β Ξ² β Prop) {init : Ξ²} (h0 : motive as.size init) {f : Ξ± β Ξ² β Ξ²}\n (hf : β i : Fin as.size, β b, motive (i.1 + 1) b β motive i.1 (f as[i] b)) :\n motive 0 (as.foldr f init)",
"start": [
570,
1
],
"end": [
583,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_map",
"code": "@[simp] theorem mem_map {f : Ξ± β Ξ²} {l : Array Ξ±} : b β l.map f β β a, a β l β§ f a = b",
"start": [
587,
1
],
"end": [
588,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mapM_eq_mapM_data",
"code": "theorem mapM_eq_mapM_data [Monad m] [LawfulMonad m] (f : Ξ± β m Ξ²) (arr : Array Ξ±) :\n arr.mapM f = return mk (β arr.data.mapM f)",
"start": [
590,
1
],
"end": [
596,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mapM_map_eq_foldl",
"code": "theorem mapM_map_eq_foldl (as : Array Ξ±) (f : Ξ± β Ξ²) (i) :\n mapM.map (m := Id) f as i b = as.foldl (start := i) (fun r a => r.push (f a)) b",
"start": [
598,
1
],
"end": [
612,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.map_eq_foldl",
"code": "theorem map_eq_foldl (as : Array Ξ±) (f : Ξ± β Ξ²) :\n as.map f = as.foldl (fun r a => r.push (f a)) #[]",
"start": [
614,
1
],
"end": [
616,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.map_induction",
"code": "theorem map_induction (as : Array Ξ±) (f : Ξ± β Ξ²) (motive : Nat β Prop) (h0 : motive 0)\n (p : Fin as.size β Ξ² β Prop) (hs : β i, motive i.1 β p i (f as[i]) β§ motive (i+1)) :\n motive as.size β§\n β eq : (as.map f).size = as.size, β i h, p β¨i, hβ© ((as.map f)[i])",
"start": [
618,
1
],
"end": [
643,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.map_spec",
"code": "theorem map_spec (as : Array Ξ±) (f : Ξ± β Ξ²) (p : Fin as.size β Ξ² β Prop)\n (hs : β i, p i (f as[i])) :\n β eq : (as.map f).size = as.size, β i h, p β¨i, hβ© ((as.map f)[i])",
"start": [
645,
1
],
"end": [
648,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_map",
"code": "@[simp] theorem getElem_map (f : Ξ± β Ξ²) (as : Array Ξ±) (i : Nat) (h) :\n ((as.map f)[i]) = f (as[i]'(size_map .. βΈ h))",
"start": [
650,
1
],
"end": [
656,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mapIdx_induction",
"code": "theorem mapIdx_induction (as : Array Ξ±) (f : Fin as.size β Ξ± β Ξ²)\n (motive : Nat β Prop) (h0 : motive 0)\n (p : Fin as.size β Ξ² β Prop)\n (hs : β i, motive i.1 β p i (f i as[i]) β§ motive (i + 1)) :\n motive as.size β§ β eq : (Array.mapIdx as f).size = as.size,\n β i h, p β¨i, hβ© ((Array.mapIdx as f)[i])",
"start": [
661,
1
],
"end": [
684,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mapIdx_spec",
"code": "theorem mapIdx_spec (as : Array Ξ±) (f : Fin as.size β Ξ± β Ξ²)\n (p : Fin as.size β Ξ² β Prop) (hs : β i, p i (f i as[i])) :\n β eq : (Array.mapIdx as f).size = as.size,\n β i h, p β¨i, hβ© ((Array.mapIdx as f)[i])",
"start": [
686,
1
],
"end": [
690,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_mapIdx",
"code": "@[simp] theorem size_mapIdx (a : Array Ξ±) (f : Fin a.size β Ξ± β Ξ²) : (a.mapIdx f).size = a.size",
"start": [
692,
1
],
"end": [
693,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_zipWithIndex",
"code": "@[simp] theorem size_zipWithIndex (as : Array Ξ±) : as.zipWithIndex.size = as.size",
"start": [
695,
1
],
"end": [
696,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.getElem_mapIdx",
"code": "@[simp] theorem getElem_mapIdx (a : Array Ξ±) (f : Fin a.size β Ξ± β Ξ²) (i : Nat)\n (h : i < (mapIdx a f).size) :\n haveI : i < a.size := by simp_all\n (a.mapIdx f)[i] = f β¨i, thisβ© a[i]",
"start": [
698,
1
],
"end": [
702,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_modify",
"code": "@[simp] theorem size_modify (a : Array Ξ±) (i : Nat) (f : Ξ± β Ξ±) : (a.modify i f).size = a.size",
"start": [
706,
1
],
"end": [
708,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_modify",
"code": "theorem get_modify {arr : Array Ξ±} {x i} (h : i < arr.size) :\n (arr.modify x f).get β¨i, by simp [h]β© =\n if x = i then f (arr.get β¨i, hβ©) else arr.get β¨i, hβ©",
"start": [
710,
1
],
"end": [
715,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.filter_data",
"code": "@[simp] theorem filter_data (p : Ξ± β Bool) (l : Array Ξ±) :\n (l.filter p).data = l.data.filter p",
"start": [
719,
1
],
"end": [
728,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.filter_filter",
"code": "@[simp] theorem filter_filter (q) (l : Array Ξ±) :\n filter p (filter q l) = filter (fun a => p a β§ q a) l",
"start": [
730,
1
],
"end": [
733,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_filter",
"code": "@[simp] theorem mem_filter : x β filter p as β x β as β§ p x",
"start": [
735,
1
],
"end": [
736,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_of_mem_filter",
"code": "theorem mem_of_mem_filter {a : Ξ±} {l} (h : a β filter p l) : a β l",
"start": [
738,
1
],
"end": [
739,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.filterMap_data",
"code": "@[simp] theorem filterMap_data (f : Ξ± β Option Ξ²) (l : Array Ξ±) :\n (l.filterMap f).data = l.data.filterMap f",
"start": [
743,
1
],
"end": [
754,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_filterMap",
"code": "@[simp] theorem mem_filterMap (f : Ξ± β Option Ξ²) (l : Array Ξ±) {b : Ξ²} :\n b β filterMap f l β β a, a β l β§ f a = some b",
"start": [
756,
1
],
"end": [
758,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_empty",
"code": "theorem size_empty : (#[] : Array Ξ±).size = 0",
"start": [
762,
1
],
"end": [
762,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.empty_data",
"code": "theorem empty_data : (#[] : Array Ξ±).data = []",
"start": [
764,
1
],
"end": [
764,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.push_eq_append_singleton",
"code": "theorem push_eq_append_singleton (as : Array Ξ±) (x) : as.push x = as ++ #[x]",
"start": [
768,
1
],
"end": [
768,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.mem_append",
"code": "@[simp] theorem mem_append {a : Ξ±} {s t : Array Ξ±} : a β s ++ t β a β s β¨ a β t",
"start": [
770,
1
],
"end": [
771,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_append",
"code": "theorem size_append (as bs : Array Ξ±) : (as ++ bs).size = as.size + bs.size",
"start": [
773,
1
],
"end": [
774,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_append_left",
"code": "theorem get_append_left {as bs : Array Ξ±} {h : i < (as ++ bs).size} (hlt : i < as.size) :\n (as ++ bs)[i] = as[i]",
"start": [
776,
1
],
"end": [
781,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_append_right",
"code": "theorem get_append_right {as bs : Array Ξ±} {h : i < (as ++ bs).size} (hle : as.size β€ i)\n (hlt : i - as.size < bs.size := Nat.sub_lt_left_of_lt_add hle (size_append .. βΈ h)) :\n (as ++ bs)[i] = bs[i - as.size]",
"start": [
783,
1
],
"end": [
789,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.append_nil",
"code": "@[simp] theorem append_nil (as : Array Ξ±) : as ++ #[] = as",
"start": [
791,
1
],
"end": [
792,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.nil_append",
"code": "@[simp] theorem nil_append (as : Array Ξ±) : #[] ++ as = as",
"start": [
794,
1
],
"end": [
795,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.append_assoc",
"code": "theorem append_assoc (as bs cs : Array Ξ±) : as ++ bs ++ cs = as ++ (bs ++ cs)",
"start": [
797,
1
],
"end": [
798,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_loop_zero",
"code": "theorem extract_loop_zero (as bs : Array Ξ±) (start : Nat) : extract.loop as 0 start bs = bs",
"start": [
802,
1
],
"end": [
803,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_loop_succ",
"code": "theorem extract_loop_succ (as bs : Array Ξ±) (size start : Nat) (h : start < as.size) :\n extract.loop as (size+1) start bs = extract.loop as size (start+1) (bs.push as[start])",
"start": [
805,
1
],
"end": [
807,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_loop_of_ge",
"code": "theorem extract_loop_of_ge (as bs : Array Ξ±) (size start : Nat) (h : start β₯ as.size) :\n extract.loop as size start bs = bs",
"start": [
809,
1
],
"end": [
811,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_loop_eq_aux",
"code": "theorem extract_loop_eq_aux (as bs : Array Ξ±) (size start : Nat) :\n extract.loop as size start bs = bs ++ extract.loop as size start #[]",
"start": [
813,
1
],
"end": [
825,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_loop_eq",
"code": "theorem extract_loop_eq (as bs : Array Ξ±) (size start : Nat) (h : start + size β€ as.size) :\n extract.loop as size start bs = bs ++ as.extract start (start + size)",
"start": [
827,
1
],
"end": [
829,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_extract_loop",
"code": "theorem size_extract_loop (as bs : Array Ξ±) (size start : Nat) :\n (extract.loop as size start bs).size = bs.size + min size (as.size - start)",
"start": [
831,
1
],
"end": [
841,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.size_extract",
"code": "@[simp] theorem size_extract (as : Array Ξ±) (start stop : Nat) :\n (as.extract start stop).size = min stop as.size - start",
"start": [
843,
1
],
"end": [
846,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_extract_loop_lt_aux",
"code": "theorem get_extract_loop_lt_aux (as bs : Array Ξ±) (size start : Nat) (hlt : i < bs.size) :\n i < (extract.loop as size start bs).size",
"start": [
848,
1
],
"end": [
852,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_extract_loop_lt",
"code": "theorem get_extract_loop_lt (as bs : Array Ξ±) (size start : Nat) (hlt : i < bs.size)\n (h := get_extract_loop_lt_aux as bs size start hlt) :\n (extract.loop as size start bs)[i] = bs[i]",
"start": [
854,
1
],
"end": [
859,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_extract_loop_ge_aux",
"code": "theorem get_extract_loop_ge_aux (as bs : Array Ξ±) (size start : Nat) (hge : i β₯ bs.size)\n (h : i < (extract.loop as size start bs).size) : start + i - bs.size < as.size",
"start": [
861,
1
],
"end": [
870,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_extract_loop_ge",
"code": "theorem get_extract_loop_ge (as bs : Array Ξ±) (size start : Nat) (hge : i β₯ bs.size)\n (h : i < (extract.loop as size start bs).size)\n (h' := get_extract_loop_ge_aux as bs size start hge h) :\n (extract.loop as size start bs)[i] = as[start + i - bs.size]",
"start": [
872,
1
],
"end": [
901,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_extract_aux",
"code": "theorem get_extract_aux {as : Array Ξ±} {start stop : Nat} (h : i < (as.extract start stop).size) :\n start + i < as.size",
"start": [
903,
1
],
"end": [
906,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_extract",
"code": "@[simp] theorem get_extract {as : Array Ξ±} {start stop : Nat}\n (h : i < (as.extract start stop).size) :\n (as.extract start stop)[i] = as[start + i]'(get_extract_aux h)",
"start": [
908,
1
],
"end": [
912,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_all",
"code": "@[simp] theorem extract_all (as : Array Ξ±) : as.extract 0 as.size = as",
"start": [
914,
1
],
"end": [
917,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_empty_of_stop_le_start",
"code": "theorem extract_empty_of_stop_le_start (as : Array Ξ±) {start stop : Nat} (h : stop β€ start) :\n as.extract start stop = #[]",
"start": [
919,
1
],
"end": [
922,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_empty_of_size_le_start",
"code": "theorem extract_empty_of_size_le_start (as : Array Ξ±) {start stop : Nat} (h : as.size β€ start) :\n as.extract start stop = #[]",
"start": [
924,
1
],
"end": [
927,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.extract_empty",
"code": "@[simp] theorem extract_empty (start stop : Nat) : (#[] : Array Ξ±).extract start stop = #[]",
"start": [
929,
1
],
"end": [
930,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.anyM_loop_iff_exists",
"code": "theorem anyM_loop_iff_exists (p : Ξ± β Bool) (as : Array Ξ±) (start stop) (h : stop β€ as.size) :\n anyM.loop (m := Id) p as stop h start = true β\n β i : Fin as.size, start β€ βi β§ βi < stop β§ p as[i] = true",
"start": [
935,
1
],
"end": [
954,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.any_iff_exists",
"code": "theorem any_iff_exists (p : Ξ± β Bool) (as : Array Ξ±) (start stop) :\n any as p start stop β β i : Fin as.size, start β€ i.1 β§ i.1 < stop β§ p as[i]",
"start": [
957,
1
],
"end": [
967,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.any_eq_true",
"code": "theorem any_eq_true (p : Ξ± β Bool) (as : Array Ξ±) :\n any as p β β i : Fin as.size, p as[i]",
"start": [
969,
1
],
"end": [
970,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.any_def",
"code": "theorem any_def {p : Ξ± β Bool} (as : Array Ξ±) : as.any p = as.data.any p",
"start": [
972,
1
],
"end": [
974,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.all_eq_not_any_not",
"code": "theorem all_eq_not_any_not (p : Ξ± β Bool) (as : Array Ξ±) (start stop) :\n all as p start stop = !(any as (!p Β·) start stop)",
"start": [
978,
1
],
"end": [
981,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.all_iff_forall",
"code": "theorem all_iff_forall (p : Ξ± β Bool) (as : Array Ξ±) (start stop) :\n all as p start stop β β i : Fin as.size, start β€ i.1 β§ i.1 < stop β p as[i]",
"start": [
983,
1
],
"end": [
990,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.all_eq_true",
"code": "theorem all_eq_true (p : Ξ± β Bool) (as : Array Ξ±) : all as p β β i : Fin as.size, p as[i]",
"start": [
992,
1
],
"end": [
993,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.all_def",
"code": "theorem all_def {p : Ξ± β Bool} (as : Array Ξ±) : as.all p = as.data.all p",
"start": [
995,
1
],
"end": [
1002,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.all_eq_true_iff_forall_mem",
"code": "theorem all_eq_true_iff_forall_mem {l : Array Ξ±} : l.all p β β x, x β l β p x",
"start": [
1004,
1
],
"end": [
1005,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.contains_def",
"code": "theorem contains_def [DecidableEq Ξ±] {a : Ξ±} {as : Array Ξ±} : as.contains a β a β as",
"start": [
1009,
1
],
"end": [
1010,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_swap_right",
"code": "@[simp] theorem get_swap_right (a : Array Ξ±) {i j : Fin a.size} : (a.swap i j)[j.val] = a[i]",
"start": [
1019,
1
],
"end": [
1020,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_swap_left",
"code": "@[simp] theorem get_swap_left (a : Array Ξ±) {i j : Fin a.size} : (a.swap i j)[i.val] = a[j]",
"start": [
1022,
1
],
"end": [
1030,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_swap_of_ne",
"code": "@[simp] theorem get_swap_of_ne (a : Array Ξ±) {i j : Fin a.size} (hp : p < a.size)\n (hi : p β i) (hj : p β j) : (a.swap i j)[p]'(a.size_swap .. |>.symm βΈ hp) = a[p]",
"start": [
1032,
1
],
"end": [
1042,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_swap",
"code": "theorem get_swap (a : Array Ξ±) (i j : Fin a.size) (k : Nat) (hk: k < a.size) :\n (a.swap i j)[k]'(by simp_all) = if k = i then a[j] else if k = j then a[i] else a[k]",
"start": [
1044,
1
],
"end": [
1048,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.get_swap'",
"code": "theorem get_swap' (a : Array Ξ±) (i j : Fin a.size) (k : Nat) (hk' : k < (a.swap i j).size) :\n (a.swap i j)[k] = if k = i then a[j] else if k = j then a[i] else a[k]'(by simp_all)",
"start": [
1050,
1
],
"end": [
1052,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.swap_swap",
"code": "@[simp] theorem swap_swap (a : Array Ξ±) {i j : Fin a.size} :\n (a.swap i j).swap β¨i.1, (a.size_swap ..).symm βΈi.2β© β¨j.1, (a.size_swap ..).symm βΈj.2β© = a",
"start": [
1054,
1
],
"end": [
1062,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.swap_comm",
"code": "theorem swap_comm (a : Array Ξ±) {i j : Fin a.size} : a.swap i j = a.swap j i",
"start": [
1064,
1
],
"end": [
1071,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/JsonRpc.lean | [
".lake/packages/lean4/src/lean/Init/System/IO.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBTree.lean"
] | [
{
"full_name": "Lean.JsonRpc.RequestID",
"code": "inductive RequestID where\n | str (s : String)\n | num (n : JsonNumber)\n | null\n deriving Inhabited, BEq, Ord",
"start": [
19,
1
],
"end": [
25,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.ErrorCode",
"code": "inductive ErrorCode where\n \n | parseError\n \n | invalidRequest\n \n | methodNotFound\n \n | invalidParams\n \n | internalError\n \n | serverNotInitialized\n | unknownErrorCode\n \n | contentModified\n \n | requestCancelled\n | rpcNeedsReconnect\n | workerExited\n | workerCrashed\n deriving Inhabited, BEq",
"start": [
35,
1
],
"end": [
69,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.Message",
"code": "inductive Message where\n \n | request (id : RequestID) (method : String) (params? : Option Structured)\n \n | notification (method : String) (params? : Option Structured)\n \n | response (id : RequestID) (result : Json)\n \n | responseError (id : RequestID) (code : ErrorCode) (message : String) (data? : Option Json)",
"start": [
100,
1
],
"end": [
113,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.Batch",
"code": "def Batch := Array Message",
"start": [
115,
1
],
"end": [
115,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.Request",
"code": "structure Request (Ξ± : Type u) where\n id : RequestID\n method : String\n param : Ξ±\n deriving Inhabited, BEq",
"start": [
117,
1
],
"end": [
128,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.Notification",
"code": "structure Notification (Ξ± : Type u) where\n method : String\n param : Ξ±\n deriving Inhabited, BEq",
"start": [
133,
1
],
"end": [
143,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.Response",
"code": "structure Response (Ξ± : Type u) where\n id : RequestID\n result : Ξ±\n deriving Inhabited, BEq",
"start": [
148,
1
],
"end": [
162,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.ResponseError",
"code": "structure ResponseError (Ξ± : Type u) where\n id : RequestID\n code : ErrorCode\n \n message : String\n \n data? : Option Ξ± := none\n deriving Inhabited, BEq",
"start": [
167,
1
],
"end": [
181,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.RequestID.lt",
"code": "private def RequestID.lt : RequestID β RequestID β Bool\n | RequestID.str a, RequestID.str b => a < b\n | RequestID.num a, RequestID.num b => a < b\n | RequestID.null, RequestID.num _ => true\n | RequestID.null, RequestID.str _ => true\n | RequestID.num _, RequestID.str _ => true\n | _, _ => false",
"start": [
192,
1
],
"end": [
198,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonRpc.RequestID.ltProp",
"code": "private def RequestID.ltProp : LT RequestID :=\n β¨fun a b => RequestID.lt a b = trueβ©",
"start": [
200,
1
],
"end": [
201,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.readMessage",
"code": "def readMessage (h : FS.Stream) (nBytes : Nat) : IO Message := do\n let j β h.readJson nBytes\n match fromJson? j with\n | Except.ok m => pure m\n | Except.error inner => throw $ userError s!\"JSON '{j.compress}' did not have the format of a JSON-RPC message.\\n{inner}\"",
"start": [
279,
3
],
"end": [
283,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.readRequestAs",
"code": "def readRequestAs (h : FS.Stream) (nBytes : Nat) (expectedMethod : String) (Ξ±) [FromJson Ξ±] : IO (Request Ξ±) := do\n let m β h.readMessage nBytes\n match m with\n | Message.request id method params? =>\n if method = expectedMethod then\n let j := toJson params?\n match fromJson? j with\n | Except.ok v => pure β¨id, expectedMethod, vβ©\n | Except.error inner => throw $ userError s!\"Unexpected param '{j.compress}' for method '{expectedMethod}'\\n{inner}\"\n else\n throw $ userError s!\"Expected method '{expectedMethod}', got method '{method}'\"\n | _ => throw $ userError s!\"Expected JSON-RPC request, got: '{(toJson m).compress}'\"",
"start": [
285,
3
],
"end": [
296,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.readNotificationAs",
"code": "def readNotificationAs (h : FS.Stream) (nBytes : Nat) (expectedMethod : String) (Ξ±) [FromJson Ξ±] : IO (Notification Ξ±) := do\n let m β h.readMessage nBytes\n match m with\n | Message.notification method params? =>\n if method = expectedMethod then\n let j := toJson params?\n match fromJson? j with\n | Except.ok v => pure β¨expectedMethod, vβ©\n | Except.error inner => throw $ userError s!\"Unexpected param '{j.compress}' for method '{expectedMethod}'\\n{inner}\"\n else\n throw $ userError s!\"Expected method '{expectedMethod}', got method '{method}'\"\n | _ => throw $ userError s!\"Expected JSON-RPC notification, got: '{(toJson m).compress}'\"",
"start": [
298,
3
],
"end": [
309,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.readResponseAs",
"code": "def readResponseAs (h : FS.Stream) (nBytes : Nat) (expectedID : RequestID) (Ξ±) [FromJson Ξ±] : IO (Response Ξ±) := do\n let m β h.readMessage nBytes\n match m with\n | Message.response id result =>\n if id == expectedID then\n match fromJson? result with\n | Except.ok v => pure β¨expectedID, vβ©\n | Except.error inner => throw $ userError s!\"Unexpected result '{result.compress}'\\n{inner}\"\n else\n throw $ userError s!\"Expected id {expectedID}, got id {id}\"\n | _ => throw $ userError s!\"Expected JSON-RPC response, got: '{(toJson m).compress}'\"",
"start": [
311,
3
],
"end": [
321,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeMessage",
"code": "def writeMessage (h : FS.Stream) (m : Message) : IO Unit :=\n h.writeJson (toJson m)",
"start": [
327,
3
],
"end": [
328,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeRequest",
"code": "def writeRequest (h : FS.Stream) (r : Request Ξ±) : IO Unit :=\n h.writeMessage r",
"start": [
330,
3
],
"end": [
331,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeNotification",
"code": "def writeNotification (h : FS.Stream) (n : Notification Ξ±) : IO Unit :=\n h.writeMessage n",
"start": [
333,
3
],
"end": [
334,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeResponse",
"code": "def writeResponse (h : FS.Stream) (r : Response Ξ±) : IO Unit :=\n h.writeMessage r",
"start": [
336,
3
],
"end": [
337,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeResponseError",
"code": "def writeResponseError (h : FS.Stream) (e : ResponseError Unit) : IO Unit :=\n h.writeMessage (Message.responseError e.id e.code e.message none)",
"start": [
339,
3
],
"end": [
340,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeResponseErrorWithData",
"code": "def writeResponseErrorWithData (h : FS.Stream) (e : ResponseError Ξ±) : IO Unit :=\n h.writeMessage e",
"start": [
342,
3
],
"end": [
343,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/SubExpr.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Basic.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/TopDownAnalyze.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Builtins.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator/Options.lean"
] | [] |
.lake/packages/lean4/src/lean/Lean/ParserCompiler.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/WHNF.lean",
".lake/packages/lean4/src/lean/Lean/ParserCompiler/Attribute.lean",
".lake/packages/lean4/src/lean/Lean/KeyedDeclsAttribute.lean",
".lake/packages/lean4/src/lean/Lean/Meta/ReduceEval.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Extension.lean"
] | [
{
"full_name": "Lean.ParserCompiler.Context",
"code": "structure Context (Ξ± : Type) where\n varName : Name\n categoryAttr : KeyedDeclsAttribute Ξ±\n combinatorAttr : CombinatorAttribute",
"start": [
20,
1
],
"end": [
23,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.Context.tyName",
"code": "def Context.tyName {Ξ±} (ctx : Context Ξ±) : Name := ctx.categoryAttr.defn.valueTypeName",
"start": [
25,
1
],
"end": [
25,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.replaceParserTy",
"code": "def replaceParserTy {Ξ±} (ctx : Context Ξ±) (e : Expr) : Expr :=\n e.replace fun e =>\n let e := if e.isOptParam then e.appFn!.appArg! else e\n if e.isConstOf `Lean.Parser.Parser then mkConst ctx.tyName else none",
"start": [
27,
1
],
"end": [
32,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.parserNodeKind?",
"code": "partial def parserNodeKind? (e : Expr) : MetaM (Option Name) := do\n let reduceEval? e : MetaM (Option Name) := do\n try pure <| some (β reduceEval e) catch _ => pure none\n let e β whnfCore e\n if e matches Expr.lam .. then\n lambdaLetTelescope e fun _ e => parserNodeKind? e\n else if e.isAppOfArity ``leadingNode 3 || e.isAppOfArity ``trailingNode 4 || e.isAppOfArity ``node 2 then\n reduceEval? (e.getArg! 0)\n else if e.isAppOfArity ``withAntiquot 2 then\n parserNodeKind? (e.getArg! 1)\n else forallTelescope (β inferType e.getAppFn) fun params _ => do\n let lctx β getLCtx\n if let [(i, _)] := params.toList.enum.filter (lctx.getFVar! Β·.2 |>.type.isConstOf ``Parser) then\n parserNodeKind? (e.getArg! i)\n else\n return none",
"start": [
35,
1
],
"end": [
52,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.compileParserExpr",
"code": "partial def compileParserExpr (e : Expr) : MetaM Expr := do\n let e β whnfCore e\n match e with\n | .lam .. => lambdaLetTelescope e fun xs b => compileParserExpr b >>= mkLambdaFVars xs\n | .fvar .. => return e\n | _ => do\n let fn := e.getAppFn\n let .const c .. := fn | throwError \"call of unknown parser at '{e}'\"\n let mkCall (p : Name) := do\n let ty β inferType (mkConst p)\n forallTelescope ty fun params _ => do\n let mut p := mkConst p\n let args := e.getAppArgs\n for i in [:Nat.min params.size args.size] do\n let param := params[i]!\n let arg := args[i]!\n let paramTy β inferType param\n let resultTy β forallTelescope paramTy fun _ b => pure b\n let arg β if resultTy.isConstOf ctx.tyName then compileParserExpr arg else pure arg\n p := mkApp p arg\n return p\n let env β getEnv\n match ctx.combinatorAttr.getDeclFor? env c with\n | some p => mkCall p\n | none =>\n let c' := c ++ ctx.varName\n let cinfo β getConstInfo c\n let resultTy β forallTelescope cinfo.type fun _ b => pure b\n if resultTy.isConstOf ``Lean.Parser.TrailingParser || resultTy.isConstOf ``Lean.Parser.Parser then do\n let some value β pure cinfo.value?\n | throwError \"don't know how to generate {ctx.varName} for non-definition '{e}'\"\n unless (env.getModuleIdxFor? c).isNone || force do\n throwError \"refusing to generate code for imported parser declaration '{c}'; use `@[run_parser_attribute_hooks]` on its definition instead.\"\n let value β compileParserExpr <| replaceParserTy ctx value\n let ty β forallTelescope cinfo.type fun params _ =>\n params.foldrM (init := mkConst ctx.tyName) fun param ty => do\n let paramTy β replaceParserTy ctx <$> inferType param\n return mkForall `_ BinderInfo.default paramTy ty\n let decl := Declaration.defnDecl {\n name := c', levelParams := []\n type := ty, value := value, hints := ReducibilityHints.opaque, safety := DefinitionSafety.safe\n }\n let env β getEnv\n let env β match env.addAndCompile {} decl with\n | Except.ok env => pure env\n | Except.error kex => do throwError (β (kex.toMessageData {}).toString)\n setEnv <| ctx.combinatorAttr.setDeclFor env c c'\n if cinfo.type.isConst then\n if let some kind β parserNodeKind? cinfo.value! then\n let attrName := if builtin then ctx.categoryAttr.defn.builtinName else ctx.categoryAttr.defn.name\n let stx := mkNode `Lean.Parser.Attr.simple #[mkIdent attrName, mkNullNode #[mkIdent kind]]\n Attribute.add c' attrName stx\n mkCall c'\n else\n let some e' β unfoldDefinition? e\n | throwError \"don't know how to generate {ctx.varName} for non-parser combinator '{e}'\"\n compileParserExpr e'",
"start": [
58,
1
],
"end": [
127,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.compileEmbeddedParsers",
"code": "def compileEmbeddedParsers : ParserDescr β MetaM Unit\n | ParserDescr.const _ => pure ()\n | ParserDescr.unary _ d => compileEmbeddedParsers d\n | ParserDescr.binary _ dβ dβ => compileEmbeddedParsers dβ *> compileEmbeddedParsers dβ\n | ParserDescr.parser constName => discard <| compileParserExpr ctx (mkConst constName) (builtin := builtin) (force := false)\n | ParserDescr.node _ _ d => compileEmbeddedParsers d\n | ParserDescr.nodeWithAntiquot _ _ d => compileEmbeddedParsers d\n | ParserDescr.sepBy p _ psep _ => compileEmbeddedParsers p *> compileEmbeddedParsers psep\n | ParserDescr.sepBy1 p _ psep _ => compileEmbeddedParsers p *> compileEmbeddedParsers psep\n | ParserDescr.trailingNode _ _ _ d => compileEmbeddedParsers d\n | ParserDescr.symbol _ => pure ()\n | ParserDescr.nonReservedSymbol _ _ => pure ()\n | ParserDescr.cat _ _ => pure ()",
"start": [
131,
1
],
"end": [
143,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParserCompiler.registerParserCompiler",
"code": "unsafe def registerParserCompiler {Ξ±} (ctx : Context Ξ±) : IO Unit := do\n Parser.registerParserAttributeHook {\n postAdd := fun catName constName builtin => do\n let info β getConstInfo constName\n if info.type.isConstOf ``Lean.ParserDescr || info.type.isConstOf ``Lean.TrailingParserDescr then\n let d β evalConstCheck ParserDescr `Lean.ParserDescr constName <|>\n evalConstCheck TrailingParserDescr `Lean.TrailingParserDescr constName\n compileEmbeddedParsers ctx d (builtin := builtin) |>.run'\n else\n let force := catName.isAnonymous\n discard (compileParserExpr ctx (mkConst constName) (builtin := builtin) (force := force)).run'\n }",
"start": [
145,
1
],
"end": [
158,
4
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/FVarSubst.lean | [
".lake/packages/lean4/src/lean/Lean/LocalContext.lean",
".lake/packages/lean4/src/lean/Lean/Data/AssocList.lean",
".lake/packages/lean4/src/lean/Lean/Util/ReplaceExpr.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.Meta.FVarSubst",
"code": "structure FVarSubst where\n map : AssocList FVarId Expr := {}\n deriving Inhabited",
"start": [
13,
1
],
"end": [
21,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.empty",
"code": "def empty : FVarSubst := {}",
"start": [
25,
1
],
"end": [
25,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.isEmpty",
"code": "def isEmpty (s : FVarSubst) : Bool :=\n s.map.isEmpty",
"start": [
27,
1
],
"end": [
28,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.contains",
"code": "def contains (s : FVarSubst) (fvarId : FVarId) : Bool :=\n s.map.contains fvarId",
"start": [
30,
1
],
"end": [
31,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.insert",
"code": "def insert (s : FVarSubst) (fvarId : FVarId) (v : Expr) : FVarSubst :=\n if s.contains fvarId then s\n else\n let map := s.map.mapVal fun e => e.replaceFVarId fvarId v;\n { map := map.insert fvarId v }",
"start": [
33,
1
],
"end": [
38,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.erase",
"code": "def erase (s : FVarSubst) (fvarId : FVarId) : FVarSubst :=\n { map := s.map.erase fvarId }",
"start": [
40,
1
],
"end": [
41,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.find?",
"code": "def find? (s : FVarSubst) (fvarId : FVarId) : Option Expr :=\n s.map.find? fvarId",
"start": [
43,
1
],
"end": [
44,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.get",
"code": "def get (s : FVarSubst) (fvarId : FVarId) : Expr :=\n match s.map.find? fvarId with\n | none => mkFVar fvarId | some v => v",
"start": [
46,
1
],
"end": [
49,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.apply",
"code": "def apply (s : FVarSubst) (e : Expr) : Expr :=\n if s.map.isEmpty then e\n else if !e.hasFVar then e\n else e.replace fun e => match e with\n | Expr.fvar fvarId => match s.map.find? fvarId with\n | none => e\n | some v => v\n | _ => none",
"start": [
51,
1
],
"end": [
59,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.domain",
"code": "def domain (s : FVarSubst) : List FVarId :=\n s.map.foldl (init := []) fun r k _ => k :: r",
"start": [
61,
1
],
"end": [
62,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.any",
"code": "def any (p : FVarId β Expr β Bool) (s : FVarSubst) : Bool :=\n s.map.any p",
"start": [
64,
1
],
"end": [
65,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FVarSubst.append",
"code": "def append (s t : FVarSubst) : FVarSubst :=\n s.1.foldl (fun s' k v => s'.insert k (t.apply v)) t",
"start": [
67,
1
],
"end": [
72,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "LocalDecl.applyFVarSubst",
"code": "def LocalDecl.applyFVarSubst (s : Meta.FVarSubst) : LocalDecl β LocalDecl\n | LocalDecl.cdecl i id n t bi k => LocalDecl.cdecl i id n (s.apply t) bi k\n | LocalDecl.ldecl i id n t v nd k => LocalDecl.ldecl i id n (s.apply t) (s.apply v) nd k",
"start": [
77,
1
],
"end": [
79,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Expr.applyFVarSubst",
"code": "abbrev Expr.applyFVarSubst (s : Meta.FVarSubst) (e : Expr) : Expr :=\n s.apply e",
"start": [
81,
1
],
"end": [
82,
12
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Intro.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Util.lean"
] | [
{
"full_name": "Lean.Meta.introNImp",
"code": "@[inline] private partial def introNImp {Ο} (mvarId : MVarId) (n : Nat) (mkName : LocalContext β Name β Bool β Ο β MetaM (Name Γ Ο)) (s : Ο)\n : MetaM (Array FVarId Γ MVarId) := mvarId.withContext do\n mvarId.checkNotAssigned `introN\n let mvarType β mvarId.getType\n let lctx β getLCtx\n let rec @[specialize] loop (i : Nat) (lctx : LocalContext) (fvars : Array Expr) (j : Nat) (s : Ο) (type : Expr) : MetaM (Array Expr Γ MVarId) := do\n match i, type with\n | 0, type =>\n let type := type.instantiateRevRange j fvars.size fvars\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewLocalInstances fvars j do\n let tag β mvarId.getTag\n let type := type.headBeta\n let newMVar β mkFreshExprSyntheticOpaqueMVar type tag\n let newVal β mkLambdaFVars fvars newMVar\n mvarId.assign newVal\n return (fvars, newMVar.mvarId!)\n | i+1, .letE n type val body _ =>\n let type := type.instantiateRevRange j fvars.size fvars\n let type := type.headBeta\n let val := val.instantiateRevRange j fvars.size fvars\n let fvarId β mkFreshFVarId\n let (n, s) β mkName lctx n true s\n let lctx := lctx.mkLetDecl fvarId n type val\n let fvar := mkFVar fvarId\n let fvars := fvars.push fvar\n loop i lctx fvars j s body\n | i+1, .forallE n type body c =>\n let type := type.instantiateRevRange j fvars.size fvars\n let type := type.headBeta\n let fvarId β mkFreshFVarId\n let (n, s) β mkName lctx n c.isExplicit s\n let lctx := lctx.mkLocalDecl fvarId n type c\n let fvar := mkFVar fvarId\n let fvars := fvars.push fvar\n loop i lctx fvars j s body\n | i+1, type =>\n if let some (n, type, val, body) := type.letFun? then\n let type := type.instantiateRevRange j fvars.size fvars\n let type := type.headBeta\n let val := val.instantiateRevRange j fvars.size fvars\n let fvarId β mkFreshFVarId\n let (n, s) β mkName lctx n true s\n let lctx := lctx.mkLetDecl fvarId n type val\n let fvar := mkFVar fvarId\n let fvars := fvars.push fvar\n loop i lctx fvars j s body\n else\n let type := type.instantiateRevRange j fvars.size fvars\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewLocalInstances fvars j do\n \n let newType := (β instantiateMVars type).cleanupAnnotations\n if newType.isForall || newType.isLet || newType.isLetFun then\n loop (i+1) lctx fvars fvars.size s newType\n else\n let newType β whnf newType\n if newType.isForall then\n loop (i+1) lctx fvars fvars.size s newType\n else\n throwTacticEx `introN mvarId \"insufficient number of binders\"\n let (fvars, mvarId) β loop n lctx #[] 0 s mvarType\n return (fvars.map Expr.fvarId!, mvarId)",
"start": [
11,
1
],
"end": [
78,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshBinderNameForTacticCore",
"code": "private def mkFreshBinderNameForTacticCore (lctx : LocalContext) (binderName : Name) (hygienic := true) : MetaM Name := do\n if hygienic then\n mkFreshUserName binderName\n else\n return lctx.getUnusedName binderName",
"start": [
86,
1
],
"end": [
90,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshBinderNameForTactic",
"code": "def mkFreshBinderNameForTactic (binderName : Name) : MetaM Name := do\n mkFreshBinderNameForTacticCore (β getLCtx) binderName (tactic.hygienic.get (β getOptions))",
"start": [
92,
1
],
"end": [
98,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAuxNameImp",
"code": "private def mkAuxNameImp (preserveBinderNames : Bool) (hygienic : Bool) (useNamesForExplicitOnly : Bool)\n (lctx : LocalContext) (binderName : Name) (isExplicit : Bool) : List Name β MetaM (Name Γ List Name)\n | [] => mkAuxNameWithoutGivenName []\n | n :: rest => do\n if useNamesForExplicitOnly && !isExplicit then\n mkAuxNameWithoutGivenName (n :: rest)\n else if n != Name.mkSimple \"_\" then\n return (n, rest)\n else\n mkAuxNameWithoutGivenName rest\nwhere\n mkAuxNameWithoutGivenName (rest : List Name) : MetaM (Name Γ List Name) := do\n let binderName β if binderName.isAnonymous then mkFreshUserName `a else pure binderName\n if preserveBinderNames then\n return (binderName, rest)\n else\n let binderName β mkFreshBinderNameForTacticCore lctx binderName hygienic\n return (binderName, rest)",
"start": [
100,
1
],
"end": [
119,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.introNCore",
"code": "def introNCore (mvarId : MVarId) (n : Nat) (givenNames : List Name) (useNamesForExplicitOnly : Bool) (preserveBinderNames : Bool)\n : MetaM (Array FVarId Γ MVarId) := do\n let hygienic := tactic.hygienic.get (β getOptions)\n if n == 0 then\n return (#[], mvarId)\n else\n introNImp mvarId n (mkAuxNameImp preserveBinderNames hygienic useNamesForExplicitOnly) givenNames",
"start": [
121,
1
],
"end": [
127,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.introN",
"code": "abbrev _root_.Lean.MVarId.introN (mvarId : MVarId) (n : Nat) (givenNames : List Name := []) (useNamesForExplicitOnly := false) : MetaM (Array FVarId Γ MVarId) :=\n introNCore mvarId n givenNames (useNamesForExplicitOnly := useNamesForExplicitOnly) (preserveBinderNames := false)",
"start": [
129,
1
],
"end": [
133,
117
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.introN",
"code": "@[deprecated MVarId.introN (since := \"2022-07-15\")]\nabbrev introN (mvarId : MVarId) (n : Nat) (givenNames : List Name := []) (useNamesForExplicitOnly := false) : MetaM (Array FVarId Γ MVarId) :=\n mvarId.introN n givenNames useNamesForExplicitOnly",
"start": [
135,
1
],
"end": [
137,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.introNP",
"code": "abbrev _root_.Lean.MVarId.introNP (mvarId : MVarId) (n : Nat) : MetaM (Array FVarId Γ MVarId) :=\n introNCore mvarId n [] (useNamesForExplicitOnly := false) (preserveBinderNames := true)",
"start": [
139,
1
],
"end": [
144,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.introNP",
"code": "@[deprecated MVarId.introNP (since := \"2022-07-15\")]\nabbrev introNP (mvarId : MVarId) (n : Nat) : MetaM (Array FVarId Γ MVarId) :=\n mvarId.introNP n",
"start": [
146,
1
],
"end": [
148,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.intro",
"code": "def _root_.Lean.MVarId.intro (mvarId : MVarId) (name : Name) : MetaM (FVarId Γ MVarId) := do\n let (fvarIds, mvarId) β mvarId.introN 1 [name]\n return (fvarIds[0]!, mvarId)",
"start": [
150,
1
],
"end": [
155,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.intro",
"code": "@[deprecated MVarId.intro (since := \"2022-07-15\")]\ndef intro (mvarId : MVarId) (name : Name) : MetaM (FVarId Γ MVarId) := do\n mvarId.intro name",
"start": [
157,
1
],
"end": [
159,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.intro1Core",
"code": "def intro1Core (mvarId : MVarId) (preserveBinderNames : Bool) : MetaM (FVarId Γ MVarId) := do\n let (fvarIds, mvarId) β introNCore mvarId 1 [] (useNamesForExplicitOnly := false) preserveBinderNames\n return (fvarIds[0]!, mvarId)",
"start": [
161,
1
],
"end": [
163,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.intro1",
"code": "abbrev _root_.Lean.MVarId.intro1 (mvarId : MVarId) : MetaM (FVarId Γ MVarId) :=\n intro1Core mvarId false",
"start": [
165,
1
],
"end": [
170,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.intro1",
"code": "@[deprecated MVarId.intro1 (since := \"2022-07-15\")]\nabbrev intro1 (mvarId : MVarId) : MetaM (FVarId Γ MVarId) :=\n mvarId.intro1",
"start": [
172,
1
],
"end": [
174,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.intro1P",
"code": "abbrev _root_.Lean.MVarId.intro1P (mvarId : MVarId) : MetaM (FVarId Γ MVarId) :=\n intro1Core mvarId true",
"start": [
176,
1
],
"end": [
181,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.intro1P",
"code": "@[deprecated MVarId.intro1P (since := \"2022-07-15\")]\nabbrev intro1P (mvarId : MVarId) : MetaM (FVarId Γ MVarId) :=\n mvarId.intro1P",
"start": [
183,
1
],
"end": [
185,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getIntrosSize",
"code": "private partial def getIntrosSize : Expr β Nat\n | .forallE _ _ b _ => getIntrosSize b + 1\n | .letE _ _ _ b _ => getIntrosSize b + 1\n | .mdata _ b => getIntrosSize b\n | e =>\n if let some (_, _, _, b) := e.letFun? then\n getIntrosSize b + 1\n else\n 0",
"start": [
187,
1
],
"end": [
195,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.intros",
"code": "def _root_.Lean.MVarId.intros (mvarId : MVarId) : MetaM (Array FVarId Γ MVarId) := do\n let type β mvarId.getType\n let type β instantiateMVars type\n let n := getIntrosSize type\n if n == 0 then\n return (#[], mvarId)\n else\n mvarId.introN n",
"start": [
197,
1
],
"end": [
207,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.intros",
"code": "@[deprecated MVarId.intros (since := \"2022-07-15\")]\ndef intros (mvarId : MVarId) : MetaM (Array FVarId Γ MVarId) := do\n mvarId.intros",
"start": [
209,
1
],
"end": [
211,
16
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/ForEachExpr.lean | [
".lake/packages/lean4/src/lean/Lean/Util/MonadCache.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.ForEachExpr.visit",
"code": "def visit (g : Expr β m Bool) (e : Expr) : MonadCacheT Expr Unit m Unit :=\n checkCache e fun _ => do\n if (β g e) then\n match e with\n | Expr.forallE _ d b _ => do visit g d; visit g b\n | Expr.lam _ d b _ => do visit g d; visit g b\n | Expr.letE _ t v b _ => do visit g t; visit g v; visit g b\n | Expr.app f a => do visit g f; visit g a\n | Expr.mdata _ b => visit g b\n | Expr.proj _ _ b => visit g b\n | _ => pure ()",
"start": [
19,
1
],
"end": [
29,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.forEach'",
"code": "@[inline] def Expr.forEach' (e : Expr) (f : Expr β m Bool) : m Unit :=\n (ForEachExpr.visit f e).run",
"start": [
33,
1
],
"end": [
35,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.forEach",
"code": "@[inline] def Expr.forEach (e : Expr) (f : Expr β m Unit) : m Unit :=\n e.forEach' fun e => do f e; pure true",
"start": [
37,
1
],
"end": [
38,
40
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Revert.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Clear.lean"
] | [
{
"full_name": "Lean.MVarId.revert",
"code": "def _root_.Lean.MVarId.revert (mvarId : MVarId) (fvarIds : Array FVarId) (preserveOrder : Bool := false)\n (clearAuxDeclsInsteadOfRevert := false) : MetaM (Array FVarId Γ MVarId) := do\n if fvarIds.isEmpty then\n pure (#[], mvarId)\n else mvarId.withContext do\n mvarId.checkNotAssigned `revert\n unless clearAuxDeclsInsteadOfRevert do\n for fvarId in fvarIds do\n if (β fvarId.getDecl) |>.isAuxDecl then\n throwError \"failed to revert {mkFVar fvarId}, it is an auxiliary declaration created to represent recursive definitions\"\n let fvars := fvarIds.map mkFVar\n let toRevert β collectForwardDeps fvars preserveOrder\n \n let mut mvarId := mvarId\n let mut toRevertNew := #[]\n for x in toRevert do\n if (β x.fvarId!.getDecl).isAuxDecl then\n mvarId β mvarId.clear x.fvarId!\n else\n toRevertNew := toRevertNew.push x\n let tag β mvarId.getTag\n mvarId.setKind .natural\n let (e, toRevert) β\n try\n liftMkBindingM <| MetavarContext.revert toRevertNew mvarId preserveOrder\n finally\n mvarId.setKind .syntheticOpaque\n let mvar := e.getAppFn\n mvar.mvarId!.setTag tag\n return (toRevert.map Expr.fvarId!, mvar.mvarId!)",
"start": [
11,
1
],
"end": [
47,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.revertAfter",
"code": "def _root_.Lean.MVarId.revertAfter (mvarId : MVarId) (fvarId : FVarId) : MetaM (Array FVarId Γ MVarId) :=\n mvarId.withContext do\n let localDecl β fvarId.getDecl\n let fvarIds := (β getLCtx).foldl (init := #[]) (start := localDecl.index+1) fun fvarIds decl => fvarIds.push decl.fvarId\n mvarId.revert fvarIds (preserveOrder := true) (clearAuxDeclsInsteadOfRevert := true)",
"start": [
49,
1
],
"end": [
54,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.revert",
"code": "@[deprecated MVarId.revert (since := \"2022-07-15\")]\ndef revert (mvarId : MVarId) (fvarIds : Array FVarId) (preserveOrder : Bool := false) : MetaM (Array FVarId Γ MVarId) := do\n mvarId.revert fvarIds preserveOrder",
"start": [
56,
1
],
"end": [
58,
38
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/InsertionSort.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/BasicAux.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/BinSearch.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/QSort.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/Lemmas.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/Mem.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/DecidableEq.lean"
] | [] |
.lake/packages/lean4/src/lean/Lean/Data/Lsp/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json.lean",
".lake/packages/lean4/src/lean/Lean/Data/JsonRpc.lean"
] | [
{
"full_name": "Lean.Lsp.CancelParams",
"code": "structure CancelParams where\n id : JsonRpc.RequestID\n deriving Inhabited, BEq, ToJson, FromJson",
"start": [
22,
1
],
"end": [
24,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.DocumentUri",
"code": "abbrev DocumentUri := String",
"start": [
26,
1
],
"end": [
26,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.Position",
"code": "structure Position where\n line : Nat\n character : Nat\n deriving Inhabited, BEq, Ord, Hashable, ToJson, FromJson",
"start": [
28,
1
],
"end": [
35,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.Range",
"code": "structure Range where\n start : Position\n Β«endΒ» : Position\n deriving Inhabited, BEq, Hashable, ToJson, FromJson, Ord",
"start": [
43,
1
],
"end": [
46,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.Location",
"code": "structure Location where\n uri : DocumentUri\n range : Range\n deriving Inhabited, BEq, ToJson, FromJson, Ord",
"start": [
51,
1
],
"end": [
55,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.LocationLink",
"code": "structure LocationLink where\n originSelectionRange? : Option Range\n targetUri : DocumentUri\n targetRange : Range\n targetSelectionRange : Range\n deriving ToJson, FromJson",
"start": [
57,
1
],
"end": [
62,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.Command",
"code": "structure Command where\n \n title : String\n \n command : String\n \n arguments? : Option (Array Json) := none\n deriving ToJson, FromJson",
"start": [
66,
1
],
"end": [
80,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.SnippetString",
"code": "structure SnippetString where\n value : String\n deriving ToJson, FromJson",
"start": [
82,
1
],
"end": [
112,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextEdit",
"code": "structure TextEdit where\n \n range : Range\n \n newText : String\n \n \n leanExtSnippet? : Option SnippetString := none\n \n annotationId? : Option String := none\n deriving ToJson, FromJson",
"start": [
114,
1
],
"end": [
146,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextEditBatch",
"code": "def TextEditBatch := Array TextEdit",
"start": [
148,
1
],
"end": [
149,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextDocumentIdentifier",
"code": "structure TextDocumentIdentifier where\n uri : DocumentUri\n deriving ToJson, FromJson",
"start": [
165,
1
],
"end": [
167,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.VersionedTextDocumentIdentifier",
"code": "structure VersionedTextDocumentIdentifier where\n uri : DocumentUri\n version? : Option Nat := none\n deriving ToJson, FromJson",
"start": [
169,
1
],
"end": [
172,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextDocumentEdit",
"code": "structure TextDocumentEdit where\n textDocument : VersionedTextDocumentIdentifier\n edits : TextEditBatch\n deriving ToJson, FromJson",
"start": [
174,
1
],
"end": [
180,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.ChangeAnnotation",
"code": "structure ChangeAnnotation where\n \n label : String\n \n needsConfirmation : Bool := false\n \n description? : Option String := none\n deriving ToJson, FromJson",
"start": [
182,
1
],
"end": [
193,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.CreateFile.Options",
"code": "structure CreateFile.Options where\n overwrite : Bool := false\n ignoreIfExists : Bool := false\n deriving ToJson, FromJson",
"start": [
195,
1
],
"end": [
199,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.DeleteFile.Options",
"code": "structure DeleteFile.Options where\n recursive : Bool := false\n ignoreIfNotExists := false\n deriving ToJson, FromJson",
"start": [
201,
1
],
"end": [
205,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.CreateFile",
"code": "structure CreateFile where\n uri : DocumentUri\n options? : Option CreateFile.Options := none\n annotationId? : Option String := none\n deriving ToJson, FromJson",
"start": [
207,
1
],
"end": [
211,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.RenameFile",
"code": "structure RenameFile where\n oldUri : DocumentUri\n newUri : DocumentUri\n options? : Option CreateFile.Options := none\n annotationId? : Option String := none\n deriving ToJson, FromJson",
"start": [
213,
1
],
"end": [
218,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.DeleteFile",
"code": "structure DeleteFile where\n uri : DocumentUri\n options? : Option DeleteFile.Options := none\n annotationId? : Option String := none\n deriving ToJson, FromJson",
"start": [
220,
1
],
"end": [
224,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.DocumentChange",
"code": "inductive DocumentChange where\n | create : CreateFile β DocumentChange\n | rename : RenameFile β DocumentChange\n | delete : DeleteFile β DocumentChange\n | edit : TextDocumentEdit β DocumentChange",
"start": [
226,
1
],
"end": [
233,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkspaceEdit",
"code": "structure WorkspaceEdit where\n \n changes? : Option (RBMap DocumentUri TextEditBatch compare) := none\n \n documentChanges? : Option (Array DocumentChange) := none\n \n changeAnnotations? : Option (RBMap String ChangeAnnotation compare) := none\n deriving ToJson, FromJson",
"start": [
252,
1
],
"end": [
279,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkspaceEdit.ofTextDocumentEdit",
"code": "def ofTextDocumentEdit (e : TextDocumentEdit) : WorkspaceEdit :=\n { documentChanges? := #[DocumentChange.edit e]}",
"start": [
301,
1
],
"end": [
302,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkspaceEdit.ofTextEdit",
"code": "def ofTextEdit (doc : VersionedTextDocumentIdentifier) (te : TextEdit) : WorkspaceEdit :=\n ofTextDocumentEdit { textDocument := doc, edits := #[te]}",
"start": [
304,
1
],
"end": [
305,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.ApplyWorkspaceEditParams",
"code": "structure ApplyWorkspaceEditParams where\n \n label? : Option String := none\n \n edit : WorkspaceEdit\n deriving ToJson, FromJson",
"start": [
309,
1
],
"end": [
319,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextDocumentItem",
"code": "structure TextDocumentItem where\n \n uri : DocumentUri\n \n languageId : String\n \n version : Nat\n \n text : String\n deriving ToJson, FromJson",
"start": [
321,
1
],
"end": [
334,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextDocumentPositionParams",
"code": "structure TextDocumentPositionParams where\n textDocument : TextDocumentIdentifier\n position : Position\n deriving ToJson, FromJson",
"start": [
336,
1
],
"end": [
339,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.DocumentFilter",
"code": "structure DocumentFilter where\n language? : Option String := none\n scheme? : Option String := none\n pattern? : Option String := none\n deriving ToJson, FromJson",
"start": [
344,
1
],
"end": [
348,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.DocumentSelector",
"code": "def DocumentSelector := Array DocumentFilter",
"start": [
350,
1
],
"end": [
350,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.StaticRegistrationOptions",
"code": "structure StaticRegistrationOptions where\n id? : Option String := none\n deriving ToJson, FromJson",
"start": [
358,
1
],
"end": [
360,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.TextDocumentRegistrationOptions",
"code": "structure TextDocumentRegistrationOptions where\n documentSelector? : Option DocumentSelector := none\n deriving ToJson, FromJson",
"start": [
362,
1
],
"end": [
364,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.MarkupKind",
"code": "inductive MarkupKind where\n | plaintext | markdown",
"start": [
366,
1
],
"end": [
367,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.MarkupContent",
"code": "structure MarkupContent where\n kind : MarkupKind\n value : String\n deriving ToJson, FromJson",
"start": [
378,
1
],
"end": [
381,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.ProgressToken",
"code": "abbrev ProgressToken := String",
"start": [
383,
1
],
"end": [
387,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.ProgressParams",
"code": "structure ProgressParams (Ξ± : Type) where\n token : ProgressToken\n value : Ξ±\n deriving ToJson",
"start": [
389,
1
],
"end": [
395,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkDoneProgressReport",
"code": "structure WorkDoneProgressReport where\n kind := \"report\"\n \n message? : Option String := none\n \n cancellable := false\n \n percentage? : Option Nat := none\n deriving ToJson",
"start": [
397,
1
],
"end": [
406,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkDoneProgressBegin",
"code": "structure WorkDoneProgressBegin extends WorkDoneProgressReport where\n kind := \"begin\"\n title : String\n deriving ToJson",
"start": [
408,
1
],
"end": [
412,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkDoneProgressEnd",
"code": "structure WorkDoneProgressEnd where\n kind := \"end\"\n message? : Option String := none\n deriving ToJson",
"start": [
414,
1
],
"end": [
418,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkDoneProgressParams",
"code": "structure WorkDoneProgressParams where\n workDoneToken? : Option ProgressToken := none\n deriving ToJson, FromJson",
"start": [
420,
1
],
"end": [
422,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.PartialResultParams",
"code": "structure PartialResultParams where\n partialResultToken? : Option ProgressToken := none\n deriving ToJson, FromJson",
"start": [
424,
1
],
"end": [
426,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Lsp.WorkDoneProgressOptions",
"code": "structure WorkDoneProgressOptions where\n workDoneProgress := false\n deriving ToJson, FromJson",
"start": [
428,
1
],
"end": [
431,
28
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/HeadIndex.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.HeadIndex",
"code": "inductive HeadIndex where\n | fvar (fvarId : FVarId)\n | mvar (mvarId : MVarId)\n | const (constName : Name)\n | proj (structName : Name) (idx : Nat)\n | lit (litVal : Literal)\n | sort\n | lam\n | forallE\n deriving Inhabited, BEq, Repr",
"start": [
11,
1
],
"end": [
33,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.HeadIndex.hash",
"code": "protected def HeadIndex.hash : HeadIndex β UInt64\n | fvar fvarId => mixHash 11 <| hash fvarId\n | mvar mvarId => mixHash 13 <| hash mvarId\n | const constName => mixHash 17 <| hash constName\n | proj structName idx => mixHash 19 <| mixHash (hash structName) (hash idx)\n | lit litVal => mixHash 23 <| hash litVal\n | sort => 29\n | lam => 31\n | forallE => 37",
"start": [
35,
1
],
"end": [
44,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.headNumArgs",
"code": "def headNumArgs (e : Expr) : Nat :=\n go e 0\nwhere\n go : Expr β Nat β Nat\n | app f _, n => go f (n + 1)\n | letE _ _ _ b _, n => go b n\n | mdata _ e, n => go e n\n | _, n => n",
"start": [
50,
1
],
"end": [
58,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.toHeadIndexQuick?",
"code": "private def toHeadIndexQuick? : Expr β Option HeadIndex\n | mvar mvarId => HeadIndex.mvar mvarId\n | fvar fvarId => HeadIndex.fvar fvarId\n | const constName _ => HeadIndex.const constName\n | proj structName idx _ => HeadIndex.proj structName idx\n | sort _ => HeadIndex.sort\n | lam .. => HeadIndex.lam\n | forallE .. => HeadIndex.forallE\n | lit v => HeadIndex.lit v\n | app f _ => toHeadIndexQuick? f\n | letE _ _ _ b _ => toHeadIndexQuick? b\n | mdata _ e => toHeadIndexQuick? e\n | _ => none",
"start": [
60,
1
],
"end": [
80,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.toHeadIndexSlow",
"code": "private partial def toHeadIndexSlow : Expr β HeadIndex\n | mvar mvarId => HeadIndex.mvar mvarId\n | fvar fvarId => HeadIndex.fvar fvarId\n | const constName _ => HeadIndex.const constName\n | proj structName idx _ => HeadIndex.proj structName idx\n | sort _ => HeadIndex.sort\n | lam .. => HeadIndex.lam\n | forallE .. => HeadIndex.forallE\n | lit v => HeadIndex.lit v\n | app f _ => toHeadIndexSlow f\n | letE _ _ v b _ => toHeadIndexSlow (b.instantiate1 v)\n | mdata _ e => toHeadIndexSlow e\n | _ => panic! \"unexpected expression kind\"",
"start": [
82,
1
],
"end": [
100,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.toHeadIndex",
"code": "def toHeadIndex (e : Expr) : HeadIndex :=\n match toHeadIndexQuick? e with\n | some i => i\n | none => toHeadIndexSlow e",
"start": [
102,
1
],
"end": [
108,
30
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/AuxLemma.lean | [
".lake/packages/lean4/src/lean/Lean/AddDecl.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Meta.AuxLemmas",
"code": "structure AuxLemmas where\n idx : Nat := 1\n lemmas : PHashMap Expr (Name Γ List Name) := {}\n deriving Inhabited",
"start": [
12,
1
],
"end": [
15,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkAuxLemma",
"code": "def mkAuxLemma (levelParams : List Name) (type : Expr) (value : Expr) : MetaM Name := do\n let env β getEnv\n let s := auxLemmasExt.getState env\n let mkNewAuxLemma := do\n let auxName := Name.mkNum (env.mainModule ++ `_auxLemma) s.idx\n addDecl <| Declaration.thmDecl {\n name := auxName\n levelParams, type, value\n }\n modifyEnv fun env => auxLemmasExt.modifyState env fun β¨idx, lemmasβ© => β¨idx + 1, lemmas.insert type (auxName, levelParams)β©\n return auxName\n match s.lemmas.find? type with\n | some (name, levelParams') => if levelParams == levelParams' then return name else mkNewAuxLemma\n | none => mkNewAuxLemma",
"start": [
19,
1
],
"end": [
41,
26
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/DocString.lean | [
".lake/packages/lean4/src/lean/Lean/DocString/Extension.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Tactic/Doc.lean"
] | [
{
"full_name": "Lean.findDocString?",
"code": "def findDocString? (env : Environment) (declName : Name) (includeBuiltin := true) : IO (Option String) := do\n let declName := alternativeOfTactic env declName |>.getD declName\n let exts := getTacticExtensionString env declName\n return (β findSimpleDocString? env declName (includeBuiltin := includeBuiltin)).map (Β· ++ exts)",
"start": [
19,
1
],
"end": [
29,
98
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/PrettyPrinter.lean | [
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Formatter.lean",
".lake/packages/lean4/src/lean/Lean/ParserCompiler.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Module.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Parenthesizer.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter/Delaborator.lean"
] | [
{
"full_name": "Lean.PPContext.runCoreM",
"code": "def PPContext.runCoreM {Ξ± : Type} (ppCtx : PPContext) (x : CoreM Ξ±) : IO Ξ± :=\n Prod.fst <$> x.toIO { options := ppCtx.opts, currNamespace := ppCtx.currNamespace\n openDecls := ppCtx.openDecls\n fileName := \"<PrettyPrinter>\", fileMap := default\n diag := getDiag ppCtx.opts }\n { env := ppCtx.env, ngen := { namePrefix := `_pp_uniq } }",
"start": [
15,
1
],
"end": [
20,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PPContext.runMetaM",
"code": "def PPContext.runMetaM {Ξ± : Type} (ppCtx : PPContext) (x : MetaM Ξ±) : IO Ξ± :=\n ppCtx.runCoreM <| x.run' { lctx := ppCtx.lctx } { mctx := ppCtx.mctx }",
"start": [
22,
1
],
"end": [
23,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppCategory",
"code": "def ppCategory (cat : Name) (stx : Syntax) : CoreM Format := do\n let opts β getOptions\n let stx := (sanitizeSyntax stx).run' { options := opts }\n parenthesizeCategory cat stx >>= formatCategory cat",
"start": [
27,
1
],
"end": [
30,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppTerm",
"code": "def ppTerm (stx : Term) : CoreM Format := ppCategory `term stx",
"start": [
32,
1
],
"end": [
32,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppUsing",
"code": "def ppUsing (e : Expr) (delab : Expr β MetaM Term) : MetaM Format := do\n let lctx := (β getLCtx).sanitizeNames.run' { options := (β getOptions) }\n Meta.withLCtx lctx #[] do\n ppTerm (β delab e)",
"start": [
34,
1
],
"end": [
37,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppExpr",
"code": "def ppExpr (e : Expr) : MetaM Format := do\n ppUsing e delab",
"start": [
39,
1
],
"end": [
40,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppExprWithInfos",
"code": "def ppExprWithInfos (e : Expr) (optsPerPos : Delaborator.OptionsPerPos := {}) (delab := Delaborator.delab)\n : MetaM FormatWithInfos := do\n let lctx := (β getLCtx).sanitizeNames.run' { options := (β getOptions) }\n Meta.withLCtx lctx #[] do\n let (stx, infos) β delabCore e optsPerPos delab\n let fmt β ppTerm stx\n return β¨fmt, infosβ©",
"start": [
42,
1
],
"end": [
50,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppExprLegacy",
"code": "@[export lean_pp_expr]\ndef ppExprLegacy (env : Environment) (mctx : MetavarContext) (lctx : LocalContext) (opts : Options) (e : Expr) : IO Format :=\n Prod.fst <$> ((withOptions (fun _ => opts) <| ppExpr e).run' { lctx := lctx } { mctx := mctx }).toIO\n { fileName := \"<PrettyPrinter>\", fileMap := default }\n { env := env }",
"start": [
52,
1
],
"end": [
56,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppTactic",
"code": "def ppTactic (stx : TSyntax `tactic) : CoreM Format := ppCategory `tactic stx",
"start": [
58,
1
],
"end": [
58,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppCommand",
"code": "def ppCommand (stx : Syntax.Command) : CoreM Format := ppCategory `command stx",
"start": [
60,
1
],
"end": [
60,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppModule",
"code": "def ppModule (stx : TSyntax ``Parser.Module.module) : CoreM Format := do\n parenthesize Lean.Parser.Module.module.parenthesizer stx >>= format Lean.Parser.Module.module.formatter",
"start": [
62,
1
],
"end": [
63,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.ppSignature",
"code": "def ppSignature (c : Name) : MetaM FormatWithInfos := do\n let decl β getConstInfo c\n let e := .const c (decl.levelParams.map mkLevelParam)\n let (stx, infos) β delabCore e (delab := delabConstWithSignature)\n return β¨β ppTerm β¨stxβ©, infosβ©",
"start": [
66,
1
],
"end": [
71,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.noContext",
"code": "private partial def noContext : MessageData β MessageData\n | MessageData.withContext _ msg => noContext msg\n | MessageData.withNamingContext ctx msg => MessageData.withNamingContext ctx (noContext msg)\n | MessageData.nest n msg => MessageData.nest n (noContext msg)\n | MessageData.group msg => MessageData.group (noContext msg)\n | MessageData.compose msgβ msgβ => MessageData.compose (noContext msgβ) (noContext msgβ)\n | MessageData.tagged tag msg => MessageData.tagged tag (noContext msg)\n | MessageData.trace data header children =>\n MessageData.trace data (noContext header) (children.map noContext)\n | msg => msg",
"start": [
73,
1
],
"end": [
82,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.withoutContext",
"code": "private def withoutContext {m} [MonadExcept Exception m] (x : m Ξ±) : m Ξ± :=\n tryCatch x fun\n | Exception.error ref msg => throw <| Exception.error ref (noContext msg)\n | ex => throw ex",
"start": [
85,
1
],
"end": [
88,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.registerParserCompilers",
"code": "@[builtin_init]\nunsafe def registerParserCompilers : IO Unit := do\n ParserCompiler.registerParserCompiler β¨`parenthesizer, parenthesizerAttribute, combinatorParenthesizerAttributeβ©\n ParserCompiler.registerParserCompiler β¨`formatter, formatterAttribute, combinatorFormatterAttributeβ©",
"start": [
101,
1
],
"end": [
104,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofFormatWithInfosM",
"code": "def ofFormatWithInfosM (fmt : MetaM FormatWithInfos) : MessageData :=\n .lazy fun ctx => ctx.runMetaM <|\n withOptions (pp.tagAppFns.set Β· true) <|\n .ofFormatWithInfos <$> fmt",
"start": [
112,
1
],
"end": [
120,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofLazyM",
"code": "def ofLazyM (f : MetaM MessageData) (es : Array Expr := #[]) : MessageData :=\n .lazy\n (f := fun ppctxt => ppctxt.runMetaM f)\n (hasSyntheticSorry := fun mvarctxt => es.any (fun a =>\n instantiateMVarsCore mvarctxt a |>.1.hasSyntheticSorry\n ))",
"start": [
122,
1
],
"end": [
132,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofConst",
"code": "def ofConst (e : Expr) : MessageData :=\n if e.isConst then\n .ofFormatWithInfosM (PrettyPrinter.ppExprWithInfos (delab := delabConst) e)\n else\n panic! \"not a constant\"",
"start": [
134,
1
],
"end": [
142,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.signature",
"code": "def signature (c : Name) : MessageData :=\n .ofFormatWithInfosM (PrettyPrinter.ppSignature c)",
"start": [
144,
1
],
"end": [
146,
52
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Eqns.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Match/MatcherInfo.lean",
".lake/packages/lean4/src/lean/Lean/ReservedNameAction.lean",
".lake/packages/lean4/src/lean/Lean/AddDecl.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean"
] | [
{
"full_name": "Lean.Meta.markAsRecursive",
"code": "def markAsRecursive (declName : Name) : CoreM Unit :=\n modifyEnv (recExt.tag Β· declName)",
"start": [
21,
1
],
"end": [
25,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isRecursiveDefinition",
"code": "def isRecursiveDefinition (declName : Name) : CoreM Bool :=\n return recExt.isTagged (β getEnv) declName",
"start": [
27,
1
],
"end": [
31,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.eqnThmSuffixBase",
"code": "def eqnThmSuffixBase := \"eq\"",
"start": [
33,
1
],
"end": [
33,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.eqnThmSuffixBasePrefix",
"code": "def eqnThmSuffixBasePrefix := eqnThmSuffixBase ++ \"_\"",
"start": [
34,
1
],
"end": [
34,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.eqn1ThmSuffix",
"code": "def eqn1ThmSuffix := eqnThmSuffixBasePrefix ++ \"1\"",
"start": [
35,
1
],
"end": [
35,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isEqnReservedNameSuffix",
"code": "def isEqnReservedNameSuffix (s : String) : Bool :=\n eqnThmSuffixBasePrefix.isPrefixOf s && (s.drop 3).isNat",
"start": [
38,
1
],
"end": [
40,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.unfoldThmSuffix",
"code": "def unfoldThmSuffix := \"eq_def\"",
"start": [
42,
1
],
"end": [
42,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isUnfoldReservedNameSuffix",
"code": "def isUnfoldReservedNameSuffix (s : String) : Bool :=\n s == unfoldThmSuffix",
"start": [
44,
1
],
"end": [
46,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ensureEqnReservedNamesAvailable",
"code": "def ensureEqnReservedNamesAvailable (declName : Name) : CoreM Unit := do\n ensureReservedNameAvailable declName unfoldThmSuffix\n ensureReservedNameAvailable declName eqn1ThmSuffix",
"start": [
48,
1
],
"end": [
53,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.GetEqnsFn",
"code": "def GetEqnsFn := Name β MetaM (Option (Array Name))",
"start": [
71,
1
],
"end": [
71,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.registerGetEqnsFn",
"code": "def registerGetEqnsFn (f : GetEqnsFn) : IO Unit := do\n unless (β initializing) do\n throw (IO.userError \"failed to register equation getter, this kind of extension can only be registered during initialization\")\n getEqnsFnsRef.modify (f :: Β·)",
"start": [
75,
1
],
"end": [
103,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.shouldGenerateEqnThms",
"code": "private def shouldGenerateEqnThms (declName : Name) : MetaM Bool := do\n if let some (.defnInfo info) := (β getEnv).find? declName then\n return !(β isProp info.type)\n else\n return false",
"start": [
105,
1
],
"end": [
110,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.EqnsExtState",
"code": "structure EqnsExtState where\n map : PHashMap Name (Array Name) := {}\n mapInv : PHashMap Name Name := {} deriving Inhabited",
"start": [
112,
1
],
"end": [
115,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSimpleEqThm",
"code": "private def mkSimpleEqThm (declName : Name) (suffix := Name.mkSimple unfoldThmSuffix) : MetaM (Option Name) := do\n if let some (.defnInfo info) := (β getEnv).find? declName then\n lambdaTelescope (cleanupAnnotations := true) info.value fun xs body => do\n let lhs := mkAppN (mkConst info.name <| info.levelParams.map mkLevelParam) xs\n let type β mkForallFVars xs (β mkEq lhs body)\n let value β mkLambdaFVars xs (β mkEqRefl lhs)\n let name := declName ++ suffix\n addDecl <| Declaration.thmDecl {\n name, type, value\n levelParams := info.levelParams\n }\n return some name\n else\n return none",
"start": [
121,
1
],
"end": [
137,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isEqnThm?",
"code": "def isEqnThm? (thmName : Name) : CoreM (Option Name) := do\n return eqnsExt.getState (β getEnv) |>.mapInv.find? thmName",
"start": [
139,
1
],
"end": [
143,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.registerEqnThms",
"code": "private def registerEqnThms (declName : Name) (eqThms : Array Name) : CoreM Unit := do\n modifyEnv fun env => eqnsExt.modifyState env fun s => { s with\n map := s.map.insert declName eqThms\n mapInv := eqThms.foldl (init := s.mapInv) fun mapInv eqThm => mapInv.insert eqThm declName\n }",
"start": [
145,
1
],
"end": [
152,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.alreadyGenerated?",
"code": "private partial def alreadyGenerated? (declName : Name) : MetaM (Option (Array Name)) := do\n let env β getEnv\n let eq1 := Name.str declName eqn1ThmSuffix\n if env.contains eq1 then\n let rec loop (idx : Nat) (eqs : Array Name) : MetaM (Array Name) := do\n let nextEq := declName ++ (`eq).appendIndexAfter idx\n if env.contains nextEq then\n loop (idx+1) (eqs.push nextEq)\n else\n return eqs\n let eqs β loop 2 #[eq1]\n registerEqnThms declName eqs\n return some eqs\n else\n return none",
"start": [
154,
1
],
"end": [
171,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getEqnsFor?",
"code": "def getEqnsFor? (declName : Name) (nonRec := false) : MetaM (Option (Array Name)) := withLCtx {} {} do\n if let some eqs := eqnsExt.getState (β getEnv) |>.map.find? declName then\n return some eqs\n else if let some eqs β alreadyGenerated? declName then\n return some eqs\n else if (β shouldGenerateEqnThms declName) then\n for f in (β getEqnsFnsRef.get) do\n if let some r β f declName then\n registerEqnThms declName r\n return some r\n if nonRec then\n let some eqThm β mkSimpleEqThm declName (suffix := Name.mkSimple eqn1ThmSuffix) | return none\n let r := #[eqThm]\n registerEqnThms declName r\n return some r\n return none",
"start": [
173,
1
],
"end": [
193,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.GetUnfoldEqnFn",
"code": "def GetUnfoldEqnFn := Name β MetaM (Option Name)",
"start": [
195,
1
],
"end": [
195,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.registerGetUnfoldEqnFn",
"code": "def registerGetUnfoldEqnFn (f : GetUnfoldEqnFn) : IO Unit := do\n unless (β initializing) do\n throw (IO.userError \"failed to register equation getter, this kind of extension can only be registered during initialization\")\n getUnfoldEqnFnsRef.modify (f :: Β·)",
"start": [
199,
1
],
"end": [
227,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getUnfoldEqnFor?",
"code": "def getUnfoldEqnFor? (declName : Name) (nonRec := false) : MetaM (Option Name) := withLCtx {} {} do\n let env β getEnv\n let unfoldName := Name.str declName unfoldThmSuffix\n if env.contains unfoldName then\n return some unfoldName\n if (β shouldGenerateEqnThms declName) then\n for f in (β getUnfoldEqnFnsRef.get) do\n if let some r β f declName then\n unless r == unfoldName do\n throwError \"invalid unfold theorem name `{r}` has been generated expected `{unfoldName}`\"\n return some r\n if nonRec then\n return (β mkSimpleEqThm declName)\n return none",
"start": [
229,
1
],
"end": [
247,
15
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/MatchUtil.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Util/Recognizers.lean",
".lake/packages/lean4/src/lean/Lean/Meta/CtorRecognizer.lean"
] | [
{
"full_name": "Lean.Meta.testHelper",
"code": "@[inline] def testHelper (e : Expr) (p : Expr β MetaM Bool) : MetaM Bool := do\n if (β p e) then\n return true\n else\n p (β whnf e)",
"start": [
13,
1
],
"end": [
17,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchHelper?",
"code": "@[inline] def matchHelper? (e : Expr) (p? : Expr β MetaM (Option Ξ±)) : MetaM (Option Ξ±) := do\n match (β p? e) with\n | none => p? (β whnf e)\n | s => return s",
"start": [
19,
1
],
"end": [
22,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchEq?",
"code": "def matchEq? (e : Expr) : MetaM (Option (Expr Γ Expr Γ Expr)) :=\n matchHelper? e fun e => return Expr.eq? e",
"start": [
24,
1
],
"end": [
26,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchHEq?",
"code": "def matchHEq? (e : Expr) : MetaM (Option (Expr Γ Expr Γ Expr Γ Expr)) :=\n matchHelper? e fun e => return Expr.heq? e",
"start": [
28,
1
],
"end": [
29,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchEqHEq?",
"code": "def matchEqHEq? (e : Expr) : MetaM (Option (Expr Γ Expr Γ Expr)) := do\n if let some r β matchEq? e then\n return some r\n else if let some (Ξ±, lhs, Ξ², rhs) β matchHEq? e then\n if (β isDefEq Ξ± Ξ²) then\n return some (Ξ±, lhs, rhs)\n return none\n else\n return none",
"start": [
31,
1
],
"end": [
42,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchFalse",
"code": "def matchFalse (e : Expr) : MetaM Bool := do\n testHelper e fun e => return e.isFalse",
"start": [
44,
1
],
"end": [
45,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchNot?",
"code": "def matchNot? (e : Expr) : MetaM (Option Expr) :=\n matchHelper? e fun e => do\n if let some e := e.not? then\n return e\n else if let some (a, b) := e.arrow? then\n if (β matchFalse b) then return some a else return none\n else\n return none",
"start": [
47,
1
],
"end": [
54,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchNe?",
"code": "def matchNe? (e : Expr) : MetaM (Option (Expr Γ Expr Γ Expr)) :=\n matchHelper? e fun e => do\n if let some r := e.ne? then\n return r\n else if let some e β matchNot? e then\n matchEq? e\n else\n return none",
"start": [
56,
1
],
"end": [
63,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.matchConstructorApp?",
"code": "def matchConstructorApp? (e : Expr) : MetaM (Option ConstructorVal) := do\n matchHelper? e isConstructorApp?",
"start": [
65,
1
],
"end": [
66,
35
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Assert.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Revert.lean",
".lake/packages/lean4/src/lean/Lean/Util/ForEachExpr.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Intro.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/FVarSubst.lean"
] | [
{
"full_name": "Lean.MVarId.assert",
"code": "def _root_.Lean.MVarId.assert (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) : MetaM MVarId :=\n mvarId.withContext do\n mvarId.checkNotAssigned `assert\n let tag β mvarId.getTag\n let target β mvarId.getType\n let newType := Lean.mkForall name BinderInfo.default type target\n let newMVar β mkFreshExprSyntheticOpaqueMVar newType tag\n mvarId.assign (mkApp newMVar val)\n return newMVar.mvarId!",
"start": [
14,
1
],
"end": [
25,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.assert",
"code": "@[deprecated MVarId.assert (since := \"2022-07-15\")]\ndef assert (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) : MetaM MVarId :=\n mvarId.assert name type val",
"start": [
27,
1
],
"end": [
29,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.note",
"code": "def _root_.Lean.MVarId.note (g : MVarId) (h : Name) (v : Expr) (t? : Option Expr := .none) :\n MetaM (FVarId Γ MVarId) := do\n (β g.assert h (β match t? with | some t => pure t | none => inferType v) v).intro1P",
"start": [
31,
1
],
"end": [
34,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.define",
"code": "def _root_.Lean.MVarId.define (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) : MetaM MVarId := do\n mvarId.withContext do\n mvarId.checkNotAssigned `define\n let tag β mvarId.getTag\n let target β mvarId.getType\n let newType := Lean.mkLet name type val target\n let newMVar β mkFreshExprSyntheticOpaqueMVar newType tag\n mvarId.assign newMVar\n return newMVar.mvarId!",
"start": [
36,
1
],
"end": [
47,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.define",
"code": "@[deprecated MVarId.define (since := \"2022-07-15\")]\ndef define (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) : MetaM MVarId := do\n mvarId.define name type val",
"start": [
49,
1
],
"end": [
51,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.assertExt",
"code": "def _root_.Lean.MVarId.assertExt (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) (hName : Name := `h) : MetaM MVarId := do\n mvarId.withContext do\n mvarId.checkNotAssigned `assert\n let tag β mvarId.getTag\n let target β mvarId.getType\n let u β getLevel type\n let hType := mkApp3 (mkConst `Eq [u]) type (mkBVar 0) val\n let newType := Lean.mkForall name BinderInfo.default type $ Lean.mkForall hName BinderInfo.default hType target\n let newMVar β mkFreshExprSyntheticOpaqueMVar newType tag\n let rflPrf β mkEqRefl val\n mvarId.assign (mkApp2 newMVar val rflPrf)\n return newMVar.mvarId!",
"start": [
53,
1
],
"end": [
67,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.assertExt",
"code": "@[deprecated MVarId.assertExt (since := \"2022-07-15\")]\ndef assertExt (mvarId : MVarId) (name : Name) (type : Expr) (val : Expr) (hName : Name := `h) : MetaM MVarId := do\n mvarId.assertExt name type val hName",
"start": [
69,
1
],
"end": [
71,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AssertAfterResult",
"code": "structure AssertAfterResult where\n fvarId : FVarId\n mvarId : MVarId\n subst : FVarSubst",
"start": [
73,
1
],
"end": [
76,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.assertAfter",
"code": "def _root_.Lean.MVarId.assertAfter (mvarId : MVarId) (fvarId : FVarId) (userName : Name) (type : Expr) (val : Expr) : MetaM AssertAfterResult := do\n mvarId.checkNotAssigned `assertAfter\n let (fvarIds, mvarId) β mvarId.revertAfter fvarId\n let mvarId β mvarId.assert userName type val\n let (fvarIdNew, mvarId) β mvarId.intro1P\n let (fvarIdsNew, mvarId) β mvarId.introNP fvarIds.size\n let mut subst := {}\n for f in fvarIds, fNew in fvarIdsNew do\n subst := subst.insert f (mkFVar fNew)\n return { fvarId := fvarIdNew, mvarId, subst }",
"start": [
78,
1
],
"end": [
91,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.assertAfter",
"code": "@[deprecated MVarId.assertAfter (since := \"2022-07-15\")]\ndef assertAfter (mvarId : MVarId) (fvarId : FVarId) (userName : Name) (type : Expr) (val : Expr) : MetaM AssertAfterResult := do\n mvarId.assertAfter fvarId userName type val",
"start": [
93,
1
],
"end": [
95,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Hypothesis",
"code": "structure Hypothesis where\n userName : Name\n type : Expr\n value : Expr",
"start": [
97,
1
],
"end": [
100,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.assertHypotheses",
"code": "def _root_.Lean.MVarId.assertHypotheses (mvarId : MVarId) (hs : Array Hypothesis) : MetaM (Array FVarId Γ MVarId) := do\n if hs.isEmpty then\n return (#[], mvarId)\n else mvarId.withContext do\n mvarId.checkNotAssigned `assertHypotheses\n let tag β mvarId.getTag\n let target β mvarId.getType\n let targetNew := hs.foldr (init := target) fun h targetNew =>\n mkForall h.userName BinderInfo.default h.type targetNew\n let mvarNew β mkFreshExprSyntheticOpaqueMVar targetNew tag\n let val := hs.foldl (init := mvarNew) fun val h => mkApp val h.value\n mvarId.assign val\n mvarNew.mvarId!.introNP hs.size",
"start": [
102,
1
],
"end": [
117,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.assertHypotheses",
"code": "@[deprecated MVarId.assertHypotheses (since := \"2022-07-15\")]\ndef assertHypotheses (mvarId : MVarId) (hs : Array Hypothesis) : MetaM (Array FVarId Γ MVarId) := do\n mvarId.assertHypotheses hs",
"start": [
119,
1
],
"end": [
121,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.replace",
"code": "def _root_.Lean.MVarId.replace (g : MVarId) (hyp : FVarId) (proof : Expr) (typeNew : Option Expr := none) :\n MetaM AssertAfterResult :=\n g.withContext do\n let typeNew β match typeNew with\n | some t => pure t\n | none => inferType proof\n let ldecl β hyp.getDecl\n let (_, ldecl') β findMaxFVar typeNew |>.run ldecl\n let result β g.assertAfter ldecl'.fvarId ldecl.userName typeNew proof\n (return { result with mvarId := β result.mvarId.clear hyp }) <|> pure result\nwhere\n \n findMaxFVar (e : Expr) : StateRefT LocalDecl MetaM Unit :=\n e.forEach' fun e => do\n if e.isFVar then\n let ldecl' β e.fvarId!.getDecl\n modify fun ldecl => if ldecl'.index > ldecl.index then ldecl' else ldecl\n return false\n else\n return e.hasFVar",
"start": [
124,
1
],
"end": [
152,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/OccursCheck.lean | [
".lake/packages/lean4/src/lean/Lean/MetavarContext.lean"
] | [
{
"full_name": "Lean.occursCheck",
"code": "partial def occursCheck [Monad m] [MonadMCtx m] (mvarId : MVarId) (e : Expr) : m Bool := do\n if !e.hasExprMVar then\n return true\n else\n match (β visit e |>.run |>.run {}) with\n | (.ok .., _) => return true\n | (.error .., _) => return false\nwhere\n visitMVar (mvarId' : MVarId) : ExceptT Unit (StateT ExprSet m) Unit := do\n if mvarId == mvarId' then\n throw () else\n match (β getExprMVarAssignment? mvarId') with\n | some v => visit v\n | none =>\n match (β getDelayedMVarAssignment? mvarId') with\n | some d => visitMVar d.mvarIdPending\n | none => return ()\n\n visit (e : Expr) : ExceptT Unit (StateT ExprSet m) Unit := do\n if !e.hasExprMVar then\n return ()\n else if (β get).contains e then\n return ()\n else\n modify fun s => s.insert e\n match e with\n | Expr.proj _ _ s => visit s\n | Expr.forallE _ d b _ => visit d; visit b\n | Expr.lam _ d b _ => visit d; visit b\n | Expr.letE _ t v b _ => visit t; visit v; visit b\n | Expr.mdata _ b => visit b\n | Expr.app f a => visit f; visit a\n | Expr.mvar mvarId => visitMVar mvarId\n | _ => return ()",
"start": [
11,
1
],
"end": [
48,
42
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Tactic/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Elab/Term.lean"
] | [
{
"full_name": "Lean.Elab.admitGoal",
"code": "def admitGoal (mvarId : MVarId) : MetaM Unit :=\n mvarId.withContext do\n let mvarType β inferType (mkMVar mvarId)\n mvarId.assign (β mkSorry mvarType (synthetic := true))",
"start": [
12,
1
],
"end": [
16,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.goalsToMessageData",
"code": "def goalsToMessageData (goals : List MVarId) : MessageData :=\n MessageData.joinSep (goals.map MessageData.ofGoal) m!\"\\n\\n\"",
"start": [
18,
1
],
"end": [
19,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.reportUnsolvedGoals",
"code": "def Term.reportUnsolvedGoals (goals : List MVarId) : MetaM Unit := do\n logError <| MessageData.tagged `Tactic.unsolvedGoals <| m!\"unsolved goals\\n{goalsToMessageData goals}\"\n goals.forM fun mvarId => admitGoal mvarId",
"start": [
21,
1
],
"end": [
23,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.Context",
"code": "structure Context where\n \n elaborator : Name\n \n recover : Bool := true",
"start": [
27,
1
],
"end": [
35,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticM",
"code": "abbrev TacticM := ReaderT Context $ StateRefT State TermElabM",
"start": [
37,
1
],
"end": [
37,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.Tactic",
"code": "abbrev Tactic := Syntax β TacticM Unit",
"start": [
38,
1
],
"end": [
38,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getGoals",
"code": "def getGoals : TacticM (List MVarId) :=\n return (β get).goals",
"start": [
51,
1
],
"end": [
52,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.setGoals",
"code": "def setGoals (mvarIds : List MVarId) : TacticM Unit :=\n modify fun _ => { goals := mvarIds }",
"start": [
54,
1
],
"end": [
55,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.pruneSolvedGoals",
"code": "def pruneSolvedGoals : TacticM Unit := do\n let gs β getGoals\n let gs β gs.filterM fun g => not <$> g.isAssigned\n setGoals gs",
"start": [
57,
1
],
"end": [
60,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getUnsolvedGoals",
"code": "def getUnsolvedGoals : TacticM (List MVarId) := do\n pruneSolvedGoals\n getGoals",
"start": [
62,
1
],
"end": [
64,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticM.runCore",
"code": "@[inline] private def TacticM.runCore (x : TacticM Ξ±) (ctx : Context) (s : State) : TermElabM (Ξ± Γ State) :=\n x ctx |>.run s",
"start": [
66,
1
],
"end": [
67,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.TacticM.runCore'",
"code": "@[inline] private def TacticM.runCore' (x : TacticM Ξ±) (ctx : Context) (s : State) : TermElabM Ξ± :=\n Prod.fst <$> x.runCore ctx s",
"start": [
69,
1
],
"end": [
70,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.run",
"code": "def run (mvarId : MVarId) (x : TacticM Unit) : TermElabM (List MVarId) :=\n mvarId.withContext do\n let pendingMVarsSaved := (β get).pendingMVars\n modify fun s => { s with pendingMVars := [] }\n let aux : TacticM (List MVarId) :=\n \n try\n x; getUnsolvedGoals\n catch ex =>\n if isAbortTacticException ex then\n getUnsolvedGoals\n else\n throw ex\n try\n aux.runCore' { elaborator := .anonymous } { goals := [mvarId] }\n finally\n modify fun s => { s with pendingMVars := pendingMVarsSaved }",
"start": [
72,
1
],
"end": [
90,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.saveState",
"code": "protected def saveState : TacticM SavedState :=\n return { term := (β Term.saveState), tactic := (β get) }",
"start": [
92,
1
],
"end": [
93,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.SavedState.restore",
"code": "def SavedState.restore (b : SavedState) (restoreInfo := false) : TacticM Unit := do\n b.term.restore restoreInfo\n set b.tactic",
"start": [
95,
1
],
"end": [
97,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.withRestoreOrSaveFull",
"code": "@[specialize, inherit_doc Core.withRestoreOrSaveFull]\ndef withRestoreOrSaveFull (reusableResult? : Option (Ξ± Γ SavedState)) (act : TacticM Ξ±) :\n TacticM (Ξ± Γ SavedState) := do\n if let some (_, state) := reusableResult? then\n set state.tactic\n let reusableResult? := reusableResult?.map (fun (val, state) => (val, state.term))\n let (a, term) β controlAt TermElabM fun runInBase => do\n Term.withRestoreOrSaveFull reusableResult? <| runInBase act\n return (a, { term, tactic := (β get) })",
"start": [
99,
1
],
"end": [
107,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getCurrMacroScope",
"code": "protected def getCurrMacroScope : TacticM MacroScope := do pure (β readThe Core.Context).currMacroScope",
"start": [
109,
1
],
"end": [
109,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getMainModule",
"code": "protected def getMainModule : TacticM Name := do pure (β getEnv).mainModule",
"start": [
110,
1
],
"end": [
110,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.mkTacticAttribute",
"code": "unsafe def mkTacticAttribute : IO (KeyedDeclsAttribute Tactic) :=\n mkElabAttribute Tactic `builtin_tactic `tactic `Lean.Parser.Tactic `Lean.Elab.Tactic.Tactic \"tactic\" `Lean.Elab.Tactic.tacticElabAttribute",
"start": [
112,
1
],
"end": [
113,
141
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.tacticElabAttribute",
"code": "@[builtin_init mkTacticAttribute] opaque tacticElabAttribute : KeyedDeclsAttribute Tactic",
"start": [
115,
1
],
"end": [
115,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.mkTacticInfo",
"code": "def mkTacticInfo (mctxBefore : MetavarContext) (goalsBefore : List MVarId) (stx : Syntax) : TacticM Info :=\n return Info.ofTacticInfo {\n elaborator := (β read).elaborator\n mctxBefore := mctxBefore\n goalsBefore := goalsBefore\n stx := stx\n mctxAfter := (β getMCtx)\n goalsAfter := (β getUnsolvedGoals)\n }",
"start": [
117,
1
],
"end": [
125,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.mkInitialTacticInfo",
"code": "def mkInitialTacticInfo (stx : Syntax) : TacticM (TacticM Info) := do\n let mctxBefore β getMCtx\n let goalsBefore β getUnsolvedGoals\n return mkTacticInfo mctxBefore goalsBefore stx",
"start": [
127,
1
],
"end": [
130,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.withTacticInfoContext",
"code": "@[inline] def withTacticInfoContext (stx : Syntax) (x : TacticM Ξ±) : TacticM Ξ± := do\n withInfoContext x (β mkInitialTacticInfo stx)",
"start": [
132,
1
],
"end": [
133,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.EvalTacticFailure",
"code": "structure EvalTacticFailure where\n exception : Exception\n state : SavedState",
"start": [
142,
1
],
"end": [
147,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.evalTactic",
"code": "partial def evalTactic (stx : Syntax) : TacticM Unit := do\n profileitM Exception \"tactic execution\" (decl := stx.getKind) (β getOptions) <|\n withRef stx <| withIncRecDepth <| withFreshMacroScope <| match stx with\n | .node _ k _ =>\n if k == nullKind then\n Term.withoutTacticIncrementality true do\n stx.getArgs.forM evalTactic\n else withTraceNode `Elab.step (fun _ => return stx) (tag := stx.getKind.toString) do\n let evalFns := tacticElabAttribute.getEntries (β getEnv) stx.getKind\n let macros := macroAttribute.getEntries (β getEnv) stx.getKind\n if evalFns.isEmpty && macros.isEmpty then\n throwErrorAt stx \"tactic '{stx.getKind}' has not been implemented\"\n let s β Tactic.saveState\n expandEval s macros evalFns #[]\n | .missing => pure ()\n | _ => throwError m!\"unexpected tactic{indentD stx}\"\nwhere\n throwExs (failures : Array EvalTacticFailure) : TacticM Unit := do\n if h : 0 < failures.size then\n let fail := failures[failures.size-1]\n fail.state.restore (restoreInfo := true)\n throw fail.exception else\n throwErrorAt stx \"unexpected syntax {indentD stx}\"\n\n @[inline] handleEx (s : SavedState) (failures : Array EvalTacticFailure) (ex : Exception) (k : Array EvalTacticFailure β TacticM Unit) := do\n match ex with\n | .error .. =>\n trace[Elab.tactic.backtrack] ex.toMessageData\n let failures := failures.push β¨ex, β Tactic.saveStateβ©\n s.restore (restoreInfo := true); k failures\n | .internal id _ =>\n if id == unsupportedSyntaxExceptionId then\n s.restore (restoreInfo := true); k failures\n else if id == abortTacticExceptionId then\n for msg in (β Core.getMessageLog).toList do\n trace[Elab.tactic.backtrack] msg.data\n let failures := failures.push β¨ex, β Tactic.saveStateβ©\n s.restore (restoreInfo := true); k failures\n else\n throw ex expandEval (s : SavedState) (macros : List _) (evalFns : List _) (failures : Array EvalTacticFailure) : TacticM Unit :=\n match macros with\n | [] => eval s evalFns failures\n | m :: ms =>\n try\n withReader ({ Β· with elaborator := m.declName }) do\n withTacticInfoContext stx do\n let stx' β adaptMacro m.value stx\n if evalFns.isEmpty && ms.isEmpty then if let some snap := (β readThe Term.Context).tacSnap? then\n let nextMacroScope := (β getThe Core.State).nextMacroScope\n let traceState β getTraceState\n let old? := do\n let old β snap.old?\n guard <| old.stx.isOfKind stx.getKind\n let state β old.val.get.data.finished.get.state?\n guard <| state.term.meta.core.nextMacroScope == nextMacroScope\n guard <| state.term.meta.core.traceState.traces.size == 0\n guard <| traceState.traces.size == 0\n return old.val.get\n Language.withAlwaysResolvedPromise fun promise => do\n snap.new.resolve <| .mk {\n stx := stx'\n diagnostics := .empty\n finished := .pure { state? := (β Tactic.saveState) }\n } #[{ range? := stx'.getRange?, task := promise.result }]\n withTheReader Term.Context ({ Β· with tacSnap? := some {\n new := promise\n old? := do\n let old β old?\n return β¨old.data.stx, (β old.next.get? 0)β©\n } }) do\n evalTactic stx'\n return\n evalTactic stx'\n catch ex => handleEx s failures ex (expandEval s ms evalFns)\n\n eval (s : SavedState) (evalFns : List _) (failures : Array EvalTacticFailure) : TacticM Unit := do\n match evalFns with\n | [] => throwExs failures\n | evalFn::evalFns => do\n try\n Term.withoutTacticIncrementality (!(β isIncrementalElab evalFn.declName)) do\n withReader ({ Β· with elaborator := evalFn.declName }) do\n withTacticInfoContext stx do\n evalFn.value stx\n catch ex => handleEx s failures ex (eval s evalFns)",
"start": [
149,
1
],
"end": [
248,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.throwNoGoalsToBeSolved",
"code": "def throwNoGoalsToBeSolved : TacticM Ξ± :=\n throwError \"no goals to be solved\"",
"start": [
250,
1
],
"end": [
251,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.done",
"code": "def done : TacticM Unit := do\n let gs β getUnsolvedGoals\n unless gs.isEmpty do\n Term.reportUnsolvedGoals gs\n throwAbortTactic",
"start": [
253,
1
],
"end": [
257,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.focus",
"code": "def focus (x : TacticM Ξ±) : TacticM Ξ± := do\n let mvarId :: mvarIds β getUnsolvedGoals | throwNoGoalsToBeSolved\n setGoals [mvarId]\n let a β x\n let mvarIds' β getUnsolvedGoals\n setGoals (mvarIds' ++ mvarIds)\n pure a",
"start": [
259,
1
],
"end": [
265,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.focusAndDone",
"code": "def focusAndDone (tactic : TacticM Ξ±) : TacticM Ξ± :=\n focus do\n let a β tactic\n done\n pure a",
"start": [
267,
1
],
"end": [
271,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.closeUsingOrAdmit",
"code": "def closeUsingOrAdmit (tac : TacticM Unit) : TacticM Unit := do\n \n let mvarId :: mvarIds β getUnsolvedGoals | throwNoGoalsToBeSolved\n tryCatchRuntimeEx\n (focusAndDone tac)\n fun ex => do\n if (β read).recover then\n logException ex\n admitGoal mvarId\n setGoals mvarIds\n else\n throw ex",
"start": [
273,
1
],
"end": [
286,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.tryCatch",
"code": "@[inline] protected def tryCatch {Ξ±} (x : TacticM Ξ±) (h : Exception β TacticM Ξ±) : TacticM Ξ± := do\n let b β saveState\n try x catch ex => b.restore; h ex",
"start": [
292,
1
],
"end": [
294,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.withoutRecover",
"code": "def withoutRecover (x : TacticM Ξ±) : TacticM Ξ± :=\n withReader (fun ctx => { ctx with recover := false }) x",
"start": [
300,
1
],
"end": [
302,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.orElse",
"code": "@[inline] protected def orElse (x : TacticM Ξ±) (y : Unit β TacticM Ξ±) : TacticM Ξ± := do\n try withoutRecover x catch _ => y ()",
"start": [
304,
1
],
"end": [
305,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.saveTacticInfoForToken",
"code": "def saveTacticInfoForToken (stx : Syntax) : TacticM Unit := do\n unless stx.getPos?.isNone do\n withTacticInfoContext stx (pure ())",
"start": [
314,
1
],
"end": [
321,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.withMacroExpansion",
"code": "@[inline]\ndef withMacroExpansion (beforeStx afterStx : Syntax) (x : TacticM Ξ±) : TacticM Ξ± :=\n withMacroExpansionInfo beforeStx afterStx do\n withTheReader Term.Context (fun ctx => { ctx with macroStack := { before := beforeStx, after := afterStx } :: ctx.macroStack }) x",
"start": [
323,
1
],
"end": [
327,
134
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.adaptExpander",
"code": "def adaptExpander (exp : Syntax β TacticM Syntax) : Tactic := fun stx => do\n let stx' β exp stx\n withMacroExpansion stx stx' $ evalTactic stx'",
"start": [
329,
1
],
"end": [
332,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.appendGoals",
"code": "def appendGoals (mvarIds : List MVarId) : TacticM Unit :=\n modify fun s => { s with goals := s.goals ++ mvarIds }",
"start": [
334,
1
],
"end": [
336,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.replaceMainGoal",
"code": "def replaceMainGoal (mvarIds : List MVarId) : TacticM Unit := do\n let (_ :: mvarIds') β getGoals | throwNoGoalsToBeSolved\n modify fun _ => { goals := mvarIds ++ mvarIds' }",
"start": [
338,
1
],
"end": [
342,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getMainGoal",
"code": "def getMainGoal : TacticM MVarId := do\n loop (β getGoals)\nwhere\n loop : List MVarId β TacticM MVarId\n | [] => throwNoGoalsToBeSolved\n | mvarId :: mvarIds => do\n if (β mvarId.isAssigned) then\n loop mvarIds\n else\n setGoals (mvarId :: mvarIds)\n return mvarId",
"start": [
344,
1
],
"end": [
355,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getMainDecl",
"code": "def getMainDecl : TacticM MetavarDecl := do\n (β getMainGoal).getDecl",
"start": [
357,
1
],
"end": [
359,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getMainTag",
"code": "def getMainTag : TacticM Name :=\n return (β getMainDecl).userName",
"start": [
361,
1
],
"end": [
363,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getMainTarget",
"code": "def getMainTarget : TacticM Expr := do\n instantiateMVars (β getMainDecl).type",
"start": [
365,
1
],
"end": [
367,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.withMainContext",
"code": "def withMainContext (x : TacticM Ξ±) : TacticM Ξ± := do\n (β getMainGoal).withContext x",
"start": [
369,
1
],
"end": [
371,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.evalTacticAt",
"code": "def evalTacticAt (tac : Syntax) (mvarId : MVarId) : TacticM (List MVarId) := do\n let gs β getGoals\n try\n setGoals [mvarId]\n evalTactic tac\n pruneSolvedGoals\n getGoals\n finally\n setGoals gs",
"start": [
373,
1
],
"end": [
382,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.evalTacticAtRaw",
"code": "def evalTacticAtRaw (tac : Syntax) (mvarId : MVarId) : TacticM (List MVarId) := do\n setGoals [mvarId]\n evalTactic tac\n getGoals",
"start": [
384,
1
],
"end": [
391,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.ensureHasNoMVars",
"code": "def ensureHasNoMVars (e : Expr) : TacticM Unit := do\n let e β instantiateMVars e\n let pendingMVars β getMVars e\n discard <| Term.logUnassignedUsingErrorInfos pendingMVars\n if e.hasExprMVar then\n throwError \"tactic failed, resulting expression contains metavariables{indentExpr e}\"",
"start": [
393,
1
],
"end": [
398,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.closeMainGoal",
"code": "def closeMainGoal (val : Expr) (checkUnassigned := true): TacticM Unit := do\n if checkUnassigned then\n ensureHasNoMVars val\n (β getMainGoal).assign val\n replaceMainGoal []",
"start": [
400,
1
],
"end": [
405,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.liftMetaMAtMain",
"code": "@[inline] def liftMetaMAtMain (x : MVarId β MetaM Ξ±) : TacticM Ξ± := do\n withMainContext do x (β getMainGoal)",
"start": [
407,
1
],
"end": [
408,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.liftMetaTacticAux",
"code": "@[inline] def liftMetaTacticAux (tac : MVarId β MetaM (Ξ± Γ List MVarId)) : TacticM Ξ± := do\n withMainContext do\n let (a, mvarIds) β tac (β getMainGoal)\n replaceMainGoal mvarIds\n pure a",
"start": [
410,
1
],
"end": [
414,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.liftMetaTactic",
"code": "@[inline] def liftMetaTactic (tactic : MVarId β MetaM (List MVarId)) : TacticM Unit :=\n liftMetaTacticAux fun mvarId => do\n let gs β tactic mvarId\n pure ((), gs)",
"start": [
416,
1
],
"end": [
421,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.liftMetaTactic1",
"code": "@[inline] def liftMetaTactic1 (tactic : MVarId β MetaM (Option MVarId)) : TacticM Unit :=\n withMainContext do\n if let some mvarId β tactic (β getMainGoal) then\n replaceMainGoal [mvarId]\n else\n replaceMainGoal []",
"start": [
423,
1
],
"end": [
428,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.liftMetaFinishingTactic",
"code": "@[inline] def liftMetaFinishingTactic (tac : MVarId β MetaM Unit) : TacticM Unit :=\n liftMetaTactic fun g => do tac g; pure []",
"start": [
430,
1
],
"end": [
432,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.tryTactic?",
"code": "def tryTactic? (tactic : TacticM Ξ±) : TacticM (Option Ξ±) := do\n try\n pure (some (β tactic))\n catch _ =>\n pure none",
"start": [
434,
1
],
"end": [
438,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.tryTactic",
"code": "def tryTactic (tactic : TacticM Ξ±) : TacticM Bool := do\n try\n discard tactic\n pure true\n catch _ =>\n pure false",
"start": [
440,
1
],
"end": [
445,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.tagUntaggedGoals",
"code": "def tagUntaggedGoals (parentTag : Name) (newSuffix : Name) (newGoals : List MVarId) : TacticM Unit := do\n let mctx β getMCtx\n let mut numAnonymous := 0\n for g in newGoals do\n if mctx.isAnonymousMVar g then\n numAnonymous := numAnonymous + 1\n modifyMCtx fun mctx => Id.run do\n let mut mctx := mctx\n let mut idx := 1\n for g in newGoals do\n if mctx.isAnonymousMVar g then\n if numAnonymous == 1 then\n mctx := mctx.setMVarUserName g parentTag\n else\n mctx := mctx.setMVarUserName g (parentTag ++ newSuffix.appendIndexAfter idx)\n idx := idx + 1\n pure mctx",
"start": [
446,
1
],
"end": [
466,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.getNameOfIdent'",
"code": "def getNameOfIdent' (id : Syntax) : Name :=\n if id.isIdent then id.getId else `_",
"start": [
469,
1
],
"end": [
470,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Tactic.withCaseRef",
"code": "def withCaseRef [Monad m] [MonadRef m] (arrow body : Syntax) (x : m Ξ±) : m Ξ± :=\n withRef (mkNullNode #[arrow, body]) x",
"start": [
472,
1
],
"end": [
477,
40
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Quotation/Util.lean | [
".lake/packages/lean4/src/lean/Lean/Elab/Term.lean"
] | [
{
"full_name": "Lean.Elab.Term.Quotation.getAntiquotationIds",
"code": "def getAntiquotationIds (stx : Syntax) : TermElabM (Array Ident) := do\n let mut ids := #[]\n for stx in stx.topDown (firstChoiceOnly := true) do\n if (isAntiquot stx || isTokenAntiquot stx) && !isEscapedAntiquot stx then\n let anti := getAntiquotTerm stx\n if anti.isIdent then ids := ids.push β¨antiβ©\n else if anti.isOfKind ``Parser.Term.hole then pure ()\n else throwErrorAt stx \"complex antiquotation not allowed here\"\n return ids",
"start": [
17,
1
],
"end": [
25,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.Quotation.getPatternVars",
"code": "partial def getPatternVars (stx : Syntax) : TermElabM (Array Syntax) :=\n if stx.isQuot then\n getAntiquotationIds stx\n else match stx with\n | `(_) => return #[]\n | `($id:ident) => return #[id]\n | `($id:ident@$e) => return (β getPatternVars e).push id\n | _ => throwErrorAt stx \"unsupported pattern in syntax match{indentD stx}\"",
"start": [
27,
1
],
"end": [
35,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.Quotation.getPatternsVars",
"code": "def getPatternsVars (pats : Array Syntax) : TermElabM (Array Syntax) :=\n pats.foldlM (fun vars pat => do return vars ++ (β getPatternVars pat)) #[]",
"start": [
37,
1
],
"end": [
38,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Term.Quotation.getAntiquotKindSpec?",
"code": "def getAntiquotKindSpec? (antiquot : Syntax) : Option Syntax :=\n let name := antiquot[3][1]\n if name.isMissing then none else some name",
"start": [
40,
1
],
"end": [
46,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Lsp/Utf16.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Lsp/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/Array.lean",
".lake/packages/lean4/src/lean/Lean/DeclarationRange.lean",
".lake/packages/lean4/src/lean/Lean/Data/Position.lean",
".lake/packages/lean4/src/lean/Init/Data/String.lean"
] | [
{
"full_name": "Char.utf16Size",
"code": "def utf16Size (c : Char) : UInt32 :=\n if c.val β€ 0xFFFF then 1 else 2",
"start": [
19,
1
],
"end": [
20,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "String.csize16",
"code": "private def csize16 (c : Char) : Nat :=\n c.utf16Size.toNat",
"start": [
26,
1
],
"end": [
27,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "String.utf16Length",
"code": "def utf16Length (s : String) : Nat :=\n s.foldr (fun c acc => csize16 c + acc) 0",
"start": [
29,
1
],
"end": [
30,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "String.codepointPosToUtf16PosFromAux",
"code": "private def codepointPosToUtf16PosFromAux (s : String) : Nat β Pos β Nat β Nat\n | 0, _, utf16pos => utf16pos\n | cp+1, utf8pos, utf16pos => codepointPosToUtf16PosFromAux s cp (s.next utf8pos) (utf16pos + csize16 (s.get utf8pos))",
"start": [
32,
1
],
"end": [
34,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "String.codepointPosToUtf16PosFrom",
"code": "def codepointPosToUtf16PosFrom (s : String) (n : Nat) (off : Pos) : Nat :=\n codepointPosToUtf16PosFromAux s n off 0",
"start": [
36,
1
],
"end": [
40,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "String.codepointPosToUtf16Pos",
"code": "def codepointPosToUtf16Pos (s : String) (pos : Nat) : Nat :=\n codepointPosToUtf16PosFrom s pos 0",
"start": [
42,
1
],
"end": [
43,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "String.utf16PosToCodepointPosFromAux",
"code": "private partial def utf16PosToCodepointPosFromAux (s : String) : Nat β Pos β Nat β Nat\n | 0, _, cp => cp\n | utf16pos, utf8pos, cp => utf16PosToCodepointPosFromAux s (utf16pos - csize16 (s.get utf8pos)) (s.next utf8pos) (cp + 1)",
"start": [
45,
1
],
"end": [
47,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "String.utf16PosToCodepointPosFrom",
"code": "def utf16PosToCodepointPosFrom (s : String) (utf16pos : Nat) (off : Pos) : Nat :=\n utf16PosToCodepointPosFromAux s utf16pos off 0",
"start": [
49,
1
],
"end": [
52,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "String.utf16PosToCodepointPos",
"code": "def utf16PosToCodepointPos (s : String) (pos : Nat) : Nat :=\n utf16PosToCodepointPosFrom s pos 0",
"start": [
54,
1
],
"end": [
55,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "String.codepointPosToUtf8PosFrom",
"code": "def codepointPosToUtf8PosFrom (s : String) : String.Pos β Nat β String.Pos\n | utf8pos, 0 => utf8pos\n | utf8pos, p+1 => codepointPosToUtf8PosFrom s (s.next utf8pos) p",
"start": [
57,
1
],
"end": [
60,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.lineStartPos",
"code": "private def lineStartPos (text : FileMap) (line : Nat) : String.Pos :=\n if h : line < text.positions.size then\n text.positions.get β¨line, hβ©\n else if text.positions.isEmpty then\n 0\n else\n text.positions.back",
"start": [
67,
1
],
"end": [
73,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.lspPosToUtf8Pos",
"code": "def lspPosToUtf8Pos (text : FileMap) (pos : Lsp.Position) : String.Pos :=\n let lineStartPos := lineStartPos text pos.line\n let chr := text.source.utf16PosToCodepointPosFrom pos.character lineStartPos\n text.source.codepointPosToUtf8PosFrom lineStartPos chr",
"start": [
75,
1
],
"end": [
80,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.leanPosToLspPos",
"code": "def leanPosToLspPos (text : FileMap) : Lean.Position β Lsp.Position\n | β¨line, colβ© =>\n β¨line - 1, text.source.codepointPosToUtf16PosFrom col (lineStartPos text (line - 1))β©",
"start": [
82,
1
],
"end": [
84,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.utf8PosToLspPos",
"code": "def utf8PosToLspPos (text : FileMap) (pos : String.Pos) : Lsp.Position :=\n text.leanPosToLspPos (text.toPosition pos)",
"start": [
86,
1
],
"end": [
87,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.utf8RangeToLspRange",
"code": "def utf8RangeToLspRange (text : FileMap) (range : String.Range) : Lsp.Range :=\n { start := text.utf8PosToLspPos range.start, Β«endΒ» := text.utf8PosToLspPos range.stop }",
"start": [
89,
1
],
"end": [
91,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DeclarationRange.toLspRange",
"code": "def Lean.DeclarationRange.toLspRange (r : Lean.DeclarationRange) : Lsp.Range := {\n start := β¨r.pos.line - 1, r.charUtf16β©\n Β«endΒ» := β¨r.endPos.line - 1, r.endCharUtf16β©\n}",
"start": [
96,
1
],
"end": [
104,
2
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/Specialize.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean"
] | [
{
"full_name": "Lean.Compiler.SpecializeAttributeKind",
"code": "inductive SpecializeAttributeKind where\n | specialize | nospecialize\n deriving Inhabited, BEq",
"start": [
12,
1
],
"end": [
14,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.elabSpecArgs",
"code": "private def elabSpecArgs (declName : Name) (args : Array Syntax) : MetaM (Array Nat) := do\n if args.isEmpty then return #[]\n let info β getConstInfo declName\n Meta.forallTelescopeReducing info.type fun xs _ => do\n let argNames β xs.mapM fun x => x.fvarId!.getUserName\n let mut result := #[]\n for arg in args do\n if let some idx := arg.isNatLit? then\n if idx == 0 then throwErrorAt arg \"invalid specialization argument index, index must be greater than 0\"\n let idx := idx - 1\n if idx >= argNames.size then\n throwErrorAt arg \"invalid argument index, `{declName}` has #{argNames.size} arguments\"\n if result.contains idx then throwErrorAt arg \"invalid specialization argument index, `{argNames[idx]!}` has already been specified as a specialization candidate\"\n result := result.push idx\n else\n let argName := arg.getId\n if let some idx := argNames.getIdx? argName then\n if result.contains idx then throwErrorAt arg \"invalid specialization argument name `{argName}`, it has already been specified as a specialization candidate\"\n result := result.push idx\n else\n throwErrorAt arg \"invalid specialization argument name `{argName}`, `{declName}` does have an argument with this name\"\n return result.qsort (Β·<Β·)",
"start": [
19,
1
],
"end": [
40,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.getSpecializationArgs?",
"code": "def getSpecializationArgs? (env : Environment) (declName : Name) : Option (Array Nat) :=\n specializeAttr.getParam? env declName",
"start": [
51,
1
],
"end": [
52,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasSpecializeAttribute",
"code": "def hasSpecializeAttribute (env : Environment) (declName : Name) : Bool :=\n getSpecializationArgs? env declName |>.isSome",
"start": [
54,
1
],
"end": [
55,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasNospecializeAttribute",
"code": "def hasNospecializeAttribute (env : Environment) (declName : Name) : Bool :=\n nospecializeAttr.hasTag env declName",
"start": [
57,
1
],
"end": [
58,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasSpecializeAttributeOld",
"code": "@[export lean_has_specialize_attribute]\npartial def hasSpecializeAttributeOld (env : Environment) (n : Name) : Bool :=\n match specializeAttr.getParam? env n with\n | some _ => true\n | none => if n.isInternal then hasSpecializeAttributeOld env n.getPrefix else false",
"start": [
62,
1
],
"end": [
66,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasNospecializeAttributeOld",
"code": "@[export lean_has_nospecialize_attribute]\npartial def hasNospecializeAttributeOld (env : Environment) (n : Name) : Bool :=\n nospecializeAttr.hasTag env n ||\n (n.isInternal && hasNospecializeAttributeOld env n.getPrefix)",
"start": [
68,
1
],
"end": [
71,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.SpecArgKind",
"code": "inductive SpecArgKind where\n | fixed\n | fixedNeutral | fixedHO | fixedInst | other\n deriving Inhabited",
"start": [
73,
1
],
"end": [
79,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.SpecInfo",
"code": "structure SpecInfo where\n mutualDecls : List Name\n argKinds : List SpecArgKind\n deriving Inhabited",
"start": [
81,
1
],
"end": [
84,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.SpecState",
"code": "structure SpecState where\n specInfo : SMap Name SpecInfo := {}\n cache : SMap Expr Name := {}\n deriving Inhabited",
"start": [
86,
1
],
"end": [
89,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.SpecEntry",
"code": "inductive SpecEntry where\n | info (name : Name) (info : SpecInfo)\n | cache (key : Expr) (fn : Name)\n deriving Inhabited",
"start": [
91,
1
],
"end": [
94,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.SpecState.addEntry",
"code": "def addEntry (s : SpecState) (e : SpecEntry) : SpecState :=\n match e with\n | SpecEntry.info name info => { s with specInfo := s.specInfo.insert name info }\n | SpecEntry.cache key fn => { s with cache := s.cache.insert key fn }",
"start": [
98,
1
],
"end": [
101,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.SpecState.switch",
"code": "def switch : SpecState β SpecState\n | β¨mβ, mββ© => β¨mβ.switch, mβ.switchβ©",
"start": [
103,
1
],
"end": [
104,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.addSpecializationInfo",
"code": "@[export lean_add_specialization_info]\ndef addSpecializationInfo (env : Environment) (fn : Name) (info : SpecInfo) : Environment :=\n specExtension.addEntry env (SpecEntry.info fn info)",
"start": [
114,
1
],
"end": [
116,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.getSpecializationInfo",
"code": "@[export lean_get_specialization_info]\ndef getSpecializationInfo (env : Environment) (fn : Name) : Option SpecInfo :=\n (specExtension.getState env).specInfo.find? fn",
"start": [
118,
1
],
"end": [
120,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.cacheSpecialization",
"code": "@[export lean_cache_specialization]\ndef cacheSpecialization (env : Environment) (e : Expr) (fn : Name) : Environment :=\n specExtension.addEntry env (SpecEntry.cache e fn)",
"start": [
122,
1
],
"end": [
124,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.getCachedSpecialization",
"code": "@[export lean_get_cached_specialization]\ndef getCachedSpecialization (env : Environment) (e : Expr) : Option Name :=\n (specExtension.getState env).cache.find? e",
"start": [
126,
1
],
"end": [
128,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/LCNF/Types.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean"
] | [
{
"full_name": "Lean.Compiler.LCNF.erasedExpr",
"code": "def erasedExpr := mkConst ``lcErased",
"start": [
15,
1
],
"end": [
15,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isErased",
"code": "def _root_.Lean.Expr.isErased (e : Expr) :=\n e.isAppOf ``lcErased",
"start": [
17,
1
],
"end": [
18,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isPropFormerTypeQuick",
"code": "def isPropFormerTypeQuick : Expr β Bool\n | .forallE _ _ b _ => isPropFormerTypeQuick b\n | .sort .zero => true\n | _ => false",
"start": [
20,
1
],
"end": [
23,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isPropFormerType",
"code": "partial def isPropFormerType (type : Expr) : MetaM Bool := do\n match isPropFormerTypeQuick type with\n | true => return true\n | false => go type #[]\nwhere\n go (type : Expr) (xs : Array Expr) : MetaM Bool := do\n match type with\n | .sort .zero => return true\n | .forallE n d b c => Meta.withLocalDecl n c (d.instantiateRev xs) fun x => go b (xs.push x)\n | _ =>\n let type β Meta.whnfD (type.instantiateRev xs)\n match type with\n | .sort .zero => return true\n | .forallE .. => go type #[]\n | _ => return false",
"start": [
25,
1
],
"end": [
42,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isPropFormer",
"code": "def isPropFormer (e : Expr) : MetaM Bool := do\n isPropFormerType (β Meta.inferType e)",
"start": [
44,
1
],
"end": [
48,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.toLCNFType",
"code": "partial def toLCNFType (type : Expr) : MetaM Expr := do\n if (β isProp type) then\n return erasedExpr\n let type β whnfEta type\n match type with\n | .sort u => return .sort u\n | .const .. => visitApp type #[]\n | .lam n d b bi =>\n withLocalDecl n bi d fun x => do\n let d β toLCNFType d\n let b β toLCNFType (b.instantiate1 x)\n if b.isErased then\n return b\n else\n return Expr.lam n d (b.abstract #[x]) bi\n | .forallE .. => visitForall type #[]\n | .app .. => type.withApp visitApp\n | .fvar .. => visitApp type #[]\n | _ => return erasedExpr\nwhere\n whnfEta (type : Expr) : MetaM Expr := do\n let type β whnf type\n let type' := type.eta\n if type' != type then\n whnfEta type'\n else\n return type\n\n visitForall (e : Expr) (xs : Array Expr) : MetaM Expr := do\n match e with\n | .forallE n d b bi =>\n let d := d.instantiateRev xs\n withLocalDecl n bi d fun x => do\n let d := (β toLCNFType d).abstract xs\n return .forallE n d (β visitForall b (xs.push x)) bi\n | _ =>\n let e β toLCNFType (e.instantiateRev xs)\n return e.abstract xs\n\n visitApp (f : Expr) (args : Array Expr) := do\n let fNew β match f with\n | .const declName us =>\n let .inductInfo _ β getConstInfo declName | return erasedExpr\n pure <| .const declName us\n | .fvar .. => pure f\n | _ => return erasedExpr\n let mut result := fNew\n for arg in args do\n if (β isProp arg) then\n result := mkApp result erasedExpr\n else if (β isPropFormer arg) then\n result := mkApp result erasedExpr\n else if (β isTypeFormer arg) then\n result := mkApp result (β toLCNFType arg)\n else\n result := mkApp result erasedExpr\n return result",
"start": [
113,
1
],
"end": [
172,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.joinTypes",
"code": "partial def joinTypes (a b : Expr) : Expr :=\n joinTypes? a b |>.getD erasedExpr",
"start": [
176,
1
],
"end": [
177,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.joinTypes?",
"code": "partial def joinTypes? (a b : Expr) : Option Expr := do\n if a.isErased || b.isErased then\n return erasedExpr else if a == b then\n return a\n else\n let a' := a.headBeta\n let b' := b.headBeta\n if a != a' || b != b' then\n joinTypes? a' b'\n else\n match a, b with\n | .mdata _ a, b => joinTypes? a b\n | a, .mdata _ b => joinTypes? a b\n | .app f a, .app g b =>\n (do return .app (β joinTypes? f g) (β joinTypes? a b))\n <|>\n return erasedExpr\n | .forallE n dβ bβ _, .forallE _ dβ bβ _ =>\n (do return .forallE n (β joinTypes? dβ dβ) (joinTypes bβ bβ) .default)\n <|>\n return erasedExpr\n | .lam n dβ bβ _, .lam _ dβ bβ _ =>\n (do return .lam n (β joinTypes? dβ dβ) (joinTypes bβ bβ) .default)\n <|>\n return erasedExpr\n | _, _ => return erasedExpr",
"start": [
179,
1
],
"end": [
205,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isTypeFormerType",
"code": "partial def isTypeFormerType (type : Expr) : Bool :=\n match type.headBeta with\n | .sort .. => true\n | .forallE _ _ b _ => isTypeFormerType b\n | _ => false",
"start": [
209,
1
],
"end": [
219,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.instantiateForall",
"code": "def instantiateForall (type : Expr) (ps : Array Expr) : CoreM Expr :=\n go 0 type\nwhere\n go (i : Nat) (type : Expr) : CoreM Expr :=\n if h : i < ps.size then\n if let .forallE _ _ b _ := type.headBeta then\n go (i+1) (b.instantiate1 ps[i])\n else\n throwError \"invalid instantiateForall, too many parameters\"\n else\n return type\n termination_by ps.size - i",
"start": [
221,
1
],
"end": [
238,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isPredicateType",
"code": "partial def isPredicateType (type : Expr) : Bool :=\n match type.headBeta with\n | .sort .zero => true\n | .forallE _ _ b _ => isPredicateType b\n | _ => false",
"start": [
240,
1
],
"end": [
248,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.maybeTypeFormerType",
"code": "partial def maybeTypeFormerType (type : Expr) : Bool :=\n match type.headBeta with\n | .sort .. => true\n | .forallE _ _ b _ => maybeTypeFormerType b\n | _ => type.isErased",
"start": [
250,
1
],
"end": [
260,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isClass?",
"code": "def isClass? (type : Expr) : CoreM (Option Name) := do\n let .const declName _ := type.getAppFn | return none\n if isClass (β getEnv) declName then\n return declName\n else\n return none",
"start": [
262,
1
],
"end": [
270,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isArrowClass?",
"code": "partial def isArrowClass? (type : Expr) : CoreM (Option Name) := do\n match type.headBeta with\n | .forallE _ _ b _ => isArrowClass? b\n | _ => isClass? type",
"start": [
272,
1
],
"end": [
279,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.getArrowArity",
"code": "partial def getArrowArity (e : Expr) :=\n match e.headBeta with\n | .forallE _ _ b _ => getArrowArity b + 1\n | _ => 0",
"start": [
281,
1
],
"end": [
284,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.LCNF.isInductiveWithNoCtors",
"code": "def isInductiveWithNoCtors (type : Expr) : CoreM Bool := do\n let .const declName _ := type.getAppFn | return false\n let some (.inductInfo info) := (β getEnv).find? declName | return false\n return info.numCtors == 0",
"start": [
286,
1
],
"end": [
290,
28
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/KExprMap.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/HeadIndex.lean"
] | [
{
"full_name": "Lean.Meta.KExprMap",
"code": "structure KExprMap (Ξ± : Type) where\n map : PHashMap HeadIndex (AssocList Expr Ξ±) := {}\n deriving Inhabited",
"start": [
12,
1
],
"end": [
20,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.KExprMap.find?",
"code": "def KExprMap.find? (m : KExprMap Ξ±) (e : Expr) : MetaM (Option Ξ±) := do\n match m.map.find? e.toHeadIndex with\n | none => return none\n | some ps =>\n for β¨e', aβ© in ps do\n if (β isDefEq e e') then\n return some a\n return none",
"start": [
22,
1
],
"end": [
30,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.updateList",
"code": "private def updateList (ps : AssocList Expr Ξ±) (e : Expr) (v : Ξ±) : MetaM (AssocList Expr Ξ±) := do\n match ps with\n | AssocList.nil => return AssocList.cons e v ps\n | AssocList.cons e' v' ps =>\n if (β isDefEq e e') then\n return AssocList.cons e v ps\n else\n return AssocList.cons e' v' (β updateList ps e v)",
"start": [
32,
1
],
"end": [
39,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.KExprMap.insert",
"code": "def KExprMap.insert (m : KExprMap Ξ±) (e : Expr) (v : Ξ±) : MetaM (KExprMap Ξ±) :=\n let k := e.toHeadIndex\n match m.map.find? k with\n | none => return { map := m.map.insert k (AssocList.cons e v AssocList.nil) }\n | some ps => return { map := m.map.insert k (β updateList ps e v) }",
"start": [
41,
1
],
"end": [
46,
70
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Simp/SimpCongrTheorems.lean | [
".lake/packages/lean4/src/lean/Lean/Util/CollectMVars.lean",
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Util/Recognizers.lean"
] | [
{
"full_name": "Lean.Meta.SimpCongrTheorem",
"code": "structure SimpCongrTheorem where\n theoremName : Name\n funName : Name\n hypothesesPos : Array Nat\n priority : Nat\nderiving Inhabited, Repr",
"start": [
14,
1
],
"end": [
25,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpCongrTheorems",
"code": "structure SimpCongrTheorems where\n lemmas : SMap Name (List SimpCongrTheorem) := {}\n deriving Inhabited, Repr",
"start": [
27,
1
],
"end": [
29,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpCongrTheorems.get",
"code": "def SimpCongrTheorems.get (d : SimpCongrTheorems) (declName : Name) : List SimpCongrTheorem :=\n match d.lemmas.find? declName with\n | none => []\n | some cs => cs",
"start": [
31,
1
],
"end": [
34,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addSimpCongrTheoremEntry",
"code": "def addSimpCongrTheoremEntry (d : SimpCongrTheorems) (e : SimpCongrTheorem) : SimpCongrTheorems :=\n { d with lemmas :=\n match d.lemmas.find? e.funName with\n | none => d.lemmas.insert e.funName [e]\n | some es => d.lemmas.insert e.funName <| insert es }\nwhere\n insert : List SimpCongrTheorem β List SimpCongrTheorem\n | [] => [e]\n | e'::es => if e.priority β₯ e'.priority then e::e'::es else e' :: insert es",
"start": [
36,
1
],
"end": [
44,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSimpCongrTheorem",
"code": "def mkSimpCongrTheorem (declName : Name) (prio : Nat) : MetaM SimpCongrTheorem := withReducible do\n let c β mkConstWithLevelParams declName\n let (xs, bis, type) β forallMetaTelescopeReducing (β inferType c)\n match type.eqOrIff? with\n | none => throwError \"invalid 'congr' theorem, equality expected{indentExpr type}\"\n | some (lhs, rhs) =>\n lhs.withApp fun lhsFn lhsArgs => rhs.withApp fun rhsFn rhsArgs => do\n unless lhsFn.isConst && rhsFn.isConst && lhsFn.constName! == rhsFn.constName! && lhsArgs.size == rhsArgs.size do\n throwError \"invalid 'congr' theorem, equality left/right-hand sides must be applications of the same function{indentExpr type}\"\n let mut foundMVars : MVarIdSet := {}\n for lhsArg in lhsArgs do\n for mvarId in (lhsArg.collectMVars {}).result do\n foundMVars := foundMVars.insert mvarId\n let mut i := 0\n let mut hypothesesPos := #[]\n for x in xs, bi in bis do\n if bi.isExplicit && !foundMVars.contains x.mvarId! then\n let rhsFn? β forallTelescopeReducing (β inferType x) fun ys xType => do\n match xType.eqOrIff? with\n | none => pure none | some (xLhs, xRhs) =>\n let mut j := 0\n for y in ys do\n let yType β inferType y\n unless onlyMVarsAt yType foundMVars do\n throwError \"invalid 'congr' theorem, argument #{j+1} of parameter #{i+1} contains unresolved parameter{indentExpr yType}\"\n j := j + 1\n unless onlyMVarsAt xLhs foundMVars do\n throwError \"invalid 'congr' theorem, parameter #{i+1} is not a valid hypothesis, the left-hand-side contains unresolved parameters{indentExpr xLhs}\"\n let xRhsFn := xRhs.getAppFn\n unless xRhsFn.isMVar do\n throwError \"invalid 'congr' theorem, parameter #{i+1} is not a valid hypothesis, the right-hand-side head is not a metavariable{indentExpr xRhs}\"\n unless !foundMVars.contains xRhsFn.mvarId! do\n throwError \"invalid 'congr' theorem, parameter #{i+1} is not a valid hypothesis, the right-hand-side head was already resolved{indentExpr xRhs}\"\n for arg in xRhs.getAppArgs do\n unless arg.isFVar do\n throwError \"invalid 'congr' theorem, parameter #{i+1} is not a valid hypothesis, the right-hand-side argument is not local variable{indentExpr xRhs}\"\n pure (some xRhsFn)\n match rhsFn? with\n | none => pure ()\n | some rhsFn =>\n foundMVars := foundMVars.insert x.mvarId! |>.insert rhsFn.mvarId!\n hypothesesPos := hypothesesPos.push i\n i := i + 1\n return {\n theoremName := declName\n funName := lhsFn.constName!\n hypothesesPos := hypothesesPos\n priority := prio\n }\nwhere\n \n onlyMVarsAt (t : Expr) (mvarSet : MVarIdSet) : Bool :=\n Option.isNone <| t.find? fun e => e.isMVar && !mvarSet.contains e.mvarId!",
"start": [
53,
1
],
"end": [
106,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addSimpCongrTheorem",
"code": "def addSimpCongrTheorem (declName : Name) (attrKind : AttributeKind) (prio : Nat) : MetaM Unit := do\n let lemma β mkSimpCongrTheorem declName prio\n congrExtension.add lemma attrKind",
"start": [
108,
1
],
"end": [
110,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getSimpCongrTheorems",
"code": "def getSimpCongrTheorems : CoreM SimpCongrTheorems :=\n return congrExtension.getState (β getEnv)",
"start": [
121,
1
],
"end": [
122,
44
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/CongrTheorems.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean",
".lake/packages/lean4/src/lean/Lean/Class.lean"
] | [
{
"full_name": "Lean.Meta.CongrArgKind",
"code": "inductive CongrArgKind where\n \n | fixed\n \n | fixedNoParam\n \n | eq\n \n | cast\n \n | heq\n \n | subsingletonInst\n deriving Inhabited, Repr",
"start": [
12,
1
],
"end": [
35,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.CongrTheorem",
"code": "structure CongrTheorem where\n type : Expr\n proof : Expr\n argKinds : Array CongrArgKind",
"start": [
37,
1
],
"end": [
40,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addPrimeToFVarUserNames",
"code": "private def addPrimeToFVarUserNames (ys : Array Expr) (lctx : LocalContext) : LocalContext := Id.run do\n let mut lctx := lctx\n for y in ys do\n let decl := lctx.getFVar! y\n lctx := lctx.setUserName decl.fvarId (decl.userName.appendAfter \"'\")\n return lctx",
"start": [
42,
1
],
"end": [
47,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setBinderInfosD",
"code": "private def setBinderInfosD (ys : Array Expr) (lctx : LocalContext) : LocalContext := Id.run do\n let mut lctx := lctx\n for y in ys do\n let decl := lctx.getFVar! y\n lctx := lctx.setBinderInfo decl.fvarId BinderInfo.default\n return lctx",
"start": [
49,
1
],
"end": [
54,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHCongrWithArity",
"code": "partial def mkHCongrWithArity (f : Expr) (numArgs : Nat) : MetaM CongrTheorem := do\n let fType β inferType f\n forallBoundedTelescope fType numArgs (cleanupAnnotations := true) fun xs _ =>\n forallBoundedTelescope fType numArgs (cleanupAnnotations := true) fun ys _ => do\n if xs.size != numArgs then\n throwError \"failed to generate hcongr theorem, insufficient number of arguments\"\n else\n let lctx := addPrimeToFVarUserNames ys (β getLCtx) |> setBinderInfosD ys |> setBinderInfosD xs\n withLCtx lctx (β getLocalInstances) do\n withNewEqs xs ys fun eqs argKinds => do\n let mut hs := #[]\n for x in xs, y in ys, eq in eqs do\n hs := hs.push x |>.push y |>.push eq\n let lhs := mkAppN f xs\n let rhs := mkAppN f ys\n let congrType β mkForallFVars hs (β mkHEq lhs rhs)\n return {\n type := congrType\n proof := (β mkProof congrType)\n argKinds\n }\nwhere\n withNewEqs {Ξ±} (xs ys : Array Expr) (k : Array Expr β Array CongrArgKind β MetaM Ξ±) : MetaM Ξ± :=\n let rec loop (i : Nat) (eqs : Array Expr) (kinds : Array CongrArgKind) := do\n if i < xs.size then\n let x := xs[i]!\n let y := ys[i]!\n let xType := (β inferType x).cleanupAnnotations\n let yType := (β inferType y).cleanupAnnotations\n if xType == yType then\n withLocalDeclD ((`e).appendIndexAfter (i+1)) (β mkEq x y) fun h =>\n loop (i+1) (eqs.push h) (kinds.push CongrArgKind.eq)\n else\n withLocalDeclD ((`e).appendIndexAfter (i+1)) (β mkHEq x y) fun h =>\n loop (i+1) (eqs.push h) (kinds.push CongrArgKind.heq)\n else\n k eqs kinds\n loop 0 #[] #[]\n\n mkProof (type : Expr) : MetaM Expr := do\n if let some (_, lhs, _) := type.eq? then\n mkEqRefl lhs\n else if let some (_, lhs, _, _) := type.heq? then\n mkHEqRefl lhs\n else\n forallBoundedTelescope type (some 1) (cleanupAnnotations := true) fun a type =>\n let a := a[0]!\n forallBoundedTelescope type (some 1) (cleanupAnnotations := true) fun b motive =>\n let b := b[0]!\n let type := type.bindingBody!.instantiate1 a\n withLocalDeclD motive.bindingName! motive.bindingDomain! fun eqPr => do\n let type := type.bindingBody!\n let motive := motive.bindingBody!\n let minor β mkProof type\n let mut major := eqPr\n if (β whnf (β inferType eqPr)).isHEq then\n major β mkEqOfHEq major\n let motive β mkLambdaFVars #[b] motive\n mkLambdaFVars #[a, b, eqPr] (β mkEqNDRec motive minor major)",
"start": [
56,
1
],
"end": [
114,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkHCongr",
"code": "def mkHCongr (f : Expr) : MetaM CongrTheorem := do\n mkHCongrWithArity f (β getFunInfo f).getArity",
"start": [
116,
1
],
"end": [
117,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.fixKindsForDependencies",
"code": "private def fixKindsForDependencies (info : FunInfo) (kinds : Array CongrArgKind) : Array CongrArgKind := Id.run do\n let mut kinds := kinds\n for i in [:info.paramInfo.size] do\n for j in [i+1:info.paramInfo.size] do\n if info.paramInfo[j]!.backDeps.contains i then\n if kinds[j]! matches CongrArgKind.eq || kinds[j]! matches CongrArgKind.fixed then\n kinds := kinds.set! i CongrArgKind.fixed\n break\n return kinds",
"start": [
119,
1
],
"end": [
131,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkCast",
"code": "private partial def mkCast (e : Expr) (type : Expr) (deps : Array Nat) (eqs : Array (Option Expr)) : MetaM Expr := do\n let rec go (i : Nat) (type : Expr) : MetaM Expr := do\n if i < deps.size then\n match eqs[deps[i]!]! with\n | none => go (i+1) type\n | some major =>\n let some (_, lhs, rhs) := (β inferType major).eq? | unreachable!\n if (β dependsOn type major.fvarId!) then\n let motive β mkLambdaFVars #[rhs, major] type\n let typeNew := type.replaceFVar rhs lhs |>.replaceFVar major (β mkEqRefl lhs)\n let minor β go (i+1) typeNew\n mkEqRec motive minor major\n else\n let motive β mkLambdaFVars #[rhs] type\n let typeNew := type.replaceFVar rhs lhs\n let minor β go (i+1) typeNew\n mkEqNDRec motive minor major\n else\n return e\n go 0 type",
"start": [
133,
1
],
"end": [
156,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.hasCastLike",
"code": "private def hasCastLike (kinds : Array CongrArgKind) : Bool :=\n kinds.any fun kind => kind matches CongrArgKind.cast || kind matches CongrArgKind.subsingletonInst",
"start": [
158,
1
],
"end": [
159,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNext",
"code": "private def withNext (type : Expr) (k : Expr β Expr β MetaM Ξ±) : MetaM Ξ± := do\n forallBoundedTelescope type (some 1) (cleanupAnnotations := true) fun xs type => k xs[0]! type",
"start": [
161,
1
],
"end": [
162,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.shouldUseSubsingletonInst",
"code": "private def shouldUseSubsingletonInst (info : FunInfo) (kinds : Array CongrArgKind) (i : Nat) : Bool := Id.run do\n if info.paramInfo[i]!.isDecInst then\n for j in info.paramInfo[i]!.backDeps do\n if kinds[j]! matches CongrArgKind.eq then\n return true\n return false",
"start": [
164,
1
],
"end": [
172,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getClassSubobjectMask?",
"code": "private def getClassSubobjectMask? (f : Expr) : MetaM (Option (Array Bool)) := do\n let .const declName _ := f | return none\n let .ctorInfo val β getConstInfo declName | return none\n unless isClass (β getEnv) val.induct do return none\n forallTelescopeReducing val.type (cleanupAnnotations := true) fun xs _ => do\n let env β getEnv\n let mut mask := #[]\n for i in [:xs.size] do\n if i < val.numParams then\n mask := mask.push false\n else\n let localDecl β xs[i]!.fvarId!.getDecl\n mask := mask.push (isSubobjectField? env val.induct localDecl.userName).isSome\n return some mask",
"start": [
174,
1
],
"end": [
194,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getCongrSimpKinds",
"code": "def getCongrSimpKinds (f : Expr) (info : FunInfo) : MetaM (Array CongrArgKind) := do\n \n let mut result := #[]\n let mask? β getClassSubobjectMask? f\n for i in [:info.paramInfo.size] do\n if info.resultDeps.contains i then\n result := result.push .fixed\n else if info.paramInfo[i]!.isProp then\n result := result.push .cast\n else if info.paramInfo[i]!.isInstImplicit then\n if let some mask := mask? then\n if h : i < mask.size then\n if mask[i] then\n result := result.push .eq\n continue\n if shouldUseSubsingletonInst info result i then\n result := result.push .subsingletonInst\n else\n result := result.push .fixed\n else\n result := result.push .eq\n return fixKindsForDependencies info result",
"start": [
196,
1
],
"end": [
232,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkCongrSimpCore?",
"code": "partial def mkCongrSimpCore? (f : Expr) (info : FunInfo) (kinds : Array CongrArgKind) (subsingletonInstImplicitRhs : Bool := true) : MetaM (Option CongrTheorem) := do\n if let some result β mk? f info kinds then\n return some result\n else if hasCastLike kinds then\n let kinds := kinds.map fun kind =>\n if kind matches CongrArgKind.cast || kind matches CongrArgKind.subsingletonInst then CongrArgKind.fixed else kind\n mk? f info kinds\n else\n return none\nwhere\n \n mk? (f : Expr) (info : FunInfo) (kinds : Array CongrArgKind) : MetaM (Option CongrTheorem) := do\n try\n let fType β inferType f\n forallBoundedTelescope fType kinds.size (cleanupAnnotations := true) fun lhss _ => do\n if lhss.size != kinds.size then return none\n let rec go (i : Nat) (rhss : Array Expr) (eqs : Array (Option Expr)) (hyps : Array Expr) : MetaM CongrTheorem := do\n if i == kinds.size then\n let lhs := mkAppN f lhss\n let rhs := mkAppN f rhss\n let type β mkForallFVars hyps (β mkEq lhs rhs)\n let proof β mkProof type kinds\n return { type, proof, argKinds := kinds }\n else\n let hyps := hyps.push lhss[i]!\n match kinds[i]! with\n | .heq | .fixedNoParam => unreachable!\n | .eq =>\n let localDecl β lhss[i]!.fvarId!.getDecl\n withLocalDecl localDecl.userName localDecl.binderInfo localDecl.type fun rhs => do\n withLocalDeclD (localDecl.userName.appendBefore \"e_\") (β mkEq lhss[i]! rhs) fun eq => do\n go (i+1) (rhss.push rhs) (eqs.push eq) (hyps.push rhs |>.push eq)\n | .fixed => go (i+1) (rhss.push lhss[i]!) (eqs.push none) hyps\n | .cast =>\n let rhsType := (β inferType lhss[i]!).replaceFVars (lhss[:rhss.size]) rhss\n let rhs β mkCast lhss[i]! rhsType info.paramInfo[i]!.backDeps eqs\n go (i+1) (rhss.push rhs) (eqs.push none) hyps\n | .subsingletonInst =>\n withNewBinderInfos #[(lhss[i]!.fvarId!, .implicit)] do\n let rhsType := (β inferType lhss[i]!).replaceFVars (lhss[:rhss.size]) rhss\n let rhsBi := if subsingletonInstImplicitRhs then .instImplicit else .implicit\n withLocalDecl (β lhss[i]!.fvarId!.getDecl).userName rhsBi rhsType fun rhs =>\n go (i+1) (rhss.push rhs) (eqs.push none) (hyps.push rhs)\n return some (β go 0 #[] #[] #[])\n catch _ =>\n return none\n\n mkProof (type : Expr) (kinds : Array CongrArgKind) : MetaM Expr := do\n let rec go (i : Nat) (type : Expr) : MetaM Expr := do\n if i == kinds.size then\n let some (_, lhs, _) := type.eq? | unreachable!\n mkEqRefl lhs\n else\n withNext type fun lhs type => do\n match kinds[i]! with\n | .heq | .fixedNoParam => unreachable!\n | .fixed => mkLambdaFVars #[lhs] (β go (i+1) type)\n | .cast => mkLambdaFVars #[lhs] (β go (i+1) type)\n | .eq =>\n let typeSub := type.bindingBody!.bindingBody!.instantiate #[(β mkEqRefl lhs), lhs]\n withNext type fun rhs type =>\n withNext type fun heq type => do\n let motive β mkLambdaFVars #[rhs, heq] type\n let proofSub β go (i+1) typeSub\n mkLambdaFVars #[lhs, rhs, heq] (β mkEqRec motive proofSub heq)\n | .subsingletonInst =>\n let typeSub := type.bindingBody!.instantiate #[lhs]\n withNext type fun rhs type => do\n let motive β mkLambdaFVars #[rhs] type\n let proofSub β go (i+1) typeSub\n let heq β mkAppM ``Subsingleton.elim #[lhs, rhs]\n mkLambdaFVars #[lhs, rhs] (β mkEqNDRec motive proofSub heq)\n go 0 type",
"start": [
234,
1
],
"end": [
317,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkCongrSimp?",
"code": "def mkCongrSimp? (f : Expr) (subsingletonInstImplicitRhs : Bool := true) : MetaM (Option CongrTheorem) := do\n let f := (β instantiateMVars f).cleanupAnnotations\n let info β getFunInfo f\n mkCongrSimpCore? f info (β getCongrSimpKinds f info) (subsingletonInstImplicitRhs := subsingletonInstImplicitRhs)",
"start": [
319,
1
],
"end": [
330,
116
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Simp/SimpTheorems.lean | [
".lake/packages/lean4/src/lean/Lean/Util/Recognizers.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Eqns.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean",
".lake/packages/lean4/src/lean/Lean/PrettyPrinter.lean",
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Meta/DiscrTree.lean",
".lake/packages/lean4/src/lean/Lean/DocString.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/AuxLemma.lean"
] | [
{
"full_name": "Lean.Meta.Origin",
"code": "inductive Origin where\n \n | decl (declName : Name) (post := true) (inv := false)\n \n | fvar (fvarId : FVarId)\n \n | stx (id : Name) (ref : Syntax)\n \n | other (name : Name)\n deriving Inhabited, Repr",
"start": [
17,
1
],
"end": [
43,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Origin.key",
"code": "def Origin.key : Origin β Name\n | .decl declName _ _ => declName\n | .fvar fvarId => fvarId.name\n | .stx id _ => id\n | .other name => name",
"start": [
45,
1
],
"end": [
50,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Origin.lt",
"code": "def Origin.lt : Origin β Origin β Bool\n | .decl declNameβ _ invβ, .decl declNameβ _ invβ =>\n Name.lt declNameβ declNameβ || (declNameβ == declNameβ && !invβ && invβ)\n | .decl .., _ => false\n | _, .decl .. => true\n | a, b => Name.lt a.key b.key",
"start": [
67,
1
],
"end": [
72,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremKey",
"code": "abbrev SimpTheoremKey := DiscrTree.Key",
"start": [
91,
1
],
"end": [
91,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorem",
"code": "structure SimpTheorem where\n keys : Array SimpTheoremKey := #[]\n \n levelParams : Array Name := #[]\n proof : Expr\n priority : Nat := eval_prio default\n post : Bool := true\n \n perm : Bool := false\n \n origin : Origin\n \n rfl : Bool\n deriving Inhabited",
"start": [
93,
1
],
"end": [
122,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isRflProofCore",
"code": "partial def isRflProofCore (type : Expr) (proof : Expr) : CoreM Bool := do\n match type with\n | .forallE _ _ type _ =>\n if let .lam _ _ proof _ := proof then\n isRflProofCore type proof\n else\n return false\n | _ =>\n if type.isAppOfArity ``Eq 3 then\n if proof.isAppOfArity ``Eq.refl 2 || proof.isAppOfArity ``rfl 2 then\n return true\n else if proof.isAppOfArity ``Eq.symm 4 then\n isRflProofCore type proof.appArg! else if proof.getAppFn.isConst then\n isRflTheorem proof.getAppFn.constName!\n else\n return false\n else\n return false",
"start": [
125,
3
],
"end": [
146,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isRflTheorem",
"code": "partial def isRflTheorem (declName : Name) : CoreM Bool := do\n let .thmInfo info β getConstInfo declName | return false\n isRflProofCore info.type info.value",
"start": [
148,
3
],
"end": [
150,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isRflProof",
"code": "def isRflProof (proof : Expr) : MetaM Bool := do\n if let .const declName .. := proof then\n isRflTheorem declName\n else\n isRflProofCore (β inferType proof) proof",
"start": [
153,
1
],
"end": [
157,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ppOrigin",
"code": "def ppOrigin [Monad m] [MonadEnv m] [MonadError m] : Origin β m MessageData\n | .decl n post inv => do\n let r := MessageData.ofConst (β mkConstWithLevelParams n)\n match post, inv with\n | true, true => return m!\"β {r}\"\n | true, false => return r\n | false, true => return m!\"β β {r}\"\n | false, false => return m!\"β {r}\"\n | .fvar n => return mkFVar n\n | .stx _ ref => return ref\n | .other n => return n",
"start": [
166,
1
],
"end": [
176,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ppSimpTheorem",
"code": "def ppSimpTheorem [Monad m] [MonadEnv m] [MonadError m] (s : SimpTheorem) : m MessageData := do\n let perm := if s.perm then \":perm\" else \"\"\n let name β ppOrigin s.origin\n let prio := m!\":{s.priority}\"\n return name ++ prio ++ perm",
"start": [
178,
1
],
"end": [
182,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremTree",
"code": "abbrev SimpTheoremTree := DiscrTree SimpTheorem",
"start": [
187,
1
],
"end": [
187,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems",
"code": "structure SimpTheorems where\n pre : SimpTheoremTree := DiscrTree.empty\n post : SimpTheoremTree := DiscrTree.empty\n lemmaNames : PHashSet Origin := {}\n \n toUnfold : PHashSet Name := {}\n erased : PHashSet Origin := {}\n toUnfoldThms : PHashMap Name (Array Name) := {}\n deriving Inhabited",
"start": [
189,
1
],
"end": [
200,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.simpDtConfig",
"code": "def simpDtConfig : WhnfCoreConfig := { iota := false, proj := .no, zetaDelta := false }",
"start": [
202,
1
],
"end": [
203,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.eraseCore",
"code": "partial def SimpTheorems.eraseCore (d : SimpTheorems) (thmId : Origin) : SimpTheorems :=\n let d := { d with erased := d.erased.insert thmId, lemmaNames := d.lemmaNames.erase thmId }\n if let .decl declName .. := thmId then\n let d := { d with toUnfold := d.toUnfold.erase declName }\n if let some thms := d.toUnfoldThms.find? declName then\n let dummy := true\n thms.foldl (init := d) (eraseCore Β· <| .decl Β· dummy (inv := false))\n else\n d\n else\n d",
"start": [
205,
1
],
"end": [
215,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.eraseIfExists",
"code": "private def eraseIfExists (d : SimpTheorems) (thmId : Origin) : SimpTheorems :=\n if d.lemmaNames.contains thmId then\n d.eraseCore thmId\n else\n d",
"start": [
217,
1
],
"end": [
221,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.eraseFwdIfBwd",
"code": "private def eraseFwdIfBwd (d : SimpTheorems) (e : SimpTheorem) : SimpTheorems :=\n match e.origin with\n | .decl declName post true => eraseIfExists d (.decl declName post false)\n | _ => d",
"start": [
223,
1
],
"end": [
230,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addSimpTheoremEntry",
"code": "def addSimpTheoremEntry (d : SimpTheorems) (e : SimpTheorem) : SimpTheorems :=\n let d := eraseFwdIfBwd d e\n if e.post then\n { d with post := d.post.insertCore e.keys e, lemmaNames := updateLemmaNames d.lemmaNames }\n else\n { d with pre := d.pre.insertCore e.keys e, lemmaNames := updateLemmaNames d.lemmaNames }\nwhere\n updateLemmaNames (s : PHashSet Origin) : PHashSet Origin :=\n s.insert e.origin",
"start": [
232,
1
],
"end": [
240,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.addDeclToUnfoldCore",
"code": "def SimpTheorems.addDeclToUnfoldCore (d : SimpTheorems) (declName : Name) : SimpTheorems :=\n { d with toUnfold := d.toUnfold.insert declName }",
"start": [
242,
1
],
"end": [
243,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.addLetDeclToUnfold",
"code": "def SimpTheorems.addLetDeclToUnfold (d : SimpTheorems) (fvarId : FVarId) : SimpTheorems :=\n { d with toUnfold := d.toUnfold.insert fvarId.name }",
"start": [
245,
1
],
"end": [
247,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.isDeclToUnfold",
"code": "def SimpTheorems.isDeclToUnfold (d : SimpTheorems) (declName : Name) : Bool :=\n d.toUnfold.contains declName",
"start": [
249,
1
],
"end": [
251,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.isLetDeclToUnfold",
"code": "def SimpTheorems.isLetDeclToUnfold (d : SimpTheorems) (fvarId : FVarId) : Bool :=\n d.toUnfold.contains fvarId.name",
"start": [
253,
1
],
"end": [
254,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.isLemma",
"code": "def SimpTheorems.isLemma (d : SimpTheorems) (thmId : Origin) : Bool :=\n d.lemmaNames.contains thmId",
"start": [
256,
1
],
"end": [
257,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.registerDeclToUnfoldThms",
"code": "def SimpTheorems.registerDeclToUnfoldThms (d : SimpTheorems) (declName : Name) (eqThms : Array Name) : SimpTheorems :=\n { d with toUnfoldThms := d.toUnfoldThms.insert declName eqThms }",
"start": [
259,
1
],
"end": [
261,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.erase",
"code": "def SimpTheorems.erase [Monad m] [MonadLog m] [AddMessageContext m] [MonadOptions m]\n (d : SimpTheorems) (thmId : Origin) : m SimpTheorems := do\n unless d.isLemma thmId ||\n match thmId with\n | .decl declName .. => d.isDeclToUnfold declName || d.toUnfoldThms.contains declName\n | _ => false\n do\n logWarning m!\"'{thmId.key}' does not have [simp] attribute\"\n return d.eraseCore thmId",
"start": [
263,
1
],
"end": [
271,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isPerm",
"code": "private partial def isPerm : Expr β Expr β MetaM Bool\n | .app fβ aβ, .app fβ aβ => isPerm fβ fβ <&&> isPerm aβ aβ\n | .mdata _ s, t => isPerm s t\n | s, .mdata _ t => isPerm s t\n | s@(.mvar ..), t@(.mvar ..) => isDefEq s t\n | .forallE nβ dβ bβ _, .forallE _ dβ bβ _ =>\n isPerm dβ dβ <&&> withLocalDeclD nβ dβ fun x => isPerm (bβ.instantiate1 x) (bβ.instantiate1 x)\n | .lam nβ dβ bβ _, .lam _ dβ bβ _ =>\n isPerm dβ dβ <&&> withLocalDeclD nβ dβ fun x => isPerm (bβ.instantiate1 x) (bβ.instantiate1 x)\n | .letE nβ tβ vβ bβ _, .letE _ tβ vβ bβ _ =>\n isPerm tβ tβ <&&> isPerm vβ vβ <&&> withLetDecl nβ tβ vβ fun x => isPerm (bβ.instantiate1 x) (bβ.instantiate1 x)\n | .proj _ iβ bβ, .proj _ iβ bβ => pure (iβ == iβ) <&&> isPerm bβ bβ\n | s, t => return s == t",
"start": [
273,
1
],
"end": [
285,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkBadRewrite",
"code": "private def checkBadRewrite (lhs rhs : Expr) : MetaM Unit := do\n let lhs β DiscrTree.reduceDT lhs (root := true) simpDtConfig\n if lhs == rhs && lhs.isFVar then\n throwError \"invalid `simp` theorem, equation is equivalent to{indentExpr (β mkEq lhs rhs)}\"",
"start": [
287,
1
],
"end": [
290,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.shouldPreprocess",
"code": "private partial def shouldPreprocess (type : Expr) : MetaM Bool :=\n forallTelescopeReducing type fun _ result => do\n if let some (_, lhs, rhs) := result.eq? then\n checkBadRewrite lhs rhs\n return false\n else\n return true",
"start": [
292,
1
],
"end": [
298,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.preprocess",
"code": "private partial def preprocess (e type : Expr) (inv : Bool) (isGlobal : Bool) : MetaM (List (Expr Γ Expr)) :=\n go e type\nwhere\n go (e type : Expr) : MetaM (List (Expr Γ Expr)) := do\n let type β whnf type\n if type.isForall then\n forallTelescopeReducing type fun xs type => do\n let e := mkAppN e xs\n let ps β go e type\n ps.mapM fun (e, type) =>\n return (β mkLambdaFVars xs e, β mkForallFVars xs type)\n else if let some (_, lhs, rhs) := type.eq? then\n if isGlobal then\n checkBadRewrite lhs rhs\n if inv then\n let type β mkEq rhs lhs\n let e β mkEqSymm e\n return [(e, type)]\n else\n return [(e, type)]\n else if let some (lhs, rhs) := type.iff? then\n if isGlobal then\n checkBadRewrite lhs rhs\n if inv then\n let type β mkEq rhs lhs\n let e β mkEqSymm (β mkPropExt e)\n return [(e, type)]\n else\n let type β mkEq lhs rhs\n let e β mkPropExt e\n return [(e, type)]\n else if let some (_, lhs, rhs) := type.ne? then\n if inv then\n throwError \"invalid 'β' modifier in rewrite rule to 'False'\"\n if rhs.isConstOf ``Bool.true then\n return [(β mkAppM ``Bool.of_not_eq_true #[e], β mkEq lhs (mkConst ``Bool.false))]\n else if rhs.isConstOf ``Bool.false then\n return [(β mkAppM ``Bool.of_not_eq_false #[e], β mkEq lhs (mkConst ``Bool.true))]\n let type β mkEq (β mkEq lhs rhs) (mkConst ``False)\n let e β mkEqFalse e\n return [(e, type)]\n else if let some p := type.not? then\n if inv then\n throwError \"invalid 'β' modifier in rewrite rule to 'False'\"\n if let some (_, lhs, rhs) := p.eq? then\n if rhs.isConstOf ``Bool.true then\n return [(β mkAppM ``Bool.of_not_eq_true #[e], β mkEq lhs (mkConst ``Bool.false))]\n else if rhs.isConstOf ``Bool.false then\n return [(β mkAppM ``Bool.of_not_eq_false #[e], β mkEq lhs (mkConst ``Bool.true))]\n let type β mkEq p (mkConst ``False)\n let e β mkEqFalse e\n return [(e, type)]\n else if let some (typeβ, typeβ) := type.and? then\n let eβ := mkProj ``And 0 e\n let eβ := mkProj ``And 1 e\n return (β go eβ typeβ) ++ (β go eβ typeβ)\n else\n if inv then\n throwError \"invalid 'β' modifier in rewrite rule to 'True'\"\n let type β mkEq type (mkConst ``True)\n let e β mkEqTrue e\n return [(e, type)]",
"start": [
300,
1
],
"end": [
361,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkTypeIsProp",
"code": "private def checkTypeIsProp (type : Expr) : MetaM Unit :=\n unless (β isProp type) do\n throwError \"invalid 'simp', proposition expected{indentExpr type}\"",
"start": [
363,
1
],
"end": [
365,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSimpTheoremCore",
"code": "private def mkSimpTheoremCore (origin : Origin) (e : Expr) (levelParams : Array Name) (proof : Expr) (post : Bool) (prio : Nat) (noIndexAtArgs : Bool) : MetaM SimpTheorem := do\n assert! origin != .fvar β¨.anonymousβ©\n let type β instantiateMVars (β inferType e)\n withNewMCtxDepth do\n let (_, _, type) β withReducible <| forallMetaTelescopeReducing type\n let type β whnfR type\n let (keys, perm) β\n match type.eq? with\n | some (_, lhs, rhs) => pure (β DiscrTree.mkPath lhs simpDtConfig noIndexAtArgs, β isPerm lhs rhs)\n | none => throwError \"unexpected kind of 'simp' theorem{indentExpr type}\"\n return { origin, keys, perm, post, levelParams, proof, priority := prio, rfl := (β isRflProof proof) }",
"start": [
367,
1
],
"end": [
377,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSimpTheoremsFromConst",
"code": "private def mkSimpTheoremsFromConst (declName : Name) (post : Bool) (inv : Bool) (prio : Nat) : MetaM (Array SimpTheorem) := do\n let cinfo β getConstInfo declName\n let us := cinfo.levelParams.map mkLevelParam\n let origin := .decl declName post inv\n let val := mkConst declName us\n withReducible do\n let type β inferType val\n checkTypeIsProp type\n if inv || (β shouldPreprocess type) then\n let mut r := #[]\n for (val, type) in (β preprocess val type inv (isGlobal := true)) do\n let auxName β mkAuxLemma cinfo.levelParams type val\n r := r.push <| (β mkSimpTheoremCore origin (mkConst auxName us) #[] (mkConst auxName) post prio (noIndexAtArgs := false))\n return r\n else\n return #[β mkSimpTheoremCore origin (mkConst declName us) #[] (mkConst declName) post prio (noIndexAtArgs := false)]",
"start": [
379,
1
],
"end": [
394,
123
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpEntry",
"code": "inductive SimpEntry where\n | thm : SimpTheorem β SimpEntry\n | toUnfold : Name β SimpEntry\n | toUnfoldThms : Name β Array Name β SimpEntry\n deriving Inhabited",
"start": [
396,
1
],
"end": [
400,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpExtension",
"code": "abbrev SimpExtension := SimpleScopedEnvExtension SimpEntry SimpTheorems",
"start": [
402,
1
],
"end": [
402,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpExtension.getTheorems",
"code": "def SimpExtension.getTheorems (ext : SimpExtension) : CoreM SimpTheorems :=\n return ext.getState (β getEnv)",
"start": [
404,
1
],
"end": [
405,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.addSimpTheorem",
"code": "def addSimpTheorem (ext : SimpExtension) (declName : Name) (post : Bool) (inv : Bool) (attrKind : AttributeKind) (prio : Nat) : MetaM Unit := do\n let simpThms β mkSimpTheoremsFromConst declName post inv prio\n for simpThm in simpThms do\n ext.add (SimpEntry.thm simpThm) attrKind",
"start": [
407,
1
],
"end": [
410,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSimpExt",
"code": "def mkSimpExt (name : Name := by exact decl_name%) : IO SimpExtension :=\n registerSimpleScopedEnvExtension {\n name := name\n initial := {}\n addEntry := fun d e =>\n match e with\n | .thm e => addSimpTheoremEntry d e\n | .toUnfold n => d.addDeclToUnfoldCore n\n | .toUnfoldThms n thms => d.registerDeclToUnfoldThms n thms\n }",
"start": [
412,
1
],
"end": [
421,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpExtensionMap",
"code": "abbrev SimpExtensionMap := HashMap Name SimpExtension",
"start": [
423,
1
],
"end": [
423,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getSimpExtension?",
"code": "def getSimpExtension? (attrName : Name) : IO (Option SimpExtension) :=\n return (β simpExtensionMapRef.get).find? attrName",
"start": [
427,
1
],
"end": [
428,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.addConst",
"code": "def SimpTheorems.addConst (s : SimpTheorems) (declName : Name) (post := true) (inv := false) (prio : Nat := eval_prio default) : MetaM SimpTheorems := do\n let s := { s with erased := s.erased.erase (.decl declName post inv) }\n let simpThms β mkSimpTheoremsFromConst declName post inv prio\n return simpThms.foldl addSimpTheoremEntry s",
"start": [
430,
1
],
"end": [
434,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorem.getValue",
"code": "def SimpTheorem.getValue (simpThm : SimpTheorem) : MetaM Expr := do\n if simpThm.proof.isConst && simpThm.levelParams.isEmpty then\n let info β getConstInfo simpThm.proof.constName!\n if info.levelParams.isEmpty then\n return simpThm.proof\n else\n return simpThm.proof.updateConst! (β info.levelParams.mapM fun _ => mkFreshLevelMVar)\n else\n let us β simpThm.levelParams.mapM fun _ => mkFreshLevelMVar\n return simpThm.proof.instantiateLevelParamsArray simpThm.levelParams us",
"start": [
436,
1
],
"end": [
445,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.preprocessProof",
"code": "private def preprocessProof (val : Expr) (inv : Bool) : MetaM (Array Expr) := do\n let type β inferType val\n checkTypeIsProp type\n let ps β preprocess val type inv (isGlobal := false)\n return ps.toArray.map fun (val, _) => val",
"start": [
447,
1
],
"end": [
451,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkSimpTheorems",
"code": "def mkSimpTheorems (id : Origin) (levelParams : Array Name) (proof : Expr) (post := true) (inv := false) (prio : Nat := eval_prio default) : MetaM (Array SimpTheorem) :=\n withReducible do\n (β preprocessProof proof inv).mapM fun val => mkSimpTheoremCore id val levelParams val post prio (noIndexAtArgs := true)",
"start": [
453,
1
],
"end": [
456,
125
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.add",
"code": "def SimpTheorems.add (s : SimpTheorems) (id : Origin) (levelParams : Array Name) (proof : Expr) (inv := false) (post := true) (prio : Nat := eval_prio default) : MetaM SimpTheorems := do\n if proof.isConst then\n s.addConst proof.constName! post inv prio\n else\n let simpThms β mkSimpTheorems id levelParams proof post inv prio\n return simpThms.foldl addSimpTheoremEntry s",
"start": [
458,
1
],
"end": [
464,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheorems.addDeclToUnfold",
"code": "def SimpTheorems.addDeclToUnfold (d : SimpTheorems) (declName : Name) : MetaM SimpTheorems := do\n if let some eqns β getEqnsFor? declName then\n let mut d := d\n for h : i in [:eqns.size] do\n let eqn := eqns[i]\n \n let prio := if eqns.size > 100 then\n if i + 1 = eqns.size then 0 else 1\n else\n 100 - i\n d β SimpTheorems.addConst d eqn (prio := prio)\n \n if hasSmartUnfoldingDecl (β getEnv) declName || !(β isRecursiveDefinition declName) then\n d := d.addDeclToUnfoldCore declName\n return d\n else\n return d.addDeclToUnfoldCore declName",
"start": [
466,
1
],
"end": [
505,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremsArray",
"code": "abbrev SimpTheoremsArray := Array SimpTheorems",
"start": [
507,
1
],
"end": [
507,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremsArray.addTheorem",
"code": "def SimpTheoremsArray.addTheorem (thmsArray : SimpTheoremsArray) (id : Origin) (h : Expr) : MetaM SimpTheoremsArray :=\n if thmsArray.isEmpty then\n let thms : SimpTheorems := {}\n return #[ (β thms.add id #[] h) ]\n else\n thmsArray.modifyM 0 fun thms => thms.add id #[] h",
"start": [
509,
1
],
"end": [
514,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremsArray.eraseTheorem",
"code": "def SimpTheoremsArray.eraseTheorem (thmsArray : SimpTheoremsArray) (thmId : Origin) : SimpTheoremsArray :=\n thmsArray.map fun thms => thms.eraseCore thmId",
"start": [
516,
1
],
"end": [
517,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremsArray.isErased",
"code": "def SimpTheoremsArray.isErased (thmsArray : SimpTheoremsArray) (thmId : Origin) : Bool :=\n thmsArray.any fun thms => thms.erased.contains thmId",
"start": [
519,
1
],
"end": [
520,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremsArray.isDeclToUnfold",
"code": "def SimpTheoremsArray.isDeclToUnfold (thmsArray : SimpTheoremsArray) (declName : Name) : Bool :=\n thmsArray.any fun thms => thms.isDeclToUnfold declName",
"start": [
522,
1
],
"end": [
523,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SimpTheoremsArray.isLetDeclToUnfold",
"code": "def SimpTheoremsArray.isLetDeclToUnfold (thmsArray : SimpTheoremsArray) (fvarId : FVarId) : Bool :=\n thmsArray.any fun thms => thms.isLetDeclToUnfold fvarId",
"start": [
525,
1
],
"end": [
526,
58
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Tactic/Replace.lean | [
".lake/packages/lean4/src/lean/Lean/Util/ForEachExpr.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Intro.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Assert.lean",
".lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Main.lean",
".lake/packages/lean4/src/lean/Lean/Meta/AppBuilder.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Revert.lean",
".lake/packages/lean4/src/lean/Lean/Meta/MatchUtil.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Clear.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Tactic/Util.lean"
] | [
{
"full_name": "Lean.MVarId.replaceTargetEq",
"code": "def _root_.Lean.MVarId.replaceTargetEq (mvarId : MVarId) (targetNew : Expr) (eqProof : Expr) : MetaM MVarId :=\n mvarId.withContext do\n mvarId.checkNotAssigned `replaceTarget\n let tag β mvarId.getTag\n let mvarNew β mkFreshExprSyntheticOpaqueMVar targetNew tag\n let target β mvarId.getType\n let u β getLevel target\n let eq β mkEq target targetNew\n let newProof β mkExpectedTypeHint eqProof eq\n let val := mkAppN (Lean.mkConst `Eq.mpr [u]) #[target, targetNew, newProof, mvarNew]\n mvarId.assign val\n return mvarNew.mvarId!",
"start": [
19,
1
],
"end": [
33,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.replaceTargetEq",
"code": "@[deprecated MVarId.replaceTargetEq (since := \"2022-07-15\")]\ndef replaceTargetEq (mvarId : MVarId) (targetNew : Expr) (eqProof : Expr) : MetaM MVarId :=\n mvarId.replaceTargetEq targetNew eqProof",
"start": [
35,
1
],
"end": [
37,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.replaceTargetDefEq",
"code": "def _root_.Lean.MVarId.replaceTargetDefEq (mvarId : MVarId) (targetNew : Expr) : MetaM MVarId :=\n mvarId.withContext do\n mvarId.checkNotAssigned `change\n let target β mvarId.getType\n if target == targetNew then\n return mvarId\n else\n let tag β mvarId.getTag\n let mvarNew β mkFreshExprSyntheticOpaqueMVar targetNew tag\n let newVal β mkExpectedTypeHint mvarNew target\n mvarId.assign newVal\n return mvarNew.mvarId!",
"start": [
39,
1
],
"end": [
57,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.replaceTargetDefEq",
"code": "@[deprecated MVarId.replaceTargetDefEq (since := \"2022-07-15\")]\ndef replaceTargetDefEq (mvarId : MVarId) (targetNew : Expr) : MetaM MVarId :=\n mvarId.replaceTargetDefEq targetNew",
"start": [
59,
1
],
"end": [
61,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.replaceLocalDeclCore",
"code": "private def replaceLocalDeclCore (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult :=\n mvarId.withContext do\n let localDecl β fvarId.getDecl\n let typeNewPr β mkEqMP eqProof (mkFVar fvarId)\n \n let (_, localDecl') β findMaxFVar (β instantiateMVars typeNew) |>.run localDecl\n let result β mvarId.assertAfter localDecl'.fvarId localDecl.userName typeNew typeNewPr\n (do let mvarIdNew β result.mvarId.clear fvarId\n pure { result with mvarId := mvarIdNew })\n <|> pure result\nwhere\n findMaxFVar (e : Expr) : StateRefT LocalDecl MetaM Unit :=\n e.forEach' fun e => do\n if e.isFVar then\n let localDecl' β e.fvarId!.getDecl\n modify fun localDecl => if localDecl'.index > localDecl.index then localDecl' else localDecl\n return false\n else\n return e.hasFVar",
"start": [
63,
1
],
"end": [
85,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.replaceLocalDecl",
"code": "abbrev _root_.Lean.MVarId.replaceLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult :=\n replaceLocalDeclCore mvarId fvarId typeNew eqProof",
"start": [
87,
1
],
"end": [
103,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.replaceLocalDecl",
"code": "@[deprecated MVarId.replaceLocalDecl (since := \"2022-07-15\")]\nabbrev replaceLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (eqProof : Expr) : MetaM AssertAfterResult :=\n mvarId.replaceLocalDecl fvarId typeNew eqProof",
"start": [
105,
1
],
"end": [
107,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.replaceLocalDeclDefEq",
"code": "def _root_.Lean.MVarId.replaceLocalDeclDefEq (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) : MetaM MVarId := do\n mvarId.withContext do\n if typeNew == (β fvarId.getType) then\n return mvarId\n else\n let mvarDecl β mvarId.getDecl\n let lctxNew := (β getLCtx).modifyLocalDecl fvarId (Β·.setType typeNew)\n let mvarNew β mkFreshExprMVarAt lctxNew (β getLocalInstances) mvarDecl.type mvarDecl.kind mvarDecl.userName\n mvarId.assign mvarNew\n return mvarNew.mvarId!",
"start": [
109,
1
],
"end": [
122,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.replaceLocalDeclDefEq",
"code": "@[deprecated MVarId.replaceLocalDeclDefEq (since := \"2022-07-15\")]\ndef replaceLocalDeclDefEq (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) : MetaM MVarId := do\n mvarId.replaceLocalDeclDefEq fvarId typeNew",
"start": [
124,
1
],
"end": [
126,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.change",
"code": "def _root_.Lean.MVarId.change (mvarId : MVarId) (targetNew : Expr) (checkDefEq := true) : MetaM MVarId := mvarId.withContext do\n let target β mvarId.getType\n if checkDefEq then\n unless (β isDefEq target targetNew) do\n throwTacticEx `change mvarId m!\"given type{indentExpr targetNew}\\nis not definitionally equal to{indentExpr target}\"\n mvarId.replaceTargetDefEq targetNew",
"start": [
128,
1
],
"end": [
138,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.change",
"code": "@[deprecated MVarId.change (since := \"2022-07-15\")]\ndef change (mvarId : MVarId) (targetNew : Expr) (checkDefEq := true) : MetaM MVarId := mvarId.withContext do\n mvarId.change targetNew checkDefEq",
"start": [
140,
1
],
"end": [
142,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.withReverted",
"code": "def _root_.Lean.MVarId.withReverted (mvarId : MVarId) (fvarIds : Array FVarId)\n (k : MVarId β Array FVarId β MetaM (Ξ± Γ Array (Option FVarId) Γ MVarId))\n (clearAuxDeclsInsteadOfRevert := false) : MetaM (Ξ± Γ MVarId) := do\n let (xs, mvarId) β mvarId.revert fvarIds true clearAuxDeclsInsteadOfRevert\n let (r, xs', mvarId) β k mvarId xs\n let (ys, mvarId) β mvarId.introNP xs'.size\n mvarId.withContext do\n for x? in xs', y in ys do\n if let some x := x? then\n Elab.pushInfoLeaf (.ofFVarAliasInfo { id := y, baseId := x, userName := β y.getUserName })\n return (r, mvarId)",
"start": [
144,
1
],
"end": [
184,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.changeLocalDecl",
"code": "def _root_.Lean.MVarId.changeLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr)\n (checkDefEq := true) : MetaM MVarId := do\n mvarId.checkNotAssigned `changeLocalDecl\n let (_, mvarId) β mvarId.withReverted #[fvarId] fun mvarId fvars => mvarId.withContext do\n let check (typeOld : Expr) : MetaM Unit := do\n if checkDefEq then\n unless β isDefEq typeNew typeOld do\n throwTacticEx `changeLocalDecl mvarId\n m!\"given type{indentExpr typeNew}\\nis not definitionally equal to{indentExpr typeOld}\"\n let finalize (targetNew : Expr) := do\n return ((), fvars.map .some, β mvarId.replaceTargetDefEq targetNew)\n match β mvarId.getType with\n | .forallE n d b bi => do check d; finalize (.forallE n typeNew b bi)\n | .letE n t v b ndep => do check t; finalize (.letE n typeNew v b ndep)\n | _ => throwTacticEx `changeLocalDecl mvarId \"unexpected auxiliary target\"\n return mvarId",
"start": [
186,
1
],
"end": [
211,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.changeLocalDecl",
"code": "@[deprecated MVarId.changeLocalDecl]\ndef changeLocalDecl (mvarId : MVarId) (fvarId : FVarId) (typeNew : Expr) (checkDefEq := true) : MetaM MVarId := do\n mvarId.changeLocalDecl fvarId typeNew checkDefEq",
"start": [
213,
1
],
"end": [
215,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.modifyTarget",
"code": "def _root_.Lean.MVarId.modifyTarget (mvarId : MVarId) (f : Expr β MetaM Expr) : MetaM MVarId := do\n mvarId.withContext do\n mvarId.checkNotAssigned `modifyTarget\n mvarId.change (β f (β mvarId.getType)) (checkDefEq := false)",
"start": [
217,
1
],
"end": [
223,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyTarget",
"code": "@[deprecated modifyTarget (since := \"2022-07-15\")]\ndef modifyTarget (mvarId : MVarId) (f : Expr β MetaM Expr) : MetaM MVarId := do\n mvarId.modifyTarget f",
"start": [
225,
1
],
"end": [
227,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.modifyTargetEqLHS",
"code": "def _root_.Lean.MVarId.modifyTargetEqLHS (mvarId : MVarId) (f : Expr β MetaM Expr) : MetaM MVarId := do\n mvarId.modifyTarget fun target => do\n if let some (_, lhs, rhs) β matchEq? target then\n mkEq (β f lhs) rhs\n else\n throwTacticEx `modifyTargetEqLHS mvarId m!\"equality expected{indentExpr target}\"",
"start": [
229,
1
],
"end": [
238,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyTargetEqLHS",
"code": "@[deprecated MVarId.modifyTargetEqLHS (since := \"2022-07-15\")]\ndef modifyTargetEqLHS (mvarId : MVarId) (f : Expr β MetaM Expr) : MetaM MVarId := do\n mvarId.modifyTargetEqLHS f",
"start": [
240,
1
],
"end": [
242,
29
],
"kind": "commanddeclaration"
}
] |