path
stringlengths 12
84
| imports
sequencelengths 0
4.45k
| premises
listlengths 0
625
|
---|---|---|
.lake/packages/lean4/src/lean/Init/System/IO.lean | [
".lake/packages/lean4/src/lean/Init/System/IOError.lean",
".lake/packages/lean4/src/lean/Init/Data/ToString/Macro.lean",
".lake/packages/lean4/src/lean/Init/System/FilePath.lean",
".lake/packages/lean4/src/lean/Init/Control/Reader.lean",
".lake/packages/lean4/src/lean/Init/Data/String.lean",
".lake/packages/lean4/src/lean/Init/System/ST.lean",
".lake/packages/lean4/src/lean/Init/Data/ByteArray.lean",
".lake/packages/lean4/src/lean/Init/Data/Ord.lean"
] | [
{
"full_name": "IO.RealWorld",
"code": "def IO.RealWorld : Type := Unit",
"start": [
18,
1
],
"end": [
22,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO",
"code": "def EIO (ε : Type) : Type → Type := EStateM ε IO.RealWorld",
"start": [
31,
1
],
"end": [
31,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO",
"code": "def BaseIO := EIO Empty",
"start": [
39,
1
],
"end": [
40,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO.toEIO",
"code": "@[always_inline, inline]\ndef BaseIO.toEIO (act : BaseIO α) : EIO ε α :=\n fun s => match act s with\n | EStateM.Result.ok a s => EStateM.Result.ok a s",
"start": [
45,
1
],
"end": [
48,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.toBaseIO",
"code": "@[always_inline, inline]\ndef EIO.toBaseIO (act : EIO ε α) : BaseIO (Except ε α) :=\n fun s => match act s with\n | EStateM.Result.ok a s => EStateM.Result.ok (Except.ok a) s\n | EStateM.Result.error ex s => EStateM.Result.ok (Except.error ex) s",
"start": [
52,
1
],
"end": [
56,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.catchExceptions",
"code": "@[always_inline, inline]\ndef EIO.catchExceptions (act : EIO ε α) (h : ε → BaseIO α) : BaseIO α :=\n fun s => match act s with\n | EStateM.Result.ok a s => EStateM.Result.ok a s\n | EStateM.Result.error ex s => h ex s",
"start": [
58,
1
],
"end": [
62,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "IO",
"code": "abbrev IO : Type → Type := EIO Error",
"start": [
65,
1
],
"end": [
65,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO.toIO",
"code": "@[inline] def BaseIO.toIO (act : BaseIO α) : IO α :=\n act",
"start": [
67,
1
],
"end": [
68,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.toIO",
"code": "@[inline] def EIO.toIO (f : ε → IO.Error) (act : EIO ε α) : IO α :=\n act.adaptExcept f",
"start": [
70,
1
],
"end": [
71,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.toIO'",
"code": "@[inline] def EIO.toIO' (act : EIO ε α) : IO (Except ε α) :=\n act.toBaseIO",
"start": [
73,
1
],
"end": [
74,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.toEIO",
"code": "@[inline] def IO.toEIO (f : IO.Error → ε) (act : IO α) : EIO ε α :=\n act.adaptExcept f",
"start": [
76,
1
],
"end": [
77,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "unsafeBaseIO",
"code": "@[inline] unsafe def unsafeBaseIO (fn : BaseIO α) : α :=\n match fn.run () with\n | EStateM.Result.ok a _ => a",
"start": [
83,
1
],
"end": [
85,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "unsafeEIO",
"code": "@[inline] unsafe def unsafeEIO (fn : EIO ε α) : Except ε α :=\n unsafeBaseIO fn.toBaseIO",
"start": [
87,
1
],
"end": [
88,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "unsafeIO",
"code": "@[inline] unsafe def unsafeIO (fn : IO α) : Except IO.Error α :=\n unsafeEIO fn",
"start": [
90,
1
],
"end": [
91,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "timeit",
"code": "@[extern \"lean_io_timeit\"] opaque timeit (msg : @& String) (fn : IO α) : IO α",
"start": [
93,
1
],
"end": [
93,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "allocprof",
"code": "@[extern \"lean_io_allocprof\"] opaque allocprof (msg : @& String) (fn : IO α) : IO α",
"start": [
94,
1
],
"end": [
94,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.initializing",
"code": "@[extern \"lean_io_initializing\"] opaque IO.initializing : BaseIO Bool",
"start": [
96,
1
],
"end": [
101,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO.asTask",
"code": "@[extern \"lean_io_as_task\"]\nopaque asTask (act : BaseIO α) (prio := Task.Priority.default) : BaseIO (Task α) :=\n Task.pure <$> act",
"start": [
105,
1
],
"end": [
115,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO.mapTask",
"code": "@[extern \"lean_io_map_task\"]\nopaque mapTask (f : α → BaseIO β) (t : Task α) (prio := Task.Priority.default) (sync := false) :\n BaseIO (Task β) :=\n Task.pure <$> f t.get",
"start": [
117,
1
],
"end": [
121,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO.bindTask",
"code": "@[extern \"lean_io_bind_task\"]\nopaque bindTask (t : Task α) (f : α → BaseIO (Task β)) (prio := Task.Priority.default)\n (sync := false) : BaseIO (Task β) :=\n f t.get",
"start": [
123,
1
],
"end": [
127,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "BaseIO.mapTasks",
"code": "def mapTasks (f : List α → BaseIO β) (tasks : List (Task α)) (prio := Task.Priority.default)\n (sync := false) : BaseIO (Task β) :=\n go tasks []\nwhere\n go\n | t::ts, as =>\n BaseIO.bindTask t (fun a => go ts (a :: as)) prio sync\n | [], as => f as.reverse |>.asTask prio",
"start": [
129,
1
],
"end": [
136,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.asTask",
"code": "@[inline] def asTask (act : EIO ε α) (prio := Task.Priority.default) : BaseIO (Task (Except ε α)) :=\n act.toBaseIO.asTask prio",
"start": [
142,
1
],
"end": [
144,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.mapTask",
"code": "@[inline] def mapTask (f : α → EIO ε β) (t : Task α) (prio := Task.Priority.default)\n (sync := false) : BaseIO (Task (Except ε β)) :=\n BaseIO.mapTask (fun a => f a |>.toBaseIO) t prio sync",
"start": [
146,
1
],
"end": [
149,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.bindTask",
"code": "@[inline] def bindTask (t : Task α) (f : α → EIO ε (Task (Except ε β)))\n (prio := Task.Priority.default) (sync := false) : BaseIO (Task (Except ε β)) :=\n BaseIO.bindTask t (fun a => f a |>.catchExceptions fun e => return Task.pure <| Except.error e)\n prio sync",
"start": [
151,
1
],
"end": [
155,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "EIO.mapTasks",
"code": "@[inline] def mapTasks (f : List α → EIO ε β) (tasks : List (Task α))\n (prio := Task.Priority.default) (sync := false) : BaseIO (Task (Except ε β)) :=\n BaseIO.mapTasks (fun as => f as |>.toBaseIO) tasks prio sync",
"start": [
157,
1
],
"end": [
160,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.ofExcept",
"code": "def ofExcept [ToString ε] (e : Except ε α) : IO α :=\n match e with\n | Except.ok a => pure a\n | Except.error e => throw (IO.userError (toString e))",
"start": [
166,
1
],
"end": [
169,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.lazyPure",
"code": "def lazyPure (fn : Unit → α) : IO α :=\n pure (fn ())",
"start": [
171,
1
],
"end": [
172,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.monoMsNow",
"code": "@[extern \"lean_io_mono_ms_now\"] opaque monoMsNow : BaseIO Nat",
"start": [
174,
1
],
"end": [
175,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.monoNanosNow",
"code": "@[extern \"lean_io_mono_nanos_now\"] opaque monoNanosNow : BaseIO Nat",
"start": [
177,
1
],
"end": [
178,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getRandomBytes",
"code": "@[extern \"lean_io_get_random_bytes\"] opaque getRandomBytes (nBytes : USize) : IO ByteArray",
"start": [
180,
1
],
"end": [
182,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.sleep",
"code": "def sleep (ms : UInt32) : BaseIO Unit :=\n fun s => dbgSleep ms fun _ => EStateM.Result.ok () s",
"start": [
184,
1
],
"end": [
186,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.asTask",
"code": "@[inline] def asTask (act : IO α) (prio := Task.Priority.default) : BaseIO (Task (Except IO.Error α)) :=\n EIO.asTask act prio",
"start": [
188,
1
],
"end": [
190,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.mapTask",
"code": "@[inline] def mapTask (f : α → IO β) (t : Task α) (prio := Task.Priority.default) (sync := false) :\n BaseIO (Task (Except IO.Error β)) :=\n EIO.mapTask f t prio sync",
"start": [
192,
1
],
"end": [
195,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.bindTask",
"code": "@[inline] def bindTask (t : Task α) (f : α → IO (Task (Except IO.Error β)))\n (prio := Task.Priority.default) (sync := false) : BaseIO (Task (Except IO.Error β)) :=\n EIO.bindTask t f prio sync",
"start": [
197,
1
],
"end": [
200,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.mapTasks",
"code": "@[inline] def mapTasks (f : List α → IO β) (tasks : List (Task α)) (prio := Task.Priority.default)\n (sync := false) : BaseIO (Task (Except IO.Error β)) :=\n EIO.mapTasks f tasks prio sync",
"start": [
202,
1
],
"end": [
205,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.checkCanceled",
"code": "@[extern \"lean_io_check_canceled\"] opaque checkCanceled : BaseIO Bool",
"start": [
207,
1
],
"end": [
208,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.cancel",
"code": "@[extern \"lean_io_cancel\"] opaque cancel : @& Task α → BaseIO Unit",
"start": [
210,
1
],
"end": [
211,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.TaskState",
"code": "inductive TaskState\n \n | waiting\n \n | running\n \n | finished\n deriving Inhabited, Repr, DecidableEq, Ord",
"start": [
213,
1
],
"end": [
231,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.TaskState.toString",
"code": "protected def TaskState.toString : TaskState → String\n | .waiting => \"waiting\"\n | .running => \"running\"\n | .finished => \"finished\"",
"start": [
238,
1
],
"end": [
241,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getTaskState",
"code": "@[extern \"lean_io_get_task_state\"] opaque getTaskState : @& Task α → BaseIO TaskState",
"start": [
245,
1
],
"end": [
246,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.hasFinished",
"code": "@[inline] def hasFinished (task : Task α) : BaseIO Bool := do\n return (← getTaskState task) matches .finished",
"start": [
248,
1
],
"end": [
250,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.wait",
"code": "@[extern \"lean_io_wait\"] opaque wait (t : Task α) : BaseIO α :=\n return t.get",
"start": [
252,
1
],
"end": [
254,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.waitAny",
"code": "@[extern \"lean_io_wait_any\"] opaque waitAny (tasks : @& List (Task α))\n (h : tasks.length > 0 := by exact Nat.zero_lt_succ _) : BaseIO α :=\n return tasks[0].get",
"start": [
256,
1
],
"end": [
259,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getNumHeartbeats",
"code": "@[extern \"lean_io_get_num_heartbeats\"] opaque getNumHeartbeats : BaseIO Nat",
"start": [
261,
1
],
"end": [
262,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.addHeartbeats",
"code": "@[extern \"lean_io_add_heartbeats\"] opaque addHeartbeats (count : UInt64) : BaseIO Unit",
"start": [
264,
1
],
"end": [
269,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Mode",
"code": "inductive FS.Mode where\n \n | read\n \n | write\n \n | writeNew\n \n | readWrite\n \n | append",
"start": [
271,
1
],
"end": [
331,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle",
"code": "opaque FS.Handle : Type := Unit",
"start": [
333,
1
],
"end": [
333,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream",
"code": "structure FS.Stream where\n flush : IO Unit\n \n read : USize → IO ByteArray\n write : ByteArray → IO Unit\n \n getLine : IO String\n putStr : String → IO Unit\n \n isTty : BaseIO Bool\n deriving Inhabited",
"start": [
335,
1
],
"end": [
356,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getStdin",
"code": "@[extern \"lean_get_stdin\"] opaque getStdin : BaseIO FS.Stream",
"start": [
360,
1
],
"end": [
360,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getStdout",
"code": "@[extern \"lean_get_stdout\"] opaque getStdout : BaseIO FS.Stream",
"start": [
361,
1
],
"end": [
361,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getStderr",
"code": "@[extern \"lean_get_stderr\"] opaque getStderr : BaseIO FS.Stream",
"start": [
362,
1
],
"end": [
362,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.setStdin",
"code": "@[extern \"lean_get_set_stdin\"] opaque setStdin : FS.Stream → BaseIO FS.Stream",
"start": [
364,
1
],
"end": [
365,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.setStdout",
"code": "@[extern \"lean_get_set_stdout\"] opaque setStdout : FS.Stream → BaseIO FS.Stream",
"start": [
366,
1
],
"end": [
367,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.setStderr",
"code": "@[extern \"lean_get_set_stderr\"] opaque setStderr : FS.Stream → BaseIO FS.Stream",
"start": [
368,
1
],
"end": [
369,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.iterate",
"code": "@[specialize] partial def iterate (a : α) (f : α → IO (Sum α β)) : IO β := do\n let v ← f a\n match v with\n | Sum.inl a => iterate a f\n | Sum.inr b => pure b",
"start": [
371,
1
],
"end": [
375,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.mk",
"code": "@[extern \"lean_io_prim_handle_mk\"] opaque mk (fn : @& FilePath) (mode : FS.Mode) : IO Handle",
"start": [
381,
1
],
"end": [
381,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.lock",
"code": "@[extern \"lean_io_prim_handle_lock\"] opaque lock (h : @& Handle) (exclusive := true) : IO Unit",
"start": [
383,
1
],
"end": [
390,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.tryLock",
"code": "@[extern \"lean_io_prim_handle_try_lock\"] opaque tryLock (h : @& Handle) (exclusive := true) : IO Bool",
"start": [
391,
1
],
"end": [
398,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.unlock",
"code": "@[extern \"lean_io_prim_handle_unlock\"] opaque unlock (h : @& Handle) : IO Unit",
"start": [
399,
1
],
"end": [
403,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.isTty",
"code": "@[extern \"lean_io_prim_handle_is_tty\"] opaque isTty (h : @& Handle) : BaseIO Bool",
"start": [
405,
1
],
"end": [
406,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.flush",
"code": "@[extern \"lean_io_prim_handle_flush\"] opaque flush (h : @& Handle) : IO Unit",
"start": [
408,
1
],
"end": [
408,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.rewind",
"code": "@[extern \"lean_io_prim_handle_rewind\"] opaque rewind (h : @& Handle) : IO Unit",
"start": [
409,
1
],
"end": [
410,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.truncate",
"code": "@[extern \"lean_io_prim_handle_truncate\"] opaque truncate (h : @& Handle) : IO Unit",
"start": [
411,
1
],
"end": [
419,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.read",
"code": "@[extern \"lean_io_prim_handle_read\"] opaque read (h : @& Handle) (bytes : USize) : IO ByteArray",
"start": [
420,
1
],
"end": [
425,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.write",
"code": "@[extern \"lean_io_prim_handle_write\"] opaque write (h : @& Handle) (buffer : @& ByteArray) : IO Unit",
"start": [
426,
1
],
"end": [
426,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.getLine",
"code": "@[extern \"lean_io_prim_handle_get_line\"] opaque getLine (h : @& Handle) : IO String",
"start": [
428,
1
],
"end": [
433,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.putStr",
"code": "@[extern \"lean_io_prim_handle_put_str\"] opaque putStr (h : @& Handle) (s : @& String) : IO Unit",
"start": [
434,
1
],
"end": [
434,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.realPath",
"code": "@[extern \"lean_io_realpath\"] opaque realPath (fname : FilePath) : IO FilePath",
"start": [
438,
1
],
"end": [
438,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.removeFile",
"code": "@[extern \"lean_io_remove_file\"] opaque removeFile (fname : @& FilePath) : IO Unit",
"start": [
439,
1
],
"end": [
439,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.removeDir",
"code": "@[extern \"lean_io_remove_dir\"] opaque removeDir : @& FilePath → IO Unit",
"start": [
440,
1
],
"end": [
441,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.createDir",
"code": "@[extern \"lean_io_create_dir\"] opaque createDir : @& FilePath → IO Unit",
"start": [
442,
1
],
"end": [
442,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.rename",
"code": "@[extern \"lean_io_rename\"] opaque rename (old new : @& FilePath) : IO Unit",
"start": [
444,
1
],
"end": [
450,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.getEnv",
"code": "@[extern \"lean_io_getenv\"] opaque getEnv (var : @& String) : BaseIO (Option String)",
"start": [
454,
1
],
"end": [
454,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.appPath",
"code": "@[extern \"lean_io_app_path\"] opaque appPath : IO FilePath",
"start": [
455,
1
],
"end": [
455,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.currentDir",
"code": "@[extern \"lean_io_current_dir\"] opaque currentDir : IO FilePath",
"start": [
456,
1
],
"end": [
456,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.withFile",
"code": "@[inline]\ndef withFile (fn : FilePath) (mode : Mode) (f : Handle → IO α) : IO α :=\n Handle.mk fn mode >>= f",
"start": [
460,
1
],
"end": [
462,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.putStrLn",
"code": "def Handle.putStrLn (h : Handle) (s : String) : IO Unit :=\n h.putStr (s.push '\\n')",
"start": [
464,
1
],
"end": [
465,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.readBinToEnd",
"code": "partial def Handle.readBinToEnd (h : Handle) : IO ByteArray := do\n let rec loop (acc : ByteArray) : IO ByteArray := do\n let buf ← h.read 1024\n if buf.isEmpty then\n return acc\n else\n loop (acc ++ buf)\n loop ByteArray.empty",
"start": [
467,
1
],
"end": [
474,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Handle.readToEnd",
"code": "partial def Handle.readToEnd (h : Handle) : IO String := do\n let rec loop (s : String) := do\n let line ← h.getLine\n if line.isEmpty then\n return s\n else\n loop (s ++ line)\n loop \"\"",
"start": [
476,
1
],
"end": [
483,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.readBinFile",
"code": "def readBinFile (fname : FilePath) : IO ByteArray := do\n let h ← Handle.mk fname Mode.read\n h.readBinToEnd",
"start": [
485,
1
],
"end": [
487,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.readFile",
"code": "def readFile (fname : FilePath) : IO String := do\n let h ← Handle.mk fname Mode.read\n h.readToEnd",
"start": [
489,
1
],
"end": [
491,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.lines",
"code": "partial def lines (fname : FilePath) : IO (Array String) := do\n let h ← Handle.mk fname Mode.read\n let rec read (lines : Array String) := do\n let line ← h.getLine\n if line.length == 0 then\n pure lines\n else if line.back == '\\n' then\n let line := line.dropRight 1\n let line := if System.Platform.isWindows && line.back == '\\x0d' then line.dropRight 1 else line\n read <| lines.push line\n else\n pure <| lines.push line\n read #[]",
"start": [
493,
1
],
"end": [
505,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.writeBinFile",
"code": "def writeBinFile (fname : FilePath) (content : ByteArray) : IO Unit := do\n let h ← Handle.mk fname Mode.write\n h.write content",
"start": [
507,
1
],
"end": [
509,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.writeFile",
"code": "def writeFile (fname : FilePath) (content : String) : IO Unit := do\n let h ← Handle.mk fname Mode.write\n h.putStr content",
"start": [
511,
1
],
"end": [
513,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.putStrLn",
"code": "def Stream.putStrLn (strm : FS.Stream) (s : String) : IO Unit :=\n strm.putStr (s.push '\\n')",
"start": [
515,
1
],
"end": [
516,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.DirEntry",
"code": "structure DirEntry where\n root : FilePath\n fileName : String\n deriving Repr",
"start": [
518,
1
],
"end": [
521,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.DirEntry.path",
"code": "def DirEntry.path (entry : DirEntry) : FilePath :=\n entry.root / entry.fileName",
"start": [
523,
1
],
"end": [
524,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.FileType",
"code": "inductive FileType where\n | dir\n | file\n | symlink\n | other\n deriving Repr, BEq",
"start": [
526,
1
],
"end": [
531,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.SystemTime",
"code": "structure SystemTime where\n sec : Int\n nsec : UInt32\n deriving Repr, BEq, Ord, Inhabited",
"start": [
533,
1
],
"end": [
536,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Metadata",
"code": "structure Metadata where\n accessed : SystemTime\n modified : SystemTime\n byteSize : UInt64\n type : FileType\n deriving Repr",
"start": [
541,
1
],
"end": [
547,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "System.FilePath.readDir",
"code": "@[extern \"lean_io_read_dir\"]\nopaque readDir : @& FilePath → IO (Array IO.FS.DirEntry)",
"start": [
555,
1
],
"end": [
556,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "System.FilePath.metadata",
"code": "@[extern \"lean_io_metadata\"]\nopaque metadata : @& FilePath → IO IO.FS.Metadata",
"start": [
558,
1
],
"end": [
559,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "System.FilePath.isDir",
"code": "def isDir (p : FilePath) : BaseIO Bool := do\n match (← p.metadata.toBaseIO) with\n | Except.ok m => return m.type == IO.FS.FileType.dir\n | Except.error _ => return false",
"start": [
561,
1
],
"end": [
564,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "System.FilePath.pathExists",
"code": "def pathExists (p : FilePath) : BaseIO Bool :=\n return (← p.metadata.toBaseIO).toBool",
"start": [
566,
1
],
"end": [
567,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "System.FilePath.walkDir",
"code": "partial def walkDir (p : FilePath) (enter : FilePath → IO Bool := fun _ => pure true) : IO (Array FilePath) :=\n Prod.snd <$> StateT.run (go p) #[]\nwhere\n go p := do\n if !(← enter p) then\n return ()\n for d in (← p.readDir) do\n modify (·.push d.path)\n match (← d.path.metadata.toBaseIO) with\n | .ok { type := .symlink, .. } =>\n let p' ← FS.realPath d.path\n if (← p'.isDir) then\n if (← enter p) then\n go p'\n | .ok { type := .dir, .. } => go d.path\n | .ok _ => pure ()\n | .error (.noFileOrDirectory ..) => pure ()\n | .error e => throw e",
"start": [
569,
1
],
"end": [
591,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.withStdin",
"code": "def withStdin [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (h : FS.Stream) (x : m α) : m α := do\n let prev ← setStdin h\n try x finally discard <| setStdin prev",
"start": [
597,
1
],
"end": [
599,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.withStdout",
"code": "def withStdout [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (h : FS.Stream) (x : m α) : m α := do\n let prev ← setStdout h\n try\n x\n finally\n discard <| setStdout prev",
"start": [
601,
1
],
"end": [
606,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.withStderr",
"code": "def withStderr [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (h : FS.Stream) (x : m α) : m α := do\n let prev ← setStderr h\n try x finally discard <| setStderr prev",
"start": [
608,
1
],
"end": [
610,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.print",
"code": "def print [ToString α] (s : α) : IO Unit := do\n let out ← getStdout\n out.putStr <| toString s",
"start": [
612,
1
],
"end": [
614,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.println",
"code": "def println [ToString α] (s : α) : IO Unit :=\n print ((toString s).push '\\n')",
"start": [
616,
1
],
"end": [
617,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.eprint",
"code": "def eprint [ToString α] (s : α) : IO Unit := do\n let out ← getStderr\n out.putStr <| toString s",
"start": [
619,
1
],
"end": [
621,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.eprintln",
"code": "def eprintln [ToString α] (s : α) : IO Unit :=\n eprint <| toString s |>.push '\\n'",
"start": [
623,
1
],
"end": [
624,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.eprintAux",
"code": "@[export lean_io_eprint]\nprivate def eprintAux (s : String) : IO Unit :=\n eprint s",
"start": [
626,
1
],
"end": [
628,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.eprintlnAux",
"code": "@[export lean_io_eprintln]\nprivate def eprintlnAux (s : String) : IO Unit :=\n eprintln s",
"start": [
630,
1
],
"end": [
632,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.appDir",
"code": "def appDir : IO FilePath := do\n let p ← appPath\n let some p ← pure p.parent\n | throw <| IO.userError s!\"System.IO.appDir: unexpected filename '{p}'\"\n FS.realPath p",
"start": [
634,
1
],
"end": [
638,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.createDirAll",
"code": "partial def FS.createDirAll (p : FilePath) : IO Unit := do\n if ← p.isDir then\n return ()\n if let some parent := p.parent then\n createDirAll parent\n try\n createDir p\n catch\n | e =>\n if ← p.isDir then\n pure () else\n throw e",
"start": [
640,
1
],
"end": [
653,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.removeDirAll",
"code": "partial def FS.removeDirAll (p : FilePath) : IO Unit := do\n for ent in (← p.readDir) do\n if (← ent.path.isDir : Bool) then\n removeDirAll ent.path\n else\n removeFile ent.path\n removeDir p",
"start": [
655,
1
],
"end": [
664,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.getCurrentDir",
"code": "@[extern \"lean_io_process_get_current_dir\"] opaque getCurrentDir : IO FilePath",
"start": [
668,
1
],
"end": [
669,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.setCurrentDir",
"code": "@[extern \"lean_io_process_set_current_dir\"] opaque setCurrentDir (path : @& FilePath) : IO Unit",
"start": [
671,
1
],
"end": [
672,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.getPID",
"code": "@[extern \"lean_io_process_get_pid\"] opaque getPID : BaseIO UInt32",
"start": [
674,
1
],
"end": [
675,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Stdio",
"code": "inductive Stdio where\n | piped\n | inherit\n | null",
"start": [
677,
1
],
"end": [
680,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Stdio.toHandleType",
"code": "def Stdio.toHandleType : Stdio → Type\n | Stdio.piped => FS.Handle\n | Stdio.inherit => Unit\n | Stdio.null => Unit",
"start": [
682,
1
],
"end": [
685,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.StdioConfig",
"code": "structure StdioConfig where\n \n stdin := Stdio.inherit\n \n stdout := Stdio.inherit\n \n stderr := Stdio.inherit",
"start": [
687,
1
],
"end": [
693,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.SpawnArgs",
"code": "structure SpawnArgs extends StdioConfig where\n \n cmd : String\n \n args : Array String := #[]\n \n cwd : Option FilePath := none\n \n env : Array (String × Option String) := #[]\n \n setsid : Bool := false",
"start": [
695,
1
],
"end": [
705,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Child",
"code": "structure Child (cfg : StdioConfig) where\n stdin : cfg.stdin.toHandleType\n stdout : cfg.stdout.toHandleType\n stderr : cfg.stderr.toHandleType",
"start": [
708,
1
],
"end": [
711,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.spawn",
"code": "@[extern \"lean_io_process_spawn\"] opaque spawn (args : SpawnArgs) : IO (Child args.toStdioConfig)",
"start": [
713,
1
],
"end": [
713,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Child.wait",
"code": "@[extern \"lean_io_process_child_wait\"] opaque Child.wait {cfg : @& StdioConfig} : @& Child cfg → IO UInt32",
"start": [
715,
1
],
"end": [
715,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Child.kill",
"code": "@[extern \"lean_io_process_child_kill\"] opaque Child.kill {cfg : @& StdioConfig} : @& Child cfg → IO Unit",
"start": [
717,
1
],
"end": [
719,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Child.takeStdin",
"code": "@[extern \"lean_io_process_child_take_stdin\"] opaque Child.takeStdin {cfg : @& StdioConfig} : Child cfg →\n IO (cfg.stdin.toHandleType × Child { cfg with stdin := Stdio.null })",
"start": [
721,
1
],
"end": [
728,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.Output",
"code": "structure Output where\n exitCode : UInt32\n stdout : String\n stderr : String",
"start": [
730,
1
],
"end": [
733,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.output",
"code": "def output (args : SpawnArgs) : IO Output := do\n let child ← spawn { args with stdout := .piped, stderr := .piped, stdin := .null }\n let stdout ← IO.asTask child.stdout.readToEnd Task.Priority.dedicated\n let stderr ← child.stderr.readToEnd\n let exitCode ← child.wait\n let stdout ← IO.ofExcept stdout.get\n pure { exitCode := exitCode, stdout := stdout, stderr := stderr }",
"start": [
735,
1
],
"end": [
745,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.run",
"code": "def run (args : SpawnArgs) : IO String := do\n let out ← output args\n if out.exitCode != 0 then\n throw <| IO.userError <| \"process '\" ++ args.cmd ++ \"' exited with code \" ++ toString out.exitCode\n pure out.stdout",
"start": [
747,
1
],
"end": [
752,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Process.exit",
"code": "@[extern \"lean_io_exit\"] opaque exit : UInt8 → IO α",
"start": [
754,
1
],
"end": [
754,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.AccessRight",
"code": "structure AccessRight where\n read : Bool := false\n write : Bool := false\n execution : Bool := false",
"start": [
758,
1
],
"end": [
761,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.AccessRight.flags",
"code": "def AccessRight.flags (acc : AccessRight) : UInt32 :=\n let r : UInt32 := if acc.read then 0x4 else 0\n let w : UInt32 := if acc.write then 0x2 else 0\n let x : UInt32 := if acc.execution then 0x1 else 0\n r.lor <| w.lor x",
"start": [
763,
1
],
"end": [
767,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FileRight",
"code": "structure FileRight where\n user : AccessRight := {}\n group : AccessRight := {}\n other : AccessRight := {}",
"start": [
769,
1
],
"end": [
772,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FileRight.flags",
"code": "def FileRight.flags (acc : FileRight) : UInt32 :=\n let u : UInt32 := acc.user.flags.shiftLeft 6\n let g : UInt32 := acc.group.flags.shiftLeft 3\n let o : UInt32 := acc.other.flags\n u.lor <| g.lor o",
"start": [
774,
1
],
"end": [
778,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Prim.setAccessRights",
"code": "@[extern \"lean_chmod\"] opaque Prim.setAccessRights (filename : @& FilePath) (mode : UInt32) : IO Unit",
"start": [
780,
1
],
"end": [
780,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.setAccessRights",
"code": "def setAccessRights (filename : FilePath) (mode : FileRight) : IO Unit :=\n Prim.setAccessRights filename mode.flags",
"start": [
782,
1
],
"end": [
783,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.Ref",
"code": "abbrev Ref (α : Type) := ST.Ref IO.RealWorld α",
"start": [
785,
1
],
"end": [
786,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.mkRef",
"code": "def mkRef (a : α) : BaseIO (IO.Ref α) :=\n ST.mkRef a",
"start": [
790,
1
],
"end": [
791,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.CancelToken",
"code": "structure CancelToken where\n private ref : IO.Ref Bool",
"start": [
793,
1
],
"end": [
801,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.CancelToken.new",
"code": "def new : BaseIO CancelToken :=\n CancelToken.mk <$> IO.mkRef false",
"start": [
805,
1
],
"end": [
807,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.CancelToken.set",
"code": "def set (tk : CancelToken) : BaseIO Unit :=\n tk.ref.set true",
"start": [
809,
1
],
"end": [
811,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.CancelToken.isSet",
"code": "def isSet (tk : CancelToken) : BaseIO Bool :=\n tk.ref.get",
"start": [
813,
1
],
"end": [
815,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.ofHandle",
"code": "@[export lean_stream_of_handle]\ndef ofHandle (h : Handle) : Stream where\n flush := Handle.flush h\n read := Handle.read h\n write := Handle.write h\n getLine := Handle.getLine h\n putStr := Handle.putStr h\n isTty := Handle.isTty h",
"start": [
822,
1
],
"end": [
829,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.Buffer",
"code": "structure Buffer where\n data : ByteArray := ByteArray.empty\n pos : Nat := 0",
"start": [
831,
1
],
"end": [
833,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.ofBuffer",
"code": "def ofBuffer (r : Ref Buffer) : Stream where\n flush := pure ()\n read := fun n => r.modifyGet fun b =>\n let data := b.data.extract b.pos (b.pos + n.toNat)\n (data, { b with pos := b.pos + data.size })\n write := fun data => r.modify fun b =>\n { b with data := data.copySlice 0 b.data b.pos data.size false, pos := b.pos + data.size }\n getLine := do\n let buf ← r.modifyGet fun b =>\n let pos := match b.data.findIdx? (start := b.pos) fun u => u == 0 || u = '\\n'.toNat.toUInt8 with\n | some pos => if b.data.get! pos == 0 then pos else pos + 1\n | none => b.data.size\n (b.data.extract b.pos pos, { b with pos := pos })\n match String.fromUTF8? buf with\n | some str => pure str\n | none => throw (.userError \"invalid UTF-8\")\n putStr := fun s => r.modify fun b =>\n let data := s.toUTF8\n { b with data := data.copySlice 0 b.data b.pos data.size false, pos := b.pos + data.size }\n isTty := pure false",
"start": [
835,
1
],
"end": [
856,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.withIsolatedStreams",
"code": "def withIsolatedStreams [Monad m] [MonadFinally m] [MonadLiftT BaseIO m] (x : m α)\n (isolateStderr := true) : m (String × α) := do\n let bIn ← mkRef { : Stream.Buffer }\n let bOut ← mkRef { : Stream.Buffer }\n let r ← withStdin (Stream.ofBuffer bIn) <|\n withStdout (Stream.ofBuffer bOut) <|\n (if isolateStderr then withStderr (Stream.ofBuffer bOut) else id) <|\n x\n let bOut ← liftM (m := BaseIO) bOut.get\n let out := String.fromUTF8! bOut.data\n pure (out, r)",
"start": [
860,
1
],
"end": [
871,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Eval",
"code": "class Eval (α : Type u) where\n eval : (Unit → α) → (hideUnit : Bool := true) → IO Unit",
"start": [
880,
1
],
"end": [
885,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instEval",
"code": "instance instEval [ToString α] : Eval α where\n eval a _ := IO.println (toString (a ()))",
"start": [
887,
1
],
"end": [
888,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.runEval",
"code": "def runEval [Eval α] (a : Unit → α) : IO (String × Except IO.Error Unit) :=\n IO.FS.withIsolatedStreams (Eval.eval a false |>.toBaseIO)",
"start": [
906,
1
],
"end": [
907,
60
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Format/Syntax.lean | [
".lake/packages/lean4/src/lean/Init/Data/Format/Instances.lean",
".lake/packages/lean4/src/lean/Init/Data/Format/Macro.lean",
".lake/packages/lean4/src/lean/Init/Meta.lean"
] | [
{
"full_name": "Lean.Syntax.formatInfo",
"code": "private def formatInfo (showInfo : Bool) (info : SourceInfo) (f : Format) : Format :=\n match showInfo, info with\n | true, SourceInfo.original lead pos trail endPos => f!\"{repr lead.toString}:{pos}:{f}:{endPos}:{repr trail.toString}\"\n | true, SourceInfo.synthetic pos endPos true => f!\"{pos}!:{f}:{endPos}\"\n | true, SourceInfo.synthetic pos endPos false => f!\"{pos}:{f}:{endPos}\"\n | _, _ => f",
"start": [
16,
1
],
"end": [
21,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.formatStxAux",
"code": "partial def formatStxAux (maxDepth : Option Nat) (showInfo : Bool) (depth : Nat) : Syntax → Format\n | atom info val => formatInfo showInfo info <| format (repr val)\n | ident info _ val _ => formatInfo showInfo info <| format \"`\" ++ format val\n | missing => \"<missing>\"\n | node info kind args =>\n let depth := depth + 1;\n if kind == nullKind then\n sbracket <|\n if args.size > 0 && depth > maxDepth.getD depth then\n \"..\"\n else\n joinSep (args.toList.map (formatStxAux maxDepth showInfo depth)) line\n else\n let shorterName := kind.replacePrefix `Lean.Parser Name.anonymous\n let header := formatInfo showInfo info <| format shorterName\n let body : List Format :=\n if args.size > 0 && depth > maxDepth.getD depth then\n [\"..\"]\n else\n args.toList.map (formatStxAux maxDepth showInfo depth)\n paren <| joinSep (header :: body) line",
"start": [
23,
1
],
"end": [
43,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.formatStx",
"code": "def formatStx (stx : Syntax) (maxDepth : Option Nat := none) (showInfo := false) : Format :=\n formatStxAux maxDepth showInfo 0 stx",
"start": [
45,
1
],
"end": [
49,
39
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/NameMap.lean | [
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean",
".lake/packages/lean4/src/lean/Lean/Data/Name.lean",
".lake/packages/lean4/src/lean/Lean/Data/HashSet.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBTree.lean",
".lake/packages/lean4/src/lean/Lean/Data/SSet.lean"
] | [
{
"full_name": "Lean.NameMap",
"code": "def NameMap (α : Type) := RBMap Name α Name.quickCmp",
"start": [
14,
1
],
"end": [
14,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNameMap",
"code": "@[inline] def mkNameMap (α : Type) : NameMap α := mkRBMap Name α Name.quickCmp",
"start": [
16,
1
],
"end": [
16,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameMap.insert",
"code": "def insert (m : NameMap α) (n : Name) (a : α) := RBMap.insert m n a",
"start": [
26,
1
],
"end": [
26,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameMap.contains",
"code": "def contains (m : NameMap α) (n : Name) : Bool := RBMap.contains m n",
"start": [
28,
1
],
"end": [
28,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameMap.find?",
"code": "def find? (m : NameMap α) (n : Name) : Option α := RBMap.find? m n",
"start": [
30,
1
],
"end": [
30,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSet",
"code": "def NameSet := RBTree Name Name.quickCmp",
"start": [
37,
1
],
"end": [
37,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSet.empty",
"code": "def empty : NameSet := mkRBTree Name Name.quickCmp",
"start": [
40,
1
],
"end": [
40,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSet.insert",
"code": "def insert (s : NameSet) (n : Name) : NameSet := RBTree.insert s n",
"start": [
43,
1
],
"end": [
43,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSet.contains",
"code": "def contains (s : NameSet) (n : Name) : Bool := RBMap.contains s n",
"start": [
44,
1
],
"end": [
44,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSet.append",
"code": "def append (s t : NameSet) : NameSet :=\n s.mergeBy (fun _ _ _ => .unit) t",
"start": [
48,
1
],
"end": [
50,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSSet",
"code": "def NameSSet := SSet Name",
"start": [
57,
1
],
"end": [
57,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSSet.empty",
"code": "abbrev empty : NameSSet := SSet.empty",
"start": [
60,
1
],
"end": [
60,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSSet.insert",
"code": "abbrev insert (s : NameSSet) (n : Name) : NameSSet := SSet.insert s n",
"start": [
63,
1
],
"end": [
63,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSSet.contains",
"code": "abbrev contains (s : NameSSet) (n : Name) : Bool := SSet.contains s n",
"start": [
64,
1
],
"end": [
64,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameHashSet",
"code": "def NameHashSet := HashSet Name",
"start": [
67,
1
],
"end": [
67,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameHashSet.empty",
"code": "@[inline] def empty : NameHashSet := HashSet.empty",
"start": [
70,
1
],
"end": [
70,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameHashSet.insert",
"code": "def insert (s : NameHashSet) (n : Name) := HashSet.insert s n",
"start": [
73,
1
],
"end": [
73,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameHashSet.contains",
"code": "def contains (s : NameHashSet) (n : Name) : Bool := HashSet.contains s n",
"start": [
74,
1
],
"end": [
74,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MacroScopesView.isPrefixOf",
"code": "def MacroScopesView.isPrefixOf (v₁ v₂ : MacroScopesView) : Bool :=\n v₁.name.isPrefixOf v₂.name &&\n v₁.scopes == v₂.scopes &&\n v₁.mainModule == v₂.mainModule &&\n v₁.imported == v₂.imported",
"start": [
77,
1
],
"end": [
81,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MacroScopesView.isSuffixOf",
"code": "def MacroScopesView.isSuffixOf (v₁ v₂ : MacroScopesView) : Bool :=\n v₁.name.isSuffixOf v₂.name &&\n v₁.scopes == v₂.scopes &&\n v₁.mainModule == v₂.mainModule &&\n v₁.imported == v₂.imported",
"start": [
83,
1
],
"end": [
87,
29
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ImportingFlag.lean | [
".lake/packages/lean4/src/lean/Init/System/IO.lean"
] | [
{
"full_name": "Lean.enableInitializersExecution",
"code": "@[export lean_enable_initializer_execution]\nunsafe def enableInitializersExecution : IO Unit :=\n runInitializersRef.set true",
"start": [
14,
1
],
"end": [
28,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isInitializerExecutionEnabled",
"code": "def isInitializerExecutionEnabled : IO Bool :=\n runInitializersRef.get",
"start": [
30,
1
],
"end": [
31,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.initializing",
"code": "def initializing : IO Bool :=\n IO.initializing <||> importingRef.get",
"start": [
33,
1
],
"end": [
38,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withImporting",
"code": "def withImporting (x : IO α) : IO α :=\n try\n importingRef.set true\n x\n finally\n importingRef.set false\n runInitializersRef.set false",
"start": [
40,
1
],
"end": [
56,
33
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/KVMap.lean | [
".lake/packages/lean4/src/lean/Init/Data/Format/Syntax.lean",
".lake/packages/lean4/src/lean/Init/Data/List/Control.lean"
] | [
{
"full_name": "Lean.DataValue",
"code": "inductive DataValue where\n | ofString (v : String)\n | ofBool (v : Bool)\n | ofName (v : Name)\n | ofNat (v : Nat)\n | ofInt (v : Int)\n | ofSyntax (v : Syntax)\n deriving Inhabited, BEq, Repr",
"start": [
12,
1
],
"end": [
20,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DataValue.beqExp",
"code": "@[export lean_data_value_beq]\ndef DataValue.beqExp (a b : DataValue) : Bool :=\n a == b",
"start": [
22,
1
],
"end": [
24,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkBoolDataValueEx",
"code": "@[export lean_mk_bool_data_value] def mkBoolDataValueEx (b : Bool) : DataValue := DataValue.ofBool b",
"start": [
26,
1
],
"end": [
26,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DataValue.getBoolEx",
"code": "@[export lean_data_value_bool] def DataValue.getBoolEx : DataValue → Bool\n | DataValue.ofBool b => b\n | _ => false",
"start": [
27,
1
],
"end": [
29,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DataValue.sameCtor",
"code": "def DataValue.sameCtor : DataValue → DataValue → Bool\n | .ofString _, .ofString _ => true\n | .ofBool _, .ofBool _ => true\n | .ofName _, .ofName _ => true\n | .ofNat _, .ofNat _ => true\n | .ofInt _, .ofInt _ => true\n | .ofSyntax _, .ofSyntax _ => true\n | _, _ => false",
"start": [
31,
1
],
"end": [
38,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DataValue.str",
"code": "@[export lean_data_value_to_string]\ndef DataValue.str : DataValue → String\n | .ofString v => v\n | .ofBool v => toString v\n | .ofName v => toString v\n | .ofNat v => toString v\n | .ofInt v => toString v\n | .ofSyntax v => toString v",
"start": [
40,
1
],
"end": [
47,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap",
"code": "structure KVMap where\n entries : List (Name × DataValue) := []\n deriving Inhabited, Repr",
"start": [
59,
1
],
"end": [
68,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.empty",
"code": "def empty : KVMap :=\n {}",
"start": [
73,
1
],
"end": [
74,
5
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.isEmpty",
"code": "def isEmpty : KVMap → Bool\n | ⟨m⟩ => m.isEmpty",
"start": [
76,
1
],
"end": [
77,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.size",
"code": "def size (m : KVMap) : Nat :=\n m.entries.length",
"start": [
79,
1
],
"end": [
80,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.findCore",
"code": "def findCore : List (Name × DataValue) → Name → Option DataValue\n | [], _ => none\n | (k,v)::m, k' => if k == k' then some v else findCore m k'",
"start": [
82,
1
],
"end": [
84,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.find",
"code": "def find : KVMap → Name → Option DataValue\n | ⟨m⟩, k => findCore m k",
"start": [
86,
1
],
"end": [
87,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.findD",
"code": "def findD (m : KVMap) (k : Name) (d₀ : DataValue) : DataValue :=\n (m.find k).getD d₀",
"start": [
89,
1
],
"end": [
90,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.insertCore",
"code": "def insertCore : List (Name × DataValue) → Name → DataValue → List (Name × DataValue)\n | [], k', v' => [(k',v')]\n | (k,v)::m, k', v' => if k == k' then (k, v') :: m else (k, v) :: insertCore m k' v'",
"start": [
92,
1
],
"end": [
94,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.insert",
"code": "def insert : KVMap → Name → DataValue → KVMap\n | ⟨m⟩, k, v => ⟨insertCore m k v⟩",
"start": [
96,
1
],
"end": [
97,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.contains",
"code": "def contains (m : KVMap) (n : Name) : Bool :=\n (m.find n).isSome",
"start": [
99,
1
],
"end": [
100,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.erase",
"code": "def erase : KVMap → Name → KVMap\n | ⟨m⟩, k => ⟨m.filter fun a => a.1 ≠ k⟩",
"start": [
102,
1
],
"end": [
104,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.getString",
"code": "def getString (m : KVMap) (k : Name) (defVal := \"\") : String :=\n match m.find k with\n | some (DataValue.ofString v) => v\n | _ => defVal",
"start": [
106,
1
],
"end": [
109,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.getNat",
"code": "def getNat (m : KVMap) (k : Name) (defVal := 0) : Nat :=\n match m.find k with\n | some (DataValue.ofNat v) => v\n | _ => defVal",
"start": [
111,
1
],
"end": [
114,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.getInt",
"code": "def getInt (m : KVMap) (k : Name) (defVal : Int := 0) : Int :=\n match m.find k with\n | some (DataValue.ofInt v) => v\n | _ => defVal",
"start": [
116,
1
],
"end": [
119,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.getBool",
"code": "def getBool (m : KVMap) (k : Name) (defVal := false) : Bool :=\n match m.find k with\n | some (DataValue.ofBool v) => v\n | _ => defVal",
"start": [
121,
1
],
"end": [
124,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.getName",
"code": "def getName (m : KVMap) (k : Name) (defVal := Name.anonymous) : Name :=\n match m.find k with\n | some (DataValue.ofName v) => v\n | _ => defVal",
"start": [
126,
1
],
"end": [
129,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.getSyntax",
"code": "def getSyntax (m : KVMap) (k : Name) (defVal := Syntax.missing) : Syntax :=\n match m.find k with\n | some (DataValue.ofSyntax v) => v\n | _ => defVal",
"start": [
131,
1
],
"end": [
134,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.setString",
"code": "def setString (m : KVMap) (k : Name) (v : String) : KVMap :=\n m.insert k (DataValue.ofString v)",
"start": [
136,
1
],
"end": [
137,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.setNat",
"code": "def setNat (m : KVMap) (k : Name) (v : Nat) : KVMap :=\n m.insert k (DataValue.ofNat v)",
"start": [
139,
1
],
"end": [
140,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.setInt",
"code": "def setInt (m : KVMap) (k : Name) (v : Int) : KVMap :=\n m.insert k (DataValue.ofInt v)",
"start": [
142,
1
],
"end": [
143,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.setBool",
"code": "def setBool (m : KVMap) (k : Name) (v : Bool) : KVMap :=\n m.insert k (DataValue.ofBool v)",
"start": [
145,
1
],
"end": [
146,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.setName",
"code": "def setName (m : KVMap) (k : Name) (v : Name) : KVMap :=\n m.insert k (DataValue.ofName v)",
"start": [
148,
1
],
"end": [
149,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.setSyntax",
"code": "def setSyntax (m : KVMap) (k : Name) (v : Syntax) : KVMap :=\n m.insert k (DataValue.ofSyntax v)",
"start": [
151,
1
],
"end": [
152,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.updateString",
"code": "def updateString (m : KVMap) (k : Name) (f : String → String) : KVMap :=\n m.insert k <| DataValue.ofString <| f <| m.getString k",
"start": [
154,
1
],
"end": [
156,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.updateNat",
"code": "def updateNat (m : KVMap) (k : Name) (f : Nat → Nat) : KVMap :=\n m.insert k <| DataValue.ofNat <| f <| m.getNat k",
"start": [
158,
1
],
"end": [
160,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.updateInt",
"code": "def updateInt (m : KVMap) (k : Name) (f : Int → Int) : KVMap :=\n m.insert k <| DataValue.ofInt <| f <| m.getInt k",
"start": [
162,
1
],
"end": [
164,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.updateBool",
"code": "def updateBool (m : KVMap) (k : Name) (f : Bool → Bool) : KVMap :=\n m.insert k <| DataValue.ofBool <| f <| m.getBool k",
"start": [
166,
1
],
"end": [
168,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.updateName",
"code": "def updateName (m : KVMap) (k : Name) (f : Name → Name) : KVMap :=\n m.insert k <| DataValue.ofName <| f <| m.getName k",
"start": [
170,
1
],
"end": [
172,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.updateSyntax",
"code": "def updateSyntax (m : KVMap) (k : Name) (f : Syntax → Syntax) : KVMap :=\n m.insert k <| DataValue.ofSyntax <| f <| m.getSyntax k",
"start": [
174,
1
],
"end": [
176,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.forIn",
"code": "@[inline] protected def forIn.{w, w'} {δ : Type w} {m : Type w → Type w'} [Monad m]\n (kv : KVMap) (init : δ) (f : Name × DataValue → δ → m (ForInStep δ)) : m δ :=\n kv.entries.forIn init f",
"start": [
178,
1
],
"end": [
180,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.subsetAux",
"code": "def subsetAux : List (Name × DataValue) → KVMap → Bool\n | [], _ => true\n | (k, v₁)::m₁, m₂ =>\n match m₂.find k with\n | some v₂ => v₁ == v₂ && subsetAux m₁ m₂\n | none => false",
"start": [
185,
1
],
"end": [
190,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.subset",
"code": "def subset : KVMap → KVMap → Bool\n | ⟨m₁⟩, m₂ => subsetAux m₁ m₂",
"start": [
192,
1
],
"end": [
193,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.mergeBy",
"code": "def mergeBy (mergeFn : Name → DataValue → DataValue → DataValue) (l r : KVMap)\n : KVMap := Id.run do\n let mut result := l\n for ⟨k, vᵣ⟩ in r do\n if let some vₗ := result.find k then\n result := result.insert k (mergeFn k vₗ vᵣ)\n else\n result := result.insert k vᵣ\n return result",
"start": [
195,
1
],
"end": [
203,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.eqv",
"code": "def eqv (m₁ m₂ : KVMap) : Bool :=\n subset m₁ m₂ && subset m₂ m₁",
"start": [
205,
1
],
"end": [
206,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.Value",
"code": "class Value (α : Type) where\n toDataValue : α → DataValue\n ofDataValue? : DataValue → Option α",
"start": [
211,
1
],
"end": [
213,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.get?",
"code": "@[inline] def get? {α : Type} [Value α] (m : KVMap) (k : Name) : Option α :=\n m.find k |>.bind Value.ofDataValue?",
"start": [
215,
1
],
"end": [
216,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.get",
"code": "@[inline] def get {α : Type} [Value α] (m : KVMap) (k : Name) (defVal : α) : α :=\n m.get? k |>.getD defVal",
"start": [
218,
1
],
"end": [
219,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.set",
"code": "@[inline] def set {α : Type} [Value α] (m : KVMap) (k : Name) (v : α) : KVMap :=\n m.insert k (Value.toDataValue v)",
"start": [
221,
1
],
"end": [
222,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KVMap.update",
"code": "@[inline] def update {α : Type} [Value α] (m : KVMap) (k : Name) (f : Option α → Option α) : KVMap :=\n match f (m.get? k) with\n | some a => m.set k a\n | none => m.erase k",
"start": [
224,
1
],
"end": [
227,
22
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Float.lean | [
".lake/packages/lean4/src/lean/Init/Data/Int/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/ToString/Basic.lean",
".lake/packages/lean4/src/lean/Init/Core.lean"
] | [
{
"full_name": "FloatSpec",
"code": "structure FloatSpec where\n float : Type\n val : float\n lt : float → float → Prop\n le : float → float → Prop\n decLt : DecidableRel lt\n decLe : DecidableRel le",
"start": [
11,
1
],
"end": [
17,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "floatSpec",
"code": "opaque floatSpec : FloatSpec := {\n float := Unit,\n val := (),\n lt := fun _ _ => True,\n le := fun _ _ => True,\n decLt := fun _ _ => inferInstanceAs (Decidable True),\n decLe := fun _ _ => inferInstanceAs (Decidable True)\n}",
"start": [
20,
1
],
"end": [
27,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Float",
"code": "structure Float where\n val : floatSpec.float",
"start": [
29,
1
],
"end": [
32,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.add",
"code": "@[extern \"lean_float_add\"] opaque Float.add : Float → Float → Float",
"start": [
36,
1
],
"end": [
36,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.sub",
"code": "@[extern \"lean_float_sub\"] opaque Float.sub : Float → Float → Float",
"start": [
37,
1
],
"end": [
37,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.mul",
"code": "@[extern \"lean_float_mul\"] opaque Float.mul : Float → Float → Float",
"start": [
38,
1
],
"end": [
38,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.div",
"code": "@[extern \"lean_float_div\"] opaque Float.div : Float → Float → Float",
"start": [
39,
1
],
"end": [
39,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.neg",
"code": "@[extern \"lean_float_negate\"] opaque Float.neg : Float → Float",
"start": [
40,
1
],
"end": [
40,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.lt",
"code": "def Float.lt : Float → Float → Prop := fun a b =>\n match a, b with\n | ⟨a⟩, ⟨b⟩ => floatSpec.lt a b",
"start": [
43,
1
],
"end": [
45,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.le",
"code": "def Float.le : Float → Float → Prop := fun a b =>\n floatSpec.le a.val b.val",
"start": [
47,
1
],
"end": [
48,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.beq",
"code": "@[extern \"lean_float_beq\"] opaque Float.beq (a b : Float) : Bool",
"start": [
58,
1
],
"end": [
59,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.decLt",
"code": "@[extern \"lean_float_decLt\"] opaque Float.decLt (a b : Float) : Decidable (a < b) :=\n match a, b with\n | ⟨a⟩, ⟨b⟩ => floatSpec.decLt a b",
"start": [
63,
1
],
"end": [
65,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.decLe",
"code": "@[extern \"lean_float_decLe\"] opaque Float.decLe (a b : Float) : Decidable (a ≤ b) :=\n match a, b with\n | ⟨a⟩, ⟨b⟩ => floatSpec.decLe a b",
"start": [
67,
1
],
"end": [
69,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "floatDecLt",
"code": "instance floatDecLt (a b : Float) : Decidable (a < b) := Float.decLt a b",
"start": [
71,
1
],
"end": [
71,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "floatDecLe",
"code": "instance floatDecLe (a b : Float) : Decidable (a ≤ b) := Float.decLe a b",
"start": [
72,
1
],
"end": [
72,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.toString",
"code": "@[extern \"lean_float_to_string\"] opaque Float.toString : Float → String",
"start": [
74,
1
],
"end": [
74,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.toUInt8",
"code": "@[extern \"lean_float_to_uint8\"] opaque Float.toUInt8 : Float → UInt8",
"start": [
76,
1
],
"end": [
78,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.toUInt16",
"code": "@[extern \"lean_float_to_uint16\"] opaque Float.toUInt16 : Float → UInt16",
"start": [
79,
1
],
"end": [
81,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.toUInt32",
"code": "@[extern \"lean_float_to_uint32\"] opaque Float.toUInt32 : Float → UInt32",
"start": [
82,
1
],
"end": [
84,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.toUInt64",
"code": "@[extern \"lean_float_to_uint64\"] opaque Float.toUInt64 : Float → UInt64",
"start": [
85,
1
],
"end": [
87,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.toUSize",
"code": "@[extern \"lean_float_to_usize\"] opaque Float.toUSize : Float → USize",
"start": [
88,
1
],
"end": [
90,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.isNaN",
"code": "@[extern \"lean_float_isnan\"] opaque Float.isNaN : Float → Bool",
"start": [
92,
1
],
"end": [
92,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.isFinite",
"code": "@[extern \"lean_float_isfinite\"] opaque Float.isFinite : Float → Bool",
"start": [
93,
1
],
"end": [
93,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.isInf",
"code": "@[extern \"lean_float_isinf\"] opaque Float.isInf : Float → Bool",
"start": [
94,
1
],
"end": [
94,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.frExp",
"code": "@[extern \"lean_float_frexp\"] opaque Float.frExp : Float → Float × Int",
"start": [
95,
1
],
"end": [
99,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "UInt64.toFloat",
"code": "@[extern \"lean_uint64_to_float\"] opaque UInt64.toFloat (n : UInt64) : Float",
"start": [
109,
1
],
"end": [
109,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.sin",
"code": "@[extern \"sin\"] opaque Float.sin : Float → Float",
"start": [
111,
1
],
"end": [
111,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.cos",
"code": "@[extern \"cos\"] opaque Float.cos : Float → Float",
"start": [
112,
1
],
"end": [
112,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.tan",
"code": "@[extern \"tan\"] opaque Float.tan : Float → Float",
"start": [
113,
1
],
"end": [
113,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.asin",
"code": "@[extern \"asin\"] opaque Float.asin : Float → Float",
"start": [
114,
1
],
"end": [
114,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.acos",
"code": "@[extern \"acos\"] opaque Float.acos : Float → Float",
"start": [
115,
1
],
"end": [
115,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.atan",
"code": "@[extern \"atan\"] opaque Float.atan : Float → Float",
"start": [
116,
1
],
"end": [
116,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.atan2",
"code": "@[extern \"atan2\"] opaque Float.atan2 : Float → Float → Float",
"start": [
117,
1
],
"end": [
117,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.sinh",
"code": "@[extern \"sinh\"] opaque Float.sinh : Float → Float",
"start": [
118,
1
],
"end": [
118,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.cosh",
"code": "@[extern \"cosh\"] opaque Float.cosh : Float → Float",
"start": [
119,
1
],
"end": [
119,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.tanh",
"code": "@[extern \"tanh\"] opaque Float.tanh : Float → Float",
"start": [
120,
1
],
"end": [
120,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.asinh",
"code": "@[extern \"asinh\"] opaque Float.asinh : Float → Float",
"start": [
121,
1
],
"end": [
121,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.acosh",
"code": "@[extern \"acosh\"] opaque Float.acosh : Float → Float",
"start": [
122,
1
],
"end": [
122,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.atanh",
"code": "@[extern \"atanh\"] opaque Float.atanh : Float → Float",
"start": [
123,
1
],
"end": [
123,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.exp",
"code": "@[extern \"exp\"] opaque Float.exp : Float → Float",
"start": [
124,
1
],
"end": [
124,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.exp2",
"code": "@[extern \"exp2\"] opaque Float.exp2 : Float → Float",
"start": [
125,
1
],
"end": [
125,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.log",
"code": "@[extern \"log\"] opaque Float.log : Float → Float",
"start": [
126,
1
],
"end": [
126,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.log2",
"code": "@[extern \"log2\"] opaque Float.log2 : Float → Float",
"start": [
127,
1
],
"end": [
127,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.log10",
"code": "@[extern \"log10\"] opaque Float.log10 : Float → Float",
"start": [
128,
1
],
"end": [
128,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.pow",
"code": "@[extern \"pow\"] opaque Float.pow : Float → Float → Float",
"start": [
129,
1
],
"end": [
129,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.sqrt",
"code": "@[extern \"sqrt\"] opaque Float.sqrt : Float → Float",
"start": [
130,
1
],
"end": [
130,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.cbrt",
"code": "@[extern \"cbrt\"] opaque Float.cbrt : Float → Float",
"start": [
131,
1
],
"end": [
131,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.ceil",
"code": "@[extern \"ceil\"] opaque Float.ceil : Float → Float",
"start": [
132,
1
],
"end": [
132,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.floor",
"code": "@[extern \"floor\"] opaque Float.floor : Float → Float",
"start": [
133,
1
],
"end": [
133,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.round",
"code": "@[extern \"round\"] opaque Float.round : Float → Float",
"start": [
134,
1
],
"end": [
134,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.abs",
"code": "@[extern \"fabs\"] opaque Float.abs : Float → Float",
"start": [
135,
1
],
"end": [
135,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.scaleB",
"code": "@[extern \"lean_float_scaleb\"]\nopaque Float.scaleB (x : Float) (i : @& Int) : Float",
"start": [
143,
1
],
"end": [
147,
53
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Options.lean | [
".lake/packages/lean4/src/lean/Lean/Data/KVMap.lean",
".lake/packages/lean4/src/lean/Lean/ImportingFlag.lean",
".lake/packages/lean4/src/lean/Lean/Data/NameMap.lean"
] | [
{
"full_name": "Lean.Options",
"code": "def Options := KVMap",
"start": [
13,
1
],
"end": [
13,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Options.empty",
"code": "def Options.empty : Options := {}",
"start": [
15,
1
],
"end": [
15,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.OptionDecl",
"code": "structure OptionDecl where\n declName : Name := by exact decl_name%\n defValue : DataValue\n group : String := \"\"\n descr : String := \"\"\n deriving Inhabited",
"start": [
22,
1
],
"end": [
27,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.OptionDecls",
"code": "def OptionDecls := NameMap OptionDecl",
"start": [
29,
1
],
"end": [
29,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerOption",
"code": "@[export lean_register_option]\ndef registerOption (name : Name) (decl : OptionDecl) : IO Unit := do\n unless (← initializing) do\n throw (IO.userError \"failed to register option, options can only be registered during initialization\")\n let decls ← optionDeclsRef.get\n if decls.contains name then\n throw $ IO.userError s!\"invalid option declaration '{name}', option already exists\"\n optionDeclsRef.set $ decls.insert name decl",
"start": [
35,
1
],
"end": [
42,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getOptionDecls",
"code": "def getOptionDecls : IO OptionDecls := optionDeclsRef.get",
"start": [
44,
1
],
"end": [
44,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getOptionDeclsArray",
"code": "@[export lean_get_option_decls_array]\ndef getOptionDeclsArray : IO (Array (Name × OptionDecl)) := do\n let decls ← getOptionDecls\n pure $ decls.fold\n (fun (r : Array (Name × OptionDecl)) k v => r.push (k, v))\n #[]",
"start": [
46,
1
],
"end": [
51,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getOptionDecl",
"code": "def getOptionDecl (name : Name) : IO OptionDecl := do\n let decls ← getOptionDecls\n let (some decl) ← pure (decls.find? name) | throw $ IO.userError s!\"unknown option '{name}'\"\n pure decl",
"start": [
53,
1
],
"end": [
56,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getOptionDefaultValue",
"code": "def getOptionDefaultValue (name : Name) : IO DataValue := do\n let decl ← getOptionDecl name\n pure decl.defValue",
"start": [
58,
1
],
"end": [
60,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getOptionDescr",
"code": "def getOptionDescr (name : Name) : IO String := do\n let decl ← getOptionDecl name\n pure decl.descr",
"start": [
62,
1
],
"end": [
64,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadOptions",
"code": "class MonadOptions (m : Type → Type) where\n getOptions : m Options",
"start": [
66,
1
],
"end": [
67,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBoolOption",
"code": "def getBoolOption (k : Name) (defValue := false) : m Bool := do\n let opts ← getOptions\n return opts.getBool k defValue",
"start": [
76,
1
],
"end": [
78,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getNatOption",
"code": "def getNatOption (k : Name) (defValue := 0) : m Nat := do\n let opts ← getOptions\n return opts.getNat k defValue",
"start": [
80,
1
],
"end": [
82,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadWithOptions",
"code": "class MonadWithOptions (m : Type → Type) where\n withOptions (f : Options → Options) (x : m α) : m α",
"start": [
84,
1
],
"end": [
85,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withInPattern",
"code": "def withInPattern [MonadWithOptions m] (x : m α) : m α :=\n withOptions (fun o => o.setBool `_inPattern true) x",
"start": [
95,
1
],
"end": [
96,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Options.getInPattern",
"code": "def Options.getInPattern (o : Options) : Bool :=\n o.getBool `_inPattern",
"start": [
98,
1
],
"end": [
99,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option",
"code": "protected structure Option (α : Type) where\n name : Name\n defValue : α\n deriving Inhabited",
"start": [
101,
1
],
"end": [
105,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option.Decl",
"code": "protected structure Decl (α : Type) where\n defValue : α\n group : String := \"\"\n descr : String := \"\"",
"start": [
109,
1
],
"end": [
112,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option.get?",
"code": "protected def get? [KVMap.Value α] (opts : Options) (opt : Lean.Option α) : Option α :=\n opts.get? opt.name",
"start": [
114,
1
],
"end": [
115,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option.get",
"code": "protected def get [KVMap.Value α] (opts : Options) (opt : Lean.Option α) : α :=\n opts.get opt.name opt.defValue",
"start": [
117,
1
],
"end": [
118,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option.set",
"code": "protected def set [KVMap.Value α] (opts : Options) (opt : Lean.Option α) (val : α) : Options :=\n opts.set opt.name val",
"start": [
120,
1
],
"end": [
121,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option.setIfNotSet",
"code": "protected def setIfNotSet [KVMap.Value α] (opts : Options) (opt : Lean.Option α) (val : α) : Options :=\n if opts.contains opt.name then opts else opt.set opts val",
"start": [
123,
1
],
"end": [
125,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Option.register",
"code": "protected def register [KVMap.Value α] (name : Name) (decl : Lean.Option.Decl α) (ref : Name := by exact decl_name%) : IO (Lean.Option α) := do\n registerOption name {\n declName := ref\n defValue := KVMap.Value.toDataValue decl.defValue\n group := decl.group\n descr := decl.descr\n }\n return { name := name, defValue := decl.defValue }",
"start": [
127,
1
],
"end": [
134,
53
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Range.lean | [
".lake/packages/lean4/src/lean/Init/Meta.lean"
] | [
{
"full_name": "Std.Range",
"code": "structure Range where\n start : Nat := 0\n stop : Nat\n step : Nat := 1",
"start": [
12,
1
],
"end": [
15,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.Range.forIn",
"code": "@[inline] protected def forIn {β : Type u} {m : Type u → Type v} [Monad m] (range : Range) (init : β) (f : Nat → β → m (ForInStep β)) : m β :=\n let rec @[specialize] loop (fuel i stop step : Nat) (b : β) : m β := do\n if i ≥ stop then\n return b\n else match fuel with\n | 0 => pure b\n | fuel+1 => match (← f i b) with\n | ForInStep.done b => pure b\n | ForInStep.yield b => loop fuel (i + step) stop step b\n loop range.stop range.start range.stop range.step init",
"start": [
23,
1
],
"end": [
33,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.Range.forIn'",
"code": "@[inline] protected def forIn' {β : Type u} {m : Type u → Type v} [Monad m] (range : Range) (init : β) (f : (i : Nat) → i ∈ range → β → m (ForInStep β)) : m β :=\n let rec @[specialize] loop (start stop step : Nat) (f : (i : Nat) → start ≤ i ∧ i < stop → β → m (ForInStep β)) (fuel i : Nat) (hl : start ≤ i) (b : β) : m β := do\n if hu : i < stop then\n match fuel with\n | 0 => pure b\n | fuel+1 => match (← f i ⟨hl, hu⟩ b) with\n | ForInStep.done b => pure b\n | ForInStep.yield b => loop start stop step f fuel (i + step) (Nat.le_trans hl (Nat.le_add_right ..)) b\n else\n return b\n loop range.start range.stop range.step f range.stop range.start (Nat.le_refl ..) init",
"start": [
38,
1
],
"end": [
48,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.Range.forM",
"code": "@[inline] protected def forM {m : Type u → Type v} [Monad m] (range : Range) (f : Nat → m PUnit) : m PUnit :=\n let rec @[specialize] loop (fuel i stop step : Nat) : m PUnit := do\n if i ≥ stop then\n pure ⟨⟩\n else match fuel with\n | 0 => pure ⟨⟩\n | fuel+1 => f i; loop fuel (i + step) stop step\n loop range.stop range.start range.stop range.step",
"start": [
53,
1
],
"end": [
60,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Membership.mem.upper",
"code": "theorem Membership.mem.upper {i : Nat} {r : Std.Range} (h : i ∈ r) : i < r.stop",
"start": [
79,
1
],
"end": [
79,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Membership.mem.lower",
"code": "theorem Membership.mem.lower {i : Nat} {r : Std.Range} (h : i ∈ r) : r.start ≤ i",
"start": [
81,
1
],
"end": [
81,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Membership.get_elem_helper",
"code": "theorem Membership.get_elem_helper {i n : Nat} {r : Std.Range} (h₁ : i ∈ r) (h₂ : r.stop = n) :\n i < n",
"start": [
83,
1
],
"end": [
84,
23
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Hashable.lean | [
".lake/packages/lean4/src/lean/Init/Data/String.lean",
".lake/packages/lean4/src/lean/Init/Data/UInt/Basic.lean"
] | [
{
"full_name": "hash64",
"code": "@[always_inline, inline] def hash64 (u : UInt64) : UInt64 :=\n mixHash u 11",
"start": [
62,
1
],
"end": [
64,
15
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/OfScientific.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Log2.lean",
".lake/packages/lean4/src/lean/Init/Data/Float.lean",
".lake/packages/lean4/src/lean/Init/Meta.lean"
] | [
{
"full_name": "OfScientific",
"code": "class OfScientific (α : Type u) where\n ofScientific (mantissa : Nat) (exponentSign : Bool) (decimalExponent : Nat) : α",
"start": [
11,
1
],
"end": [
17,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.ofBinaryScientific",
"code": "def Float.ofBinaryScientific (m : Nat) (e : Int) : Float :=\n let s := m.log2 - 63\n let m := (m >>> s).toUInt64\n let e := e + s\n m.toFloat.scaleB e",
"start": [
19,
1
],
"end": [
24,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.ofScientific",
"code": "protected opaque Float.ofScientific (m : Nat) (s : Bool) (e : Nat) : Float :=\n if s then\n let s := 64 - m.log2 let m := (m <<< (3 * e + s)) / 5^e\n Float.ofBinaryScientific m (-4 * e - s)\n else\n Float.ofBinaryScientific (m * 5^e) e",
"start": [
26,
1
],
"end": [
32,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.ofNat",
"code": "@[export lean_float_of_nat]\ndef Float.ofNat (n : Nat) : Float :=\n OfScientific.ofScientific n false 0",
"start": [
45,
1
],
"end": [
47,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Float.ofInt",
"code": "def Float.ofInt : Int → Float\n | Int.ofNat n => Float.ofNat n\n | Int.negSucc n => Float.neg (Float.ofNat (Nat.succ n))",
"start": [
49,
1
],
"end": [
51,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.toFloat",
"code": "abbrev Nat.toFloat (n : Nat) : Float :=\n Float.ofNat n",
"start": [
55,
1
],
"end": [
56,
16
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Format.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Options.lean"
] | [
{
"full_name": "Std.Format.getWidth",
"code": "def getWidth (o : Options) : Nat := o.get `format.width defWidth",
"start": [
14,
1
],
"end": [
14,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.Format.getIndent",
"code": "def getIndent (o : Options) : Nat := o.get `format.indent defIndent",
"start": [
15,
1
],
"end": [
15,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.Format.getUnicode",
"code": "def getUnicode (o : Options) : Bool := o.get `format.unicode defUnicode",
"start": [
16,
1
],
"end": [
16,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.Format.pretty'",
"code": "def pretty' (f : Format) (o : Options := {}) : String :=\n pretty f (format.width.get o)",
"start": [
33,
1
],
"end": [
34,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.formatKVMap",
"code": "def formatKVMap (m : KVMap) : Format :=\n sbracket (Format.joinSep m.entries \", \")",
"start": [
67,
1
],
"end": [
68,
43
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json/Basic.lean | [
".lake/packages/lean4/src/lean/Init/Data/ToString/Macro.lean",
".lake/packages/lean4/src/lean/Init/Data/OfScientific.lean",
".lake/packages/lean4/src/lean/Init/Data/Hashable.lean",
".lake/packages/lean4/src/lean/Init/Data/List/Control.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean",
".lake/packages/lean4/src/lean/Init/Data/Range.lean"
] | [
{
"full_name": "Lean.JsonNumber",
"code": "structure JsonNumber where\n mantissa : Int\n exponent : Nat\n deriving DecidableEq, Hashable",
"start": [
18,
1
],
"end": [
21,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.fromNat",
"code": "protected def fromNat (n : Nat) : JsonNumber := ⟨n, 0⟩",
"start": [
25,
1
],
"end": [
25,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.fromInt",
"code": "protected def fromInt (n : Int) : JsonNumber := ⟨n, 0⟩",
"start": [
26,
1
],
"end": [
26,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.countDigits",
"code": "private partial def countDigits (n : Nat) : Nat :=\n let rec loop (n digits : Nat) : Nat :=\n if n ≤ 9 then\n digits\n else\n loop (n/10) (digits+1)\n loop n 1",
"start": [
32,
1
],
"end": [
38,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.normalize",
"code": "protected def normalize : JsonNumber → Int × Nat × Int\n | ⟨m, e⟩ => Id.run do\n if m = 0 then (0, 0, 0)\n else\n let sign : Int := if m > 0 then 1 else -1\n let mut mAbs := m.natAbs\n let nDigits := countDigits mAbs\n for _ in [0:nDigits] do\n if mAbs % 10 = 0 then\n mAbs := mAbs / 10\n else\n break\n (sign, mAbs, -(e : Int) + nDigits)",
"start": [
41,
1
],
"end": [
54,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.lt",
"code": "def lt (a b : JsonNumber) : Bool :=\n let (as, am, ae) := a.normalize\n let (bs, bm, be) := b.normalize\n match (as, bs) with\n | (-1, 1) => true\n | (1, -1) => false\n | _ =>\n let ((am, ae), (bm, be)) :=\n if as = -1 && bs = -1 then\n ((bm, be), (am, ae))\n else\n ((am, ae), (bm, be))\n let amDigits := countDigits am\n let bmDigits := countDigits bm\n let (am, bm) :=\n if amDigits < bmDigits then\n (am * 10^(bmDigits - amDigits), bm)\n else\n (am, bm * 10^(amDigits - bmDigits))\n if ae < be then true\n else if ae > be then false\n else am < bm",
"start": [
57,
1
],
"end": [
79,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.ltProp",
"code": "def ltProp : LT JsonNumber :=\n ⟨fun a b => lt a b = true⟩",
"start": [
81,
1
],
"end": [
82,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.toString",
"code": "protected def toString : JsonNumber → String\n | ⟨m, 0⟩ => m.repr\n | ⟨m, e⟩ =>\n let sign := if m ≥ 0 then \"\" else \"-\"\n let m := m.natAbs\n let exp : Int := 9 + countDigits m - (e : Int)\n let exp := if exp < 0 then exp else 0\n let e' := 10 ^ (e - exp.natAbs)\n let left := (m / e').repr\n if m % e' = 0 && exp = 0 then\n s!\"{sign}{left}\"\n else\n let right := e' + m % e'\n |>.repr.toSubstring.drop 1\n |>.dropRightWhile (fun c => c = '0')\n |>.toString\n let exp := if exp = 0 then \"\" else \"e\" ++ exp.repr\n s!\"{sign}{left}.{right}{exp}\"",
"start": [
96,
1
],
"end": [
118,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.shiftl",
"code": "protected def shiftl : JsonNumber → Nat → JsonNumber\n | ⟨m, e⟩, s => ⟨m * (10 ^ (s - e) : Nat), e - s⟩",
"start": [
121,
1
],
"end": [
125,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.shiftr",
"code": "protected def shiftr : JsonNumber → Nat → JsonNumber\n | ⟨m, e⟩, s => ⟨m, e + s⟩",
"start": [
128,
1
],
"end": [
129,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.toFloat",
"code": "def toFloat : JsonNumber → Float\n | ⟨m, e⟩ => (if m >= 0 then 1.0 else -1.0) * OfScientific.ofScientific m.natAbs true e",
"start": [
148,
1
],
"end": [
149,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.fromPositiveFloat!",
"code": "private def fromPositiveFloat! (x : Float) : JsonNumber :=\n match Lean.Syntax.decodeScientificLitVal? (toString x) with\n | none => panic! s!\"Failed to parse {toString x}\"\n | some (m, sign, e) => OfScientific.ofScientific m sign e",
"start": [
151,
1
],
"end": [
157,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.JsonNumber.fromFloat?",
"code": "def fromFloat? (x : Float): Sum String JsonNumber :=\n if x.isNaN then Sum.inl \"NaN\"\n else if x.isInf then\n Sum.inl <| if x > 0 then \"Infinity\" else \"-Infinity\"\n else if x == 0.0 then\n Sum.inr 0 else if x < 0.0 then\n Sum.inr <| Neg.neg <| fromPositiveFloat! <| Neg.neg <| x\n else\n Sum.inr <| fromPositiveFloat! <| x",
"start": [
159,
1
],
"end": [
170,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.strLt",
"code": "def strLt (a b : String) := Decidable.decide (a < b)",
"start": [
174,
1
],
"end": [
174,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json",
"code": "inductive Json where\n | null\n | bool (b : Bool)\n | num (n : JsonNumber)\n | str (s : String)\n | arr (elems : Array Json)\n | obj (kvPairs : RBNode String (fun _ => Json))\n deriving Inhabited",
"start": [
176,
1
],
"end": [
186,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.beq'",
"code": "private partial def beq' : Json → Json → Bool\n | null, null => true\n | bool a, bool b => a == b\n | num a, num b => a == b\n | str a, str b => a == b\n | arr a, arr b =>\n let _ : BEq Json := ⟨beq'⟩\n a == b\n | obj a, obj b =>\n let _ : BEq Json := ⟨beq'⟩\n let szA := a.fold (init := 0) (fun a _ _ => a + 1)\n let szB := b.fold (init := 0) (fun a _ _ => a + 1)\n szA == szB && a.all fun field fa =>\n match b.find compare field with\n | none => false\n | some fb => fa == fb\n | _, _ => false",
"start": [
190,
1
],
"end": [
206,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.hash'",
"code": "private partial def hash' : Json → UInt64\n | null => 11\n | bool b => mixHash 13 <| hash b\n | num n => mixHash 17 <| hash n\n | str s => mixHash 19 <| hash s\n | arr elems =>\n mixHash 23 <| elems.foldl (init := 7) fun r a => mixHash r (hash' a)\n | obj kvPairs =>\n mixHash 29 <| kvPairs.fold (init := 7) fun r k v => mixHash r <| mixHash (hash k) (hash' v)",
"start": [
211,
1
],
"end": [
219,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.mkObj",
"code": "def mkObj (o : List (String × Json)) : Json :=\n obj <| Id.run do\n let mut kvPairs := RBNode.leaf\n for ⟨k, v⟩ in o do\n kvPairs := kvPairs.insert compare k v\n kvPairs",
"start": [
225,
1
],
"end": [
230,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.isNull",
"code": "def isNull : Json -> Bool\n | null => true\n | _ => false",
"start": [
238,
1
],
"end": [
240,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getObj?",
"code": "def getObj? : Json → Except String (RBNode String (fun _ => Json))\n | obj kvs => return kvs\n | _ => throw \"object expected\"",
"start": [
242,
1
],
"end": [
244,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getArr?",
"code": "def getArr? : Json → Except String (Array Json)\n | arr a => return a\n | _ => throw \"array expected\"",
"start": [
246,
1
],
"end": [
248,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getStr?",
"code": "def getStr? : Json → Except String String\n | str s => return s\n | _ => throw \"String expected\"",
"start": [
250,
1
],
"end": [
252,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getNat?",
"code": "def getNat? : Json → Except String Nat\n | (n : Nat) => return n\n | _ => throw \"Natural number expected\"",
"start": [
254,
1
],
"end": [
256,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getInt?",
"code": "def getInt? : Json → Except String Int\n | (i : Int) => return i\n | _ => throw \"Integer expected\"",
"start": [
258,
1
],
"end": [
260,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getBool?",
"code": "def getBool? : Json → Except String Bool\n | (b : Bool) => return b\n | _ => throw \"Bool expected\"",
"start": [
262,
1
],
"end": [
264,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getNum?",
"code": "def getNum? : Json → Except String JsonNumber\n | num n => return n\n | _ => throw \"number expected\"",
"start": [
266,
1
],
"end": [
268,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getObjVal?",
"code": "def getObjVal? : Json → String → Except String Json\n | obj kvs, k =>\n match kvs.find compare k with\n | some v => return v\n | none => throw s!\"property not found: {k}\"\n | _ , _ => throw \"object expected\"",
"start": [
270,
1
],
"end": [
275,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getArrVal?",
"code": "def getArrVal? : Json → Nat → Except String Json\n | arr a, i =>\n match a.get? i with\n | some v => return v\n | none => throw s!\"index out of bounds: {i}\"\n | _ , _ => throw \"array expected\"",
"start": [
277,
1
],
"end": [
282,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getObjValD",
"code": "def getObjValD (j : Json) (k : String) : Json :=\n (j.getObjVal? k).toOption.getD null",
"start": [
284,
1
],
"end": [
285,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.setObjVal!",
"code": "def setObjVal! : Json → String → Json → Json\n | obj kvs, k, v => obj <| kvs.insert compare k v\n | _ , _, _ => panic! \"Json.setObjVal!: not an object: {j}\"",
"start": [
287,
1
],
"end": [
289,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.mergeObj",
"code": "def mergeObj : Json → Json → Json\n | obj kvs₁, obj kvs₂ =>\n obj <| fold (insert compare) kvs₁ kvs₂\n | _, j₂ => j₂",
"start": [
292,
1
],
"end": [
298,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Structured",
"code": "inductive Structured where\n | arr (elems : Array Json)\n | obj (kvPairs : RBNode String (fun _ => Json))",
"start": [
300,
1
],
"end": [
302,
50
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Hygiene.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Name.lean",
".lake/packages/lean4/src/lean/Lean/Data/Options.lean",
".lake/packages/lean4/src/lean/Lean/Data/Format.lean"
] | [
{
"full_name": "Lean.Unhygienic.Context",
"code": "structure Unhygienic.Context where\n ref : Syntax\n scope : MacroScope",
"start": [
14,
1
],
"end": [
16,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Unhygienic",
"code": "abbrev Unhygienic := ReaderT Lean.Unhygienic.Context <| StateM MacroScope",
"start": [
18,
1
],
"end": [
32,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Unhygienic.run",
"code": "@[inline]\nprotected def run {α : Type} (x : Unhygienic α) : α := (x ⟨Syntax.missing, firstFrontendMacroScope⟩).run' (firstFrontendMacroScope+1)",
"start": [
43,
1
],
"end": [
44,
134
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkInaccessibleUserNameAux",
"code": "private def mkInaccessibleUserNameAux (unicode : Bool) (name : Name) (idx : Nat) : Name :=\n if unicode then\n if idx == 0 then\n name.appendAfter \"✝\"\n else\n name.appendAfter (\"✝\" ++ idx.toSuperscriptString)\n else\n name ++ Name.num `_inaccessible idx",
"start": [
47,
1
],
"end": [
54,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkInaccessibleUserName",
"code": "private def mkInaccessibleUserName (unicode : Bool) : Name → Name\n | .num p@(.str ..) idx =>\n mkInaccessibleUserNameAux unicode p idx\n | .num .anonymous idx =>\n mkInaccessibleUserNameAux unicode Name.anonymous idx\n | .num p idx =>\n if unicode then\n (mkInaccessibleUserName unicode p).appendAfter (\"⁻\" ++ idx.toSuperscriptString)\n else\n Name.mkNum (mkInaccessibleUserName unicode p) idx\n | n => n",
"start": [
56,
1
],
"end": [
66,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getSanitizeNames",
"code": "def getSanitizeNames (o : Options) : Bool := pp.sanitizeNames.get o",
"start": [
74,
1
],
"end": [
74,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameSanitizerState",
"code": "structure NameSanitizerState where\n options : Options\n \n nameStem2Idx : NameMap Nat := {}\n \n userName2Sanitized : NameMap Name := {}",
"start": [
76,
1
],
"end": [
81,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkFreshInaccessibleUserName",
"code": "private partial def mkFreshInaccessibleUserName (userName : Name) (idx : Nat) : StateM NameSanitizerState Name := do\n let s ← get\n let userNameNew := mkInaccessibleUserName (Std.Format.getUnicode s.options) (Name.mkNum userName idx)\n if s.nameStem2Idx.contains userNameNew then\n mkFreshInaccessibleUserName userName (idx+1)\n else do\n modify fun s => { s with nameStem2Idx := s.nameStem2Idx.insert userName (idx+1) }\n pure userNameNew",
"start": [
83,
1
],
"end": [
90,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.sanitizeName",
"code": "def sanitizeName (userName : Name) : StateM NameSanitizerState Name := do\n let stem := userName.eraseMacroScopes;\n let idx := (← get).nameStem2Idx.find? stem |>.getD 0\n let san ← mkFreshInaccessibleUserName stem idx\n modify fun s => { s with userName2Sanitized := s.userName2Sanitized.insert userName san }\n pure san",
"start": [
92,
1
],
"end": [
98,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.sanitizeSyntaxAux",
"code": "private partial def sanitizeSyntaxAux : Syntax → StateM NameSanitizerState Syntax\n | stx@(Syntax.ident _ _ n _) => do\n let n ← match (← get).userName2Sanitized.find? n with\n | some n' => pure n'\n | none => if n.hasMacroScopes then sanitizeName n else pure n\n return mkIdentFrom stx n\n | Syntax.node info k args => Syntax.node info k <$> args.mapM sanitizeSyntaxAux\n | stx => pure stx",
"start": [
100,
1
],
"end": [
107,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.sanitizeSyntax",
"code": "def sanitizeSyntax (stx : Syntax) : StateM NameSanitizerState Syntax := do\n if getSanitizeNames (← get).options then\n sanitizeSyntaxAux stx\n else\n pure stx",
"start": [
109,
1
],
"end": [
113,
13
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array/QSort.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean"
] | [
{
"full_name": "Array.qpartition",
"code": "def qpartition (as : Array α) (lt : α → α → Bool) (lo hi : Nat) : Nat × Array α :=\n if h : as.size = 0 then (0, as) else have : Inhabited α := ⟨as[0]'(by revert h; cases as.size <;> simp)⟩ let mid := (lo + hi) / 2\n let as := if lt (as.get! mid) (as.get! lo) then as.swap! lo mid else as\n let as := if lt (as.get! hi) (as.get! lo) then as.swap! lo hi else as\n let as := if lt (as.get! mid) (as.get! hi) then as.swap! mid hi else as\n let pivot := as.get! hi\n let rec loop (as : Array α) (i j : Nat) :=\n if h : j < hi then\n if lt (as.get! j) pivot then\n let as := as.swap! i j\n loop as (i+1) (j+1)\n else\n loop as i (j+1)\n else\n let as := as.swap! i hi\n (i, as)\n termination_by hi - j\n decreasing_by all_goals simp_wf; decreasing_trivial_pre_omega\n loop as lo lo",
"start": [
12,
1
],
"end": [
31,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.qsort",
"code": "@[inline] partial def qsort (as : Array α) (lt : α → α → Bool) (low := 0) (high := as.size - 1) : Array α :=\n let rec @[specialize] sort (as : Array α) (low high : Nat) :=\n if low < high then\n let p := qpartition as lt low high;\n let mid := p.1\n let as := p.2\n if mid >= high then as\n else\n let as := sort as low mid\n sort as (mid+1) high\n else as\n sort as low high",
"start": [
33,
1
],
"end": [
45,
19
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/PersistentHashSet.lean | [
".lake/packages/lean4/src/lean/Lean/Data/PersistentHashMap.lean"
] | [
{
"full_name": "Lean.PersistentHashSet",
"code": "structure PersistentHashSet (α : Type u) [BEq α] [Hashable α] where\n (set : PersistentHashMap α Unit)",
"start": [
12,
1
],
"end": [
13,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PHashSet",
"code": "abbrev PHashSet (α : Type u) [BEq α] [Hashable α] := PersistentHashSet α",
"start": [
15,
1
],
"end": [
15,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.empty",
"code": "@[inline] def empty [BEq α] [Hashable α] : PersistentHashSet α :=\n { set := PersistentHashMap.empty }",
"start": [
19,
1
],
"end": [
20,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.isEmpty",
"code": "@[inline] def isEmpty (s : PersistentHashSet α) : Bool :=\n s.set.isEmpty",
"start": [
30,
1
],
"end": [
31,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.insert",
"code": "@[inline] def insert (s : PersistentHashSet α) (a : α) : PersistentHashSet α :=\n { set := s.set.insert a () }",
"start": [
33,
1
],
"end": [
34,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.erase",
"code": "@[inline] def erase (s : PersistentHashSet α) (a : α) : PersistentHashSet α :=\n { set := s.set.erase a }",
"start": [
36,
1
],
"end": [
37,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.find?",
"code": "@[inline] def find? (s : PersistentHashSet α) (a : α) : Option α :=\n match s.set.findEntry? a with\n | some (a, _) => some a\n | none => none",
"start": [
39,
1
],
"end": [
42,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.contains",
"code": "@[inline] def contains (s : PersistentHashSet α) (a : α) : Bool :=\n s.set.contains a",
"start": [
44,
1
],
"end": [
45,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.foldM",
"code": "@[inline] def foldM {β : Type v} {m : Type v → Type v} [Monad m] (f : β → α → m β) (init : β) (s : PersistentHashSet α) : m β :=\n s.set.foldlM (init := init) fun d a _ => f d a",
"start": [
47,
1
],
"end": [
48,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentHashSet.fold",
"code": "@[inline] def fold {β : Type v} (f : β → α → β) (init : β) (s : PersistentHashSet α) : β :=\n Id.run $ s.foldM f init",
"start": [
50,
1
],
"end": [
51,
26
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json/Printer.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Format.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Basic.lean"
] | [
{
"full_name": "Lean.Json.escapeAux",
"code": "private def escapeAux (acc : String) (c : Char) : String :=\n if c = '\"' then acc ++ \"\\\\\\\"\"\n else if c = '\\\\' then\n acc ++ \"\\\\\\\\\"\n else if c = '\\n' then\n acc ++ \"\\\\n\"\n else if c = '\\x0d' then\n acc ++ \"\\\\r\"\n else if 0x0020 ≤ c.val ∧ c.val ≤ 0x10ffff then\n acc ++ String.singleton c\n else\n let n := c.toNat;\n acc ++ \"\\\\u\" ++\n [ Nat.digitChar (n / 4096),\n Nat.digitChar ((n % 4096) / 256),\n Nat.digitChar ((n % 256) / 16),\n Nat.digitChar (n % 16) ].asString",
"start": [
13,
1
],
"end": [
39,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.escape",
"code": "def escape (s : String) : String :=\n s.foldl escapeAux \"\"",
"start": [
41,
1
],
"end": [
42,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.renderString",
"code": "def renderString (s : String) : String :=\n \"\\\"\" ++ escape s ++ \"\\\"\"",
"start": [
44,
1
],
"end": [
45,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.render",
"code": "partial def render : Json → Format\n | null => \"null\"\n | bool true => \"true\"\n | bool false => \"false\"\n | num s => s.toString\n | str s => renderString s\n | arr elems =>\n let elems := Format.joinSep (elems.map render).toList (\",\" ++ Format.line);\n Format.bracket \"[\" elems \"]\"\n | obj kvs =>\n let renderKV : String → Json → Format := fun k v =>\n Format.group (renderString k ++ \":\" ++ Format.line ++ render v);\n let kvs := Format.joinSep (kvs.fold (fun acc k j => renderKV k j :: acc) []) (\",\" ++ Format.line);\n Format.bracket \"{\" kvs \"}\"",
"start": [
49,
1
],
"end": [
62,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.pretty",
"code": "def pretty (j : Json) (lineWidth := 80) : String :=\n Format.pretty (render j) lineWidth",
"start": [
65,
1
],
"end": [
66,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.CompressWorkItem",
"code": "protected inductive CompressWorkItem\n | json (j : Json)\n | arrayElem (j : Json)\n | arrayEnd\n | objectField (k : String) (j : Json)\n | objectEnd\n | comma",
"start": [
68,
1
],
"end": [
74,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.compress",
"code": "partial def compress (j : Json) : String :=\n go \"\" [json j]\nwhere go (acc : String) : List Json.CompressWorkItem → String\n | [] => acc\n | json j :: is =>\n match j with\n | null => go (acc ++ \"null\") is\n | bool true => go (acc ++ \"true\") is\n | bool false => go (acc ++ \"false\") is\n | num s => go (acc ++ s.toString) is\n | str s => go (acc ++ renderString s) is\n | arr elems => go (acc ++ \"[\") (elems.toList.map arrayElem ++ [arrayEnd] ++ is)\n | obj kvs => go (acc ++ \"{\") (kvs.fold (init := []) (fun acc k j => objectField k j :: acc) ++ [objectEnd] ++ is)\n | arrayElem j :: arrayEnd :: is => go acc (json j :: arrayEnd :: is)\n | arrayElem j :: is => go acc (json j :: comma :: is)\n | arrayEnd :: is => go (acc ++ \"]\") is\n | objectField k j :: objectEnd :: is => go (acc ++ renderString k ++ \":\") (json j :: objectEnd :: is)\n | objectField k j :: is => go (acc ++ renderString k ++ \":\") (json j :: comma :: is)\n | objectEnd :: is => go (acc ++ \"}\") is\n | comma :: is => go (acc ++ \",\") is",
"start": [
77,
1
],
"end": [
96,
61
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Parsec.lean | [
".lake/packages/lean4/src/lean/Init/Data/ToString/Macro.lean",
".lake/packages/lean4/src/lean/Init/NotationExtra.lean"
] | [
{
"full_name": "Lean.Parsec.ParseResult",
"code": "inductive ParseResult (α : Type) where\n | success (pos : String.Iterator) (res : α)\n | error (pos : String.Iterator) (err : String)\n deriving Repr",
"start": [
13,
1
],
"end": [
16,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec",
"code": "def Parsec (α : Type) : Type := String.Iterator → Lean.Parsec.ParseResult α",
"start": [
19,
1
],
"end": [
19,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.pure",
"code": "@[inline]\nprotected def pure (a : α) : Parsec α := λ it =>\n success it a",
"start": [
28,
1
],
"end": [
30,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.bind",
"code": "@[inline]\ndef bind {α β : Type} (f : Parsec α) (g : α → Parsec β) : Parsec β := λ it =>\n match f it with\n | success rem a => g a rem\n | error pos msg => error pos msg",
"start": [
32,
1
],
"end": [
36,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.fail",
"code": "@[inline]\ndef fail (msg : String) : Parsec α := fun it =>\n error it msg",
"start": [
41,
1
],
"end": [
43,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.tryCatch",
"code": "@[inline]\ndef tryCatch (p : Parsec α)\n (csuccess : α → Parsec β)\n (cerror : Unit → Parsec β)\n : Parsec β := fun it =>\n match p it with\n | .success rem a => csuccess a rem\n | .error rem err =>\n if it.pos = rem.pos then cerror () rem else .error rem err",
"start": [
45,
1
],
"end": [
54,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.orElse",
"code": "@[inline]\ndef orElse (p : Parsec α) (q : Unit → Parsec α) : Parsec α :=\n tryCatch p pure q",
"start": [
56,
1
],
"end": [
58,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.attempt",
"code": "@[inline]\ndef attempt (p : Parsec α) : Parsec α := λ it =>\n match p it with\n | success rem res => success rem res\n | error _ err => error it err",
"start": [
60,
1
],
"end": [
64,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.run",
"code": "protected def run (p : Parsec α) (s : String) : Except String α :=\n match p s.mkIterator with\n | Parsec.ParseResult.success _ res => Except.ok res\n | Parsec.ParseResult.error it err => Except.error s!\"offset {repr it.i.byteIdx}: {err}\"",
"start": [
69,
1
],
"end": [
72,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.expectedEndOfInput",
"code": "def expectedEndOfInput := \"expected end of input\"",
"start": [
74,
1
],
"end": [
74,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.eof",
"code": "@[inline]\ndef eof : Parsec Unit := fun it =>\n if it.hasNext then\n error it expectedEndOfInput\n else\n success it ()",
"start": [
76,
1
],
"end": [
81,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.manyCore",
"code": "@[specialize]\npartial def manyCore (p : Parsec α) (acc : Array α) : Parsec $ Array α :=\n tryCatch p (manyCore p <| acc.push ·) (fun _ => pure acc)",
"start": [
83,
1
],
"end": [
85,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.many",
"code": "@[inline]\ndef many (p : Parsec α) : Parsec $ Array α := manyCore p #[]",
"start": [
87,
1
],
"end": [
88,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.many1",
"code": "@[inline]\ndef many1 (p : Parsec α) : Parsec $ Array α := do manyCore p #[←p]",
"start": [
90,
1
],
"end": [
91,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.manyCharsCore",
"code": "@[specialize]\npartial def manyCharsCore (p : Parsec Char) (acc : String) : Parsec String :=\n tryCatch p (manyCharsCore p <| acc.push ·) (fun _ => pure acc)",
"start": [
93,
1
],
"end": [
95,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.manyChars",
"code": "@[inline]\ndef manyChars (p : Parsec Char) : Parsec String := manyCharsCore p \"\"",
"start": [
97,
1
],
"end": [
98,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.many1Chars",
"code": "@[inline]\ndef many1Chars (p : Parsec Char) : Parsec String := do manyCharsCore p (←p).toString",
"start": [
100,
1
],
"end": [
101,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.pstring",
"code": "def pstring (s : String) : Parsec String := λ it =>\n let substr := it.extract (it.forward s.length)\n if substr = s then\n success (it.forward s.length) substr\n else\n error it s!\"expected: {s}\"",
"start": [
103,
1
],
"end": [
109,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.skipString",
"code": "@[inline]\ndef skipString (s : String) : Parsec Unit := pstring s *> pure ()",
"start": [
111,
1
],
"end": [
112,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.unexpectedEndOfInput",
"code": "def unexpectedEndOfInput := \"unexpected end of input\"",
"start": [
114,
1
],
"end": [
114,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.anyChar",
"code": "@[inline]\ndef anyChar : Parsec Char := λ it =>\n if it.hasNext then success it.next it.curr else error it unexpectedEndOfInput",
"start": [
116,
1
],
"end": [
118,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.pchar",
"code": "@[inline]\ndef pchar (c : Char) : Parsec Char := attempt do\n if (←anyChar) = c then pure c else fail s!\"expected: '{c}'\"",
"start": [
120,
1
],
"end": [
122,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.skipChar",
"code": "@[inline]\ndef skipChar (c : Char) : Parsec Unit := pchar c *> pure ()",
"start": [
124,
1
],
"end": [
125,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.digit",
"code": "@[inline]\ndef digit : Parsec Char := attempt do\n let c ← anyChar\n if '0' ≤ c ∧ c ≤ '9' then return c else fail s!\"digit expected\"",
"start": [
127,
1
],
"end": [
130,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.hexDigit",
"code": "@[inline]\ndef hexDigit : Parsec Char := attempt do\n let c ← anyChar\n if ('0' ≤ c ∧ c ≤ '9')\n ∨ ('a' ≤ c ∧ c ≤ 'f')\n ∨ ('A' ≤ c ∧ c ≤ 'F') then return c else fail s!\"hex digit expected\"",
"start": [
132,
1
],
"end": [
137,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.asciiLetter",
"code": "@[inline]\ndef asciiLetter : Parsec Char := attempt do\n let c ← anyChar\n if ('A' ≤ c ∧ c ≤ 'Z') ∨ ('a' ≤ c ∧ c ≤ 'z') then return c else fail s!\"ASCII letter expected\"",
"start": [
139,
1
],
"end": [
142,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.satisfy",
"code": "@[inline]\ndef satisfy (p : Char → Bool) : Parsec Char := attempt do\n let c ← anyChar\n if p c then return c else fail \"condition not satisfied\"",
"start": [
144,
1
],
"end": [
147,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.notFollowedBy",
"code": "@[inline]\ndef notFollowedBy (p : Parsec α) : Parsec Unit := λ it =>\n match p it with\n | success _ _ => error it \"\"\n | error _ _ => success it ()",
"start": [
149,
1
],
"end": [
153,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.skipWs",
"code": "partial def skipWs (it : String.Iterator) : String.Iterator :=\n if it.hasNext then\n let c := it.curr\n if c = '\\u0009' ∨ c = '\\u000a' ∨ c = '\\u000d' ∨ c = '\\u0020' then\n skipWs it.next\n else\n it\n else\n it",
"start": [
155,
1
],
"end": [
163,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.peek?",
"code": "@[inline]\ndef peek? : Parsec (Option Char) := fun it =>\n if it.hasNext then\n success it it.curr\n else\n success it none",
"start": [
165,
1
],
"end": [
170,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.peek!",
"code": "@[inline]\ndef peek! : Parsec Char := do\n let some c ← peek? | fail unexpectedEndOfInput\n return c",
"start": [
172,
1
],
"end": [
175,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.skip",
"code": "@[inline]\ndef skip : Parsec Unit := fun it =>\n success it.next ()",
"start": [
177,
1
],
"end": [
179,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parsec.ws",
"code": "@[inline]\ndef ws : Parsec Unit := fun it =>\n success (skipWs it) ()",
"start": [
181,
1
],
"end": [
183,
25
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Level.lean | [
".lake/packages/lean4/src/lean/Lean/Data/PersistentHashSet.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/QSort.lean",
".lake/packages/lean4/src/lean/Lean/Data/HashMap.lean",
".lake/packages/lean4/src/lean/Lean/Data/Name.lean",
".lake/packages/lean4/src/lean/Lean/Data/HashSet.lean",
".lake/packages/lean4/src/lean/Lean/Data/Format.lean",
".lake/packages/lean4/src/lean/Lean/Hygiene.lean",
".lake/packages/lean4/src/lean/Lean/Data/PersistentHashMap.lean"
] | [
{
"full_name": "Nat.imax",
"code": "def Nat.imax (n m : Nat) : Nat :=\n if m = 0 then 0 else Nat.max n m",
"start": [
16,
1
],
"end": [
17,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.Data",
"code": "def Level.Data := UInt64",
"start": [
21,
1
],
"end": [
27,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.Data.hash",
"code": "def Level.Data.hash (c : Level.Data) : UInt64 :=\n c.toUInt32.toUInt64",
"start": [
32,
1
],
"end": [
33,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.Data.depth",
"code": "def Level.Data.depth (c : Level.Data) : UInt32 :=\n (c.shiftRight 40).toUInt32",
"start": [
38,
1
],
"end": [
39,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.Data.hasMVar",
"code": "def Level.Data.hasMVar (c : Level.Data) : Bool :=\n ((c.shiftRight 32).land 1) == 1",
"start": [
41,
1
],
"end": [
42,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.Data.hasParam",
"code": "def Level.Data.hasParam (c : Level.Data) : Bool :=\n ((c.shiftRight 33).land 1) == 1",
"start": [
44,
1
],
"end": [
45,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.mkData",
"code": "def Level.mkData (h : UInt64) (depth : Nat := 0) (hasMVar hasParam : Bool := false) : Level.Data :=\n if depth > Nat.pow 2 24 - 1 then panic! \"universe level depth is too big\"\n else\n let r : UInt64 := h.toUInt32.toUInt64 + hasMVar.toUInt64.shiftLeft 32 + hasParam.toUInt64.shiftLeft 33 + depth.toUInt64.shiftLeft 40\n r",
"start": [
47,
1
],
"end": [
51,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LevelMVarId",
"code": "structure LevelMVarId where\n name : Name\n deriving Inhabited, BEq, Hashable, Repr",
"start": [
66,
1
],
"end": [
69,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LMVarId",
"code": "abbrev LMVarId := LevelMVarId",
"start": [
71,
1
],
"end": [
72,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LMVarIdSet",
"code": "def LMVarIdSet := RBTree LMVarId (Name.quickCmp ·.name ·.name)\n deriving Inhabited, EmptyCollection",
"start": [
77,
1
],
"end": [
78,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LMVarIdMap",
"code": "def LMVarIdMap (α : Type) := RBMap LMVarId α (Name.quickCmp ·.name ·.name)",
"start": [
82,
1
],
"end": [
82,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level",
"code": "inductive Level where\n | zero : Level\n | succ : Level → Level\n | max : Level → Level → Level\n | imax : Level → Level → Level\n | param : Name → Level\n | mvar : LMVarId → Level\nwith\n @[computed_field] data : Level → Data\n | .zero => mkData 2221 0 false false\n | .mvar mvarId => mkData (mixHash 2237 <| hash mvarId) 0 true false\n | .param name => mkData (mixHash 2239 <| hash name) 0 false true\n | .succ u => mkData (mixHash 2243 <| u.data.hash) (u.data.depth.toNat + 1) u.data.hasMVar u.data.hasParam\n | .max u v => mkData (mixHash 2251 <| mixHash (u.data.hash) (v.data.hash)) (Nat.max u.data.depth.toNat v.data.depth.toNat + 1)\n (u.data.hasMVar || v.data.hasMVar) (u.data.hasParam || v.data.hasParam)\n | .imax u v => mkData (mixHash 2267 <| mixHash (u.data.hash) (v.data.hash)) (Nat.max u.data.depth.toNat v.data.depth.toNat + 1)\n (u.data.hasMVar || v.data.hasMVar) (u.data.hasParam || v.data.hasParam)\n\nderiving Inhabited, Repr",
"start": [
91,
1
],
"end": [
109,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.hash",
"code": "protected def hash (u : Level) : UInt64 :=\n u.data.hash",
"start": [
113,
1
],
"end": [
114,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.depth",
"code": "def depth (u : Level) : Nat :=\n u.data.depth.toNat",
"start": [
118,
1
],
"end": [
119,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.hasMVar",
"code": "def hasMVar (u : Level) : Bool :=\n u.data.hasMVar",
"start": [
121,
1
],
"end": [
122,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.hasParam",
"code": "def hasParam (u : Level) : Bool :=\n u.data.hasParam",
"start": [
124,
1
],
"end": [
125,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.hashEx",
"code": "@[export lean_level_hash] def hashEx (u : Level) : UInt32 := hash u |>.toUInt32",
"start": [
127,
1
],
"end": [
127,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.hasMVarEx",
"code": "@[export lean_level_has_mvar] def hasMVarEx : Level → Bool := hasMVar",
"start": [
128,
1
],
"end": [
128,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.hasParamEx",
"code": "@[export lean_level_has_param] def hasParamEx : Level → Bool := hasParam",
"start": [
129,
1
],
"end": [
129,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.depthEx",
"code": "@[export lean_level_depth] def depthEx (u : Level) : UInt32 := u.data.depth",
"start": [
130,
1
],
"end": [
130,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.levelZero",
"code": "def levelZero :=\n Level.zero",
"start": [
134,
1
],
"end": [
135,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelMVar",
"code": "def mkLevelMVar (mvarId : LMVarId) :=\n Level.mvar mvarId",
"start": [
137,
1
],
"end": [
138,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelParam",
"code": "def mkLevelParam (name : Name) :=\n Level.param name",
"start": [
140,
1
],
"end": [
141,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelSucc",
"code": "def mkLevelSucc (u : Level) :=\n Level.succ u",
"start": [
143,
1
],
"end": [
144,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelMax",
"code": "def mkLevelMax (u v : Level) :=\n Level.max u v",
"start": [
146,
1
],
"end": [
147,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelIMax",
"code": "def mkLevelIMax (u v : Level) :=\n Level.imax u v",
"start": [
149,
1
],
"end": [
150,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.levelOne",
"code": "def levelOne := mkLevelSucc levelZero",
"start": [
152,
1
],
"end": [
152,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelZeroEx",
"code": "@[export lean_level_mk_zero] def mkLevelZeroEx : Unit → Level := fun _ => levelZero",
"start": [
154,
1
],
"end": [
154,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelSuccEx",
"code": "@[export lean_level_mk_succ] def mkLevelSuccEx : Level → Level := mkLevelSucc",
"start": [
155,
1
],
"end": [
155,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelMVarEx",
"code": "@[export lean_level_mk_mvar] def mkLevelMVarEx : LMVarId → Level := mkLevelMVar",
"start": [
156,
1
],
"end": [
156,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelParamEx",
"code": "@[export lean_level_mk_param] def mkLevelParamEx : Name → Level := mkLevelParam",
"start": [
157,
1
],
"end": [
157,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelMaxEx",
"code": "@[export lean_level_mk_max] def mkLevelMaxEx : Level → Level → Level := mkLevelMax",
"start": [
158,
1
],
"end": [
158,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelIMaxEx",
"code": "@[export lean_level_mk_imax] def mkLevelIMaxEx : Level → Level → Level := mkLevelIMax",
"start": [
159,
1
],
"end": [
159,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isZero",
"code": "def isZero : Level → Bool\n | zero => true\n | _ => false",
"start": [
163,
1
],
"end": [
165,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isSucc",
"code": "def isSucc : Level → Bool\n | succ .. => true\n | _ => false",
"start": [
167,
1
],
"end": [
169,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isMax",
"code": "def isMax : Level → Bool\n | max .. => true\n | _ => false",
"start": [
171,
1
],
"end": [
173,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isIMax",
"code": "def isIMax : Level → Bool\n | imax .. => true\n | _ => false",
"start": [
175,
1
],
"end": [
177,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isMaxIMax",
"code": "def isMaxIMax : Level → Bool\n | max .. => true\n | imax .. => true\n | _ => false",
"start": [
179,
1
],
"end": [
182,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isParam",
"code": "def isParam : Level → Bool\n | param .. => true\n | _ => false",
"start": [
184,
1
],
"end": [
186,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isMVar",
"code": "def isMVar : Level → Bool\n | mvar .. => true\n | _ => false",
"start": [
188,
1
],
"end": [
190,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.mvarId!",
"code": "def mvarId! : Level → LMVarId\n | mvar mvarId => mvarId\n | _ => panic! \"metavariable expected\"",
"start": [
192,
1
],
"end": [
194,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isNeverZero",
"code": "def isNeverZero : Level → Bool\n | zero => false\n | param .. => false\n | mvar .. => false\n | succ .. => true\n | max l₁ l₂ => isNeverZero l₁ || isNeverZero l₂\n | imax _ l₂ => isNeverZero l₂",
"start": [
196,
1
],
"end": [
204,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.ofNat",
"code": "def ofNat : Nat → Level\n | 0 => levelZero\n | n+1 => mkLevelSucc (ofNat n)",
"start": [
206,
1
],
"end": [
208,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.instOfNat",
"code": "instance instOfNat (n : Nat) : OfNat Level n where\n ofNat := ofNat n",
"start": [
210,
1
],
"end": [
211,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.addOffsetAux",
"code": "def addOffsetAux : Nat → Level → Level\n | 0, u => u\n | (n+1), u => addOffsetAux n (mkLevelSucc u)",
"start": [
213,
1
],
"end": [
215,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.addOffset",
"code": "def addOffset (u : Level) (n : Nat) : Level :=\n u.addOffsetAux n",
"start": [
217,
1
],
"end": [
218,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isExplicit",
"code": "def isExplicit : Level → Bool\n | zero => true\n | succ u => !u.hasMVar && !u.hasParam && isExplicit u\n | _ => false",
"start": [
220,
1
],
"end": [
223,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.getOffsetAux",
"code": "def getOffsetAux : Level → Nat → Nat\n | succ u , r => getOffsetAux u (r+1)\n | _, r => r",
"start": [
225,
1
],
"end": [
227,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.getOffset",
"code": "def getOffset (lvl : Level) : Nat :=\n getOffsetAux lvl 0",
"start": [
229,
1
],
"end": [
230,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.getLevelOffset",
"code": "def getLevelOffset : Level → Level\n | succ u => getLevelOffset u\n | u => u",
"start": [
232,
1
],
"end": [
234,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.toNat",
"code": "def toNat (lvl : Level) : Option Nat :=\n match lvl.getLevelOffset with\n | zero => lvl.getOffset\n | _ => none",
"start": [
236,
1
],
"end": [
239,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.beq",
"code": "@[extern \"lean_level_eq\"]\nprotected opaque beq (a : @& Level) (b : @& Level) : Bool",
"start": [
241,
1
],
"end": [
242,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.occurs",
"code": "def occurs : Level → Level → Bool\n | u, v@(succ v₁ ) => u == v || occurs u v₁\n | u, v@(max v₁ v₂ ) => u == v || occurs u v₁ || occurs u v₂\n | u, v@(imax v₁ v₂ ) => u == v || occurs u v₁ || occurs u v₂\n | u, v => u == v",
"start": [
246,
1
],
"end": [
251,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.ctorToNat",
"code": "def ctorToNat : Level → Nat\n | zero .. => 0\n | param .. => 1\n | mvar .. => 2\n | succ .. => 3\n | max .. => 4\n | imax .. => 5",
"start": [
253,
1
],
"end": [
259,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.normLtAux",
"code": "def normLtAux : Level → Nat → Level → Nat → Bool\n | succ l₁, k₁, l₂, k₂ => normLtAux l₁ (k₁+1) l₂ k₂\n | l₁, k₁, succ l₂, k₂ => normLtAux l₁ k₁ l₂ (k₂+1)\n | l₁@(max l₁₁ l₁₂), k₁, l₂@(max l₂₁ l₂₂), k₂ =>\n if l₁ == l₂ then k₁ < k₂\n else if l₁₁ != l₂₁ then normLtAux l₁₁ 0 l₂₁ 0\n else normLtAux l₁₂ 0 l₂₂ 0\n | l₁@(imax l₁₁ l₁₂), k₁, l₂@(imax l₂₁ l₂₂), k₂ =>\n if l₁ == l₂ then k₁ < k₂\n else if l₁₁ != l₂₁ then normLtAux l₁₁ 0 l₂₁ 0\n else normLtAux l₁₂ 0 l₂₂ 0\n | param n₁, k₁, param n₂, k₂ => if n₁ == n₂ then k₁ < k₂ else Name.lt n₁ n₂ | mvar n₁, k₁, mvar n₂, k₂ => if n₁ == n₂ then k₁ < k₂ else Name.lt n₁.name n₂.name\n | l₁, k₁, l₂, k₂ => if l₁ == l₂ then k₁ < k₂ else ctorToNat l₁ < ctorToNat l₂",
"start": [
261,
1
],
"end": [
280,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.normLt",
"code": "def normLt (l₁ l₂ : Level) : Bool :=\n normLtAux l₁ 0 l₂ 0",
"start": [
282,
1
],
"end": [
288,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isAlreadyNormalizedCheap",
"code": "private def isAlreadyNormalizedCheap : Level → Bool\n | zero => true\n | param _ => true\n | mvar _ => true\n | succ u => isAlreadyNormalizedCheap u\n | _ => false",
"start": [
290,
1
],
"end": [
295,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.mkIMaxAux",
"code": "private def mkIMaxAux : Level → Level → Level\n | _, zero => zero\n | zero, u => u\n | u₁, u₂ => if u₁ == u₂ then u₁ else mkLevelIMax u₁ u₂",
"start": [
298,
1
],
"end": [
301,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.getMaxArgsAux",
"code": "@[specialize] private partial def getMaxArgsAux (normalize : Level → Level) : Level → Bool → Array Level → Array Level\n | max l₁ l₂, alreadyNormalized, lvls => getMaxArgsAux normalize l₂ alreadyNormalized (getMaxArgsAux normalize l₁ alreadyNormalized lvls)\n | l, false, lvls => getMaxArgsAux normalize (normalize l) true lvls\n | l, true, lvls => lvls.push l",
"start": [
304,
1
],
"end": [
307,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.accMax",
"code": "private def accMax (result : Level) (prev : Level) (offset : Nat) : Level :=\n if result.isZero then prev.addOffset offset\n else mkLevelMax result (prev.addOffset offset)",
"start": [
309,
1
],
"end": [
311,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.mkMaxAux",
"code": "private partial def mkMaxAux (lvls : Array Level) (extraK : Nat) (i : Nat) (prev : Level) (prevK : Nat) (result : Level) : Level :=\n if h : i < lvls.size then\n let lvl := lvls.get ⟨i, h⟩\n let curr := lvl.getLevelOffset\n let currK := lvl.getOffset\n if curr == prev then\n mkMaxAux lvls extraK (i+1) curr currK result\n else\n mkMaxAux lvls extraK (i+1) curr currK (accMax result prev (extraK + prevK))\n else\n accMax result prev (extraK + prevK)",
"start": [
321,
1
],
"end": [
331,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.skipExplicit",
"code": "private partial def skipExplicit (lvls : Array Level) (i : Nat) : Nat :=\n if h : i < lvls.size then\n let lvl := lvls.get ⟨i, h⟩\n if lvl.getLevelOffset.isZero then skipExplicit lvls (i+1) else i\n else\n i",
"start": [
336,
1
],
"end": [
341,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isExplicitSubsumedAux",
"code": "private partial def isExplicitSubsumedAux (lvls : Array Level) (maxExplicit : Nat) (i : Nat) : Bool :=\n if h : i < lvls.size then\n let lvl := lvls.get ⟨i, h⟩\n if lvl.getOffset ≥ maxExplicit then true\n else isExplicitSubsumedAux lvls maxExplicit (i+1)\n else\n false",
"start": [
343,
1
],
"end": [
356,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isExplicitSubsumed",
"code": "private def isExplicitSubsumed (lvls : Array Level) (firstNonExplicit : Nat) : Bool :=\n if firstNonExplicit == 0 then false\n else\n let max := (lvls.get! (firstNonExplicit - 1)).getOffset;\n isExplicitSubsumedAux lvls max firstNonExplicit",
"start": [
359,
1
],
"end": [
363,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.normalize",
"code": "partial def normalize (l : Level) : Level :=\n if isAlreadyNormalizedCheap l then l\n else\n let k := l.getOffset\n let u := l.getLevelOffset\n match u with\n | max l₁ l₂ =>\n let lvls := getMaxArgsAux normalize l₁ false #[]\n let lvls := getMaxArgsAux normalize l₂ false lvls\n let lvls := lvls.qsort normLt\n let firstNonExplicit := skipExplicit lvls 0\n let i := if isExplicitSubsumed lvls firstNonExplicit then firstNonExplicit else firstNonExplicit - 1\n let lvl₁ := lvls[i]!\n let prev := lvl₁.getLevelOffset\n let prevK := lvl₁.getOffset\n mkMaxAux lvls k (i+1) prev prevK levelZero\n | imax l₁ l₂ =>\n if l₂.isNeverZero then addOffset (normalize (mkLevelMax l₁ l₂)) k\n else\n let l₁ := normalize l₁\n let l₂ := normalize l₂\n addOffset (mkIMaxAux l₁ l₂) k\n | _ => unreachable!",
"start": [
365,
1
],
"end": [
387,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.isEquiv",
"code": "def isEquiv (u v : Level) : Bool :=\n u == v || u.normalize == v.normalize",
"start": [
389,
1
],
"end": [
394,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.dec",
"code": "def dec : Level → Option Level\n | zero => none\n | param _ => none\n | mvar _ => none\n | succ l => l\n | max l₁ l₂ => return mkLevelMax (← dec l₁) (← dec l₂)\n \n | imax l₁ l₂ => return mkLevelMax (← dec l₁) (← dec l₂)",
"start": [
396,
1
],
"end": [
405,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result",
"code": "inductive Result where\n | leaf : Name → Result\n | num : Nat → Result\n | offset : Result → Nat → Result\n | maxNode : List Result → Result\n | imaxNode : List Result → Result",
"start": [
410,
1
],
"end": [
415,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result.succ",
"code": "def Result.succ : Result → Result\n | Result.offset f k => Result.offset f (k+1)\n | Result.num k => Result.num (k+1)\n | f => Result.offset f 1",
"start": [
417,
1
],
"end": [
420,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result.max",
"code": "def Result.max : Result → Result → Result\n | f, Result.maxNode Fs => Result.maxNode (f::Fs)\n | f₁, f₂ => Result.maxNode [f₁, f₂]",
"start": [
422,
1
],
"end": [
424,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result.imax",
"code": "def Result.imax : Result → Result → Result\n | f, Result.imaxNode Fs => Result.imaxNode (f::Fs)\n | f₁, f₂ => Result.imaxNode [f₁, f₂]",
"start": [
426,
1
],
"end": [
428,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.toResult",
"code": "def toResult (l : Level) (mvars : Bool) : Result :=\n match l with\n | zero => Result.num 0\n | succ l => Result.succ (toResult l mvars)\n | max l₁ l₂ => Result.max (toResult l₁ mvars) (toResult l₂ mvars)\n | imax l₁ l₂ => Result.imax (toResult l₁ mvars) (toResult l₂ mvars)\n | param n => Result.leaf n\n | mvar n =>\n if mvars then\n Result.leaf <| n.name.replacePrefix `_uniq (Name.mkSimple \"?u\")\n else\n Result.leaf `_",
"start": [
430,
1
],
"end": [
441,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.parenIfFalse",
"code": "private def parenIfFalse : Format → Bool → Format\n | f, true => f\n | f, false => f.paren",
"start": [
443,
1
],
"end": [
445,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result.formatLst",
"code": "private partial def Result.formatLst : List Result → Format\n | [] => Format.nil\n | r::rs => Format.line ++ format r false ++ formatLst rs",
"start": [
448,
3
],
"end": [
450,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result.format",
"code": "partial def Result.format : Result → Bool → Format\n | Result.leaf n, _ => Std.format n\n | Result.num k, _ => toString k\n | Result.offset f 0, r => format f r\n | Result.offset f (k+1), r =>\n let f' := format f false;\n parenIfFalse (f' ++ \"+\" ++ Std.format (k+1)) r\n | Result.maxNode fs, r => parenIfFalse (Format.group <| \"max\" ++ formatLst fs) r\n | Result.imaxNode fs, r => parenIfFalse (Format.group <| \"imax\" ++ formatLst fs) r",
"start": [
452,
3
],
"end": [
460,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.PP.Result.quote",
"code": "protected partial def Result.quote (r : Result) (prec : Nat) : Syntax.Level :=\n let addParen (s : Syntax.Level) :=\n if prec > 0 then Unhygienic.run `(level| ( $s )) else s\n match r with\n | Result.leaf n => Unhygienic.run `(level| $(mkIdent n):ident)\n | Result.num k => Unhygienic.run `(level| $(quote k):num)\n | Result.offset r 0 => Result.quote r prec\n | Result.offset r (k+1) => addParen <| Unhygienic.run `(level| $(Result.quote r 65) + $(quote (k+1)):num)\n | Result.maxNode rs => addParen <| Unhygienic.run `(level| max $(rs.toArray.map (Result.quote · max_prec))*)\n | Result.imaxNode rs => addParen <| Unhygienic.run `(level| imax $(rs.toArray.map (Result.quote · max_prec))*)",
"start": [
463,
1
],
"end": [
472,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.format",
"code": "protected def format (u : Level) (mvars : Bool) : Format :=\n (PP.toResult u mvars).format true",
"start": [
476,
1
],
"end": [
477,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.quote",
"code": "protected def quote (u : Level) (prec : Nat := 0) (mvars : Bool := true) : Syntax.Level :=\n (PP.toResult u (mvars := mvars)).quote prec",
"start": [
485,
1
],
"end": [
486,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelMaxCore",
"code": "@[inline] private def mkLevelMaxCore (u v : Level) (elseK : Unit → Level) : Level :=\n let subsumes (u v : Level) : Bool :=\n if v.isExplicit && u.getOffset ≥ v.getOffset then true\n else match u with\n | Level.max u₁ u₂ => v == u₁ || v == u₂\n | _ => false\n if u == v then u\n else if u.isZero then v\n else if v.isZero then u\n else if subsumes u v then u\n else if subsumes v u then v\n else if u.getLevelOffset == v.getLevelOffset then\n if u.getOffset ≥ v.getOffset then u else v\n else\n elseK ()",
"start": [
493,
1
],
"end": [
507,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelMax'",
"code": "def mkLevelMax' (u v : Level) : Level :=\n mkLevelMaxCore u v fun _ => mkLevelMax u v",
"start": [
510,
1
],
"end": [
511,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.simpLevelMax'",
"code": "def simpLevelMax' (u v : Level) (d : Level) : Level :=\n mkLevelMaxCore u v fun _ => d",
"start": [
513,
1
],
"end": [
514,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelIMaxCore",
"code": "@[inline] private def mkLevelIMaxCore (u v : Level) (elseK : Unit → Level) : Level :=\n if v.isNeverZero then mkLevelMax' u v\n else if v.isZero then v\n else if u.isZero then v\n else if u == v then u\n else elseK ()",
"start": [
516,
1
],
"end": [
521,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLevelIMax'",
"code": "def mkLevelIMax' (u v : Level) : Level :=\n mkLevelIMaxCore u v fun _ => mkLevelIMax u v",
"start": [
524,
1
],
"end": [
525,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.simpLevelIMax'",
"code": "def simpLevelIMax' (u v : Level) (d : Level) :=\n mkLevelIMaxCore u v fun _ => d",
"start": [
527,
1
],
"end": [
528,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.updateSucc!Impl",
"code": "@[inline] private unsafe def updateSucc!Impl (lvl : Level) (newLvl : Level) : Level :=\n match lvl with\n | succ l => if ptrEq l newLvl then lvl else mkLevelSucc newLvl\n | _ => panic! \"succ level expected\"",
"start": [
538,
1
],
"end": [
541,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.updateSucc!",
"code": "@[implemented_by updateSucc!Impl]\ndef updateSucc! (lvl : Level) (newLvl : Level) : Level :=\n match lvl with\n | succ _ => mkLevelSucc newLvl\n | _ => panic! \"succ level expected\"",
"start": [
543,
1
],
"end": [
547,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.updateMax!Impl",
"code": "@[inline] private unsafe def updateMax!Impl (lvl : Level) (newLhs : Level) (newRhs : Level) : Level :=\n match lvl with\n | max lhs rhs => if ptrEq lhs newLhs && ptrEq rhs newRhs then simpLevelMax' newLhs newRhs lvl else mkLevelMax' newLhs newRhs\n | _ => panic! \"max level expected\"",
"start": [
549,
1
],
"end": [
552,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.updateMax!",
"code": "@[implemented_by updateMax!Impl]\ndef updateMax! (lvl : Level) (newLhs : Level) (newRhs : Level) : Level :=\n match lvl with\n | max _ _ => mkLevelMax' newLhs newRhs\n | _ => panic! \"max level expected\"",
"start": [
554,
1
],
"end": [
558,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.updateIMax!Impl",
"code": "@[inline] private unsafe def updateIMax!Impl (lvl : Level) (newLhs : Level) (newRhs : Level) : Level :=\n match lvl with\n | imax lhs rhs => if ptrEq lhs newLhs && ptrEq rhs newRhs then simpLevelIMax' newLhs newRhs lvl else mkLevelIMax' newLhs newRhs\n | _ => panic! \"imax level expected\"",
"start": [
560,
1
],
"end": [
563,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.updateIMax!",
"code": "@[implemented_by updateIMax!Impl]\ndef updateIMax! (lvl : Level) (newLhs : Level) (newRhs : Level) : Level :=\n match lvl with\n | imax _ _ => mkLevelIMax' newLhs newRhs\n | _ => panic! \"imax level expected\"",
"start": [
565,
1
],
"end": [
569,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.mkNaryMax",
"code": "def mkNaryMax : List Level → Level\n | [] => levelZero\n | [u] => u\n | u::us => mkLevelMax' u (mkNaryMax us)",
"start": [
571,
1
],
"end": [
574,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.substParams",
"code": "@[specialize] def substParams (u : Level) (s : Name → Option Level) : Level :=\n go u\nwhere\n go (u : Level) : Level :=\n match u with\n | .zero => u\n | .succ v => if u.hasParam then u.updateSucc! (go v) else u\n | .max v₁ v₂ => if u.hasParam then u.updateMax! (go v₁) (go v₂) else u\n | .imax v₁ v₂ => if u.hasParam then u.updateIMax! (go v₁) (go v₂) else u\n | .param n => match s n with\n | some u' => u'\n | none => u\n | u => u",
"start": [
576,
1
],
"end": [
588,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.getParamSubst",
"code": "def getParamSubst : List Name → List Level → Name → Option Level\n | p::ps, u::us, p' => if p == p' then some u else getParamSubst ps us p'\n | _, _, _ => none",
"start": [
590,
1
],
"end": [
592,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.instantiateParams",
"code": "def instantiateParams (u : Level) (paramNames : List Name) (vs : List Level) : Level :=\n u.substParams (getParamSubst paramNames vs)",
"start": [
594,
1
],
"end": [
595,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.geq",
"code": "def geq (u v : Level) : Bool :=\n go u.normalize v.normalize\nwhere\n go (u v : Level) : Bool :=\n u == v ||\n match u, v with\n | _, zero => true\n | u, max v₁ v₂ => go u v₁ && go u v₂\n | max u₁ u₂, v => go u₁ v || go u₂ v\n | u, imax v₁ v₂ => go u v₁ && go u v₂\n | imax _ u₂, v => go u₂ v\n | succ u, succ v => go u v\n | _, _ =>\n let v' := v.getLevelOffset\n (u.getLevelOffset == v' || v'.isZero)\n && u.getOffset ≥ v.getOffset\n termination_by (u, v)",
"start": [
597,
1
],
"end": [
613,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LevelMap",
"code": "abbrev LevelMap (α : Type) := HashMap Level α",
"start": [
617,
1
],
"end": [
617,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentLevelMap",
"code": "abbrev PersistentLevelMap (α : Type) := PHashMap Level α",
"start": [
618,
1
],
"end": [
618,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LevelSet",
"code": "abbrev LevelSet := HashSet Level",
"start": [
619,
1
],
"end": [
619,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentLevelSet",
"code": "abbrev PersistentLevelSet := PHashSet Level",
"start": [
620,
1
],
"end": [
620,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PLevelSet",
"code": "abbrev PLevelSet := PersistentLevelSet",
"start": [
621,
1
],
"end": [
621,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.collectMVars",
"code": "def Level.collectMVars (u : Level) (s : LMVarIdSet := {}) : LMVarIdSet :=\n match u with\n | succ v => collectMVars v s\n | max u v => collectMVars u (collectMVars v s)\n | imax u v => collectMVars u (collectMVars v s)\n | mvar n => s.insert n\n | _ => s",
"start": [
623,
1
],
"end": [
629,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.find?",
"code": "def Level.find? (u : Level) (p : Level → Bool) : Option Level :=\n let rec visit (u : Level) : Option Level :=\n if p u then\n return u\n else match u with\n | succ v => visit v\n | max u v => visit u <|> visit v\n | imax u v => visit u <|> visit v\n | _ => failure\n visit u",
"start": [
631,
1
],
"end": [
640,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Level.any",
"code": "def Level.any (u : Level) (p : Level → Bool) : Bool :=\n u.find? p |>.isSome",
"start": [
642,
1
],
"end": [
643,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.toLevel",
"code": "abbrev Nat.toLevel (n : Nat) : Lean.Level :=\n Lean.Level.ofNat n",
"start": [
647,
1
],
"end": [
648,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json/FromToJson.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json/Printer.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Basic.lean"
] | [
{
"full_name": "Lean.FromJson",
"code": "class FromJson (α : Type u) where\n fromJson? : Json → Except String α",
"start": [
15,
1
],
"end": [
16,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ToJson",
"code": "class ToJson (α : Type u) where\n toJson : α → Json",
"start": [
20,
1
],
"end": [
21,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.bignumFromJson?",
"code": "def bignumFromJson? (j : Json) : Except String Nat := do\n let s ← j.getStr?\n let some v := Syntax.decodeNatLitVal? s | throw s!\"expected a string-encoded number, got '{j}'\"\n return v",
"start": [
92,
1
],
"end": [
98,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.bignumToJson",
"code": "def bignumToJson (n : Nat) : Json :=\n toString n",
"start": [
100,
1
],
"end": [
101,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.toStructured?",
"code": "def toStructured? [ToJson α] (v : α) : Except String Structured :=\n fromJson? (toJson v)",
"start": [
156,
1
],
"end": [
157,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.getObjValAs?",
"code": "def getObjValAs? (j : Json) (α : Type u) [FromJson α] (k : String) : Except String α :=\n fromJson? <| j.getObjValD k",
"start": [
159,
1
],
"end": [
160,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.setObjValAs!",
"code": "def setObjValAs! (j : Json) {α : Type u} [ToJson α] (k : String) (v : α) : Json :=\n j.setObjVal! k <| toJson v",
"start": [
162,
1
],
"end": [
163,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.opt",
"code": "def opt [ToJson α] (k : String) : Option α → List (String × Json)\n | none => []\n | some o => [⟨k, toJson o⟩]",
"start": [
165,
1
],
"end": [
167,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.parseTagged",
"code": "def parseTagged\n (json : Json)\n (tag : String)\n (nFields : Nat)\n (fieldNames? : Option (Array Name)) : Except String (Array Json) :=\n if nFields == 0 then\n match getStr? json with\n | Except.ok s => if s == tag then Except.ok #[] else throw s!\"incorrect tag: {s} ≟ {tag}\"\n | Except.error err => Except.error err\n else\n match getObjVal? json tag with\n | Except.ok payload =>\n match fieldNames? with\n | some fieldNames =>\n do\n let mut fields := #[]\n for fieldName in fieldNames do\n fields := fields.push (←getObjVal? payload fieldName.getString!)\n Except.ok fields\n | none =>\n if nFields == 1 then\n Except.ok #[payload]\n else\n match getArr? payload with\n | Except.ok fields =>\n if fields.size == nFields then\n Except.ok fields\n else\n Except.error s!\"incorrect number of fields: {fields.size} ≟ {nFields}\"\n | Except.error err => Except.error err\n | Except.error err => Except.error err",
"start": [
169,
1
],
"end": [
200,
43
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json/Parser.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Parsec.lean",
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Basic.lean"
] | [
{
"full_name": "Lean.Json.Parser.hexChar",
"code": "@[inline]\ndef hexChar : Parsec Nat := do\n let c ← anyChar\n if '0' ≤ c ∧ c ≤ '9' then\n pure $ c.val.toNat - '0'.val.toNat\n else if 'a' ≤ c ∧ c ≤ 'f' then\n pure $ c.val.toNat - 'a'.val.toNat + 10\n else if 'A' ≤ c ∧ c ≤ 'F' then\n pure $ c.val.toNat - 'A'.val.toNat + 10\n else\n fail \"invalid hex character\"",
"start": [
16,
1
],
"end": [
26,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.escapedChar",
"code": "def escapedChar : Parsec Char := do\n let c ← anyChar\n match c with\n | '\\\\' => return '\\\\'\n | '\"' => return '\"'\n | '/' => return '/'\n | 'b' => return '\\x08'\n | 'f' => return '\\x0c'\n | 'n' => return '\\n'\n | 'r' => return '\\x0d'\n | 't' => return '\\t'\n | 'u' =>\n let u1 ← hexChar; let u2 ← hexChar; let u3 ← hexChar; let u4 ← hexChar\n return Char.ofNat $ 4096*u1 + 256*u2 + 16*u3 + u4\n | _ => fail \"illegal \\\\u escape\"",
"start": [
28,
1
],
"end": [
42,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.strCore",
"code": "partial def strCore (acc : String) : Parsec String := do\n let c ← peek!\n if c = '\"' then skip\n return acc\n else\n let c ← anyChar\n if c = '\\\\' then\n strCore (acc.push (← escapedChar))\n else if 0x0020 ≤ c.val ∧ c.val ≤ 0x10ffff then\n strCore (acc.push c)\n else\n fail \"unexpected character in string\"",
"start": [
44,
1
],
"end": [
59,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.str",
"code": "def str : Parsec String := strCore \"\"",
"start": [
61,
1
],
"end": [
61,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.natCore",
"code": "partial def natCore (acc digits : Nat) : Parsec (Nat × Nat) := do\n let some c ← peek? | return (acc, digits)\n if '0' ≤ c ∧ c ≤ '9' then\n skip\n let acc' := 10*acc + (c.val.toNat - '0'.val.toNat)\n natCore acc' (digits+1)\n else\n return (acc, digits)",
"start": [
63,
1
],
"end": [
70,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.lookahead",
"code": "@[inline]\ndef lookahead (p : Char → Prop) (desc : String) [DecidablePred p] : Parsec Unit := do\n let c ← peek!\n if p c then\n return ()\n else\n fail <| \"expected \" ++ desc",
"start": [
72,
1
],
"end": [
78,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.natNonZero",
"code": "@[inline]\ndef natNonZero : Parsec Nat := do\n lookahead (fun c => '1' ≤ c ∧ c ≤ '9') \"1-9\"\n let (n, _) ← natCore 0 0\n return n",
"start": [
80,
1
],
"end": [
84,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.natNumDigits",
"code": "@[inline]\ndef natNumDigits : Parsec (Nat × Nat) := do\n lookahead (fun c => '0' ≤ c ∧ c ≤ '9') \"digit\"\n natCore 0 0",
"start": [
86,
1
],
"end": [
89,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.natMaybeZero",
"code": "@[inline]\ndef natMaybeZero : Parsec Nat := do\n let (n, _) ← natNumDigits\n return n",
"start": [
91,
1
],
"end": [
94,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.num",
"code": "def num : Parsec JsonNumber := do\n let c ← peek!\n let sign ← if c = '-' then\n skip\n pure (-1 : Int)\n else\n pure 1\n let c ← peek!\n let res ← if c = '0' then\n skip\n pure 0\n else\n natNonZero\n let c? ← peek?\n let res : JsonNumber ← if c? = some '.' then\n skip\n let (n, d) ← natNumDigits\n if d > USize.size then fail \"too many decimals\"\n let mantissa' := sign * (res * (10^d : Nat) + n)\n let exponent' := d\n pure <| JsonNumber.mk mantissa' exponent'\n else\n pure <| JsonNumber.fromInt (sign * res)\n let c? ← peek?\n if c? = some 'e' ∨ c? = some 'E' then\n skip\n let c ← peek!\n if c = '-' then\n skip\n let n ← natMaybeZero\n return res.shiftr n\n else\n if c = '+' then skip\n let n ← natMaybeZero\n if n > USize.size then fail \"exp too large\"\n return res.shiftl n\n else\n return res",
"start": [
96,
1
],
"end": [
133,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.arrayCore",
"code": "partial def arrayCore (anyCore : Parsec Json) (acc : Array Json) : Parsec (Array Json) := do\n let hd ← anyCore\n let acc' := acc.push hd\n let c ← anyChar\n if c = ']' then\n ws\n return acc'\n else if c = ',' then\n ws\n arrayCore anyCore acc'\n else\n fail \"unexpected character in array\"",
"start": [
135,
1
],
"end": [
146,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.objectCore",
"code": "partial def objectCore (anyCore : Parsec Json) : Parsec (RBNode String (fun _ => Json)) := do\n lookahead (fun c => c = '\"') \"\\\"\"; skip; let k ← strCore \"\"; ws\n lookahead (fun c => c = ':') \":\"; skip; ws\n let v ← anyCore\n let c ← anyChar\n if c = '}' then\n ws\n return RBNode.singleton k v\n else if c = ',' then\n ws\n let kvs ← objectCore anyCore\n return kvs.insert compare k v\n else\n fail \"unexpected character in object\"",
"start": [
148,
1
],
"end": [
162,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.anyCore",
"code": "partial def anyCore : Parsec Json := do\n let c ← peek!\n if c = '[' then\n skip; ws\n let c ← peek!\n if c = ']' then\n skip; ws\n return Json.arr (Array.mkEmpty 0)\n else\n let a ← arrayCore anyCore (Array.mkEmpty 4)\n return Json.arr a\n else if c = '{' then\n skip; ws\n let c ← peek!\n if c = '}' then\n skip; ws\n return Json.obj (RBNode.leaf)\n else\n let kvs ← objectCore anyCore\n return Json.obj kvs\n else if c = '\\\"' then\n skip\n let s ← strCore \"\"\n ws\n return Json.str s\n else if c = 'f' then\n skipString \"false\"; ws\n return Json.bool false\n else if c = 't' then\n skipString \"true\"; ws\n return Json.bool true\n else if c = 'n' then\n skipString \"null\"; ws\n return Json.null\n else if c = '-' ∨ ('0' ≤ c ∧ c ≤ '9') then\n let n ← num\n ws\n return Json.num n\n else\n fail \"unexpected input\"",
"start": [
164,
1
],
"end": [
203,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Json.Parser.any",
"code": "def any : Parsec Json := do\n ws\n let res ← anyCore\n eof\n return res",
"start": [
206,
1
],
"end": [
210,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Json.parse",
"code": "def parse (s : String) : Except String Lean.Json :=\n match Json.Parser.any s.mkIterator with\n | Parsec.ParseResult.success _ res => Except.ok res\n | Parsec.ParseResult.error it err => Except.error s!\"offset {repr it.i.byteIdx}: {err}\"",
"start": [
216,
1
],
"end": [
219,
91
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Syntax.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Name.lean",
".lake/packages/lean4/src/lean/Init/Data/Hashable.lean",
".lake/packages/lean4/src/lean/Init/Data/Range.lean",
".lake/packages/lean4/src/lean/Lean/Data/Format.lean"
] | [
{
"full_name": "String.Range",
"code": "protected structure String.Range where\n start : String.Pos\n stop : String.Pos\n deriving Inhabited, Repr, BEq, Hashable",
"start": [
12,
1
],
"end": [
19,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "String.Range.contains",
"code": "def String.Range.contains (r : String.Range) (pos : String.Pos) (includeStop := false) : Bool :=\n r.start <= pos && (if includeStop then pos <= r.stop else pos < r.stop)",
"start": [
21,
1
],
"end": [
22,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "String.Range.includes",
"code": "def String.Range.includes (super sub : String.Range) : Bool :=\n super.start <= sub.start && super.stop >= sub.stop",
"start": [
24,
1
],
"end": [
25,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SourceInfo.updateTrailing",
"code": "def SourceInfo.updateTrailing (trailing : Substring) : SourceInfo → SourceInfo\n | SourceInfo.original leading pos _ endPos => SourceInfo.original leading pos trailing endPos\n | info => info",
"start": [
29,
1
],
"end": [
31,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SourceInfo.getRange?",
"code": "def SourceInfo.getRange? (canonicalOnly := false) (info : SourceInfo) : Option String.Range :=\n return ⟨(← info.getPos? canonicalOnly), (← info.getTailPos? canonicalOnly)⟩",
"start": [
33,
1
],
"end": [
34,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IsNode",
"code": "inductive IsNode : Syntax → Prop where\n | mk (info : SourceInfo) (kind : SyntaxNodeKind) (args : Array Syntax) : IsNode (Syntax.node info kind args)",
"start": [
40,
1
],
"end": [
41,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode",
"code": "def SyntaxNode : Type := {s : Syntax // IsNode s }",
"start": [
43,
1
],
"end": [
43,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.unreachIsNodeMissing",
"code": "def unreachIsNodeMissing {β} : IsNode Syntax.missing → β := nofun",
"start": [
45,
1
],
"end": [
45,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.unreachIsNodeAtom",
"code": "def unreachIsNodeAtom {β} {info val} : IsNode (Syntax.atom info val) → β := nofun",
"start": [
46,
1
],
"end": [
46,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.unreachIsNodeIdent",
"code": "def unreachIsNodeIdent {β info rawVal val preresolved} : IsNode (Syntax.ident info rawVal val preresolved) → β := nofun",
"start": [
47,
1
],
"end": [
47,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isLitKind",
"code": "def isLitKind (k : SyntaxNodeKind) : Bool :=\n k == strLitKind || k == numLitKind || k == charLitKind || k == nameLitKind || k == scientificLitKind",
"start": [
49,
1
],
"end": [
50,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.getKind",
"code": "@[inline] def getKind (n : SyntaxNode) : SyntaxNodeKind :=\n match n with\n | ⟨Syntax.node _ k _, _⟩ => k\n | ⟨Syntax.missing, h⟩ => unreachIsNodeMissing h\n | ⟨Syntax.atom .., h⟩ => unreachIsNodeAtom h\n | ⟨Syntax.ident .., h⟩ => unreachIsNodeIdent h",
"start": [
54,
1
],
"end": [
59,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.withArgs",
"code": "@[inline] def withArgs {β} (n : SyntaxNode) (fn : Array Syntax → β) : β :=\n match n with\n | ⟨Syntax.node _ _ args, _⟩ => fn args\n | ⟨Syntax.missing, h⟩ => unreachIsNodeMissing h\n | ⟨Syntax.atom _ _, h⟩ => unreachIsNodeAtom h\n | ⟨Syntax.ident _ _ _ _, h⟩ => unreachIsNodeIdent h",
"start": [
61,
1
],
"end": [
66,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.getNumArgs",
"code": "@[inline] def getNumArgs (n : SyntaxNode) : Nat :=\n withArgs n fun args => args.size",
"start": [
68,
1
],
"end": [
69,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.getArg",
"code": "@[inline] def getArg (n : SyntaxNode) (i : Nat) : Syntax :=\n withArgs n fun args => args.get! i",
"start": [
71,
1
],
"end": [
72,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.getArgs",
"code": "@[inline] def getArgs (n : SyntaxNode) : Array Syntax :=\n withArgs n fun args => args",
"start": [
74,
1
],
"end": [
75,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.modifyArgs",
"code": "@[inline] def modifyArgs (n : SyntaxNode) (fn : Array Syntax → Array Syntax) : Syntax :=\n match n with\n | ⟨Syntax.node i k args, _⟩ => Syntax.node i k (fn args)\n | ⟨Syntax.missing, h⟩ => unreachIsNodeMissing h\n | ⟨Syntax.atom _ _, h⟩ => unreachIsNodeAtom h\n | ⟨Syntax.ident _ _ _ _, h⟩ => unreachIsNodeIdent h",
"start": [
77,
1
],
"end": [
82,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.structRangeEq",
"code": "partial def structRangeEq : Syntax → Syntax → Bool\n | .missing, .missing => true\n | .node info k args, .node info' k' args' =>\n info.getRange? == info'.getRange? && k == k' && args.isEqv args' structRangeEq\n | .atom info val, .atom info' val' => info.getRange? == info'.getRange? && val == val'\n | .ident info rawVal val preresolved, .ident info' rawVal' val' preresolved' =>\n info.getRange? == info'.getRange? && rawVal == rawVal' && val == val' &&\n preresolved == preresolved'\n | _, _ => false",
"start": [
88,
1
],
"end": [
103,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.structRangeEqWithTraceReuse",
"code": "def structRangeEqWithTraceReuse (opts : Options) (stx1 stx2 : Syntax) : Bool :=\n if stx1.structRangeEq stx2 then\n true\n else\n if opts.getBool `trace.Elab.reuse then\n dbg_trace \"reuse stopped:\n{stx1.formatStx (showInfo := true)} !=\n{stx2.formatStx (showInfo := true)}\"\n false\n else\n false",
"start": [
105,
1
],
"end": [
116,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.eqWithInfo",
"code": "partial def eqWithInfo : Syntax → Syntax → Bool\n | .missing, .missing => true\n | .node info k args, .node info' k' args' =>\n info == info' && k == k' && args.isEqv args' eqWithInfo\n | .atom info val, .atom info' val' => info == info' && val == val'\n | .ident info rawVal val preresolved, .ident info' rawVal' val' preresolved' =>\n info == info' && rawVal == rawVal' && val == val' && preresolved == preresolved'\n | _, _ => false",
"start": [
119,
1
],
"end": [
127,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.eqWithInfoAndTraceReuse",
"code": "def eqWithInfoAndTraceReuse (opts : Options) (stx1 stx2 : Syntax) : Bool :=\n if stx1.eqWithInfo stx2 then\n true\n else\n if opts.getBool `trace.Elab.reuse then\n dbg_trace \"reuse stopped:\n{stx1.formatStx (showInfo := true)} !=\n{stx2.formatStx (showInfo := true)}\"\n false\n else\n false",
"start": [
129,
1
],
"end": [
140,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getAtomVal",
"code": "def getAtomVal : Syntax → String\n | atom _ val => val\n | _ => \"\"",
"start": [
142,
1
],
"end": [
144,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.setAtomVal",
"code": "def setAtomVal : Syntax → String → Syntax\n | atom info _, v => (atom info v)\n | stx, _ => stx",
"start": [
146,
1
],
"end": [
148,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.ifNode",
"code": "@[inline] def ifNode {β} (stx : Syntax) (hyes : SyntaxNode → β) (hno : Unit → β) : β :=\n match stx with\n | Syntax.node i k args => hyes ⟨Syntax.node i k args, IsNode.mk i k args⟩\n | _ => hno ()",
"start": [
150,
1
],
"end": [
153,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.ifNodeKind",
"code": "@[inline] def ifNodeKind {β} (stx : Syntax) (kind : SyntaxNodeKind) (hyes : SyntaxNode → β) (hno : Unit → β) : β :=\n match stx with\n | Syntax.node i k args => if k == kind then hyes ⟨Syntax.node i k args, IsNode.mk i k args⟩ else hno ()\n | _ => hno ()",
"start": [
155,
1
],
"end": [
158,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.asNode",
"code": "def asNode : Syntax → SyntaxNode\n | Syntax.node info kind args => ⟨Syntax.node info kind args, IsNode.mk info kind args⟩\n | _ => ⟨mkNullNode, IsNode.mk _ _ _⟩",
"start": [
160,
1
],
"end": [
162,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getIdAt",
"code": "def getIdAt (stx : Syntax) (i : Nat) : Name :=\n (stx.getArg i).getId",
"start": [
164,
1
],
"end": [
165,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.modifyArgs",
"code": "@[inline] def modifyArgs (stx : Syntax) (fn : Array Syntax → Array Syntax) : Syntax :=\n match stx with\n | node i k args => node i k (fn args)\n | stx => stx",
"start": [
167,
1
],
"end": [
170,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.modifyArg",
"code": "@[inline] def modifyArg (stx : Syntax) (i : Nat) (fn : Syntax → Syntax) : Syntax :=\n match stx with\n | node info k args => node info k (args.modify i fn)\n | stx => stx",
"start": [
172,
1
],
"end": [
175,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.replaceM",
"code": "@[specialize] partial def replaceM {m : Type → Type} [Monad m] (fn : Syntax → m (Option Syntax)) : Syntax → m (Syntax)\n | stx@(node info kind args) => do\n match (← fn stx) with\n | some stx => return stx\n | none => return node info kind (← args.mapM (replaceM fn))\n | stx => do\n let o ← fn stx\n return o.getD stx",
"start": [
177,
1
],
"end": [
184,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.rewriteBottomUpM",
"code": "@[specialize] partial def rewriteBottomUpM {m : Type → Type} [Monad m] (fn : Syntax → m (Syntax)) : Syntax → m (Syntax)\n | node info kind args => do\n let args ← args.mapM (rewriteBottomUpM fn)\n fn (node info kind args)\n | stx => fn stx",
"start": [
186,
1
],
"end": [
190,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.rewriteBottomUp",
"code": "@[inline] def rewriteBottomUp (fn : Syntax → Syntax) (stx : Syntax) : Syntax :=\n Id.run <| stx.rewriteBottomUpM fn",
"start": [
192,
1
],
"end": [
193,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.updateInfo",
"code": "private def updateInfo : SourceInfo → String.Pos → String.Pos → SourceInfo\n | SourceInfo.original lead pos trail endPos, leadStart, trailStop =>\n SourceInfo.original { lead with startPos := leadStart } pos { trail with stopPos := trailStop } endPos\n | info, _, _ => info",
"start": [
195,
1
],
"end": [
198,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.chooseNiceTrailStop",
"code": "private def chooseNiceTrailStop (trail : Substring) : String.Pos :=\ntrail.startPos + trail.posOf '\\n'",
"start": [
200,
1
],
"end": [
201,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.updateLeadingAux",
"code": "@[inline]\nprivate def updateLeadingAux : Syntax → StateM String.Pos (Option Syntax)\n | atom info@(SourceInfo.original _ _ trail _) val => do\n let trailStop := chooseNiceTrailStop trail\n let newInfo := updateInfo info (← get) trailStop\n set trailStop\n return some (atom newInfo val)\n | ident info@(SourceInfo.original _ _ trail _) rawVal val pre => do\n let trailStop := chooseNiceTrailStop trail\n let newInfo := updateInfo info (← get) trailStop\n set trailStop\n return some (ident newInfo rawVal val pre)\n | _ => pure none",
"start": [
203,
1
],
"end": [
217,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.updateLeading",
"code": "def updateLeading : Syntax → Syntax :=\n fun stx => (replaceM updateLeadingAux stx).run' 0",
"start": [
219,
1
],
"end": [
235,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.updateTrailing",
"code": "partial def updateTrailing (trailing : Substring) : Syntax → Syntax\n | Syntax.atom info val => Syntax.atom (info.updateTrailing trailing) val\n | Syntax.ident info rawVal val pre => Syntax.ident (info.updateTrailing trailing) rawVal val pre\n | n@(Syntax.node info k args) =>\n if args.size == 0 then n\n else\n let i := args.size - 1\n let last := updateTrailing trailing args[i]!\n let args := args.set! i last;\n Syntax.node info k args\n | s => s",
"start": [
237,
1
],
"end": [
247,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.identComponents",
"code": "def identComponents (stx : Syntax) (nFields? : Option Nat := none) : List Syntax :=\n match stx with\n | ident si@(SourceInfo.original lead pos trail _) rawStr val _ => Id.run do\n let val := val.eraseMacroScopes\n let nameComps := nameComps val nFields?\n let rawComps := splitNameLit rawStr\n if !rawComps.isEmpty then\n let rawComps :=\n if let some nFields := nFields? then\n let nPrefix := rawComps.length - nFields\n let prefixSz := rawComps.take nPrefix |>.foldl (init := 0) fun acc (ss : Substring) => acc + ss.bsize + 1\n let prefixSz := prefixSz - 1 rawStr.extract 0 ⟨prefixSz⟩ :: rawComps.drop nPrefix\n else\n rawComps\n if nameComps.length == rawComps.length then\n return nameComps.zip rawComps |>.map fun (id, ss) =>\n let off := ss.startPos - rawStr.startPos\n let lead := if off == 0 then lead else \"\".toSubstring\n let trail := if ss.stopPos == rawStr.stopPos then trail else \"\".toSubstring\n let info := original lead (pos + off) trail (pos + off + ⟨ss.bsize⟩)\n ident info ss id []\n nameComps.map fun n => ident si n.toString.toSubstring n []\n | ident si _ val _ =>\n let val := val.eraseMacroScopes\n \n nameComps val nFields? |>.map fun n => ident si n.toString.toSubstring n []\n | _ => unreachable!\n where\n nameComps (n : Name) (nFields? : Option Nat) : List Name :=\n if let some nFields := nFields? then\n let nameComps := n.components\n let nPrefix := nameComps.length - nFields\n let namePrefix := nameComps.take nPrefix |>.foldl (init := Name.anonymous) fun acc n => acc ++ n\n namePrefix :: nameComps.drop nPrefix\n else\n n.components",
"start": [
250,
1
],
"end": [
294,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.TopDown",
"code": "structure TopDown where\n firstChoiceOnly : Bool\n stx : Syntax",
"start": [
296,
1
],
"end": [
298,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.topDown",
"code": "def topDown (stx : Syntax) (firstChoiceOnly := false) : TopDown := ⟨firstChoiceOnly, stx⟩",
"start": [
300,
1
],
"end": [
304,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.reprint",
"code": "partial def reprint (stx : Syntax) : Option String := do\n let mut s := \"\"\n for stx in stx.topDown (firstChoiceOnly := true) do\n match stx with\n | atom info val => s := s ++ reprintLeaf info val\n | ident info rawVal _ _ => s := s ++ reprintLeaf info rawVal.toString\n | node _ kind args =>\n if kind == choiceKind then\n let s0 ← reprint args[0]!\n for arg in args[1:] do\n let s' ← reprint arg\n guard (s0 == s')\n | _ => pure ()\n return s\nwhere\n reprintLeaf (info : SourceInfo) (val : String) : String :=\n match info with\n | SourceInfo.original lead _ trail _ => s!\"{lead}{val}{trail}\"\n | _ => s!\" {val} \"",
"start": [
326,
1
],
"end": [
350,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.hasMissing",
"code": "def hasMissing (stx : Syntax) : Bool := Id.run do\n for stx in stx.topDown do\n if stx.isMissing then\n return true\n return false",
"start": [
352,
1
],
"end": [
356,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getRange?",
"code": "def getRange? (stx : Syntax) (canonicalOnly := false) : Option String.Range :=\n match stx.getPos? canonicalOnly, stx.getTailPos? canonicalOnly with\n | some start, some stop => some { start, stop }\n | _, _ => none",
"start": [
358,
1
],
"end": [
361,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.ofRange",
"code": "def ofRange (range : String.Range) (canonical := true) : Lean.Syntax :=\n .atom (.synthetic range.start range.stop canonical) \"\"",
"start": [
363,
1
],
"end": [
365,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser",
"code": "structure Traverser where\n cur : Syntax\n parents : Array Syntax\n idxs : Array Nat",
"start": [
367,
1
],
"end": [
375,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser.fromSyntax",
"code": "def fromSyntax (stx : Syntax) : Traverser :=\n ⟨stx, #[], #[]⟩",
"start": [
379,
1
],
"end": [
380,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser.setCur",
"code": "def setCur (t : Traverser) (stx : Syntax) : Traverser :=\n { t with cur := stx }",
"start": [
382,
1
],
"end": [
383,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser.down",
"code": "def down (t : Traverser) (idx : Nat) : Traverser :=\n if idx < t.cur.getNumArgs then\n { cur := t.cur.getArg idx, parents := t.parents.push <| t.cur.setArg idx default, idxs := t.idxs.push idx }\n else\n { cur := Syntax.missing, parents := t.parents.push t.cur, idxs := t.idxs.push idx }",
"start": [
385,
1
],
"end": [
390,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser.up",
"code": "def up (t : Traverser) : Traverser :=\n if t.parents.size > 0 then\n let cur := if t.idxs.back < t.parents.back.getNumArgs then t.parents.back.setArg t.idxs.back t.cur else t.parents.back\n { cur := cur, parents := t.parents.pop, idxs := t.idxs.pop }\n else\n t",
"start": [
392,
1
],
"end": [
398,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser.left",
"code": "def left (t : Traverser) : Traverser :=\n if t.parents.size > 0 then\n t.up.down (t.idxs.back - 1)\n else\n t",
"start": [
400,
1
],
"end": [
405,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Traverser.right",
"code": "def right (t : Traverser) : Traverser :=\n if t.parents.size > 0 then\n t.up.down (t.idxs.back + 1)\n else\n t",
"start": [
407,
1
],
"end": [
412,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser",
"code": "class MonadTraverser (m : Type → Type) where\n st : MonadState Traverser m",
"start": [
416,
1
],
"end": [
418,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.getCur",
"code": "def getCur : m Syntax := Traverser.cur <$> t.st.get",
"start": [
424,
1
],
"end": [
424,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.setCur",
"code": "def setCur (stx : Syntax) : m Unit := @modify _ _ t.st (fun t => t.setCur stx)",
"start": [
425,
1
],
"end": [
425,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.goDown",
"code": "def goDown (idx : Nat) : m Unit := @modify _ _ t.st (fun t => t.down idx)",
"start": [
426,
1
],
"end": [
426,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.goUp",
"code": "def goUp : m Unit := @modify _ _ t.st (fun t => t.up)",
"start": [
427,
1
],
"end": [
427,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.goLeft",
"code": "def goLeft : m Unit := @modify _ _ t.st (fun t => t.left)",
"start": [
428,
1
],
"end": [
428,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.goRight",
"code": "def goRight : m Unit := @modify _ _ t.st (fun t => t.right)",
"start": [
429,
1
],
"end": [
429,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.MonadTraverser.getIdx",
"code": "def getIdx : m Nat := do\n let st ← t.st.get\n return st.idxs.back?.getD 0",
"start": [
431,
1
],
"end": [
433,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SyntaxNode.getIdAt",
"code": "@[inline] def getIdAt (n : SyntaxNode) (i : Nat) : Name :=\n (n.getArg i).getId",
"start": [
440,
1
],
"end": [
441,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkListNode",
"code": "def mkListNode (args : Array Syntax) : Syntax :=\n mkNullNode args",
"start": [
445,
1
],
"end": [
446,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isQuot",
"code": "def isQuot : Syntax → Bool\n | Syntax.node _ (Name.str _ \"quot\") _ => true\n | Syntax.node _ `Lean.Parser.Term.dynamicQuot _ => true\n | _ => false",
"start": [
451,
1
],
"end": [
454,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getQuotContent",
"code": "def getQuotContent (stx : Syntax) : Syntax :=\n let stx := if stx.getNumArgs == 1 then stx[0] else stx\n if stx.isOfKind `Lean.Parser.Term.dynamicQuot then\n stx[3]\n else\n stx[1]",
"start": [
456,
1
],
"end": [
461,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isAntiquot",
"code": "def isAntiquot : Syntax → Bool\n | .node _ (.str _ \"antiquot\") _ => true\n | _ => false",
"start": [
464,
1
],
"end": [
466,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isAntiquots",
"code": "def isAntiquots (stx : Syntax) : Bool :=\n stx.isAntiquot || (stx.isOfKind choiceKind && stx.getNumArgs > 0 && stx.getArgs.all isAntiquot)",
"start": [
468,
1
],
"end": [
469,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getCanonicalAntiquot",
"code": "def getCanonicalAntiquot (stx : Syntax) : Syntax :=\n if stx.isOfKind choiceKind then\n stx[0]\n else\n stx",
"start": [
471,
1
],
"end": [
475,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.mkAntiquotNode",
"code": "def mkAntiquotNode (kind : Name) (term : Syntax) (nesting := 0) (name : Option String := none) (isPseudoKind := false) : Syntax :=\n let nesting := mkNullNode (mkArray nesting (mkAtom \"$\"))\n let term :=\n if term.isIdent then term\n else if term.isOfKind `Lean.Parser.Term.hole then term[0]\n else mkNode `antiquotNestedExpr #[mkAtom \"(\", term, mkAtom \")\"]\n let name := match name with\n | some name => mkNode `antiquotName #[mkAtom \":\", mkAtom name]\n | none => mkNullNode\n mkNode (kind ++ (if isPseudoKind then `pseudo else Name.anonymous) ++ `antiquot) #[mkAtom \"$\", nesting, term, name]",
"start": [
477,
1
],
"end": [
486,
118
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isEscapedAntiquot",
"code": "def isEscapedAntiquot (stx : Syntax) : Bool :=\n !stx[1].getArgs.isEmpty",
"start": [
489,
1
],
"end": [
490,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.unescapeAntiquot",
"code": "def unescapeAntiquot (stx : Syntax) : Syntax :=\n if isAntiquot stx then\n stx.setArg 1 <| mkNullNode stx[1].getArgs.pop\n else\n stx",
"start": [
493,
1
],
"end": [
497,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getAntiquotTerm",
"code": "def getAntiquotTerm (stx : Syntax) : Syntax :=\n let e := if stx.isAntiquot then stx[2] else stx[3]\n if e.isIdent then e\n else if e.isAtom then mkNode `Lean.Parser.Term.hole #[e]\n else\n e[1]",
"start": [
500,
1
],
"end": [
506,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.antiquotKind?",
"code": "def antiquotKind? : Syntax → Option (SyntaxNodeKind × Bool)\n | .node _ (.str (.str k \"pseudo\") \"antiquot\") _ => (k, true)\n | .node _ (.str k \"antiquot\") _ => (k, false)\n | _ => none",
"start": [
508,
1
],
"end": [
512,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.antiquotKinds",
"code": "def antiquotKinds (stx : Syntax) : List (SyntaxNodeKind × Bool) :=\n if stx.isOfKind choiceKind then\n stx.getArgs.filterMap antiquotKind? |>.toList\n else\n match antiquotKind? stx with\n | some stx => [stx]\n | none => []",
"start": [
514,
1
],
"end": [
520,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.antiquotSpliceKind?",
"code": "def antiquotSpliceKind? : Syntax → Option SyntaxNodeKind\n | .node _ (.str k \"antiquot_scope\") _ => some k\n | _ => none",
"start": [
523,
1
],
"end": [
525,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isAntiquotSplice",
"code": "def isAntiquotSplice (stx : Syntax) : Bool :=\n antiquotSpliceKind? stx |>.isSome",
"start": [
527,
1
],
"end": [
528,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getAntiquotSpliceContents",
"code": "def getAntiquotSpliceContents (stx : Syntax) : Array Syntax :=\n stx[3].getArgs",
"start": [
530,
1
],
"end": [
531,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getAntiquotSpliceSuffix",
"code": "def getAntiquotSpliceSuffix (stx : Syntax) : Syntax :=\n if stx.isAntiquotSplice then\n stx[5]\n else\n stx[1]",
"start": [
534,
1
],
"end": [
538,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.mkAntiquotSpliceNode",
"code": "def mkAntiquotSpliceNode (kind : SyntaxNodeKind) (contents : Array Syntax) (suffix : String) (nesting := 0) : Syntax :=\n let nesting := mkNullNode (mkArray nesting (mkAtom \"$\"))\n mkNode (kind ++ `antiquot_splice) #[mkAtom \"$\", nesting, mkAtom \"[\", mkNullNode contents, mkAtom \"]\", mkAtom suffix]",
"start": [
540,
1
],
"end": [
542,
119
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.antiquotSuffixSplice?",
"code": "def antiquotSuffixSplice? : Syntax → Option SyntaxNodeKind\n | .node _ (.str k \"antiquot_suffix_splice\") _ => some k\n | _ => none",
"start": [
545,
1
],
"end": [
547,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isAntiquotSuffixSplice",
"code": "def isAntiquotSuffixSplice (stx : Syntax) : Bool :=\n antiquotSuffixSplice? stx |>.isSome",
"start": [
549,
1
],
"end": [
550,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.getAntiquotSuffixSpliceInner",
"code": "def getAntiquotSuffixSpliceInner (stx : Syntax) : Syntax :=\n stx[0]",
"start": [
553,
1
],
"end": [
554,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.mkAntiquotSuffixSpliceNode",
"code": "def mkAntiquotSuffixSpliceNode (kind : SyntaxNodeKind) (inner : Syntax) (suffix : String) : Syntax :=\n mkNode (kind ++ `antiquot_suffix_splice) #[inner, mkAtom suffix]",
"start": [
556,
1
],
"end": [
557,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isTokenAntiquot",
"code": "def isTokenAntiquot (stx : Syntax) : Bool :=\n stx.isOfKind `token_antiquot",
"start": [
559,
1
],
"end": [
560,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.isAnyAntiquot",
"code": "def isAnyAntiquot (stx : Syntax) : Bool :=\n stx.isAntiquot || stx.isAntiquotSplice || stx.isAntiquotSuffixSplice || stx.isTokenAntiquot",
"start": [
562,
1
],
"end": [
563,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Stack",
"code": "protected abbrev Stack := List (Syntax × Nat)",
"start": [
565,
1
],
"end": [
568,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.findStack?",
"code": "partial def findStack? (root : Syntax) (visit : Syntax → Bool) (accept : Syntax → Bool := fun stx => !stx.hasArgs) : Option Syntax.Stack :=\n if visit root then go [] root else none\nwhere\n go (stack : Syntax.Stack) (stx : Syntax) : Option Syntax.Stack := Id.run do\n if accept stx then\n return (stx, 0) :: stack for i in [0:stx.getNumArgs] do\n if visit stx[i] then\n if let some stack := go ((stx, i) :: stack) stx[i] then\n return stack\n return none",
"start": [
570,
1
],
"end": [
581,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Syntax.Stack.matches",
"code": "def Stack.matches (stack : Syntax.Stack) (pattern : List $ Option SyntaxNodeKind) : Bool :=\n stack.length >= pattern.length &&\n (stack\n |>.zipWith (fun (s, _) p => p |>.map (s.isOfKind ·) |>.getD true) pattern\n |>.all id)",
"start": [
583,
1
],
"end": [
589,
15
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Int/Pow.lean | [
".lake/packages/lean4/src/lean/Init/Data/Int/Lemmas.lean"
] | [
{
"full_name": "Int.pow_zero",
"code": "protected theorem pow_zero (b : Int) : b^0 = 1",
"start": [
13,
1
],
"end": [
13,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.pow_succ",
"code": "protected theorem pow_succ (b : Int) (e : Nat) : b ^ (e+1) = (b ^ e) * b",
"start": [
15,
1
],
"end": [
15,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.pow_succ'",
"code": "protected theorem pow_succ' (b : Int) (e : Nat) : b ^ (e+1) = b * (b ^ e)",
"start": [
16,
1
],
"end": [
17,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.pow_le_pow_of_le_left",
"code": "theorem pow_le_pow_of_le_left {n m : Nat} (h : n ≤ m) : ∀ (i : Nat), n^i ≤ m^i",
"start": [
19,
1
],
"end": [
21,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.pow_le_pow_of_le_right",
"code": "theorem pow_le_pow_of_le_right {n : Nat} (hx : n > 0) {i : Nat} : ∀ {j}, i ≤ j → n^i ≤ n^j",
"start": [
23,
1
],
"end": [
33,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.pos_pow_of_pos",
"code": "theorem pos_pow_of_pos {n : Nat} (m : Nat) (h : 0 < n) : 0 < n^m",
"start": [
35,
1
],
"end": [
36,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.natCast_pow",
"code": "theorem natCast_pow (b n : Nat) : ((b^n : Nat) : Int) = (b : Int) ^ n",
"start": [
38,
1
],
"end": [
42,
73
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Nat/Simproc.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/Bool.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/Lemmas.lean"
] | [
{
"full_name": "Nat.Simproc.sub_add_eq_comm",
"code": "theorem sub_add_eq_comm (a b c : Nat) : a - (b + c) = a - c - b",
"start": [
19,
1
],
"end": [
21,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_sub_add_le",
"code": "theorem add_sub_add_le (a c : Nat) {b d : Nat} (h : b ≤ d) : a + b - (c + d) = a - (c + (d-b))",
"start": [
23,
1
],
"end": [
34,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_sub_add_ge",
"code": "theorem add_sub_add_ge (a c : Nat) {b d : Nat} (h : b ≥ d) : a + b - (c + d) = a + (b - d) - c",
"start": [
36,
1
],
"end": [
37,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_sub_le",
"code": "theorem add_sub_le (a : Nat) {b c : Nat} (h : b ≤ c) : a + b - c = a - (c - b)",
"start": [
39,
1
],
"end": [
42,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_eq_gt",
"code": "theorem add_eq_gt (a : Nat) {b c : Nat} (h : b > c) : (a + b = c) = False",
"start": [
46,
1
],
"end": [
47,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.eq_add_gt",
"code": "theorem eq_add_gt (a : Nat) {b c : Nat} (h : c > a) : (a = b + c) = False",
"start": [
49,
1
],
"end": [
51,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_eq_add_le",
"code": "theorem add_eq_add_le (a c : Nat) {b d : Nat} (h : b ≤ d) : (a + b = c + d) = (a = c + (d - b))",
"start": [
53,
1
],
"end": [
55,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_eq_add_ge",
"code": "theorem add_eq_add_ge (a c : Nat) {b d : Nat} (h : b ≥ d) : (a + b = c + d) = (a + (b - d) = c)",
"start": [
57,
1
],
"end": [
58,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_eq_le",
"code": "theorem add_eq_le (a : Nat) {b c : Nat} (h : b ≤ c) : (a + b = c) = (a = c - b)",
"start": [
60,
1
],
"end": [
63,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.eq_add_le",
"code": "theorem eq_add_le {a : Nat} (b : Nat) {c : Nat} (h : c ≤ a) : (a = b + c) = (b = a - c)",
"start": [
65,
1
],
"end": [
67,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.beqEqOfEqEq",
"code": "theorem beqEqOfEqEq {a b c d : Nat} (p : (a = b) = (c = d)) : (a == b) = (c == d)",
"start": [
71,
1
],
"end": [
72,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.beqFalseOfEqFalse",
"code": "theorem beqFalseOfEqFalse {a b : Nat} (p : (a = b) = False) : (a == b) = false",
"start": [
74,
1
],
"end": [
75,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.bneEqOfEqEq",
"code": "theorem bneEqOfEqEq {a b c d : Nat} (p : (a = b) = (c = d)) : (a != b) = (c != d)",
"start": [
77,
1
],
"end": [
78,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.bneTrueOfEqFalse",
"code": "theorem bneTrueOfEqFalse {a b : Nat} (p : (a = b) = False) : (a != b) = true",
"start": [
80,
1
],
"end": [
81,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_le_add_le",
"code": "theorem add_le_add_le (a c : Nat) {b d : Nat} (h : b ≤ d) : (a + b ≤ c + d) = (a ≤ c + (d - b))",
"start": [
85,
1
],
"end": [
87,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_le_add_ge",
"code": "theorem add_le_add_ge (a c : Nat) {b d : Nat} (h : b ≥ d) : (a + b ≤ c + d) = (a + (b - d) ≤ c)",
"start": [
89,
1
],
"end": [
90,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_le_le",
"code": "theorem add_le_le (a : Nat) {b c : Nat} (h : b ≤ c) : (a + b ≤ c) = (a ≤ c - b)",
"start": [
92,
1
],
"end": [
95,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.add_le_gt",
"code": "theorem add_le_gt (a : Nat) {b c : Nat} (h : b > c) : (a + b ≤ c) = False",
"start": [
97,
1
],
"end": [
98,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.le_add_le",
"code": "theorem le_add_le (a : Nat) {b c : Nat} (h : a ≤ c) : (a ≤ b + c) = True",
"start": [
100,
1
],
"end": [
101,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.Simproc.le_add_ge",
"code": "theorem le_add_ge (a : Nat) {b c : Nat} (h : a ≥ c) : (a ≤ b + c) = (a - c ≤ b)",
"start": [
103,
1
],
"end": [
106,
10
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Expr.lean | [
".lake/packages/lean4/src/lean/Lean/Data/KVMap.lean",
".lake/packages/lean4/src/lean/Init/Data/Hashable.lean",
".lake/packages/lean4/src/lean/Lean/Level.lean",
".lake/packages/lean4/src/lean/Lean/Data/SMap.lean"
] | [
{
"full_name": "Lean.Literal",
"code": "inductive Literal where\n \n | natVal (val : Nat)\n \n | strVal (val : String)\n deriving Inhabited, BEq, Repr",
"start": [
14,
1
],
"end": [
20,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Literal.hash",
"code": "protected def Literal.hash : Literal → UInt64\n | .natVal v => hash v\n | .strVal v => hash v",
"start": [
22,
1
],
"end": [
24,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Literal.lt",
"code": "def Literal.lt : Literal → Literal → Bool\n | .natVal _, .strVal _ => true\n | .natVal v₁, .natVal v₂ => v₁ < v₂\n | .strVal v₁, .strVal v₂ => v₁ < v₂\n | _, _ => false",
"start": [
28,
1
],
"end": [
36,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo",
"code": "inductive BinderInfo where\n \n | default\n \n | implicit\n \n | strictImplicit\n \n | instImplicit\n deriving Inhabited, BEq, Repr",
"start": [
43,
1
],
"end": [
77,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo.hash",
"code": "def BinderInfo.hash : BinderInfo → UInt64\n | .default => 947\n | .implicit => 1019\n | .strictImplicit => 1087\n | .instImplicit => 1153",
"start": [
79,
1
],
"end": [
83,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo.isExplicit",
"code": "def BinderInfo.isExplicit : BinderInfo → Bool\n | .implicit => false\n | .strictImplicit => false\n | .instImplicit => false\n | _ => true",
"start": [
85,
1
],
"end": [
93,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo.isInstImplicit",
"code": "def BinderInfo.isInstImplicit : BinderInfo → Bool\n | BinderInfo.instImplicit => true\n | _ => false",
"start": [
97,
1
],
"end": [
100,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo.isImplicit",
"code": "def BinderInfo.isImplicit : BinderInfo → Bool\n | BinderInfo.implicit => true\n | _ => false",
"start": [
102,
1
],
"end": [
105,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo.isStrictImplicit",
"code": "def BinderInfo.isStrictImplicit : BinderInfo → Bool\n | BinderInfo.strictImplicit => true\n | _ => false",
"start": [
107,
1
],
"end": [
110,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MData",
"code": "abbrev MData := KVMap",
"start": [
112,
1
],
"end": [
113,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MData.empty",
"code": "abbrev MData.empty : MData := {}",
"start": [
114,
1
],
"end": [
114,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data",
"code": "def Expr.Data := UInt64",
"start": [
116,
1
],
"end": [
129,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.hash",
"code": "def Expr.Data.hash (c : Expr.Data) : UInt64 :=\n c.toUInt32.toUInt64",
"start": [
134,
1
],
"end": [
135,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.approxDepth",
"code": "def Expr.Data.approxDepth (c : Expr.Data) : UInt8 :=\n ((c.shiftRight 32).land 255).toUInt8",
"start": [
140,
1
],
"end": [
141,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.looseBVarRange",
"code": "def Expr.Data.looseBVarRange (c : Expr.Data) : UInt32 :=\n (c.shiftRight 44).toUInt32",
"start": [
143,
1
],
"end": [
144,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.hasFVar",
"code": "def Expr.Data.hasFVar (c : Expr.Data) : Bool :=\n ((c.shiftRight 40).land 1) == 1",
"start": [
146,
1
],
"end": [
147,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.hasExprMVar",
"code": "def Expr.Data.hasExprMVar (c : Expr.Data) : Bool :=\n ((c.shiftRight 41).land 1) == 1",
"start": [
149,
1
],
"end": [
150,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.hasLevelMVar",
"code": "def Expr.Data.hasLevelMVar (c : Expr.Data) : Bool :=\n ((c.shiftRight 42).land 1) == 1",
"start": [
152,
1
],
"end": [
153,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.Data.hasLevelParam",
"code": "def Expr.Data.hasLevelParam (c : Expr.Data) : Bool :=\n ((c.shiftRight 43).land 1) == 1",
"start": [
155,
1
],
"end": [
156,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BinderInfo.toUInt64",
"code": "@[extern \"lean_uint8_to_uint64\"]\ndef BinderInfo.toUInt64 : BinderInfo → UInt64\n | .default => 0\n | .implicit => 1\n | .strictImplicit => 2\n | .instImplicit => 3",
"start": [
160,
1
],
"end": [
165,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mkData",
"code": "def Expr.mkData\n (h : UInt64) (looseBVarRange : Nat := 0) (approxDepth : UInt32 := 0)\n (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool := false)\n : Expr.Data :=\n let approxDepth : UInt8 := if approxDepth > 255 then 255 else approxDepth.toUInt8\n assert! (looseBVarRange ≤ Nat.pow 2 20 - 1)\n let r : UInt64 :=\n h.toUInt32.toUInt64 +\n approxDepth.toUInt64.shiftLeft 32 +\n hasFVar.toUInt64.shiftLeft 40 +\n hasExprMVar.toUInt64.shiftLeft 41 +\n hasLevelMVar.toUInt64.shiftLeft 42 +\n hasLevelParam.toUInt64.shiftLeft 43 +\n looseBVarRange.toUInt64.shiftLeft 44\n r",
"start": [
167,
1
],
"end": [
181,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mkAppData",
"code": "@[inline] def Expr.mkAppData (fData : Data) (aData : Data) : Data :=\n let depth := (max fData.approxDepth.toUInt16 aData.approxDepth.toUInt16) + 1\n let approxDepth := if depth > 255 then 255 else depth.toUInt8\n let looseBVarRange := max fData.looseBVarRange aData.looseBVarRange\n let hash := mixHash fData aData\n let fData : UInt64 := fData\n let aData : UInt64 := aData\n assert! (looseBVarRange ≤ (Nat.pow 2 20 - 1).toUInt32)\n ((fData ||| aData) &&& ((15 : UInt64) <<< (40 : UInt64))) ||| hash.toUInt32.toUInt64 ||| (approxDepth.toUInt64 <<< (32 : UInt64)) ||| (looseBVarRange.toUInt64 <<< (44 : UInt64))",
"start": [
183,
1
],
"end": [
192,
180
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mkDataForBinder",
"code": "@[inline] def Expr.mkDataForBinder (h : UInt64) (looseBVarRange : Nat) (approxDepth : UInt32) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool) : Expr.Data :=\n Expr.mkData h looseBVarRange approxDepth hasFVar hasExprMVar hasLevelMVar hasLevelParam",
"start": [
194,
1
],
"end": [
195,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mkDataForLet",
"code": "@[inline] def Expr.mkDataForLet (h : UInt64) (looseBVarRange : Nat) (approxDepth : UInt32) (hasFVar hasExprMVar hasLevelMVar hasLevelParam : Bool) : Expr.Data :=\n Expr.mkData h looseBVarRange approxDepth hasFVar hasExprMVar hasLevelMVar hasLevelParam",
"start": [
197,
1
],
"end": [
198,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId",
"code": "structure FVarId where\n name : Name\n deriving Inhabited, BEq, Hashable",
"start": [
217,
1
],
"end": [
227,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarIdSet",
"code": "def FVarIdSet := RBTree FVarId (Name.quickCmp ·.name ·.name)\n deriving Inhabited, EmptyCollection",
"start": [
232,
1
],
"end": [
236,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarIdSet.insert",
"code": "def FVarIdSet.insert (s : FVarIdSet) (fvarId : FVarId) : FVarIdSet :=\n RBTree.insert s fvarId",
"start": [
240,
1
],
"end": [
241,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarIdHashSet",
"code": "def FVarIdHashSet := HashSet FVarId\n deriving Inhabited, EmptyCollection",
"start": [
243,
1
],
"end": [
248,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarIdMap",
"code": "def FVarIdMap (α : Type) := RBMap FVarId α (Name.quickCmp ·.name ·.name)",
"start": [
250,
1
],
"end": [
253,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarIdMap.insert",
"code": "def FVarIdMap.insert (s : FVarIdMap α) (fvarId : FVarId) (a : α) : FVarIdMap α :=\n RBMap.insert s fvarId a",
"start": [
255,
1
],
"end": [
256,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId",
"code": "structure MVarId where\n name : Name\n deriving Inhabited, BEq, Hashable, Repr",
"start": [
263,
1
],
"end": [
266,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarIdSet",
"code": "def MVarIdSet := RBTree MVarId (Name.quickCmp ·.name ·.name)\n deriving Inhabited, EmptyCollection",
"start": [
271,
1
],
"end": [
272,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarIdSet.insert",
"code": "def MVarIdSet.insert (s : MVarIdSet) (mvarId : MVarId) : MVarIdSet :=\n RBTree.insert s mvarId",
"start": [
274,
1
],
"end": [
275,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarIdMap",
"code": "def MVarIdMap (α : Type) := RBMap MVarId α (Name.quickCmp ·.name ·.name)",
"start": [
279,
1
],
"end": [
279,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarIdMap.insert",
"code": "def MVarIdMap.insert (s : MVarIdMap α) (mvarId : MVarId) (a : α) : MVarIdMap α :=\n RBMap.insert s mvarId a",
"start": [
281,
1
],
"end": [
282,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr",
"code": "inductive Expr where\n \n | bvar (deBruijnIndex : Nat)\n\n \n | fvar (fvarId : FVarId)\n\n \n | mvar (mvarId : MVarId)\n\n \n | sort (u : Level)\n\n \n | const (declName : Name) (us : List Level)\n\n \n | app (fn : Expr) (arg : Expr)\n\n \n | lam (binderName : Name) (binderType : Expr) (body : Expr) (binderInfo : BinderInfo)\n\n \n | forallE (binderName : Name) (binderType : Expr) (body : Expr) (binderInfo : BinderInfo)\n\n \n | letE (declName : Name) (type : Expr) (value : Expr) (body : Expr) (nonDep : Bool)\n\n \n | lit : Literal → Expr\n\n \n | mdata (data : MData) (expr : Expr)\n\n \n | proj (typeName : Name) (idx : Nat) (struct : Expr)\nwith\n @[computed_field, extern \"lean_expr_data\"]\n data : @& Expr → Data\n | .const n lvls => mkData (mixHash 5 <| mixHash (hash n) (hash lvls)) 0 0 false false (lvls.any Level.hasMVar) (lvls.any Level.hasParam)\n | .bvar idx => mkData (mixHash 7 <| hash idx) (idx+1)\n | .sort lvl => mkData (mixHash 11 <| hash lvl) 0 0 false false lvl.hasMVar lvl.hasParam\n | .fvar fvarId => mkData (mixHash 13 <| hash fvarId) 0 0 true\n | .mvar fvarId => mkData (mixHash 17 <| hash fvarId) 0 0 false true\n | .mdata _m e =>\n let d := e.data.approxDepth.toUInt32+1\n mkData (mixHash d.toUInt64 <| e.data.hash) e.data.looseBVarRange.toNat d e.data.hasFVar e.data.hasExprMVar e.data.hasLevelMVar e.data.hasLevelParam\n | .proj s i e =>\n let d := e.data.approxDepth.toUInt32+1\n mkData (mixHash d.toUInt64 <| mixHash (hash s) <| mixHash (hash i) e.data.hash)\n e.data.looseBVarRange.toNat d e.data.hasFVar e.data.hasExprMVar e.data.hasLevelMVar e.data.hasLevelParam\n | .app f a => mkAppData f.data a.data\n | .lam _ t b _ =>\n let d := (max t.data.approxDepth.toUInt32 b.data.approxDepth.toUInt32) + 1\n mkDataForBinder (mixHash d.toUInt64 <| mixHash t.data.hash b.data.hash)\n (max t.data.looseBVarRange.toNat (b.data.looseBVarRange.toNat - 1))\n d\n (t.data.hasFVar || b.data.hasFVar)\n (t.data.hasExprMVar || b.data.hasExprMVar)\n (t.data.hasLevelMVar || b.data.hasLevelMVar)\n (t.data.hasLevelParam || b.data.hasLevelParam)\n | .forallE _ t b _ =>\n let d := (max t.data.approxDepth.toUInt32 b.data.approxDepth.toUInt32) + 1\n mkDataForBinder (mixHash d.toUInt64 <| mixHash t.data.hash b.data.hash)\n (max t.data.looseBVarRange.toNat (b.data.looseBVarRange.toNat - 1))\n d\n (t.data.hasFVar || b.data.hasFVar)\n (t.data.hasExprMVar || b.data.hasExprMVar)\n (t.data.hasLevelMVar || b.data.hasLevelMVar)\n (t.data.hasLevelParam || b.data.hasLevelParam)\n | .letE _ t v b _ =>\n let d := (max (max t.data.approxDepth.toUInt32 v.data.approxDepth.toUInt32) b.data.approxDepth.toUInt32) + 1\n mkDataForLet (mixHash d.toUInt64 <| mixHash t.data.hash <| mixHash v.data.hash b.data.hash)\n (max (max t.data.looseBVarRange.toNat v.data.looseBVarRange.toNat) (b.data.looseBVarRange.toNat - 1))\n d\n (t.data.hasFVar || v.data.hasFVar || b.data.hasFVar)\n (t.data.hasExprMVar || v.data.hasExprMVar || b.data.hasExprMVar)\n (t.data.hasLevelMVar || v.data.hasLevelMVar || b.data.hasLevelMVar)\n (t.data.hasLevelParam || v.data.hasLevelParam || b.data.hasLevelParam)\n | .lit l => mkData (mixHash 3 (hash l))\nderiving Inhabited, Repr",
"start": [
291,
1
],
"end": [
510,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ctorName",
"code": "def ctorName : Expr → String\n | bvar .. => \"bvar\"\n | fvar .. => \"fvar\"\n | mvar .. => \"mvar\"\n | sort .. => \"sort\"\n | const .. => \"const\"\n | app .. => \"app\"\n | lam .. => \"lam\"\n | forallE .. => \"forallE\"\n | letE .. => \"letE\"\n | lit .. => \"lit\"\n | mdata .. => \"mdata\"\n | proj .. => \"proj\"",
"start": [
514,
1
],
"end": [
527,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hash",
"code": "protected def hash (e : Expr) : UInt64 :=\n e.data.hash",
"start": [
529,
1
],
"end": [
530,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasFVar",
"code": "def hasFVar (e : Expr) : Bool :=\n e.data.hasFVar",
"start": [
534,
1
],
"end": [
539,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasExprMVar",
"code": "def hasExprMVar (e : Expr) : Bool :=\n e.data.hasExprMVar",
"start": [
541,
1
],
"end": [
546,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLevelMVar",
"code": "def hasLevelMVar (e : Expr) : Bool :=\n e.data.hasLevelMVar",
"start": [
548,
1
],
"end": [
553,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasMVar",
"code": "def hasMVar (e : Expr) : Bool :=\n let d := e.data\n d.hasExprMVar || d.hasLevelMVar",
"start": [
555,
1
],
"end": [
561,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLevelParam",
"code": "def hasLevelParam (e : Expr) : Bool :=\n e.data.hasLevelParam",
"start": [
563,
1
],
"end": [
568,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.approxDepth",
"code": "def approxDepth (e : Expr) : UInt32 :=\n e.data.approxDepth.toUInt32",
"start": [
570,
1
],
"end": [
576,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.looseBVarRange",
"code": "def looseBVarRange (e : Expr) : Nat :=\n e.data.looseBVarRange.toNat",
"start": [
578,
1
],
"end": [
585,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.binderInfo",
"code": "def binderInfo (e : Expr) : BinderInfo :=\n match e with\n | .forallE _ _ _ bi => bi\n | .lam _ _ _ bi => bi\n | _ => .default",
"start": [
587,
1
],
"end": [
594,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hashEx",
"code": "@[export lean_expr_hash] def hashEx : Expr → UInt64 := hash",
"start": [
599,
1
],
"end": [
599,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasFVarEx",
"code": "@[export lean_expr_has_fvar] def hasFVarEx : Expr → Bool := hasFVar",
"start": [
600,
1
],
"end": [
600,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasExprMVarEx",
"code": "@[export lean_expr_has_expr_mvar] def hasExprMVarEx : Expr → Bool := hasExprMVar",
"start": [
601,
1
],
"end": [
601,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLevelMVarEx",
"code": "@[export lean_expr_has_level_mvar] def hasLevelMVarEx : Expr → Bool := hasLevelMVar",
"start": [
602,
1
],
"end": [
602,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasMVarEx",
"code": "@[export lean_expr_has_mvar] def hasMVarEx : Expr → Bool := hasMVar",
"start": [
603,
1
],
"end": [
603,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLevelParamEx",
"code": "@[export lean_expr_has_level_param] def hasLevelParamEx : Expr → Bool := hasLevelParam",
"start": [
604,
1
],
"end": [
604,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.looseBVarRangeEx",
"code": "@[export lean_expr_loose_bvar_range] def looseBVarRangeEx (e : Expr) : UInt32 := e.data.looseBVarRange",
"start": [
605,
1
],
"end": [
605,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.binderInfoEx",
"code": "@[export lean_expr_binder_info] def binderInfoEx : Expr → BinderInfo := binderInfo",
"start": [
606,
1
],
"end": [
606,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkConst",
"code": "def mkConst (declName : Name) (us : List Level := []) : Expr :=\n .const declName us",
"start": [
610,
1
],
"end": [
612,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Literal.type",
"code": "def Literal.type : Literal → Expr\n | .natVal _ => mkConst `Nat\n | .strVal _ => mkConst `String",
"start": [
614,
1
],
"end": [
617,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Literal.typeEx",
"code": "@[export lean_lit_type]\ndef Literal.typeEx : Literal → Expr := Literal.type",
"start": [
619,
1
],
"end": [
620,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkBVar",
"code": "def mkBVar (idx : Nat) : Expr :=\n .bvar idx",
"start": [
622,
1
],
"end": [
624,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkSort",
"code": "def mkSort (u : Level) : Expr :=\n .sort u",
"start": [
626,
1
],
"end": [
628,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkFVar",
"code": "def mkFVar (fvarId : FVarId) : Expr :=\n .fvar fvarId",
"start": [
630,
1
],
"end": [
636,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkMVar",
"code": "def mkMVar (mvarId : MVarId) : Expr :=\n .mvar mvarId",
"start": [
638,
1
],
"end": [
644,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkMData",
"code": "def mkMData (m : MData) (e : Expr) : Expr :=\n .mdata m e",
"start": [
646,
1
],
"end": [
650,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkProj",
"code": "def mkProj (structName : Name) (idx : Nat) (struct : Expr) : Expr :=\n .proj structName idx struct",
"start": [
652,
1
],
"end": [
656,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp",
"code": "@[match_pattern] def mkApp (f a : Expr) : Expr :=\n .app f a",
"start": [
658,
1
],
"end": [
662,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLambda",
"code": "def mkLambda (x : Name) (bi : BinderInfo) (t : Expr) (b : Expr) : Expr :=\n .lam x t b bi",
"start": [
664,
1
],
"end": [
668,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkForall",
"code": "def mkForall (x : Name) (bi : BinderInfo) (t : Expr) (b : Expr) : Expr :=\n .forallE x t b bi",
"start": [
670,
1
],
"end": [
674,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkSimpleThunkType",
"code": "def mkSimpleThunkType (type : Expr) : Expr :=\n mkForall Name.anonymous .default (mkConst `Unit) type",
"start": [
676,
1
],
"end": [
678,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkSimpleThunk",
"code": "def mkSimpleThunk (type : Expr) : Expr :=\n mkLambda `_ BinderInfo.default (mkConst `Unit) type",
"start": [
680,
1
],
"end": [
682,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLet",
"code": "def mkLet (x : Name) (t : Expr) (v : Expr) (b : Expr) (nonDep : Bool := false) : Expr :=\n .letE x t v b nonDep",
"start": [
684,
1
],
"end": [
688,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAppB",
"code": "@[match_pattern] def mkAppB (f a b : Expr) := mkApp (mkApp f a) b",
"start": [
690,
1
],
"end": [
690,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp2",
"code": "@[match_pattern] def mkApp2 (f a b : Expr) := mkAppB f a b",
"start": [
691,
1
],
"end": [
691,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp3",
"code": "@[match_pattern] def mkApp3 (f a b c : Expr) := mkApp (mkAppB f a b) c",
"start": [
692,
1
],
"end": [
692,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp4",
"code": "@[match_pattern] def mkApp4 (f a b c d : Expr) := mkAppB (mkAppB f a b) c d",
"start": [
693,
1
],
"end": [
693,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp5",
"code": "@[match_pattern] def mkApp5 (f a b c d e : Expr) := mkApp (mkApp4 f a b c d) e",
"start": [
694,
1
],
"end": [
694,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp6",
"code": "@[match_pattern] def mkApp6 (f a b c d e₁ e₂ : Expr) := mkAppB (mkApp4 f a b c d) e₁ e₂",
"start": [
695,
1
],
"end": [
695,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp7",
"code": "@[match_pattern] def mkApp7 (f a b c d e₁ e₂ e₃ : Expr) := mkApp3 (mkApp4 f a b c d) e₁ e₂ e₃",
"start": [
696,
1
],
"end": [
696,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp8",
"code": "@[match_pattern] def mkApp8 (f a b c d e₁ e₂ e₃ e₄ : Expr) := mkApp4 (mkApp4 f a b c d) e₁ e₂ e₃ e₄",
"start": [
697,
1
],
"end": [
697,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp9",
"code": "@[match_pattern] def mkApp9 (f a b c d e₁ e₂ e₃ e₄ e₅ : Expr) := mkApp5 (mkApp4 f a b c d) e₁ e₂ e₃ e₄ e₅",
"start": [
698,
1
],
"end": [
698,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkApp10",
"code": "@[match_pattern] def mkApp10 (f a b c d e₁ e₂ e₃ e₄ e₅ e₆ : Expr) := mkApp6 (mkApp4 f a b c d) e₁ e₂ e₃ e₄ e₅ e₆",
"start": [
699,
1
],
"end": [
699,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLit",
"code": "def mkLit (l : Literal) : Expr :=\n .lit l",
"start": [
701,
1
],
"end": [
705,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkRawNatLit",
"code": "def mkRawNatLit (n : Nat) : Expr :=\n mkLit (.natVal n)",
"start": [
707,
1
],
"end": [
713,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatLit",
"code": "def mkNatLit (n : Nat) : Expr :=\n let r := mkRawNatLit n\n mkApp3 (mkConst ``OfNat.ofNat [levelZero]) (mkConst ``Nat) r (mkApp (mkConst ``instOfNatNat) r)",
"start": [
715,
1
],
"end": [
722,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkStrLit",
"code": "def mkStrLit (s : String) : Expr :=\n mkLit (.strVal s)",
"start": [
724,
1
],
"end": [
726,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkBVarEx",
"code": "@[export lean_expr_mk_bvar] def mkBVarEx : Nat → Expr := mkBVar",
"start": [
728,
1
],
"end": [
728,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkFVarEx",
"code": "@[export lean_expr_mk_fvar] def mkFVarEx : FVarId → Expr := mkFVar",
"start": [
729,
1
],
"end": [
729,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkMVarEx",
"code": "@[export lean_expr_mk_mvar] def mkMVarEx : MVarId → Expr := mkMVar",
"start": [
730,
1
],
"end": [
730,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkSortEx",
"code": "@[export lean_expr_mk_sort] def mkSortEx : Level → Expr := mkSort",
"start": [
731,
1
],
"end": [
731,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkConstEx",
"code": "@[export lean_expr_mk_const] def mkConstEx (c : Name) (lvls : List Level) : Expr := mkConst c lvls",
"start": [
732,
1
],
"end": [
732,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAppEx",
"code": "@[export lean_expr_mk_app] def mkAppEx : Expr → Expr → Expr := mkApp",
"start": [
733,
1
],
"end": [
733,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLambdaEx",
"code": "@[export lean_expr_mk_lambda] def mkLambdaEx (n : Name) (d b : Expr) (bi : BinderInfo) : Expr := mkLambda n bi d b",
"start": [
734,
1
],
"end": [
734,
115
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkForallEx",
"code": "@[export lean_expr_mk_forall] def mkForallEx (n : Name) (d b : Expr) (bi : BinderInfo) : Expr := mkForall n bi d b",
"start": [
735,
1
],
"end": [
735,
115
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLetEx",
"code": "@[export lean_expr_mk_let] def mkLetEx (n : Name) (t v b : Expr) : Expr := mkLet n t v b",
"start": [
736,
1
],
"end": [
736,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLitEx",
"code": "@[export lean_expr_mk_lit] def mkLitEx : Literal → Expr := mkLit",
"start": [
737,
1
],
"end": [
737,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkMDataEx",
"code": "@[export lean_expr_mk_mdata] def mkMDataEx : MData → Expr → Expr := mkMData",
"start": [
738,
1
],
"end": [
738,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkProjEx",
"code": "@[export lean_expr_mk_proj] def mkProjEx : Name → Nat → Expr → Expr := mkProj",
"start": [
739,
1
],
"end": [
739,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAppN",
"code": "def mkAppN (f : Expr) (args : Array Expr) : Expr :=\n args.foldl mkApp f",
"start": [
741,
1
],
"end": [
745,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAppRangeAux",
"code": "private partial def mkAppRangeAux (n : Nat) (args : Array Expr) (i : Nat) (e : Expr) : Expr :=\n if i < n then mkAppRangeAux n args (i+1) (mkApp e (args.get! i)) else e",
"start": [
747,
1
],
"end": [
748,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAppRange",
"code": "def mkAppRange (f : Expr) (i j : Nat) (args : Array Expr) : Expr :=\n mkAppRangeAux j args i f",
"start": [
750,
1
],
"end": [
752,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAppRev",
"code": "def mkAppRev (fn : Expr) (revArgs : Array Expr) : Expr :=\n revArgs.foldr (fun a r => mkApp r a) fn",
"start": [
754,
1
],
"end": [
756,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.dbgToString",
"code": "@[extern \"lean_expr_dbg_to_string\"]\nopaque dbgToString (e : @& Expr) : String",
"start": [
760,
1
],
"end": [
761,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.quickLt",
"code": "@[extern \"lean_expr_quick_lt\"]\nopaque quickLt (a : @& Expr) (b : @& Expr) : Bool",
"start": [
763,
1
],
"end": [
765,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.lt",
"code": "@[extern \"lean_expr_lt\"]\nopaque lt (a : @& Expr) (b : @& Expr) : Bool",
"start": [
767,
1
],
"end": [
769,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.eqv",
"code": "@[extern \"lean_expr_eqv\"]\nopaque eqv (a : @& Expr) (b : @& Expr) : Bool",
"start": [
771,
1
],
"end": [
776,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.equal",
"code": "@[extern \"lean_expr_equal\"]\nopaque equal (a : @& Expr) (b : @& Expr) : Bool",
"start": [
781,
1
],
"end": [
786,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isSort",
"code": "def isSort : Expr → Bool\n | sort .. => true\n | _ => false",
"start": [
788,
1
],
"end": [
791,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isType",
"code": "def isType : Expr → Bool\n | sort (.succ ..) => true\n | _ => false",
"start": [
793,
1
],
"end": [
796,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isType0",
"code": "def isType0 : Expr → Bool\n | sort (.succ .zero) => true\n | _ => false",
"start": [
798,
1
],
"end": [
801,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isProp",
"code": "def isProp : Expr → Bool\n | sort .zero => true\n | _ => false",
"start": [
803,
1
],
"end": [
806,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isBVar",
"code": "def isBVar : Expr → Bool\n | bvar .. => true\n | _ => false",
"start": [
808,
1
],
"end": [
811,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isMVar",
"code": "def isMVar : Expr → Bool\n | mvar .. => true\n | _ => false",
"start": [
813,
1
],
"end": [
816,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isFVar",
"code": "def isFVar : Expr → Bool\n | fvar .. => true\n | _ => false",
"start": [
818,
1
],
"end": [
821,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isApp",
"code": "def isApp : Expr → Bool\n | app .. => true\n | _ => false",
"start": [
823,
1
],
"end": [
826,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isProj",
"code": "def isProj : Expr → Bool\n | proj .. => true\n | _ => false",
"start": [
828,
1
],
"end": [
831,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isConst",
"code": "def isConst : Expr → Bool\n | const .. => true\n | _ => false",
"start": [
833,
1
],
"end": [
836,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isConstOf",
"code": "def isConstOf : Expr → Name → Bool\n | const n .., m => n == m\n | _, _ => false",
"start": [
838,
1
],
"end": [
846,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isFVarOf",
"code": "def isFVarOf : Expr → FVarId → Bool\n | .fvar fvarId, fvarId' => fvarId == fvarId'\n | _, _ => false",
"start": [
848,
1
],
"end": [
857,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isForall",
"code": "def isForall : Expr → Bool\n | forallE .. => true\n | _ => false",
"start": [
859,
1
],
"end": [
862,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isLambda",
"code": "def isLambda : Expr → Bool\n | lam .. => true\n | _ => false",
"start": [
864,
1
],
"end": [
867,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isBinding",
"code": "def isBinding : Expr → Bool\n | lam .. => true\n | forallE .. => true\n | _ => false",
"start": [
869,
1
],
"end": [
873,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isLet",
"code": "def isLet : Expr → Bool\n | letE .. => true\n | _ => false",
"start": [
875,
1
],
"end": [
878,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isMData",
"code": "def isMData : Expr → Bool\n | mdata .. => true\n | _ => false",
"start": [
880,
1
],
"end": [
883,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isLit",
"code": "def isLit : Expr → Bool\n | lit .. => true\n | _ => false",
"start": [
885,
1
],
"end": [
888,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appFn!",
"code": "def appFn! : Expr → Expr\n | app f _ => f\n | _ => panic! \"application expected\"",
"start": [
890,
1
],
"end": [
892,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appArg!",
"code": "def appArg! : Expr → Expr\n | app _ a => a\n | _ => panic! \"application expected\"",
"start": [
894,
1
],
"end": [
896,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appFn!'",
"code": "def appFn!' : Expr → Expr\n | mdata _ b => appFn!' b\n | app f _ => f\n | _ => panic! \"application expected\"",
"start": [
898,
1
],
"end": [
901,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appArg!'",
"code": "def appArg!' : Expr → Expr\n | mdata _ b => appArg!' b\n | app _ a => a\n | _ => panic! \"application expected\"",
"start": [
903,
1
],
"end": [
906,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appArg",
"code": "def appArg (e : Expr) (h : e.isApp) : Expr :=\n match e, h with\n | .app _ a, _ => a",
"start": [
908,
1
],
"end": [
910,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appFn",
"code": "def appFn (e : Expr) (h : e.isApp) : Expr :=\n match e, h with\n | .app f _, _ => f",
"start": [
912,
1
],
"end": [
914,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.sortLevel!",
"code": "def sortLevel! : Expr → Level\n | sort u => u\n | _ => panic! \"sort expected\"",
"start": [
916,
1
],
"end": [
918,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.litValue!",
"code": "def litValue! : Expr → Literal\n | lit v => v\n | _ => panic! \"literal expected\"",
"start": [
920,
1
],
"end": [
922,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isRawNatLit",
"code": "def isRawNatLit : Expr → Bool\n | lit (Literal.natVal _) => true\n | _ => false",
"start": [
924,
1
],
"end": [
926,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.rawNatLit?",
"code": "def rawNatLit? : Expr → Option Nat\n | lit (Literal.natVal v) => v\n | _ => none",
"start": [
928,
1
],
"end": [
930,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isStringLit",
"code": "def isStringLit : Expr → Bool\n | lit (Literal.strVal _) => true\n | _ => false",
"start": [
932,
1
],
"end": [
934,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isCharLit",
"code": "def isCharLit : Expr → Bool\n | app (const c _) a => c == ``Char.ofNat && a.isRawNatLit\n | _ => false",
"start": [
936,
1
],
"end": [
938,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.constName!",
"code": "def constName! : Expr → Name\n | const n _ => n\n | _ => panic! \"constant expected\"",
"start": [
940,
1
],
"end": [
942,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.constName?",
"code": "def constName? : Expr → Option Name\n | const n _ => some n\n | _ => none",
"start": [
944,
1
],
"end": [
946,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.constName",
"code": "def constName (e : Expr) : Name :=\n e.constName?.getD Name.anonymous",
"start": [
948,
1
],
"end": [
950,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.constLevels!",
"code": "def constLevels! : Expr → List Level\n | const _ ls => ls\n | _ => panic! \"constant expected\"",
"start": [
952,
1
],
"end": [
954,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.bvarIdx!",
"code": "def bvarIdx! : Expr → Nat\n | bvar idx => idx\n | _ => panic! \"bvar expected\"",
"start": [
956,
1
],
"end": [
958,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.fvarId!",
"code": "def fvarId! : Expr → FVarId\n | fvar n => n\n | _ => panic! \"fvar expected\"",
"start": [
960,
1
],
"end": [
962,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mvarId!",
"code": "def mvarId! : Expr → MVarId\n | mvar n => n\n | _ => panic! \"mvar expected\"",
"start": [
964,
1
],
"end": [
966,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.bindingName!",
"code": "def bindingName! : Expr → Name\n | forallE n _ _ _ => n\n | lam n _ _ _ => n\n | _ => panic! \"binding expected\"",
"start": [
968,
1
],
"end": [
971,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.bindingDomain!",
"code": "def bindingDomain! : Expr → Expr\n | forallE _ d _ _ => d\n | lam _ d _ _ => d\n | _ => panic! \"binding expected\"",
"start": [
973,
1
],
"end": [
976,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.bindingBody!",
"code": "def bindingBody! : Expr → Expr\n | forallE _ _ b _ => b\n | lam _ _ b _ => b\n | _ => panic! \"binding expected\"",
"start": [
978,
1
],
"end": [
981,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.bindingInfo!",
"code": "def bindingInfo! : Expr → BinderInfo\n | forallE _ _ _ bi => bi\n | lam _ _ _ bi => bi\n | _ => panic! \"binding expected\"",
"start": [
983,
1
],
"end": [
986,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.letName!",
"code": "def letName! : Expr → Name\n | letE n .. => n\n | _ => panic! \"let expression expected\"",
"start": [
988,
1
],
"end": [
990,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.letType!",
"code": "def letType! : Expr → Expr\n | letE _ t .. => t\n | _ => panic! \"let expression expected\"",
"start": [
992,
1
],
"end": [
994,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.letValue!",
"code": "def letValue! : Expr → Expr\n | letE _ _ v .. => v\n | _ => panic! \"let expression expected\"",
"start": [
996,
1
],
"end": [
998,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.letBody!",
"code": "def letBody! : Expr → Expr\n | letE _ _ _ b .. => b\n | _ => panic! \"let expression expected\"",
"start": [
1000,
1
],
"end": [
1002,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.consumeMData",
"code": "def consumeMData : Expr → Expr\n | mdata _ e => consumeMData e\n | e => e",
"start": [
1004,
1
],
"end": [
1006,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mdataExpr!",
"code": "def mdataExpr! : Expr → Expr\n | mdata _ e => e\n | _ => panic! \"mdata expression expected\"",
"start": [
1008,
1
],
"end": [
1010,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.projExpr!",
"code": "def projExpr! : Expr → Expr\n | proj _ _ e => e\n | _ => panic! \"proj expression expected\"",
"start": [
1012,
1
],
"end": [
1014,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.projIdx!",
"code": "def projIdx! : Expr → Nat\n | proj _ i _ => i\n | _ => panic! \"proj expression expected\"",
"start": [
1016,
1
],
"end": [
1018,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getForallBody",
"code": "def getForallBody : Expr → Expr\n | forallE _ _ b .. => getForallBody b\n | e => e",
"start": [
1020,
1
],
"end": [
1027,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getForallBodyMaxDepth",
"code": "def getForallBodyMaxDepth : (maxDepth : Nat) → Expr → Expr\n | (n+1), forallE _ _ b _ => getForallBodyMaxDepth n b\n | 0, e => e\n | _, e => e",
"start": [
1029,
1
],
"end": [
1032,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getForallBinderNames",
"code": "def getForallBinderNames : Expr → List Name\n | forallE n _ b _ => n :: getForallBinderNames b\n | _ => []",
"start": [
1034,
1
],
"end": [
1038,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppFn",
"code": "def getAppFn : Expr → Expr\n | app f _ => getAppFn f\n | e => e",
"start": [
1040,
1
],
"end": [
1047,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppFn'",
"code": "def getAppFn' : Expr → Expr\n | app f _ => getAppFn' f\n | mdata _ a => getAppFn' a\n | e => e",
"start": [
1049,
1
],
"end": [
1055,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isAppOf",
"code": "def isAppOf (e : Expr) (n : Name) : Bool :=\n match e.getAppFn with\n | const c _ => c == n\n | _ => false",
"start": [
1057,
1
],
"end": [
1061,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isAppOfArity",
"code": "def isAppOfArity : Expr → Name → Nat → Bool\n | const c _, n, 0 => c == n\n | app f _, n, a+1 => isAppOfArity f n a\n | _, _, _ => false",
"start": [
1063,
1
],
"end": [
1070,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isAppOfArity'",
"code": "def isAppOfArity' : Expr → Name → Nat → Bool\n | mdata _ b , n, a => isAppOfArity' b n a\n | const c _, n, 0 => c == n\n | app f _, n, a+1 => isAppOfArity' f n a\n | _, _, _ => false",
"start": [
1072,
1
],
"end": [
1077,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppNumArgsAux",
"code": "private def getAppNumArgsAux : Expr → Nat → Nat\n | app f _, n => getAppNumArgsAux f (n+1)\n | _, n => n",
"start": [
1079,
1
],
"end": [
1081,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppNumArgs",
"code": "def getAppNumArgs (e : Expr) : Nat :=\n getAppNumArgsAux e 0",
"start": [
1083,
1
],
"end": [
1085,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getBoundedAppFn",
"code": "def getBoundedAppFn : (maxArgs : Nat) → Expr → Expr\n | maxArgs' + 1, .app f _ => getBoundedAppFn maxArgs' f\n | _, e => e",
"start": [
1087,
1
],
"end": [
1096,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppArgsAux",
"code": "private def getAppArgsAux : Expr → Array Expr → Nat → Array Expr\n | app f a, as, i => getAppArgsAux f (as.set! i a) (i-1)\n | _, as, _ => as",
"start": [
1098,
1
],
"end": [
1100,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppArgs",
"code": "@[inline] def getAppArgs (e : Expr) : Array Expr :=\n let dummy := mkSort levelZero\n let nargs := e.getAppNumArgs\n getAppArgsAux e (mkArray nargs dummy) (nargs-1)",
"start": [
1102,
1
],
"end": [
1106,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getBoundedAppArgsAux",
"code": "private def getBoundedAppArgsAux : Expr → Array Expr → Nat → Array Expr\n | app f a, as, i + 1 => getBoundedAppArgsAux f (as.set! i a) i\n | _, as, _ => as",
"start": [
1108,
1
],
"end": [
1110,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getBoundedAppArgs",
"code": "@[inline] def getBoundedAppArgs (maxArgs : Nat) (e : Expr) : Array Expr :=\n let dummy := mkSort levelZero\n let nargs := min maxArgs e.getAppNumArgs\n getBoundedAppArgsAux e (mkArray nargs dummy) nargs",
"start": [
1112,
1
],
"end": [
1121,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppRevArgsAux",
"code": "private def getAppRevArgsAux : Expr → Array Expr → Array Expr\n | app f a, as => getAppRevArgsAux f (as.push a)\n | _, as => as",
"start": [
1123,
1
],
"end": [
1125,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppRevArgs",
"code": "@[inline] def getAppRevArgs (e : Expr) : Array Expr :=\n getAppRevArgsAux e (Array.mkEmpty e.getAppNumArgs)",
"start": [
1127,
1
],
"end": [
1129,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.withAppAux",
"code": "@[specialize] def withAppAux (k : Expr → Array Expr → α) : Expr → Array Expr → Nat → α\n | app f a, as, i => withAppAux k f (as.set! i a) (i-1)\n | f, as, _ => k f as",
"start": [
1131,
1
],
"end": [
1133,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.withApp",
"code": "@[inline] def withApp (e : Expr) (k : Expr → Array Expr → α) : α :=\n let dummy := mkSort levelZero\n let nargs := e.getAppNumArgs\n withAppAux k e (mkArray nargs dummy) (nargs-1)",
"start": [
1135,
1
],
"end": [
1139,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppFnArgs",
"code": "def getAppFnArgs (e : Expr) : Name × Array Expr :=\n withApp e λ e a => (e.constName, a)",
"start": [
1141,
1
],
"end": [
1143,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppArgsN",
"code": "@[inline] def getAppArgsN (e : Expr) (n : Nat) : Array Expr :=\n let dummy := mkSort levelZero\n loop n e (mkArray n dummy)\nwhere\n loop : Nat → Expr → Array Expr → Array Expr\n | 0, _, as => as\n | i+1, .app f a, as => loop i f (as.set! i a)\n | _, _, _ => panic! \"too few arguments at\"",
"start": [
1145,
1
],
"end": [
1157,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.stripArgsN",
"code": "def stripArgsN (e : Expr) (n : Nat) : Expr :=\n match n, e with\n | 0, _ => e\n | n+1, .app f _ => stripArgsN f n\n | _, _ => e",
"start": [
1159,
1
],
"end": [
1167,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAppPrefix",
"code": "def getAppPrefix (e : Expr) (n : Nat) : Expr :=\n e.stripArgsN (e.getAppNumArgs - n)",
"start": [
1169,
1
],
"end": [
1174,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.traverseApp",
"code": "def traverseApp {M} [Monad M]\n (f : Expr → M Expr) (e : Expr) : M Expr :=\n e.withApp fun fn args => mkAppN <$> f fn <*> args.mapM f",
"start": [
1176,
1
],
"end": [
1180,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.withAppRevAux",
"code": "@[specialize] private def withAppRevAux (k : Expr → Array Expr → α) : Expr → Array Expr → α\n | app f a, as => withAppRevAux k f (as.push a)\n | f, as => k f as",
"start": [
1182,
1
],
"end": [
1184,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.withAppRev",
"code": "@[inline] def withAppRev (e : Expr) (k : Expr → Array Expr → α) : α :=\n withAppRevAux k e (Array.mkEmpty e.getAppNumArgs)",
"start": [
1186,
1
],
"end": [
1188,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getRevArgD",
"code": "def getRevArgD : Expr → Nat → Expr → Expr\n | app _ a, 0, _ => a\n | app f _, i+1, v => getRevArgD f i v\n | _, _, v => v",
"start": [
1190,
1
],
"end": [
1193,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getRevArg!",
"code": "def getRevArg! : Expr → Nat → Expr\n | app _ a, 0 => a\n | app f _, i+1 => getRevArg! f i\n | _, _ => panic! \"invalid index\"",
"start": [
1195,
1
],
"end": [
1198,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getRevArg!'",
"code": "def getRevArg!' : Expr → Nat → Expr\n | mdata _ a, i => getRevArg!' a i\n | app _ a, 0 => a\n | app f _, i+1 => getRevArg!' f i\n | _, _ => panic! \"invalid index\"",
"start": [
1200,
1
],
"end": [
1205,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getArg!",
"code": "@[inline] def getArg! (e : Expr) (i : Nat) (n := e.getAppNumArgs) : Expr :=\n getRevArg! e (n - i - 1)",
"start": [
1207,
1
],
"end": [
1209,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getArg!'",
"code": "@[inline] def getArg!' (e : Expr) (i : Nat) (n := e.getAppNumArgs) : Expr :=\n getRevArg!' e (n - i - 1)",
"start": [
1211,
1
],
"end": [
1213,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getArgD",
"code": "@[inline] def getArgD (e : Expr) (i : Nat) (v₀ : Expr) (n := e.getAppNumArgs) : Expr :=\n getRevArgD e (n - i - 1) v₀",
"start": [
1215,
1
],
"end": [
1217,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLooseBVars",
"code": "def hasLooseBVars (e : Expr) : Bool :=\n e.looseBVarRange > 0",
"start": [
1219,
1
],
"end": [
1220,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isArrow",
"code": "def isArrow (e : Expr) : Bool :=\n match e with\n | forallE _ _ b _ => !b.hasLooseBVars\n | _ => false",
"start": [
1222,
1
],
"end": [
1229,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLooseBVar",
"code": "@[extern \"lean_expr_has_loose_bvar\"]\nopaque hasLooseBVar (e : @& Expr) (bvarIdx : @& Nat) : Bool",
"start": [
1231,
1
],
"end": [
1232,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasLooseBVarInExplicitDomain",
"code": "def hasLooseBVarInExplicitDomain : Expr → Nat → Bool → Bool\n | Expr.forallE _ d b bi, bvarIdx, tryRange =>\n (bi.isExplicit && hasLooseBVar d bvarIdx) || hasLooseBVarInExplicitDomain b (bvarIdx+1) tryRange\n | e, bvarIdx, tryRange => tryRange && hasLooseBVar e bvarIdx",
"start": [
1234,
1
],
"end": [
1238,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.lowerLooseBVars",
"code": "@[extern \"lean_expr_lower_loose_bvars\"]\nopaque lowerLooseBVars (e : @& Expr) (s d : @& Nat) : Expr",
"start": [
1240,
1
],
"end": [
1247,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.liftLooseBVars",
"code": "@[extern \"lean_expr_lift_loose_bvars\"]\nopaque liftLooseBVars (e : @& Expr) (s d : @& Nat) : Expr",
"start": [
1249,
1
],
"end": [
1252,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.inferImplicit",
"code": "def inferImplicit : Expr → Nat → Bool → Expr\n | Expr.forallE n d b bi, i+1, considerRange =>\n let b := inferImplicit b i considerRange\n let newInfo := if bi.isExplicit && hasLooseBVarInExplicitDomain b 0 considerRange then BinderInfo.implicit else bi\n mkForall n newInfo d b\n | e, 0, _ => e\n | e, _, _ => e",
"start": [
1254,
1
],
"end": [
1268,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiate",
"code": "@[extern \"lean_expr_instantiate\"]\nopaque instantiate (e : @& Expr) (subst : @& Array Expr) : Expr",
"start": [
1270,
1
],
"end": [
1293,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiate1",
"code": "@[extern \"lean_expr_instantiate1\"]\nopaque instantiate1 (e : @& Expr) (subst : @& Expr) : Expr",
"start": [
1295,
1
],
"end": [
1310,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiateRev",
"code": "@[extern \"lean_expr_instantiate_rev\"]\nopaque instantiateRev (e : @& Expr) (subst : @& Array Expr) : Expr",
"start": [
1312,
1
],
"end": [
1324,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiateRange",
"code": "@[extern \"lean_expr_instantiate_range\"]\nopaque instantiateRange (e : @& Expr) (beginIdx endIdx : @& Nat) (subst : @& Array Expr) : Expr",
"start": [
1326,
1
],
"end": [
1336,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiateRevRange",
"code": "@[extern \"lean_expr_instantiate_rev_range\"]\nopaque instantiateRevRange (e : @& Expr) (beginIdx endIdx : @& Nat) (subst : @& Array Expr) : Expr",
"start": [
1338,
1
],
"end": [
1348,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.abstract",
"code": "@[extern \"lean_expr_abstract\"]\nopaque abstract (e : @& Expr) (xs : @& Array Expr) : Expr",
"start": [
1350,
1
],
"end": [
1352,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.abstractRange",
"code": "@[extern \"lean_expr_abstract_range\"]\nopaque abstractRange (e : @& Expr) (n : @& Nat) (xs : @& Array Expr) : Expr",
"start": [
1354,
1
],
"end": [
1356,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.replaceFVar",
"code": "def replaceFVar (e : Expr) (fvar : Expr) (v : Expr) : Expr :=\n (e.abstract #[fvar]).instantiate1 v",
"start": [
1358,
1
],
"end": [
1360,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.replaceFVarId",
"code": "def replaceFVarId (e : Expr) (fvarId : FVarId) (v : Expr) : Expr :=\n replaceFVar e (mkFVar fvarId) v",
"start": [
1362,
1
],
"end": [
1364,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.replaceFVars",
"code": "def replaceFVars (e : Expr) (fvars : Array Expr) (vs : Array Expr) : Expr :=\n (e.abstract fvars).instantiateRev vs",
"start": [
1366,
1
],
"end": [
1368,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isAtomic",
"code": "def isAtomic : Expr → Bool\n | Expr.const .. => true\n | Expr.sort .. => true\n | Expr.bvar .. => true\n | Expr.lit .. => true\n | Expr.mvar .. => true\n | Expr.fvar .. => true\n | _ => false",
"start": [
1373,
1
],
"end": [
1381,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkDecIsTrue",
"code": "def mkDecIsTrue (pred proof : Expr) :=\n mkAppB (mkConst `Decidable.isTrue) pred proof",
"start": [
1385,
1
],
"end": [
1386,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkDecIsFalse",
"code": "def mkDecIsFalse (pred proof : Expr) :=\n mkAppB (mkConst `Decidable.isFalse) pred proof",
"start": [
1388,
1
],
"end": [
1389,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExprMap",
"code": "abbrev ExprMap (α : Type) := HashMap Expr α",
"start": [
1391,
1
],
"end": [
1391,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentExprMap",
"code": "abbrev PersistentExprMap (α : Type) := PHashMap Expr α",
"start": [
1392,
1
],
"end": [
1392,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SExprMap",
"code": "abbrev SExprMap (α : Type) := SMap Expr α",
"start": [
1393,
1
],
"end": [
1393,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExprSet",
"code": "abbrev ExprSet := HashSet Expr",
"start": [
1395,
1
],
"end": [
1395,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentExprSet",
"code": "abbrev PersistentExprSet := PHashSet Expr",
"start": [
1396,
1
],
"end": [
1396,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PExprSet",
"code": "abbrev PExprSet := PersistentExprSet",
"start": [
1397,
1
],
"end": [
1397,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExprStructEq",
"code": "structure ExprStructEq where\n val : Expr\n deriving Inhabited",
"start": [
1399,
1
],
"end": [
1402,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExprStructEq.beq",
"code": "protected def beq : ExprStructEq → ExprStructEq → Bool\n | ⟨e₁⟩, ⟨e₂⟩ => Expr.equal e₁ e₂",
"start": [
1408,
1
],
"end": [
1409,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExprStructEq.hash",
"code": "protected def hash : ExprStructEq → UInt64\n | ⟨e⟩ => e.hash",
"start": [
1411,
1
],
"end": [
1412,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExprStructMap",
"code": "abbrev ExprStructMap (α : Type) := HashMap ExprStructEq α",
"start": [
1420,
1
],
"end": [
1420,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentExprStructMap",
"code": "abbrev PersistentExprStructMap (α : Type) := PHashMap ExprStructEq α",
"start": [
1421,
1
],
"end": [
1421,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mkAppRevRangeAux",
"code": "private partial def mkAppRevRangeAux (revArgs : Array Expr) (start : Nat) (b : Expr) (i : Nat) : Expr :=\n if i == start then b\n else\n let i := i - 1\n mkAppRevRangeAux revArgs start (mkApp b (revArgs.get! i)) i",
"start": [
1425,
1
],
"end": [
1429,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.mkAppRevRange",
"code": "def mkAppRevRange (f : Expr) (beginIdx endIdx : Nat) (revArgs : Array Expr) : Expr :=\n mkAppRevRangeAux revArgs beginIdx f endIdx",
"start": [
1431,
1
],
"end": [
1433,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.betaRev",
"code": "partial def betaRev (f : Expr) (revArgs : Array Expr) (useZeta := false) (preserveMData := false) : Expr :=\n if revArgs.size == 0 then f\n else\n let sz := revArgs.size\n let rec go (e : Expr) (i : Nat) : Expr :=\n match e with\n | Expr.lam _ _ b _ =>\n if i + 1 < sz then\n go b (i+1)\n else\n let n := sz - (i + 1)\n mkAppRevRange (b.instantiateRange n sz revArgs) 0 n revArgs\n | Expr.letE _ _ v b _ =>\n if useZeta && i < sz then\n go (b.instantiate1 v) i\n else\n let n := sz - i\n mkAppRevRange (e.instantiateRange n sz revArgs) 0 n revArgs\n | Expr.mdata k b =>\n if preserveMData then\n let n := sz - i\n mkMData k (mkAppRevRange (b.instantiateRange n sz revArgs) 0 n revArgs)\n else\n go b i\n | b =>\n let n := sz - i\n mkAppRevRange (b.instantiateRange n sz revArgs) 0 n revArgs\n go f 0",
"start": [
1435,
1
],
"end": [
1477,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.beta",
"code": "def beta (f : Expr) (args : Array Expr) : Expr :=\n betaRev f args.reverse",
"start": [
1479,
1
],
"end": [
1484,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getNumHeadLambdas",
"code": "def getNumHeadLambdas : Expr → Nat\n | .lam _ _ b _ => getNumHeadLambdas b + 1\n | .mdata _ b => getNumHeadLambdas b\n | _ => 0",
"start": [
1486,
1
],
"end": [
1492,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isHeadBetaTargetFn",
"code": "def isHeadBetaTargetFn (useZeta : Bool) : Expr → Bool\n | Expr.lam .. => true\n | Expr.letE _ _ _ b _ => useZeta && isHeadBetaTargetFn useZeta b\n | Expr.mdata _ b => isHeadBetaTargetFn useZeta b\n | _ => false",
"start": [
1494,
1
],
"end": [
1505,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.headBeta",
"code": "def headBeta (e : Expr) : Expr :=\n let f := e.getAppFn\n if f.isHeadBetaTargetFn false then betaRev f e.getAppRevArgs else e",
"start": [
1507,
1
],
"end": [
1510,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isHeadBetaTarget",
"code": "def isHeadBetaTarget (e : Expr) (useZeta := false) : Bool :=\n e.isApp && e.getAppFn.isHeadBetaTargetFn useZeta",
"start": [
1512,
1
],
"end": [
1518,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.etaExpandedBody",
"code": "private def etaExpandedBody : Expr → Nat → Nat → Option Expr\n | app f (bvar j), n+1, i => if j == i then etaExpandedBody f n (i+1) else none\n | _, _+1, _ => none\n | f, 0, _ => if f.hasLooseBVars then none else some f",
"start": [
1520,
1
],
"end": [
1523,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.etaExpandedAux",
"code": "private def etaExpandedAux : Expr → Nat → Option Expr\n | lam _ _ b _, n => etaExpandedAux b (n+1)\n | e, n => etaExpandedBody e n 0",
"start": [
1525,
1
],
"end": [
1527,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.etaExpanded?",
"code": "def etaExpanded? (e : Expr) : Option Expr :=\n etaExpandedAux e 0",
"start": [
1529,
1
],
"end": [
1538,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.etaExpandedStrict?",
"code": "def etaExpandedStrict? : Expr → Option Expr\n | lam _ _ b _ => etaExpandedAux b 1\n | _ => none",
"start": [
1540,
1
],
"end": [
1543,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getOptParamDefault?",
"code": "def getOptParamDefault? (e : Expr) : Option Expr :=\n if e.isAppOfArity ``optParam 2 then\n some e.appArg!\n else\n none",
"start": [
1545,
1
],
"end": [
1550,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getAutoParamTactic?",
"code": "def getAutoParamTactic? (e : Expr) : Option Expr :=\n if e.isAppOfArity ``autoParam 2 then\n some e.appArg!\n else\n none",
"start": [
1552,
1
],
"end": [
1557,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isOutParam",
"code": "@[export lean_is_out_param]\ndef isOutParam (e : Expr) : Bool :=\n e.isAppOfArity ``outParam 1",
"start": [
1559,
1
],
"end": [
1562,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isSemiOutParam",
"code": "def isSemiOutParam (e : Expr) : Bool :=\n e.isAppOfArity ``semiOutParam 1",
"start": [
1564,
1
],
"end": [
1566,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isOptParam",
"code": "def isOptParam (e : Expr) : Bool :=\n e.isAppOfArity ``optParam 2",
"start": [
1568,
1
],
"end": [
1570,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isAutoParam",
"code": "def isAutoParam (e : Expr) : Bool :=\n e.isAppOfArity ``autoParam 2",
"start": [
1572,
1
],
"end": [
1574,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.consumeTypeAnnotations",
"code": "@[export lean_expr_consume_type_annotations]\npartial def consumeTypeAnnotations (e : Expr) : Expr :=\n if e.isOptParam || e.isAutoParam then\n consumeTypeAnnotations e.appFn!.appArg!\n else if e.isOutParam || e.isSemiOutParam then\n consumeTypeAnnotations e.appArg!\n else\n e",
"start": [
1576,
1
],
"end": [
1590,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.cleanupAnnotations",
"code": "partial def cleanupAnnotations (e : Expr) : Expr :=\n let e' := e.consumeMData.consumeTypeAnnotations\n if e' == e then e else cleanupAnnotations e'",
"start": [
1592,
1
],
"end": [
1601,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.appFnCleanup",
"code": "def appFnCleanup (e : Expr) (h : e.isApp) : Expr :=\n match e, h with\n | .app f _, _ => f.cleanupAnnotations",
"start": [
1603,
1
],
"end": [
1609,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isFalse",
"code": "def isFalse (e : Expr) : Bool :=\n e.cleanupAnnotations.isConstOf ``False",
"start": [
1611,
1
],
"end": [
1612,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isTrue",
"code": "def isTrue (e : Expr) : Bool :=\n e.cleanupAnnotations.isConstOf ``True",
"start": [
1614,
1
],
"end": [
1615,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.nat?",
"code": "def nat? (e : Expr) : Option Nat := do\n let_expr OfNat.ofNat _ n _ := e | failure\n let lit (.natVal n) := n | failure\n n",
"start": [
1617,
1
],
"end": [
1627,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.int?",
"code": "def int? (e : Expr) : Option Int :=\n let_expr Neg.neg _ _ a := e | e.nat?\n match a.nat? with\n | none => none\n | some 0 => none\n | some n => some (-n)",
"start": [
1629,
1
],
"end": [
1640,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasAnyFVar",
"code": "@[inline] def hasAnyFVar (e : Expr) (p : FVarId → Bool) : Bool :=\n let rec @[specialize] visit (e : Expr) := if !e.hasFVar then false else\n match e with\n | Expr.forallE _ d b _ => visit d || visit b\n | Expr.lam _ d b _ => visit d || visit b\n | Expr.mdata _ e => visit e\n | Expr.letE _ t v b _ => visit t || visit v || visit b\n | Expr.app f a => visit f || visit a\n | Expr.proj _ _ e => visit e\n | Expr.fvar fvarId => p fvarId\n | _ => false\n visit e",
"start": [
1642,
1
],
"end": [
1654,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.containsFVar",
"code": "def containsFVar (e : Expr) (fvarId : FVarId) : Bool :=\n e.hasAnyFVar (· == fvarId)",
"start": [
1656,
1
],
"end": [
1658,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateApp!Impl",
"code": "@[inline] private unsafe def updateApp!Impl (e : Expr) (newFn : Expr) (newArg : Expr) : Expr :=\n match e with\n | app fn arg => if ptrEq fn newFn && ptrEq arg newArg then e else mkApp newFn newArg\n | _ => panic! \"application expected\"",
"start": [
1666,
1
],
"end": [
1669,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateApp!",
"code": "@[implemented_by updateApp!Impl]\ndef updateApp! (e : Expr) (newFn : Expr) (newArg : Expr) : Expr :=\n match e with\n | app _ _ => mkApp newFn newArg\n | _ => panic! \"application expected\"",
"start": [
1671,
1
],
"end": [
1675,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateFVar!",
"code": "@[inline] def updateFVar! (e : Expr) (fvarIdNew : FVarId) : Expr :=\n match e with\n | .fvar fvarId => if fvarId == fvarIdNew then e else .fvar fvarIdNew\n | _ => panic! \"fvar expected\"",
"start": [
1677,
1
],
"end": [
1680,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateConst!Impl",
"code": "@[inline] private unsafe def updateConst!Impl (e : Expr) (newLevels : List Level) : Expr :=\n match e with\n | const n ls => if ptrEqList ls newLevels then e else mkConst n newLevels\n | _ => panic! \"constant expected\"",
"start": [
1682,
1
],
"end": [
1685,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateConst!",
"code": "@[implemented_by updateConst!Impl]\ndef updateConst! (e : Expr) (newLevels : List Level) : Expr :=\n match e with\n | const n _ => mkConst n newLevels\n | _ => panic! \"constant expected\"",
"start": [
1687,
1
],
"end": [
1691,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateSort!Impl",
"code": "@[inline] private unsafe def updateSort!Impl (e : Expr) (u' : Level) : Expr :=\n match e with\n | sort u => if ptrEq u u' then e else mkSort u'\n | _ => panic! \"level expected\"",
"start": [
1693,
1
],
"end": [
1696,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateSort!",
"code": "@[implemented_by updateSort!Impl]\ndef updateSort! (e : Expr) (newLevel : Level) : Expr :=\n match e with\n | sort _ => mkSort newLevel\n | _ => panic! \"level expected\"",
"start": [
1698,
1
],
"end": [
1702,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateMData!Impl",
"code": "@[inline] private unsafe def updateMData!Impl (e : Expr) (newExpr : Expr) : Expr :=\n match e with\n | mdata d a => if ptrEq a newExpr then e else mkMData d newExpr\n | _ => panic! \"mdata expected\"",
"start": [
1704,
1
],
"end": [
1707,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateMData!",
"code": "@[implemented_by updateMData!Impl]\ndef updateMData! (e : Expr) (newExpr : Expr) : Expr :=\n match e with\n | mdata d _ => mkMData d newExpr\n | _ => panic! \"mdata expected\"",
"start": [
1709,
1
],
"end": [
1713,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateProj!Impl",
"code": "@[inline] private unsafe def updateProj!Impl (e : Expr) (newExpr : Expr) : Expr :=\n match e with\n | proj s i a => if ptrEq a newExpr then e else mkProj s i newExpr\n | _ => panic! \"proj expected\"",
"start": [
1715,
1
],
"end": [
1718,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateProj!",
"code": "@[implemented_by updateProj!Impl]\ndef updateProj! (e : Expr) (newExpr : Expr) : Expr :=\n match e with\n | proj s i _ => mkProj s i newExpr\n | _ => panic! \"proj expected\"",
"start": [
1720,
1
],
"end": [
1724,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateForall!Impl",
"code": "@[inline] private unsafe def updateForall!Impl (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) : Expr :=\n match e with\n | forallE n d b bi =>\n if ptrEq d newDomain && ptrEq b newBody && bi == newBinfo then\n e\n else\n mkForall n newBinfo newDomain newBody\n | _ => panic! \"forall expected\"",
"start": [
1726,
1
],
"end": [
1733,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateForall!",
"code": "@[implemented_by updateForall!Impl]\ndef updateForall! (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) : Expr :=\n match e with\n | forallE n _ _ _ => mkForall n newBinfo newDomain newBody\n | _ => panic! \"forall expected\"",
"start": [
1735,
1
],
"end": [
1739,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateForallE!",
"code": "@[inline] def updateForallE! (e : Expr) (newDomain : Expr) (newBody : Expr) : Expr :=\n match e with\n | forallE n d b bi => updateForall! (forallE n d b bi) bi newDomain newBody\n | _ => panic! \"forall expected\"",
"start": [
1741,
1
],
"end": [
1744,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateLambda!Impl",
"code": "@[inline] private unsafe def updateLambda!Impl (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) : Expr :=\n match e with\n | lam n d b bi =>\n if ptrEq d newDomain && ptrEq b newBody && bi == newBinfo then\n e\n else\n mkLambda n newBinfo newDomain newBody\n | _ => panic! \"lambda expected\"",
"start": [
1746,
1
],
"end": [
1753,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateLambda!",
"code": "@[implemented_by updateLambda!Impl]\ndef updateLambda! (e : Expr) (newBinfo : BinderInfo) (newDomain : Expr) (newBody : Expr) : Expr :=\n match e with\n | lam n _ _ _ => mkLambda n newBinfo newDomain newBody\n | _ => panic! \"lambda expected\"",
"start": [
1755,
1
],
"end": [
1759,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateLambdaE!",
"code": "@[inline] def updateLambdaE! (e : Expr) (newDomain : Expr) (newBody : Expr) : Expr :=\n match e with\n | lam n d b bi => updateLambda! (lam n d b bi) bi newDomain newBody\n | _ => panic! \"lambda expected\"",
"start": [
1761,
1
],
"end": [
1764,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateLet!Impl",
"code": "@[inline] private unsafe def updateLet!Impl (e : Expr) (newType : Expr) (newVal : Expr) (newBody : Expr) : Expr :=\n match e with\n | letE n t v b nonDep =>\n if ptrEq t newType && ptrEq v newVal && ptrEq b newBody then\n e\n else\n letE n newType newVal newBody nonDep\n | _ => panic! \"let expression expected\"",
"start": [
1766,
1
],
"end": [
1773,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateLet!",
"code": "@[implemented_by updateLet!Impl]\ndef updateLet! (e : Expr) (newType : Expr) (newVal : Expr) (newBody : Expr) : Expr :=\n match e with\n | letE n _ _ _ c => letE n newType newVal newBody c\n | _ => panic! \"let expression expected\"",
"start": [
1775,
1
],
"end": [
1779,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.updateFn",
"code": "def updateFn : Expr → Expr → Expr\n | e@(app f a), g => e.updateApp! (updateFn f g) a\n | _, g => g",
"start": [
1781,
1
],
"end": [
1783,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.eta",
"code": "partial def eta (e : Expr) : Expr :=\n match e with\n | Expr.lam _ d b _ =>\n let b' := b.eta\n match b' with\n | .app f (.bvar 0) =>\n if !f.hasLooseBVar 0 then\n f.lowerLooseBVars 1 1\n else\n e.updateLambdaE! d b'\n | _ => e.updateLambdaE! d b'\n | _ => e",
"start": [
1785,
1
],
"end": [
1799,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.setOption",
"code": "def setOption (e : Expr) (optionName : Name) [KVMap.Value α] (val : α) : Expr :=\n mkMData (MData.empty.set optionName val) e",
"start": [
1801,
1
],
"end": [
1806,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.setPPExplicit",
"code": "def setPPExplicit (e : Expr) (flag : Bool) :=\n e.setOption `pp.explicit flag",
"start": [
1808,
1
],
"end": [
1813,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.setPPUniverses",
"code": "def setPPUniverses (e : Expr) (flag : Bool) :=\n e.setOption `pp.universes flag",
"start": [
1815,
1
],
"end": [
1820,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.setAppPPExplicit",
"code": "def setAppPPExplicit (e : Expr) : Expr :=\n match e with\n | app .. =>\n let f := e.getAppFn.setPPExplicit false\n let args := e.getAppArgs.map (·.setPPExplicit false)\n mkAppN f args |>.setPPExplicit true\n | _ => e",
"start": [
1822,
1
],
"end": [
1832,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.setAppPPExplicitForExposingMVars",
"code": "def setAppPPExplicitForExposingMVars (e : Expr) : Expr :=\n match e with\n | app .. =>\n let f := e.getAppFn.setPPExplicit false\n let args := e.getAppArgs.map fun arg => if arg.hasMVar then arg else arg.setPPExplicit false\n mkAppN f args |>.setPPExplicit true\n | _ => e",
"start": [
1834,
1
],
"end": [
1844,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isLetFun",
"code": "def isLetFun (e : Expr) : Bool := e.isAppOfArity ``letFun 4",
"start": [
1846,
1
],
"end": [
1851,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.letFun?",
"code": "def letFun? (e : Expr) : Option (Name × Expr × Expr × Expr) :=\n match e with\n | .app (.app (.app (.app (.const ``letFun _) t) _β) v) f =>\n match f with\n | .lam n _ b _ => some (n, t, v, b)\n | _ => some (.anonymous, t, v, .app f (.bvar 0))\n | _ => none",
"start": [
1853,
1
],
"end": [
1869,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.letFunAppArgs?",
"code": "def letFunAppArgs? (e : Expr) : Option (Array Expr × Name × Expr × Expr × Expr) := do\n guard <| 4 ≤ e.getAppNumArgs\n guard <| e.isAppOf ``letFun\n let args := e.getAppArgs\n let t := args[0]!\n let v := args[2]!\n let f := args[3]!\n let rest := args.extract 4 args.size\n match f with\n | .lam n _ b _ => some (rest, n, t, v, b)\n | _ => some (rest, .anonymous, t, v, .app f (.bvar 0))",
"start": [
1871,
1
],
"end": [
1885,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.traverseChildren",
"code": "@[specialize]\ndef traverseChildren [Applicative M] (f : Expr → M Expr) : Expr → M Expr\n | e@(forallE _ d b _) => pure e.updateForallE! <*> f d <*> f b\n | e@(lam _ d b _) => pure e.updateLambdaE! <*> f d <*> f b\n | e@(mdata _ b) => e.updateMData! <$> f b\n | e@(letE _ t v b _) => pure e.updateLet! <*> f t <*> f v <*> f b\n | e@(app l r) => pure e.updateApp! <*> f l <*> f r\n | e@(proj _ _ b) => e.updateProj! <$> f b\n | e => pure e",
"start": [
1887,
1
],
"end": [
1896,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.foldlM",
"code": "def foldlM {α : Type} {m} [Monad m] (f : α → Expr → m α) (init : α) (e : Expr) : m α :=\n Prod.snd <$> StateT.run (e.traverseChildren (fun e' => fun a => Prod.mk e' <$> f a e')) init",
"start": [
1898,
1
],
"end": [
1901,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAnnotation",
"code": "def mkAnnotation (kind : Name) (e : Expr) : Expr :=\n mkMData (KVMap.empty.insert kind (DataValue.ofBool true)) e",
"start": [
1905,
1
],
"end": [
1910,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.annotation?",
"code": "def annotation? (kind : Name) (e : Expr) : Option Expr :=\n match e with\n | .mdata d b => if d.size == 1 && d.getBool kind false then some b else none\n | _ => none",
"start": [
1912,
1
],
"end": [
1918,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkInaccessible",
"code": "def mkInaccessible (e : Expr) : Expr :=\n mkAnnotation `_inaccessible e",
"start": [
1920,
1
],
"end": [
1925,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.inaccessible?",
"code": "def inaccessible? (e : Expr) : Option Expr :=\n annotation? `_inaccessible e",
"start": [
1927,
1
],
"end": [
1929,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.patternRefAnnotationKey",
"code": "private def patternRefAnnotationKey := `_patWithRef",
"start": [
1931,
1
],
"end": [
1931,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.patternWithRef?",
"code": "def patternWithRef? (p : Expr) : Option (Syntax × Expr) :=\n match p with\n | .mdata d _ =>\n match d.find patternRefAnnotationKey with\n | some (DataValue.ofSyntax stx) => some (stx, p.mdataExpr!)\n | _ => none\n | _ => none",
"start": [
1933,
1
],
"end": [
1944,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isPatternWithRef",
"code": "def isPatternWithRef (p : Expr) : Bool :=\n patternWithRef? p |>.isSome",
"start": [
1946,
1
],
"end": [
1947,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkPatternWithRef",
"code": "def mkPatternWithRef (p : Expr) (stx : Syntax) : Expr :=\n if patternWithRef? p |>.isSome then\n p\n else\n mkMData (KVMap.empty.insert patternRefAnnotationKey (DataValue.ofSyntax stx)) p",
"start": [
1949,
1
],
"end": [
1957,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.patternAnnotation?",
"code": "def patternAnnotation? (e : Expr) : Option Expr :=\n if let some e := inaccessible? e then\n some e\n else if let some (_, e) := patternWithRef? e then\n some e\n else\n none",
"start": [
1959,
1
],
"end": [
1966,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLHSGoalRaw",
"code": "def mkLHSGoalRaw (e : Expr) : Expr :=\n mkAnnotation `_lhsGoal e",
"start": [
1968,
1
],
"end": [
1976,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isLHSGoal?",
"code": "def isLHSGoal? (e : Expr) : Option Expr :=\n match annotation? `_lhsGoal e with\n | none => none\n | some e =>\n if e.isAppOfArity `Eq 3 then\n some e.appFn!.appArg!\n else\n none",
"start": [
1978,
1
],
"end": [
1986,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkFreshFVarId",
"code": "def mkFreshFVarId [Monad m] [MonadNameGenerator m] : m FVarId :=\n return { name := (← mkFreshId) }",
"start": [
1988,
1
],
"end": [
1993,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkFreshMVarId",
"code": "def mkFreshMVarId [Monad m] [MonadNameGenerator m] : m MVarId :=\n return { name := (← mkFreshId) }",
"start": [
1995,
1
],
"end": [
2000,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkFreshLMVarId",
"code": "def mkFreshLMVarId [Monad m] [MonadNameGenerator m] : m LMVarId :=\n return { name := (← mkFreshId) }",
"start": [
2002,
1
],
"end": [
2007,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNot",
"code": "def mkNot (p : Expr) : Expr := mkApp (mkConst ``Not) p",
"start": [
2009,
1
],
"end": [
2010,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkOr",
"code": "def mkOr (p q : Expr) : Expr := mkApp2 (mkConst ``Or) p q",
"start": [
2011,
1
],
"end": [
2012,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAnd",
"code": "def mkAnd (p q : Expr) : Expr := mkApp2 (mkConst ``And) p q",
"start": [
2013,
1
],
"end": [
2014,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAndN",
"code": "def mkAndN : List Expr → Expr\n | [] => mkConst ``True\n | [p] => p\n | p :: ps => mkAnd p (mkAndN ps)",
"start": [
2015,
1
],
"end": [
2019,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkEM",
"code": "def mkEM (p : Expr) : Expr := mkApp (mkConst ``Classical.em) p",
"start": [
2020,
1
],
"end": [
2021,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkIff",
"code": "def mkIff (p q : Expr) : Expr := mkApp2 (mkConst ``Iff) p q",
"start": [
2022,
1
],
"end": [
2023,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkType",
"code": "protected def mkType : Expr := mkConst ``Nat",
"start": [
2028,
1
],
"end": [
2028,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstAdd",
"code": "def mkInstAdd : Expr := mkConst ``instAddNat",
"start": [
2030,
1
],
"end": [
2030,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstHAdd",
"code": "def mkInstHAdd : Expr := mkApp2 (mkConst ``instHAdd [levelZero]) Nat.mkType mkInstAdd",
"start": [
2031,
1
],
"end": [
2031,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstSub",
"code": "def mkInstSub : Expr := mkConst ``instSubNat",
"start": [
2033,
1
],
"end": [
2033,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstHSub",
"code": "def mkInstHSub : Expr := mkApp2 (mkConst ``instHSub [levelZero]) Nat.mkType mkInstSub",
"start": [
2034,
1
],
"end": [
2034,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstMul",
"code": "def mkInstMul : Expr := mkConst ``instMulNat",
"start": [
2036,
1
],
"end": [
2036,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstHMul",
"code": "def mkInstHMul : Expr := mkApp2 (mkConst ``instHMul [levelZero]) Nat.mkType mkInstMul",
"start": [
2037,
1
],
"end": [
2037,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstDiv",
"code": "def mkInstDiv : Expr := mkConst ``Nat.instDiv",
"start": [
2039,
1
],
"end": [
2039,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstHDiv",
"code": "def mkInstHDiv : Expr := mkApp2 (mkConst ``instHDiv [levelZero]) Nat.mkType mkInstDiv",
"start": [
2040,
1
],
"end": [
2040,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstMod",
"code": "def mkInstMod : Expr := mkConst ``Nat.instMod",
"start": [
2042,
1
],
"end": [
2042,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstHMod",
"code": "def mkInstHMod : Expr := mkApp2 (mkConst ``instHMod [levelZero]) Nat.mkType mkInstMod",
"start": [
2043,
1
],
"end": [
2043,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstNatPow",
"code": "def mkInstNatPow : Expr := mkConst ``instNatPowNat",
"start": [
2045,
1
],
"end": [
2045,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstPow",
"code": "def mkInstPow : Expr := mkApp2 (mkConst ``instPowNat [levelZero]) Nat.mkType mkInstNatPow",
"start": [
2046,
1
],
"end": [
2046,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstHPow",
"code": "def mkInstHPow : Expr := mkApp3 (mkConst ``instHPow [levelZero, levelZero]) Nat.mkType Nat.mkType mkInstPow",
"start": [
2047,
1
],
"end": [
2047,
108
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstLT",
"code": "def mkInstLT : Expr := mkConst ``instLTNat",
"start": [
2049,
1
],
"end": [
2049,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Nat.mkInstLE",
"code": "def mkInstLE : Expr := mkConst ``instLENat",
"start": [
2050,
1
],
"end": [
2050,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.natAddFn",
"code": "private def natAddFn : Expr :=\n let nat := mkConst ``Nat\n mkApp4 (mkConst ``HAdd.hAdd [0, 0, 0]) nat nat nat Nat.mkInstHAdd",
"start": [
2054,
1
],
"end": [
2056,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.natSubFn",
"code": "private def natSubFn : Expr :=\n let nat := mkConst ``Nat\n mkApp4 (mkConst ``HSub.hSub [0, 0, 0]) nat nat nat Nat.mkInstHSub",
"start": [
2058,
1
],
"end": [
2060,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.natMulFn",
"code": "private def natMulFn : Expr :=\n let nat := mkConst ``Nat\n mkApp4 (mkConst ``HMul.hMul [0, 0, 0]) nat nat nat Nat.mkInstHMul",
"start": [
2062,
1
],
"end": [
2064,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatSucc",
"code": "def mkNatSucc (a : Expr) : Expr :=\n mkApp (mkConst ``Nat.succ) a",
"start": [
2066,
1
],
"end": [
2068,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatAdd",
"code": "def mkNatAdd (a b : Expr) : Expr :=\n mkApp2 natAddFn a b",
"start": [
2070,
1
],
"end": [
2072,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatSub",
"code": "def mkNatSub (a b : Expr) : Expr :=\n mkApp2 natSubFn a b",
"start": [
2074,
1
],
"end": [
2076,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatMul",
"code": "def mkNatMul (a b : Expr) : Expr :=\n mkApp2 natMulFn a b",
"start": [
2078,
1
],
"end": [
2080,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.natLEPred",
"code": "private def natLEPred : Expr :=\n mkApp2 (mkConst ``LE.le [0]) (mkConst ``Nat) Nat.mkInstLE",
"start": [
2082,
1
],
"end": [
2083,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatLE",
"code": "def mkNatLE (a b : Expr) : Expr :=\n mkApp2 natLEPred a b",
"start": [
2085,
1
],
"end": [
2087,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.natEqPred",
"code": "private def natEqPred : Expr :=\n mkApp (mkConst ``Eq [1]) (mkConst ``Nat)",
"start": [
2089,
1
],
"end": [
2090,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkNatEq",
"code": "def mkNatEq (a b : Expr) : Expr :=\n mkApp2 natEqPred a b",
"start": [
2092,
1
],
"end": [
2094,
23
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json/Stream.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json/Parser.lean",
".lake/packages/lean4/src/lean/Init/System/IO.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/FromToJson.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Printer.lean"
] | [
{
"full_name": "IO.FS.Stream.readJson",
"code": "def readJson (h : FS.Stream) (nBytes : Nat) : IO Json := do\n let bytes ← h.read (USize.ofNat nBytes)\n let some s := String.fromUTF8? bytes | throw (IO.userError \"invalid UTF-8\")\n ofExcept (Json.parse s)",
"start": [
18,
1
],
"end": [
22,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "IO.FS.Stream.writeJson",
"code": "def writeJson (h : FS.Stream) (j : Json) : IO Unit := do\n h.putStr j.compress\n h.flush",
"start": [
24,
1
],
"end": [
26,
10
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json/Elab.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json/FromToJson.lean",
".lake/packages/lean4/src/lean/Lean/Syntax.lean"
] | [] |
.lake/packages/lean4/src/lean/Init/Data/Int/Bitwise.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Bitwise/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/Int/Basic.lean"
] | [
{
"full_name": "Int.not",
"code": "protected def not : Int -> Int\n | Int.ofNat n => Int.negSucc n\n | Int.negSucc n => Int.ofNat n",
"start": [
14,
1
],
"end": [
27,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Int.shiftRight",
"code": "protected def shiftRight : Int → Nat → Int\n | Int.ofNat n, s => Int.ofNat (n >>> s)\n | Int.negSucc n, s => Int.negSucc (n >>> s)",
"start": [
31,
1
],
"end": [
46,
46
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Nat/Bitwise/Lemmas.lean | [
".lake/packages/lean4/src/lean/Init/Omega.lean",
".lake/packages/lean4/src/lean/Init/TacticsExtra.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/Simproc.lean",
".lake/packages/lean4/src/lean/Init/Data/Bool.lean",
".lake/packages/lean4/src/lean/Init/Data/Int/Pow.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/Bitwise/Basic.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/Lemmas.lean"
] | [
{
"full_name": "Nat.one_div_two",
"code": "@[local simp]\nprivate theorem one_div_two : 1/2 = 0",
"start": [
24,
1
],
"end": [
25,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.two_pow_succ_sub_succ_div_two",
"code": "private theorem two_pow_succ_sub_succ_div_two : (2 ^ (n+1) - (x + 1)) / 2 = 2^n - (x/2 + 1)",
"start": [
27,
1
],
"end": [
28,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.two_pow_succ_sub_one_div_two",
"code": "private theorem two_pow_succ_sub_one_div_two : (2 ^ (n+1) - 1) / 2 = 2^n - 1",
"start": [
30,
1
],
"end": [
31,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.two_mul_sub_one",
"code": "private theorem two_mul_sub_one {n : Nat} (n_pos : n > 0) : (2*n - 1) % 2 = 1",
"start": [
33,
1
],
"end": [
34,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.div2Induction",
"code": "noncomputable def div2Induction {motive : Nat → Sort u}\n (n : Nat) (ind : ∀(n : Nat), (n > 0 → motive (n/2)) → motive n) : motive n := by\n induction n using Nat.strongInductionOn with\n | ind n hyp =>\n apply ind\n intro n_pos\n if n_eq : n = 0 then\n simp [n_eq] at n_pos\n else\n apply hyp\n exact Nat.div_lt_self n_pos (Nat.le_refl _)",
"start": [
38,
1
],
"end": [
51,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.zero_and",
"code": "@[simp] theorem zero_and (x : Nat) : 0 &&& x = 0",
"start": [
53,
1
],
"end": [
56,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.and_zero",
"code": "@[simp] theorem and_zero (x : Nat) : x &&& 0 = 0",
"start": [
58,
1
],
"end": [
61,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.one_and_eq_mod_two",
"code": "@[simp] theorem one_and_eq_mod_two (n : Nat) : 1 &&& n = n % 2",
"start": [
63,
1
],
"end": [
68,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.and_one_is_mod",
"code": "@[simp] theorem and_one_is_mod (x : Nat) : x &&& 1 = x % 2",
"start": [
70,
1
],
"end": [
79,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.zero_testBit",
"code": "@[simp] theorem zero_testBit (i : Nat) : testBit 0 i = false",
"start": [
83,
1
],
"end": [
84,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_zero",
"code": "@[simp] theorem testBit_zero (x : Nat) : testBit x 0 = decide (x % 2 = 1)",
"start": [
86,
1
],
"end": [
87,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_succ",
"code": "@[simp] theorem testBit_succ (x i : Nat) : testBit x (succ i) = testBit (x/2) i",
"start": [
89,
1
],
"end": [
91,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_add_one",
"code": "@[simp] theorem testBit_add_one (x i : Nat) : testBit x (i + 1) = testBit (x/2) i",
"start": [
93,
1
],
"end": [
95,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_to_div_mod",
"code": "theorem testBit_to_div_mod {x : Nat} : testBit x i = decide (x / 2^i % 2 = 1)",
"start": [
97,
1
],
"end": [
103,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.toNat_testBit",
"code": "theorem toNat_testBit (x i : Nat) :\n (x.testBit i).toNat = x / 2 ^ i % 2",
"start": [
105,
1
],
"end": [
108,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.ne_zero_implies_bit_true",
"code": "theorem ne_zero_implies_bit_true {x : Nat} (xnz : x ≠ 0) : ∃ i, testBit x i",
"start": [
110,
1
],
"end": [
123,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.ne_implies_bit_diff",
"code": "theorem ne_implies_bit_diff {x y : Nat} (p : x ≠ y) : ∃ i, testBit x i ≠ testBit y i",
"start": [
125,
1
],
"end": [
149,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.eq_of_testBit_eq",
"code": "theorem eq_of_testBit_eq {x y : Nat} (pred : ∀i, testBit x i = testBit y i) : x = y",
"start": [
151,
1
],
"end": [
161,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.ge_two_pow_implies_high_bit_true",
"code": "theorem ge_two_pow_implies_high_bit_true {x : Nat} (p : x ≥ 2^n) : ∃ i, i ≥ n ∧ testBit x i",
"start": [
163,
1
],
"end": [
181,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_implies_ge",
"code": "theorem testBit_implies_ge {x : Nat} (p : testBit x i = true) : x ≥ 2^i",
"start": [
183,
1
],
"end": [
188,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_lt_two_pow",
"code": "theorem testBit_lt_two_pow {x i : Nat} (lt : x < 2^i) : x.testBit i = false",
"start": [
190,
1
],
"end": [
195,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.lt_pow_two_of_testBit",
"code": "theorem lt_pow_two_of_testBit (x : Nat) (p : ∀i, i ≥ n → testBit x i = false) : x < 2^n",
"start": [
197,
1
],
"end": [
203,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.succ_mod_two",
"code": "private theorem succ_mod_two : succ x % 2 = 1 - x % 2",
"start": [
205,
1
],
"end": [
212,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_succ_zero",
"code": "private theorem testBit_succ_zero : testBit (x + 1) 0 = not (testBit x 0)",
"start": [
214,
1
],
"end": [
217,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_two_pow_add_eq",
"code": "theorem testBit_two_pow_add_eq (x i : Nat) : testBit (2^i + x) i = not (testBit x i)",
"start": [
219,
1
],
"end": [
222,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_mul_two_pow_add_eq",
"code": "theorem testBit_mul_two_pow_add_eq (a b i : Nat) :\n testBit (2^i*a + b) i = Bool.xor (a%2 = 1) (testBit b i)",
"start": [
224,
1
],
"end": [
234,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_two_pow_add_gt",
"code": "theorem testBit_two_pow_add_gt {i j : Nat} (j_lt_i : j < i) (x : Nat) :\n testBit (2^i + x) j = testBit x j",
"start": [
236,
1
],
"end": [
248,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_mod_two_pow",
"code": "@[simp] theorem testBit_mod_two_pow (x j i : Nat) :\n testBit (x % 2^j) i = (decide (i < j) && testBit x i)",
"start": [
250,
1
],
"end": [
274,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_one_zero",
"code": "theorem testBit_one_zero : testBit 1 0 = true",
"start": [
276,
1
],
"end": [
276,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.not_decide_mod_two_eq_one",
"code": "theorem not_decide_mod_two_eq_one (x : Nat)\n : (!decide (x % 2 = 1)) = decide (x % 2 = 0)",
"start": [
278,
1
],
"end": [
280,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_two_pow_sub_succ",
"code": "theorem testBit_two_pow_sub_succ (h₂ : x < 2 ^ n) (i : Nat) :\n testBit (2^n - (x + 1)) i = (decide (i < n) && ! testBit x i)",
"start": [
282,
1
],
"end": [
299,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_two_pow_sub_one",
"code": "@[simp] theorem testBit_two_pow_sub_one (n i : Nat) : testBit (2^n-1) i = decide (i < n)",
"start": [
301,
1
],
"end": [
304,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_bool_to_nat",
"code": "theorem testBit_bool_to_nat (b : Bool) (i : Nat) :\n testBit (Bool.toNat b) i = (decide (i = 0) && b)",
"start": [
306,
1
],
"end": [
311,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_one_eq_true_iff_self_eq_zero",
"code": "theorem testBit_one_eq_true_iff_self_eq_zero {i : Nat} :\n Nat.testBit 1 i = true ↔ i = 0",
"start": [
313,
1
],
"end": [
316,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_bitwise",
"code": "theorem testBit_bitwise\n (false_false_axiom : f false false = false) (x y i : Nat)\n: (bitwise f x y).testBit i = f (x.testBit i) (y.testBit i)",
"start": [
320,
1
],
"end": [
344,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.eq_0_of_lt_one",
"code": "@[local simp]\nprivate theorem eq_0_of_lt_one (x : Nat) : x < 1 ↔ x = 0",
"start": [
348,
1
],
"end": [
355,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.eq_0_of_lt",
"code": "private theorem eq_0_of_lt (x : Nat) : x < 2^ 0 ↔ x = 0",
"start": [
357,
1
],
"end": [
357,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.zero_lt_pow",
"code": "@[local simp]\nprivate theorem zero_lt_pow (n : Nat) : 0 < 2^n",
"start": [
359,
1
],
"end": [
363,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.div_two_le_of_lt_two",
"code": "private theorem div_two_le_of_lt_two {m n : Nat} (p : m < 2 ^ succ n) : m / 2 < 2^n",
"start": [
365,
1
],
"end": [
367,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.bitwise_lt_two_pow",
"code": "theorem bitwise_lt_two_pow (left : x < 2^n) (right : y < 2^n) : (Nat.bitwise f x y) < 2^n",
"start": [
369,
1
],
"end": [
394,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_and",
"code": "@[simp] theorem testBit_and (x y i : Nat) : (x &&& y).testBit i = (x.testBit i && y.testBit i)",
"start": [
398,
1
],
"end": [
399,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.and_lt_two_pow",
"code": "theorem and_lt_two_pow (x : Nat) {y n : Nat} (right : y < 2^n) : (x &&& y) < 2^n",
"start": [
401,
1
],
"end": [
408,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.and_pow_two_is_mod",
"code": "@[simp] theorem and_pow_two_is_mod (x n : Nat) : x &&& (2^n-1) = x % 2^n",
"start": [
410,
1
],
"end": [
414,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.and_pow_two_identity",
"code": "theorem and_pow_two_identity {x : Nat} (lt : x < 2^n) : x &&& 2^n-1 = x",
"start": [
416,
1
],
"end": [
418,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.zero_or",
"code": "@[simp] theorem zero_or (x : Nat) : 0 ||| x = x",
"start": [
422,
1
],
"end": [
425,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.or_zero",
"code": "@[simp] theorem or_zero (x : Nat) : x ||| 0 = x",
"start": [
427,
1
],
"end": [
430,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_or",
"code": "@[simp] theorem testBit_or (x y i : Nat) : (x ||| y).testBit i = (x.testBit i || y.testBit i)",
"start": [
432,
1
],
"end": [
433,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.or_lt_two_pow",
"code": "theorem or_lt_two_pow {x y n : Nat} (left : x < 2^n) (right : y < 2^n) : x ||| y < 2^n",
"start": [
435,
1
],
"end": [
436,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_xor",
"code": "@[simp] theorem testBit_xor (x y i : Nat) :\n (x ^^^ y).testBit i = Bool.xor (x.testBit i) (y.testBit i)",
"start": [
440,
1
],
"end": [
442,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.xor_lt_two_pow",
"code": "theorem xor_lt_two_pow {x y n : Nat} (left : x < 2^n) (right : y < 2^n) : x ^^^ y < 2^n",
"start": [
444,
1
],
"end": [
445,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_mul_pow_two_add",
"code": "theorem testBit_mul_pow_two_add (a : Nat) {b i : Nat} (b_lt : b < 2^i) (j : Nat) :\n testBit (2 ^ i * a + b) j =\n if j < i then\n testBit b j\n else\n testBit a (j - i)",
"start": [
449,
1
],
"end": [
475,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_mul_pow_two",
"code": "theorem testBit_mul_pow_two :\n testBit (2 ^ i * a) j = (decide (j ≥ i) && testBit a (j-i))",
"start": [
477,
1
],
"end": [
483,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.mul_add_lt_is_or",
"code": "theorem mul_add_lt_is_or {b : Nat} (b_lt : b < 2^i) (a : Nat) : 2^i * a + b = 2^i * a ||| b",
"start": [
485,
1
],
"end": [
497,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_shiftLeft",
"code": "@[simp] theorem testBit_shiftLeft (x : Nat) : testBit (x <<< i) j =\n (decide (j ≥ i) && testBit x (j-i))",
"start": [
501,
1
],
"end": [
503,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.testBit_shiftRight",
"code": "@[simp] theorem testBit_shiftRight (x : Nat) : testBit (x >>> i) j = testBit x (i+j)",
"start": [
505,
1
],
"end": [
506,
34
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/PtrSet.lean | [
".lake/packages/lean4/src/lean/Init/Data/Hashable.lean",
".lake/packages/lean4/src/lean/Lean/Data/HashSet.lean"
] | [
{
"full_name": "Lean.Ptr",
"code": "structure Ptr (α : Type u) where\n value : α",
"start": [
12,
1
],
"end": [
13,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PtrSet",
"code": "unsafe def PtrSet (α : Type) :=\n HashSet (Ptr α)",
"start": [
21,
1
],
"end": [
25,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkPtrSet",
"code": "unsafe def mkPtrSet {α : Type} (capacity : Nat := 64) : PtrSet α :=\n mkHashSet capacity",
"start": [
27,
1
],
"end": [
28,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PtrSet.insert",
"code": "unsafe abbrev PtrSet.insert (s : PtrSet α) (a : α) : PtrSet α :=\n HashSet.insert s { value := a }",
"start": [
30,
1
],
"end": [
31,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PtrSet.contains",
"code": "unsafe abbrev PtrSet.contains (s : PtrSet α) (a : α) : Bool :=\n HashSet.contains s { value := a }",
"start": [
33,
1
],
"end": [
34,
36
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/ReplaceExpr.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.Expr.ReplaceImpl.Cache",
"code": "structure Cache where\n size : USize\n keysResults : Array NonScalar",
"start": [
14,
1
],
"end": [
18,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.Cache.new",
"code": "unsafe def Cache.new (e : Expr) : Cache :=\n let size := (1 <<< min (max e.approxDepth.toUSize 1) 13) - 1\n { size, keysResults := mkArray (2 * size).toNat (unsafeCast ()) }",
"start": [
20,
1
],
"end": [
24,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.Cache.keyIdx",
"code": "@[inline]\nunsafe def Cache.keyIdx (c : Cache) (key : Expr) : USize :=\n ptrAddrUnsafe key % c.size",
"start": [
26,
1
],
"end": [
28,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.Cache.resultIdx",
"code": "@[inline]\nunsafe def Cache.resultIdx (c : Cache) (key : Expr) : USize :=\n c.keyIdx key + c.size",
"start": [
30,
1
],
"end": [
32,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.Cache.hasResultFor",
"code": "@[inline]\nunsafe def Cache.hasResultFor (c : Cache) (key : Expr) : Bool :=\n have : (c.keyIdx key).toNat < c.keysResults.size := lcProof\n ptrEq (unsafeCast key) c.keysResults[c.keyIdx key]",
"start": [
34,
1
],
"end": [
37,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.Cache.getResultFor",
"code": "@[inline]\nunsafe def Cache.getResultFor (c : Cache) (key : Expr) : Expr :=\n have : (c.resultIdx key).toNat < c.keysResults.size := lcProof\n unsafeCast c.keysResults[c.resultIdx key]",
"start": [
39,
1
],
"end": [
42,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.Cache.store",
"code": "unsafe def Cache.store (c : Cache) (key result : Expr) : Cache :=\n { c with keysResults := c.keysResults\n |>.uset (c.keyIdx key) (unsafeCast key) lcProof\n |>.uset (c.resultIdx key) (unsafeCast result) lcProof }",
"start": [
44,
1
],
"end": [
47,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.ReplaceM",
"code": "abbrev ReplaceM := StateM Cache",
"start": [
49,
1
],
"end": [
49,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.cache",
"code": "@[inline]\nunsafe def cache (key : Expr) (result : Expr) : ReplaceM Expr := do\n modify (·.store key result)\n pure result",
"start": [
51,
1
],
"end": [
54,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.replaceUnsafeM",
"code": "@[specialize]\nunsafe def replaceUnsafeM (f? : Expr → Option Expr) (e : Expr) : ReplaceM Expr := do\n let rec @[specialize] visit (e : Expr) := do\n if (← get).hasResultFor e then\n return (← get).getResultFor e\n else match f? e with\n | some eNew => cache e eNew\n | none => match e with\n | Expr.forallE _ d b _ => cache e <| e.updateForallE! (← visit d) (← visit b)\n | Expr.lam _ d b _ => cache e <| e.updateLambdaE! (← visit d) (← visit b)\n | Expr.mdata _ b => cache e <| e.updateMData! (← visit b)\n | Expr.letE _ t v b _ => cache e <| e.updateLet! (← visit t) (← visit v) (← visit b)\n | Expr.app f a => cache e <| e.updateApp! (← visit f) (← visit a)\n | Expr.proj _ _ b => cache e <| e.updateProj! (← visit b)\n | e => pure e\n visit e",
"start": [
56,
1
],
"end": [
71,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.ReplaceImpl.replaceUnsafe",
"code": "@[inline]\nunsafe def replaceUnsafe (f? : Expr → Option Expr) (e : Expr) : Expr :=\n (replaceUnsafeM f? e).run' (Cache.new e)",
"start": [
73,
1
],
"end": [
75,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.replaceNoCache",
"code": "@[specialize]\ndef replaceNoCache (f? : Expr → Option Expr) (e : Expr) : Expr :=\n match f? e with\n | some eNew => eNew\n | none => match e with\n | .forallE _ d b _ => let d := replaceNoCache f? d; let b := replaceNoCache f? b; e.updateForallE! d b\n | .lam _ d b _ => let d := replaceNoCache f? d; let b := replaceNoCache f? b; e.updateLambdaE! d b\n | .mdata _ b => let b := replaceNoCache f? b; e.updateMData! b\n | .letE _ t v b _ => let t := replaceNoCache f? t; let v := replaceNoCache f? v; let b := replaceNoCache f? b; e.updateLet! t v b\n | .app f a => let f := replaceNoCache f? f; let a := replaceNoCache f? a; e.updateApp! f a\n | .proj _ _ b => let b := replaceNoCache f? b; e.updateProj! b\n | e => e",
"start": [
82,
1
],
"end": [
93,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.replace",
"code": "@[implemented_by ReplaceImpl.replaceUnsafe]\npartial def replace (f? : Expr → Option Expr) (e : Expr) : Expr :=\n e.replaceNoCache f?",
"start": [
95,
1
],
"end": [
97,
22
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/PersistentArray.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean",
".lake/packages/lean4/src/lean/Init/NotationExtra.lean",
".lake/packages/lean4/src/lean/Init/Data/ToString/Macro.lean"
] | [
{
"full_name": "Lean.PersistentArrayNode",
"code": "inductive PersistentArrayNode (α : Type u) where\n | node (cs : Array (PersistentArrayNode α)) : PersistentArrayNode α\n | leaf (vs : Array α) : PersistentArrayNode α\n deriving Inhabited",
"start": [
15,
1
],
"end": [
18,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArrayNode.isNode",
"code": "def isNode {α} : PersistentArrayNode α → Bool\n | node _ => true\n | leaf _ => false",
"start": [
22,
1
],
"end": [
24,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.initShift",
"code": "abbrev PersistentArray.initShift : USize := 5",
"start": [
28,
1
],
"end": [
28,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.branching",
"code": "abbrev PersistentArray.branching : USize := USize.ofNat (2 ^ PersistentArray.initShift.toNat)",
"start": [
29,
1
],
"end": [
29,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray",
"code": "structure PersistentArray (α : Type u) where\n \n root : PersistentArrayNode α := PersistentArrayNode.node (Array.mkEmpty PersistentArray.branching.toNat)\n tail : Array α := Array.mkEmpty PersistentArray.branching.toNat\n size : Nat := 0\n shift : USize := PersistentArray.initShift\n tailOff : Nat := 0\n deriving Inhabited",
"start": [
31,
1
],
"end": [
41,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PArray",
"code": "abbrev PArray (α : Type u) := PersistentArray α",
"start": [
43,
1
],
"end": [
43,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.empty",
"code": "def empty : PersistentArray α := {}",
"start": [
51,
1
],
"end": [
51,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.isEmpty",
"code": "def isEmpty (a : PersistentArray α) : Bool := a.size == 0",
"start": [
53,
1
],
"end": [
53,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mkEmptyArray",
"code": "def mkEmptyArray : Array α := Array.mkEmpty branching.toNat",
"start": [
55,
1
],
"end": [
55,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mul2Shift",
"code": "abbrev mul2Shift (i : USize) (shift : USize) : USize := i.shiftLeft shift",
"start": [
57,
1
],
"end": [
57,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.div2Shift",
"code": "abbrev div2Shift (i : USize) (shift : USize) : USize := i.shiftRight shift",
"start": [
58,
1
],
"end": [
58,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mod2Shift",
"code": "abbrev mod2Shift (i : USize) (shift : USize) : USize := USize.land i ((USize.shiftLeft 1 shift) - 1)",
"start": [
59,
1
],
"end": [
59,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.getAux",
"code": "partial def getAux [Inhabited α] : PersistentArrayNode α → USize → USize → α\n | node cs, i, shift => getAux cs[(div2Shift i shift).toNat]! (mod2Shift i shift) (shift - initShift)\n | leaf cs, i, _ => cs[i.toNat]!",
"start": [
61,
1
],
"end": [
63,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.get!",
"code": "def get! [Inhabited α] (t : PersistentArray α) (i : Nat) : α :=\n if i >= t.tailOff then\n t.tail.get! (i - t.tailOff)\n else\n getAux t.root (USize.ofNat i) t.shift",
"start": [
65,
1
],
"end": [
69,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.setAux",
"code": "partial def setAux : PersistentArrayNode α → USize → USize → α → PersistentArrayNode α\n | node cs, i, shift, a =>\n let j := div2Shift i shift\n let i := mod2Shift i shift\n let shift := shift - initShift\n node <| cs.modify j.toNat fun c => setAux c i shift a\n | leaf cs, i, _, a => leaf (cs.set! i.toNat a)",
"start": [
75,
1
],
"end": [
81,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.set",
"code": "def set (t : PersistentArray α) (i : Nat) (a : α) : PersistentArray α :=\n if i >= t.tailOff then\n { t with tail := t.tail.set! (i - t.tailOff) a }\n else\n { t with root := setAux t.root (USize.ofNat i) t.shift a }",
"start": [
83,
1
],
"end": [
87,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.modifyAux",
"code": "@[specialize] partial def modifyAux [Inhabited α] (f : α → α) : PersistentArrayNode α → USize → USize → PersistentArrayNode α\n | node cs, i, shift =>\n let j := div2Shift i shift\n let i := mod2Shift i shift\n let shift := shift - initShift\n node <| cs.modify j.toNat fun c => modifyAux f c i shift\n | leaf cs, i, _ => leaf (cs.modify i.toNat f)",
"start": [
89,
1
],
"end": [
95,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.modify",
"code": "@[specialize] def modify [Inhabited α] (t : PersistentArray α) (i : Nat) (f : α → α) : PersistentArray α :=\n if i >= t.tailOff then\n { t with tail := t.tail.modify (i - t.tailOff) f }\n else\n { t with root := modifyAux f t.root (USize.ofNat i) t.shift }",
"start": [
97,
1
],
"end": [
101,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mkNewPath",
"code": "partial def mkNewPath (shift : USize) (a : Array α) : PersistentArrayNode α :=\n if shift == 0 then\n leaf a\n else\n node (mkEmptyArray.push (mkNewPath (shift - initShift) a))",
"start": [
103,
1
],
"end": [
107,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.insertNewLeaf",
"code": "partial def insertNewLeaf : PersistentArrayNode α → USize → USize → Array α → PersistentArrayNode α\n | node cs, i, shift, a =>\n if i < branching then\n node (cs.push (leaf a))\n else\n let j := div2Shift i shift\n let i := mod2Shift i shift\n let shift := shift - initShift\n if j.toNat < cs.size then\n node <| cs.modify j.toNat fun c => insertNewLeaf c i shift a\n else\n node <| cs.push <| mkNewPath shift a\n | n, _, _, _ => n",
"start": [
109,
1
],
"end": [
121,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mkNewTail",
"code": "def mkNewTail (t : PersistentArray α) : PersistentArray α :=\n if t.size <= (mul2Shift 1 (t.shift + initShift)).toNat then\n { t with\n tail := mkEmptyArray, root := insertNewLeaf t.root (USize.ofNat (t.size - 1)) t.shift t.tail,\n tailOff := t.size }\n else\n { t with\n tail := #[],\n root := let n := mkEmptyArray.push t.root;\n node (n.push (mkNewPath t.shift t.tail)),\n shift := t.shift + initShift,\n tailOff := t.size }",
"start": [
123,
1
],
"end": [
134,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.tooBig",
"code": "def tooBig : Nat := USize.size / 8",
"start": [
136,
1
],
"end": [
136,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.push",
"code": "def push (t : PersistentArray α) (a : α) : PersistentArray α :=\n let r := { t with tail := t.tail.push a, size := t.size + 1 }\n if r.tail.size < branching.toNat || t.size >= tooBig then\n r\n else\n mkNewTail r",
"start": [
138,
1
],
"end": [
143,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.emptyArray",
"code": "private def emptyArray {α : Type u} : Array (PersistentArrayNode α) :=\n Array.mkEmpty PersistentArray.branching.toNat",
"start": [
145,
1
],
"end": [
146,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.popLeaf",
"code": "partial def popLeaf : PersistentArrayNode α → Option (Array α) × Array (PersistentArrayNode α)\n | node cs =>\n if h : cs.size ≠ 0 then\n let idx : Fin cs.size := ⟨cs.size - 1, by exact Nat.pred_lt h⟩\n let last := cs.get idx\n let cs' := cs.set idx default\n match popLeaf last with\n | (none, _) => (none, emptyArray)\n | (some l, newLast) =>\n if newLast.size == 0 then\n let cs' := cs'.pop\n if cs'.isEmpty then (some l, emptyArray) else (some l, cs')\n else\n (some l, cs'.set (Array.size_set cs idx _ ▸ idx) (node newLast))\n else\n (none, emptyArray)\n | leaf vs => (some vs, emptyArray)",
"start": [
148,
1
],
"end": [
164,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.pop",
"code": "def pop (t : PersistentArray α) : PersistentArray α :=\n if t.tail.size > 0 then\n { t with tail := t.tail.pop, size := t.size - 1 }\n else\n match popLeaf t.root with\n | (none, _) => t\n | (some last, newRoots) =>\n let last := last.pop\n let newSize := t.size - 1\n let newTailOff := newSize - last.size\n if newRoots.size == 1 && (newRoots.get! 0).isNode then\n { root := newRoots.get! 0,\n shift := t.shift - initShift,\n size := newSize,\n tail := last,\n tailOff := newTailOff }\n else\n { t with\n root := node newRoots,\n size := newSize,\n tail := last,\n tailOff := newTailOff }",
"start": [
166,
1
],
"end": [
187,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldlMAux",
"code": "@[specialize] private partial def foldlMAux (f : β → α → m β) : PersistentArrayNode α → β → m β\n | node cs, b => cs.foldlM (fun b c => foldlMAux f c b) b\n | leaf vs, b => vs.foldlM f b",
"start": [
193,
1
],
"end": [
195,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldlFromMAux",
"code": "@[specialize] private partial def foldlFromMAux (f : β → α → m β) : PersistentArrayNode α → USize → USize → β → m β\n | node cs, i, shift, b => do\n let j := (div2Shift i shift).toNat\n let b ← foldlFromMAux f (cs.get! j) (mod2Shift i shift) (shift - initShift) b\n cs.foldlM (init := b) (start := j+1) fun b c => foldlMAux f c b\n | leaf vs, i, _, b => vs.foldlM (init := b) (start := i.toNat) f",
"start": [
197,
1
],
"end": [
202,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldlM",
"code": "@[specialize] def foldlM (t : PersistentArray α) (f : β → α → m β) (init : β) (start : Nat := 0) : m β := do\n if start == 0 then\n let b ← foldlMAux f t.root init\n t.tail.foldlM f b\n else if start >= t.tailOff then\n t.tail.foldlM (init := init) (start := start - t.tailOff) f\n else do\n let b ← foldlFromMAux f t.root (USize.ofNat start) t.shift init\n t.tail.foldlM f b",
"start": [
204,
1
],
"end": [
212,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldrMAux",
"code": "@[specialize] private partial def foldrMAux [Monad m] (f : α → β → m β) : PersistentArrayNode α → β → m β\n | node cs, b => cs.foldrM (fun c b => foldrMAux f c b) b\n | leaf vs, b => vs.foldrM f b",
"start": [
214,
1
],
"end": [
216,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldrM",
"code": "@[specialize] def foldrM [Monad m] (t : PersistentArray α) (f : α → β → m β) (init : β) : m β := do\n foldrMAux f t.root (← t.tail.foldrM f init)",
"start": [
218,
1
],
"end": [
219,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.forInAux",
"code": "@[specialize]\npartial def forInAux {α : Type u} {β : Type v} {m : Type v → Type w} [Monad m] [inh : Inhabited β]\n (f : α → β → m (ForInStep β)) (n : PersistentArrayNode α) (b : β) : m (ForInStep β) := do\n let mut b := b\n match n with\n | leaf vs =>\n for v in vs do\n match (← f v b) with\n | r@(ForInStep.done _) => return r\n | ForInStep.yield bNew => b := bNew\n return ForInStep.yield b\n | node cs =>\n for c in cs do\n match (← forInAux f c b) with\n | r@(ForInStep.done _) => return r\n | ForInStep.yield bNew => b := bNew\n return ForInStep.yield b",
"start": [
222,
1
],
"end": [
238,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.forIn",
"code": "@[specialize] protected def forIn (t : PersistentArray α) (init : β) (f : α → β → m (ForInStep β)) : m β := do\n match (← forInAux (inh := ⟨init⟩) f t.root init) with\n | ForInStep.done b => pure b\n | ForInStep.yield b =>\n let mut b := b\n for v in t.tail do\n match (← f v b) with\n | ForInStep.done r => return r\n | ForInStep.yield bNew => b := bNew\n return b",
"start": [
240,
1
],
"end": [
249,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.findSomeMAux",
"code": "@[specialize] partial def findSomeMAux (f : α → m (Option β)) : PersistentArrayNode α → m (Option β)\n | node cs => cs.findSomeM? (fun c => findSomeMAux f c)\n | leaf vs => vs.findSomeM? f",
"start": [
254,
1
],
"end": [
256,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.findSomeM?",
"code": "@[specialize] def findSomeM? (t : PersistentArray α) (f : α → m (Option β)) : m (Option β) := do\n match (← findSomeMAux f t.root) with\n | none => t.tail.findSomeM? f\n | some b => pure (some b)",
"start": [
258,
1
],
"end": [
261,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.findSomeRevMAux",
"code": "@[specialize] partial def findSomeRevMAux (f : α → m (Option β)) : PersistentArrayNode α → m (Option β)\n | node cs => cs.findSomeRevM? (fun c => findSomeRevMAux f c)\n | leaf vs => vs.findSomeRevM? f",
"start": [
263,
1
],
"end": [
265,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.findSomeRevM?",
"code": "@[specialize] def findSomeRevM? (t : PersistentArray α) (f : α → m (Option β)) : m (Option β) := do\n match (← t.tail.findSomeRevM? f) with\n | none => findSomeRevMAux f t.root\n | some b => pure (some b)",
"start": [
267,
1
],
"end": [
270,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.forMAux",
"code": "@[specialize] partial def forMAux (f : α → m PUnit) : PersistentArrayNode α → m PUnit\n | node cs => cs.forM (fun c => forMAux f c)\n | leaf vs => vs.forM f",
"start": [
272,
1
],
"end": [
274,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.forM",
"code": "@[specialize] def forM (t : PersistentArray α) (f : α → m PUnit) : m PUnit :=\n forMAux f t.root *> t.tail.forM f",
"start": [
276,
1
],
"end": [
277,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldl",
"code": "@[inline] def foldl (t : PersistentArray α) (f : β → α → β) (init : β) (start : Nat := 0) : β :=\n Id.run <| t.foldlM f init start",
"start": [
281,
1
],
"end": [
282,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.foldr",
"code": "@[inline] def foldr (t : PersistentArray α) (f : α → β → β) (init : β) : β :=\n Id.run <| t.foldrM f init",
"start": [
284,
1
],
"end": [
285,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.filter",
"code": "@[inline] def filter (as : PersistentArray α) (p : α → Bool) : PersistentArray α :=\n as.foldl (init := {}) fun asNew a => if p a then asNew.push a else asNew",
"start": [
287,
1
],
"end": [
288,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.toArray",
"code": "def toArray (t : PersistentArray α) : Array α :=\n t.foldl Array.push #[]",
"start": [
290,
1
],
"end": [
291,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.append",
"code": "def append (t₁ t₂ : PersistentArray α) : PersistentArray α :=\n if t₁.isEmpty then\n t₂\n else\n t₂.foldl PersistentArray.push t₁",
"start": [
293,
1
],
"end": [
297,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.findSome?",
"code": "@[inline] def findSome? {β} (t : PersistentArray α) (f : α → (Option β)) : Option β :=\n Id.run $ t.findSomeM? f",
"start": [
301,
1
],
"end": [
302,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.findSomeRev?",
"code": "@[inline] def findSomeRev? {β} (t : PersistentArray α) (f : α → (Option β)) : Option β :=\n Id.run $ t.findSomeRevM? f",
"start": [
304,
1
],
"end": [
305,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.toList",
"code": "def toList (t : PersistentArray α) : List α :=\n (t.foldl (init := []) fun xs x => x :: xs).reverse",
"start": [
307,
1
],
"end": [
308,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.anyMAux",
"code": "@[specialize] partial def anyMAux (p : α → m Bool) : PersistentArrayNode α → m Bool\n | node cs => cs.anyM fun c => anyMAux p c\n | leaf vs => vs.anyM p",
"start": [
312,
1
],
"end": [
314,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.anyM",
"code": "@[specialize] def anyM (t : PersistentArray α) (p : α → m Bool) : m Bool :=\n anyMAux p t.root <||> t.tail.anyM p",
"start": [
316,
1
],
"end": [
317,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.allM",
"code": "@[inline] def allM (a : PersistentArray α) (p : α → m Bool) : m Bool := do\n let b ← anyM a (fun v => do let b ← p v; pure (not b))\n pure (not b)",
"start": [
319,
1
],
"end": [
321,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.any",
"code": "@[inline] def any (a : PersistentArray α) (p : α → Bool) : Bool :=\n Id.run $ anyM a p",
"start": [
325,
1
],
"end": [
326,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.all",
"code": "@[inline] def all (a : PersistentArray α) (p : α → Bool) : Bool :=\n !any a fun v => !p v",
"start": [
328,
1
],
"end": [
329,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mapMAux",
"code": "@[specialize] partial def mapMAux (f : α → m β) : PersistentArrayNode α → m (PersistentArrayNode β)\n | node cs => node <$> cs.mapM (fun c => mapMAux f c)\n | leaf vs => leaf <$> vs.mapM f",
"start": [
335,
1
],
"end": [
337,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.mapM",
"code": "@[specialize] def mapM (f : α → m β) (t : PersistentArray α) : m (PersistentArray β) := do\n let root ← mapMAux f t.root\n let tail ← t.tail.mapM f\n pure { t with tail := tail, root := root }",
"start": [
339,
1
],
"end": [
342,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.map",
"code": "@[inline] def map {β} (f : α → β) (t : PersistentArray α) : PersistentArray β :=\n Id.run $ t.mapM f",
"start": [
346,
1
],
"end": [
347,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.Stats",
"code": "structure Stats where\n numNodes : Nat\n depth : Nat\n tailSize : Nat",
"start": [
349,
1
],
"end": [
352,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.collectStats",
"code": "partial def collectStats : PersistentArrayNode α → Stats → Nat → Stats\n | node cs, s, d =>\n cs.foldl (fun s c => collectStats c s (d+1))\n { s with\n numNodes := s.numNodes + 1,\n depth := Nat.max d s.depth }\n | leaf _, s, d => { s with numNodes := s.numNodes + 1, depth := Nat.max d s.depth }",
"start": [
354,
1
],
"end": [
360,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.stats",
"code": "def stats (r : PersistentArray α) : Stats :=\n collectStats r.root { numNodes := 0, depth := 0, tailSize := r.tail.size } 0",
"start": [
362,
1
],
"end": [
363,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentArray.Stats.toString",
"code": "def Stats.toString (s : Stats) : String :=\n s!\"\\{nodes := {s.numNodes}, depth := {s.depth}, tail size := {s.tailSize}}\"",
"start": [
365,
1
],
"end": [
366,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkPersistentArray",
"code": "def mkPersistentArray {α : Type u} (n : Nat) (v : α) : PArray α :=\n n.fold (init := PersistentArray.empty) fun _ p => p.push v",
"start": [
372,
1
],
"end": [
373,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkPArray",
"code": "@[inline] def mkPArray {α : Type u} (n : Nat) (v : α) : PArray α :=\n mkPersistentArray n v",
"start": [
375,
1
],
"end": [
376,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "List.toPArray'",
"code": "def List.toPArray' {α : Type u} (xs : List α) : PersistentArray α :=\n let rec loop : List α → PersistentArray α → PersistentArray α\n | [], t => t\n | x::xs, t => loop xs (t.push x)\n loop xs {}",
"start": [
382,
1
],
"end": [
386,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.toPArray'",
"code": "def Array.toPArray' {α : Type u} (xs : Array α) : PersistentArray α :=\n xs.foldl (init := .empty) fun p x => p.push x",
"start": [
388,
1
],
"end": [
389,
48
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Nat/Control.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Basic.lean",
".lake/packages/lean4/src/lean/Init/Control/Basic.lean"
] | [
{
"full_name": "Nat.forM",
"code": "@[inline] def forM {m} [Monad m] (n : Nat) (f : Nat → m Unit) : m Unit :=\n let rec @[specialize] loop\n | 0 => pure ()\n | i+1 => do f (n-i-1); loop i\n loop n",
"start": [
13,
1
],
"end": [
17,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.forRevM",
"code": "@[inline] def forRevM {m} [Monad m] (n : Nat) (f : Nat → m Unit) : m Unit :=\n let rec @[specialize] loop\n | 0 => pure ()\n | i+1 => do f i; loop i\n loop n",
"start": [
19,
1
],
"end": [
23,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.foldM",
"code": "@[inline] def foldM {α : Type u} {m : Type u → Type v} [Monad m] (f : Nat → α → m α) (init : α) (n : Nat) : m α :=\n let rec @[specialize] loop\n | 0, a => pure a\n | i+1, a => f (n-i-1) a >>= loop i\n loop n init",
"start": [
25,
1
],
"end": [
29,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.foldRevM",
"code": "@[inline] def foldRevM {α : Type u} {m : Type u → Type v} [Monad m] (f : Nat → α → m α) (init : α) (n : Nat) : m α :=\n let rec @[specialize] loop\n | 0, a => pure a\n | i+1, a => f i a >>= loop i\n loop n init",
"start": [
31,
1
],
"end": [
35,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.allM",
"code": "@[inline] def allM {m} [Monad m] (n : Nat) (p : Nat → m Bool) : m Bool :=\n let rec @[specialize] loop\n | 0 => pure true\n | i+1 => do\n match (← p (n-i-1)) with\n | true => loop i\n | false => pure false\n loop n",
"start": [
37,
1
],
"end": [
44,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Nat.anyM",
"code": "@[inline] def anyM {m} [Monad m] (n : Nat) (p : Nat → m Bool) : m Bool :=\n let rec @[specialize] loop\n | 0 => pure false\n | i+1 => do\n match (← p (n-i-1)) with\n | true => pure true\n | false => loop i\n loop n",
"start": [
46,
1
],
"end": [
53,
9
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Dynamic.lean | [
".lake/packages/lean4/src/lean/Init/Core.lean"
] | [
{
"full_name": "TypeNameData",
"code": "private opaque TypeNameData (α : Type u) : NonemptyType.{0} :=\n ⟨Name, inferInstance⟩",
"start": [
13,
1
],
"end": [
14,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "TypeName",
"code": "@[nospecialize]\nclass TypeName (α : Type u) where private mk' ::\n private data : (TypeNameData α).type",
"start": [
16,
1
],
"end": [
34,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "TypeName.mk",
"code": "unsafe def TypeName.mk (α : Type u) (typeName : Name) : TypeName α :=\n ⟨unsafeCast typeName⟩",
"start": [
38,
1
],
"end": [
45,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "TypeName.typeNameImpl",
"code": "private unsafe def TypeName.typeNameImpl (α) [TypeName α] : Name :=\n unsafeCast (@TypeName.data α _)",
"start": [
47,
1
],
"end": [
48,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "TypeName.typeName",
"code": "@[implemented_by TypeName.typeNameImpl]\nopaque TypeName.typeName (α) [TypeName α] : Name",
"start": [
50,
1
],
"end": [
54,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "DynamicPointed",
"code": "private opaque DynamicPointed : NonemptyType.{0} :=\n ⟨Name × NonScalar, inferInstance⟩",
"start": [
56,
1
],
"end": [
57,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic",
"code": "def Dynamic : Type := DynamicPointed.type",
"start": [
59,
1
],
"end": [
65,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic.typeNameImpl",
"code": "private unsafe def Dynamic.typeNameImpl (any : Dynamic) : Name :=\n (unsafeCast any : Name × NonScalar).1",
"start": [
69,
1
],
"end": [
70,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic.typeName",
"code": "@[implemented_by Dynamic.typeNameImpl]\nopaque Dynamic.typeName (any : Dynamic) : Name",
"start": [
72,
1
],
"end": [
76,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic.get?Impl",
"code": "private unsafe def Dynamic.get?Impl (α) (any : Dynamic) [TypeName α] : Option α :=\n let ((typeName, obj) : Name × NonScalar) := unsafeCast any\n if typeName == TypeName.typeName α then\n some (unsafeCast obj)\n else\n none",
"start": [
78,
1
],
"end": [
83,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic.get?",
"code": "@[implemented_by Dynamic.get?Impl]\nopaque Dynamic.get? (α) (any : Dynamic) [TypeName α] : Option α",
"start": [
85,
1
],
"end": [
90,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic.mkImpl",
"code": "private unsafe def Dynamic.mkImpl [TypeName α] (obj : α) : Dynamic :=\n unsafeCast (TypeName.typeName α, (unsafeCast obj : NonScalar))",
"start": [
92,
1
],
"end": [
93,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Dynamic.mk",
"code": "@[implemented_by Dynamic.mkImpl]\nopaque Dynamic.mk [TypeName α] (obj : α) : Dynamic",
"start": [
95,
1
],
"end": [
96,
51
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Json.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json/FromToJson.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Printer.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Parser.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Elab.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json/Stream.lean"
] | [] |
.lake/packages/lean4/src/lean/Init/Data/BitVec/Basic.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Bitwise/Lemmas.lean",
".lake/packages/lean4/src/lean/Init/Data/Int/Bitwise.lean",
".lake/packages/lean4/src/lean/Init/Data/Nat/Power2.lean",
".lake/packages/lean4/src/lean/Init/Data/Fin/Basic.lean"
] | [
{
"full_name": "BitVec",
"code": "structure BitVec (w : Nat) where\n \n ofFin ::\n \n toFin : Fin (2^w)",
"start": [
23,
1
],
"end": [
35,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Std.BitVec",
"code": "@[deprecated (since := \"2024-04-12\")]\nprotected abbrev Std.BitVec := _root_.BitVec",
"start": [
37,
1
],
"end": [
38,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.decEq",
"code": "def BitVec.decEq (a b : BitVec n) : Decidable (a = b) :=\n match a, b with\n | ⟨n⟩, ⟨m⟩ =>\n if h : n = m then\n isTrue (h ▸ rfl)\n else\n isFalse (fun h' => BitVec.noConfusion h' (fun h' => absurd h' h))",
"start": [
43,
1
],
"end": [
49,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofNatLt",
"code": "@[match_pattern]\nprotected def ofNatLt {n : Nat} (i : Nat) (p : i < 2^n) : BitVec n where\n toFin := ⟨i, p⟩",
"start": [
57,
1
],
"end": [
60,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofNat",
"code": "@[match_pattern]\nprotected def ofNat (n : Nat) (i : Nat) : BitVec n where\n toFin := Fin.ofNat' i (Nat.two_pow_pos n)",
"start": [
62,
1
],
"end": [
65,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.instOfNat",
"code": "instance instOfNat : OfNat (BitVec n) i where ofNat := .ofNat n i",
"start": [
67,
1
],
"end": [
67,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.natCastInst",
"code": "instance natCastInst : NatCast (BitVec w) := ⟨BitVec.ofNat w⟩",
"start": [
68,
1
],
"end": [
68,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.toNat",
"code": "protected def toNat (a : BitVec n) : Nat := a.toFin.val",
"start": [
70,
1
],
"end": [
72,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.isLt",
"code": "theorem isLt (x : BitVec w) : x.toNat < 2^w",
"start": [
74,
1
],
"end": [
75,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.toNat_lt",
"code": "@[deprecated isLt (since := \"2024-03-12\")]\ntheorem toNat_lt (x : BitVec n) : x.toNat < 2^n",
"start": [
77,
1
],
"end": [
78,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofNat_eq_ofNat",
"code": "@[simp, bv_toNat] theorem ofNat_eq_ofNat : @OfNat.ofNat (BitVec n) i _ = .ofNat n i",
"start": [
80,
1
],
"end": [
82,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.natCast_eq_ofNat",
"code": "@[simp] theorem natCast_eq_ofNat (w x : Nat) : @Nat.cast (BitVec w) _ x = .ofNat w x",
"start": [
85,
1
],
"end": [
85,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.nil",
"code": "abbrev nil : BitVec 0 := 0",
"start": [
95,
1
],
"end": [
96,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.eq_nil",
"code": "theorem eq_nil (x : BitVec 0) : x = nil",
"start": [
98,
1
],
"end": [
99,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.zero",
"code": "protected def zero (n : Nat) : BitVec n := .ofNatLt 0 (Nat.two_pow_pos n)",
"start": [
105,
1
],
"end": [
106,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.allOnes",
"code": "def allOnes (n : Nat) : BitVec n :=\n .ofNatLt (2^n - 1) (Nat.le_of_eq (Nat.sub_add_cancel (Nat.two_pow_pos n)))",
"start": [
109,
1
],
"end": [
111,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.getLsb",
"code": "@[inline] def getLsb (x : BitVec w) (i : Nat) : Bool := x.toNat.testBit i",
"start": [
117,
1
],
"end": [
118,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.getMsb",
"code": "@[inline] def getMsb (x : BitVec w) (i : Nat) : Bool := i < w && getLsb x (w-1-i)",
"start": [
120,
1
],
"end": [
121,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.msb",
"code": "@[inline] protected def msb (a : BitVec n) : Bool := getMsb a 0",
"start": [
123,
1
],
"end": [
124,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.toInt",
"code": "protected def toInt (a : BitVec n) : Int :=\n if 2 * a.toNat < 2^n then\n a.toNat\n else\n (a.toNat : Int) - (2^n : Nat)",
"start": [
130,
1
],
"end": [
135,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofInt",
"code": "protected def ofInt (n : Nat) (i : Int) : BitVec n := .ofNatLt (i % (Int.ofNat (2^n))).toNat (by\n apply (Int.toNat_lt _).mpr\n · apply Int.emod_lt_of_pos\n exact Int.ofNat_pos.mpr (Nat.two_pow_pos _)\n · apply Int.emod_nonneg\n intro eq\n apply Nat.ne_of_gt (Nat.two_pow_pos n)\n exact Int.ofNat_inj.mp eq)",
"start": [
137,
1
],
"end": [
145,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.unexpandBitVecOfNat",
"code": "@[app_unexpander BitVec.ofNat] def unexpandBitVecOfNat : Lean.PrettyPrinter.Unexpander\n | `($(_) $n $i:num) => `($i:num#$n)\n | _ => throw ()",
"start": [
157,
1
],
"end": [
160,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.unexpandBitVecOfNatLt",
"code": "@[app_unexpander BitVec.ofNatLt] def unexpandBitVecOfNatLt : Lean.PrettyPrinter.Unexpander\n | `($(_) $i $p) => `($i#'$p)\n | _ => throw ()",
"start": [
166,
1
],
"end": [
169,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.toHex",
"code": "protected def toHex {n : Nat} (x : BitVec n) : String :=\n let s := (Nat.toDigits 16 x.toNat).asString\n let t := (List.replicate ((n+3) / 4 - s.length) '0').asString\n t ++ s",
"start": [
175,
1
],
"end": [
179,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.add",
"code": "protected def add (x y : BitVec n) : BitVec n := .ofNat n (x.toNat + y.toNat)",
"start": [
188,
1
],
"end": [
194,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.sub",
"code": "protected def sub (x y : BitVec n) : BitVec n := .ofNat n ((2^n - y.toNat) + x.toNat)",
"start": [
197,
1
],
"end": [
201,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.neg",
"code": "protected def neg (x : BitVec n) : BitVec n := .ofNat n (2^n - x.toNat)",
"start": [
204,
1
],
"end": [
210,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.abs",
"code": "protected def abs (s : BitVec n) : BitVec n := if s.msb then .neg s else s",
"start": [
213,
1
],
"end": [
216,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.mul",
"code": "protected def mul (x y : BitVec n) : BitVec n := BitVec.ofNat n (x.toNat * y.toNat)",
"start": [
218,
1
],
"end": [
224,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.udiv",
"code": "def udiv (x y : BitVec n) : BitVec n :=\n (x.toNat / y.toNat)#'(Nat.lt_of_le_of_lt (Nat.div_le_self _ _) x.isLt)",
"start": [
227,
1
],
"end": [
231,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.umod",
"code": "def umod (x y : BitVec n) : BitVec n :=\n (x.toNat % y.toNat)#'(Nat.lt_of_le_of_lt (Nat.mod_le _ _) x.isLt)",
"start": [
234,
1
],
"end": [
240,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.smtUDiv",
"code": "def smtUDiv (x y : BitVec n) : BitVec n := if y = 0 then allOnes n else udiv x y",
"start": [
243,
1
],
"end": [
250,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.sdiv",
"code": "def sdiv (s t : BitVec n) : BitVec n :=\n match s.msb, t.msb with\n | false, false => udiv s t\n | false, true => .neg (udiv s (.neg t))\n | true, false => .neg (udiv (.neg s) t)\n | true, true => udiv (.neg s) (.neg t)",
"start": [
252,
1
],
"end": [
268,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.smtSDiv",
"code": "def smtSDiv (s t : BitVec n) : BitVec n :=\n match s.msb, t.msb with\n | false, false => smtUDiv s t\n | false, true => .neg (smtUDiv s (.neg t))\n | true, false => .neg (smtUDiv (.neg s) t)\n | true, true => smtUDiv (.neg s) (.neg t)",
"start": [
270,
1
],
"end": [
282,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.srem",
"code": "def srem (s t : BitVec n) : BitVec n :=\n match s.msb, t.msb with\n | false, false => umod s t\n | false, true => umod s (.neg t)\n | true, false => .neg (umod (.neg s) t)\n | true, true => .neg (umod (.neg s) (.neg t))",
"start": [
284,
1
],
"end": [
294,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.smod",
"code": "def smod (s t : BitVec m) : BitVec m :=\n match s.msb, t.msb with\n | false, false => umod s t\n | false, true =>\n let u := umod s (.neg t)\n (if u = .zero m then u else .add u t)\n | true, false =>\n let u := umod (.neg s) t\n (if u = .zero m then u else .sub t u)\n | true, true => .neg (umod (.neg s) (.neg t))",
"start": [
296,
1
],
"end": [
310,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofBool",
"code": "def ofBool (b : Bool) : BitVec 1 := cond b 1 0",
"start": [
317,
1
],
"end": [
318,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofBool_false",
"code": "@[simp] theorem ofBool_false : ofBool false = 0",
"start": [
320,
1
],
"end": [
320,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofBool_true",
"code": "@[simp] theorem ofBool_true : ofBool true = 1",
"start": [
321,
1
],
"end": [
321,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.fill",
"code": "def fill (w : Nat) (b : Bool) : BitVec w := bif b then -1 else 0",
"start": [
323,
1
],
"end": [
324,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ult",
"code": "protected def ult (x y : BitVec n) : Bool := x.toNat < y.toNat",
"start": [
330,
1
],
"end": [
335,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ule",
"code": "protected def ule (x y : BitVec n) : Bool := x.toNat ≤ y.toNat",
"start": [
341,
1
],
"end": [
346,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.slt",
"code": "protected def slt (x y : BitVec n) : Bool := x.toInt < y.toInt",
"start": [
352,
1
],
"end": [
361,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.sle",
"code": "protected def sle (x y : BitVec n) : Bool := x.toInt ≤ y.toInt",
"start": [
363,
1
],
"end": [
368,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.cast",
"code": "@[inline] def cast (eq : n = m) (i : BitVec n) : BitVec m := .ofNatLt i.toNat (eq ▸ i.isLt)",
"start": [
374,
1
],
"end": [
375,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.cast_ofNat",
"code": "@[simp] theorem cast_ofNat {n m : Nat} (h : n = m) (x : Nat) :\n cast h (BitVec.ofNat n x) = BitVec.ofNat m x",
"start": [
377,
1
],
"end": [
379,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.cast_cast",
"code": "@[simp] theorem cast_cast {n m k : Nat} (h₁ : n = m) (h₂ : m = k) (x : BitVec n) :\n cast h₂ (cast h₁ x) = cast (h₁ ▸ h₂) x",
"start": [
381,
1
],
"end": [
383,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.cast_eq",
"code": "@[simp] theorem cast_eq {n : Nat} (h : n = n) (x : BitVec n) : cast h x = x",
"start": [
385,
1
],
"end": [
385,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.extractLsb'",
"code": "def extractLsb' (start len : Nat) (a : BitVec n) : BitVec len := .ofNat _ (a.toNat >>> start)",
"start": [
387,
1
],
"end": [
392,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.extractLsb",
"code": "def extractLsb (hi lo : Nat) (a : BitVec n) : BitVec (hi - lo + 1) := extractLsb' lo _ a",
"start": [
394,
1
],
"end": [
400,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.zeroExtend'",
"code": "def zeroExtend' {n w : Nat} (le : n ≤ w) (x : BitVec n) : BitVec w :=\n x.toNat#'(by\n apply Nat.lt_of_lt_of_le x.isLt\n exact Nat.pow_le_pow_of_le_right (by trivial) le)",
"start": [
402,
1
],
"end": [
408,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.shiftLeftZeroExtend",
"code": "def shiftLeftZeroExtend (msbs : BitVec w) (m : Nat) : BitVec (w+m) :=\n let shiftLeftLt {x : Nat} (p : x < 2^w) (m : Nat) : x <<< m < 2^(w+m) := by\n simp [Nat.shiftLeft_eq, Nat.pow_add]\n apply Nat.mul_lt_mul_of_pos_right p\n exact (Nat.two_pow_pos m)\n (msbs.toNat <<< m)#'(shiftLeftLt msbs.isLt m)",
"start": [
410,
1
],
"end": [
419,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.zeroExtend",
"code": "def zeroExtend (v : Nat) (x : BitVec w) : BitVec v :=\n if h : w ≤ v then\n zeroExtend' h x\n else\n .ofNat v x.toNat",
"start": [
421,
1
],
"end": [
431,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.truncate",
"code": "abbrev truncate := @zeroExtend",
"start": [
433,
1
],
"end": [
437,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.signExtend",
"code": "def signExtend (v : Nat) (x : BitVec w) : BitVec v := .ofInt v x.toInt",
"start": [
439,
1
],
"end": [
445,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.and",
"code": "protected def and (x y : BitVec n) : BitVec n :=\n (x.toNat &&& y.toNat)#'(Nat.and_lt_two_pow x.toNat y.isLt)",
"start": [
451,
1
],
"end": [
461,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.or",
"code": "protected def or (x y : BitVec n) : BitVec n :=\n (x.toNat ||| y.toNat)#'(Nat.or_lt_two_pow x.isLt y.isLt)",
"start": [
464,
1
],
"end": [
474,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.xor",
"code": "protected def xor (x y : BitVec n) : BitVec n :=\n (x.toNat ^^^ y.toNat)#'(Nat.xor_lt_two_pow x.isLt y.isLt)",
"start": [
477,
1
],
"end": [
487,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.not",
"code": "protected def not (x : BitVec n) : BitVec n := allOnes n ^^^ x",
"start": [
490,
1
],
"end": [
498,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.shiftLeft",
"code": "protected def shiftLeft (a : BitVec n) (s : Nat) : BitVec n := BitVec.ofNat n (a.toNat <<< s)",
"start": [
501,
1
],
"end": [
507,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ushiftRight",
"code": "def ushiftRight (a : BitVec n) (s : Nat) : BitVec n :=\n (a.toNat >>> s)#'(by\n let ⟨a, lt⟩ := a\n simp only [BitVec.toNat, Nat.shiftRight_eq_div_pow, Nat.div_lt_iff_lt_mul (Nat.two_pow_pos s)]\n rw [←Nat.mul_one a]\n exact Nat.mul_lt_mul_of_lt_of_le' lt (Nat.two_pow_pos s) (Nat.le_refl 1))",
"start": [
510,
1
],
"end": [
521,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.sshiftRight",
"code": "def sshiftRight (a : BitVec n) (s : Nat) : BitVec n := .ofInt n (a.toInt >>> s)",
"start": [
525,
1
],
"end": [
532,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.rotateLeftAux",
"code": "def rotateLeftAux (x : BitVec w) (n : Nat) : BitVec w :=\n x <<< n ||| x >>> (w - n)",
"start": [
537,
1
],
"end": [
540,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.rotateLeft",
"code": "def rotateLeft (x : BitVec w) (n : Nat) : BitVec w := rotateLeftAux x (n % w)",
"start": [
542,
1
],
"end": [
551,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.rotateRightAux",
"code": "def rotateRightAux (x : BitVec w) (n : Nat) : BitVec w :=\n x >>> n ||| x <<< (w - n)",
"start": [
554,
1
],
"end": [
559,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.rotateRight",
"code": "def rotateRight (x : BitVec w) (n : Nat) : BitVec w := rotateRightAux x (n % w)",
"start": [
561,
1
],
"end": [
570,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.append",
"code": "def append (msbs : BitVec n) (lsbs : BitVec m) : BitVec (n+m) :=\n shiftLeftZeroExtend msbs m ||| zeroExtend' (Nat.le_add_left m n) lsbs",
"start": [
572,
1
],
"end": [
579,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.replicate",
"code": "def replicate : (i : Nat) → BitVec w → BitVec (w*i)\n | 0, _ => 0\n | n+1, x =>\n have hEq : w + w*n = w*(n + 1) := by\n rw [Nat.mul_add, Nat.add_comm, Nat.mul_one]\n hEq ▸ (x ++ replicate n x)",
"start": [
584,
1
],
"end": [
590,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.concat",
"code": "def concat {n} (msbs : BitVec n) (lsb : Bool) : BitVec (n+1) := msbs ++ (ofBool lsb)",
"start": [
600,
1
],
"end": [
602,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.cons",
"code": "def cons {n} (msb : Bool) (lsbs : BitVec n) : BitVec (n+1) :=\n ((ofBool msb) ++ lsbs).cast (Nat.add_comm ..)",
"start": [
604,
1
],
"end": [
607,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.append_ofBool",
"code": "theorem append_ofBool (msbs : BitVec w) (lsb : Bool) :\n msbs ++ ofBool lsb = concat msbs lsb",
"start": [
609,
1
],
"end": [
611,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofBool_append",
"code": "theorem ofBool_append (msb : Bool) (lsbs : BitVec w) :\n ofBool msb ++ lsbs = (cons msb lsbs).cast (Nat.add_comm ..)",
"start": [
613,
1
],
"end": [
615,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.twoPow",
"code": "def twoPow (w : Nat) (i : Nat) : BitVec w := 1#w <<< i",
"start": [
617,
1
],
"end": [
622,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.append_eq",
"code": "@[simp] theorem append_eq (x : BitVec w) (y : BitVec v) : BitVec.append x y = x ++ y",
"start": [
628,
1
],
"end": [
628,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.shiftLeft_eq",
"code": "@[simp] theorem shiftLeft_eq (x : BitVec w) (n : Nat) : BitVec.shiftLeft x n = x <<< n",
"start": [
629,
1
],
"end": [
629,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ushiftRight_eq",
"code": "@[simp] theorem ushiftRight_eq (x : BitVec w) (n : Nat) : BitVec.ushiftRight x n = x >>> n",
"start": [
630,
1
],
"end": [
630,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.not_eq",
"code": "@[simp] theorem not_eq (x : BitVec w) : BitVec.not x = ~~~x",
"start": [
631,
1
],
"end": [
631,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.and_eq",
"code": "@[simp] theorem and_eq (x y : BitVec w) : BitVec.and x y = x &&& y",
"start": [
632,
1
],
"end": [
632,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.or_eq",
"code": "@[simp] theorem or_eq (x y : BitVec w) : BitVec.or x y = x ||| y",
"start": [
633,
1
],
"end": [
633,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.xor_eq",
"code": "@[simp] theorem xor_eq (x y : BitVec w) : BitVec.xor x y = x ^^^ y",
"start": [
634,
1
],
"end": [
634,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.neg_eq",
"code": "@[simp] theorem neg_eq (x : BitVec w) : BitVec.neg x = -x",
"start": [
635,
1
],
"end": [
635,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.add_eq",
"code": "@[simp] theorem add_eq (x y : BitVec w) : BitVec.add x y = x + y",
"start": [
636,
1
],
"end": [
636,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.sub_eq",
"code": "@[simp] theorem sub_eq (x y : BitVec w) : BitVec.sub x y = x - y",
"start": [
637,
1
],
"end": [
637,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.mul_eq",
"code": "@[simp] theorem mul_eq (x y : BitVec w) : BitVec.mul x y = x * y",
"start": [
638,
1
],
"end": [
638,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.zero_eq",
"code": "@[simp] theorem zero_eq : BitVec.zero n = 0#n",
"start": [
639,
1
],
"end": [
639,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofBoolListBE",
"code": "def ofBoolListBE : (bs : List Bool) → BitVec bs.length\n| [] => 0#0\n| b :: bs => cons b (ofBoolListBE bs)",
"start": [
642,
1
],
"end": [
645,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "BitVec.ofBoolListLE",
"code": "def ofBoolListLE : (bs : List Bool) → BitVec bs.length\n| [] => 0#0\n| b :: bs => concat (ofBoolListLE bs) b",
"start": [
647,
1
],
"end": [
650,
40
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Control/StateRef.lean | [
".lake/packages/lean4/src/lean/Init/System/IO.lean",
".lake/packages/lean4/src/lean/Init/Control/State.lean"
] | [
{
"full_name": "StateRefT'",
"code": "def StateRefT' (ω : Type) (σ : Type) (m : Type → Type) (α : Type) : Type := ReaderT (ST.Ref ω σ) m α",
"start": [
12,
1
],
"end": [
12,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "StateRefT'.run",
"code": "@[always_inline, inline]\ndef StateRefT'.run {ω σ : Type} {m : Type → Type} [Monad m] [MonadLiftT (ST ω) m] {α : Type} (x : StateRefT' ω σ m α) (s : σ) : m (α × σ) := do\n let ref ← ST.mkRef s\n let a ← x ref\n let s ← ref.get\n pure (a, s)",
"start": [
16,
1
],
"end": [
21,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "StateRefT'.run'",
"code": "@[always_inline, inline]\ndef StateRefT'.run' {ω σ : Type} {m : Type → Type} [Monad m] [MonadLiftT (ST ω) m] {α : Type} (x : StateRefT' ω σ m α) (s : σ) : m α := do\n let (a, _) ← x.run s\n pure a",
"start": [
23,
1
],
"end": [
26,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "StateRefT'.lift",
"code": "@[always_inline, inline]\nprotected def lift (x : m α) : StateRefT' ω σ m α :=\n fun _ => x",
"start": [
31,
1
],
"end": [
33,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "StateRefT'.get",
"code": "@[inline]\nprotected def get [MonadLiftT (ST ω) m] : StateRefT' ω σ m σ :=\n fun ref => ref.get",
"start": [
40,
1
],
"end": [
42,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "StateRefT'.set",
"code": "@[inline]\nprotected def set [MonadLiftT (ST ω) m] (s : σ) : StateRefT' ω σ m PUnit :=\n fun ref => ref.set s",
"start": [
44,
1
],
"end": [
46,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "StateRefT'.modifyGet",
"code": "@[inline]\nprotected def modifyGet [MonadLiftT (ST ω) m] (f : σ → α × σ) : StateRefT' ω σ m α :=\n fun ref => ref.modifyGet f",
"start": [
48,
1
],
"end": [
50,
29
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/FindExpr.lean | [
".lake/packages/lean4/src/lean/Lean/Util/PtrSet.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.Expr.FindImpl.FindM",
"code": "unsafe abbrev FindM := StateT (PtrSet Expr) Id",
"start": [
14,
1
],
"end": [
14,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.FindImpl.checkVisited",
"code": "@[inline] unsafe def checkVisited (e : Expr) : OptionT FindM Unit := do\n if (← get).contains e then\n failure\n modify fun s => s.insert e",
"start": [
16,
1
],
"end": [
19,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.FindImpl.findM?",
"code": "unsafe def findM? (p : Expr → Bool) (e : Expr) : OptionT FindM Expr :=\n let rec visit (e : Expr) := do\n checkVisited e\n if p e then\n pure e\n else match e with\n | .forallE _ d b _ => visit d <|> visit b\n | .lam _ d b _ => visit d <|> visit b\n | .mdata _ b => visit b\n | .letE _ t v b _ => visit t <|> visit v <|> visit b\n | .app f a => visit f <|> visit a\n | .proj _ _ b => visit b\n | _ => failure\n visit e",
"start": [
21,
1
],
"end": [
34,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.FindImpl.findUnsafe?",
"code": "unsafe def findUnsafe? (p : Expr → Bool) (e : Expr) : Option Expr :=\n Id.run <| findM? p e |>.run' mkPtrSet",
"start": [
36,
1
],
"end": [
37,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.find?",
"code": "@[implemented_by FindImpl.findUnsafe?]\ndef find? (p : Expr → Bool) (e : Expr) : Option Expr :=\n \n if p e then\n some e\n else match e with\n | .forallE _ d b _ => find? p d <|> find? p b\n | .lam _ d b _ => find? p d <|> find? p b\n | .mdata _ b => find? p b\n | .letE _ t v b _ => find? p t <|> find? p v <|> find? p b\n | .app f a => find? p f <|> find? p a\n | .proj _ _ b => find? p b\n | _ => none",
"start": [
41,
1
],
"end": [
53,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.occurs",
"code": "def occurs (e : Expr) (t : Expr) : Bool :=\n (t.find? fun s => s == e).isSome",
"start": [
55,
1
],
"end": [
57,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.FindStep",
"code": "inductive FindStep where\n | found\n | visit\n | done",
"start": [
59,
1
],
"end": [
65,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.FindExtImpl.findM?",
"code": "unsafe def findM? (p : Expr → FindStep) (e : Expr) : OptionT FindImpl.FindM Expr :=\n visit e\nwhere\n visitApp (e : Expr) :=\n match e with\n | .app f a .. => visitApp f <|> visit a\n | e => visit e\n\n visit (e : Expr) := do\n FindImpl.checkVisited e\n match p e with\n | .done => failure\n | .found => pure e\n | .visit =>\n match e with\n | .forallE _ d b _ => visit d <|> visit b\n | .lam _ d b _ => visit d <|> visit b\n | .mdata _ b => visit b\n | .letE _ t v b _ => visit t <|> visit v <|> visit b\n | .app .. => visitApp e\n | .proj _ _ b => visit b\n | _ => failure",
"start": [
69,
1
],
"end": [
90,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.FindExtImpl.findUnsafe?",
"code": "unsafe def findUnsafe? (p : Expr → FindStep) (e : Expr) : Option Expr :=\n Id.run <| findM? p e |>.run' mkPtrSet",
"start": [
92,
1
],
"end": [
93,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.findExt?",
"code": "@[implemented_by FindExtImpl.findUnsafe?]\nopaque findExt? (p : Expr → FindStep) (e : Expr) : Option Expr",
"start": [
97,
1
],
"end": [
101,
63
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/Path.lean | [
".lake/packages/lean4/src/lean/Init/System/IO.lean",
".lake/packages/lean4/src/lean/Init/Data/List/Control.lean"
] | [
{
"full_name": "Lean.forEachModuleInDir",
"code": "partial def forEachModuleInDir [Monad m] [MonadLiftT IO m]\n (dir : FilePath) (f : Lean.Name → m PUnit) : m PUnit := do\n for entry in (← dir.readDir) do\n if (← liftM (m := IO) <| entry.path.isDir) then\n let n := Lean.Name.mkSimple entry.fileName\n forEachModuleInDir entry.path (f <| n ++ ·)\n else if entry.path.extension == some \"lean\" then\n f <| Lean.Name.mkSimple <| FilePath.withExtension entry.fileName \"\" |>.toString",
"start": [
18,
1
],
"end": [
30,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.realPathNormalized",
"code": "def realPathNormalized (p : FilePath) : IO FilePath :=\n return (← IO.FS.realPath p).normalize",
"start": [
32,
1
],
"end": [
33,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.modToFilePath",
"code": "def modToFilePath (base : FilePath) (mod : Name) (ext : String) : FilePath :=\n go mod |>.addExtension ext\nwhere\n go : Name → FilePath\n | Name.str p h => go p / h\n | Name.anonymous => base\n | Name.num _ _ => panic! \"ill-formed import\"",
"start": [
35,
1
],
"end": [
41,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SearchPath",
"code": "abbrev SearchPath := System.SearchPath",
"start": [
43,
1
],
"end": [
44,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SearchPath.findWithExt",
"code": "def findWithExt (sp : SearchPath) (ext : String) (mod : Name) : IO (Option FilePath) := do\n let pkg := mod.getRoot.toString (escape := false)\n let root? ← sp.findM? fun p =>\n (p / pkg).isDir <||> ((p / pkg).addExtension ext).pathExists\n return root?.map (modToFilePath · mod ext)",
"start": [
48,
1
],
"end": [
55,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SearchPath.findModuleWithExt",
"code": "def findModuleWithExt (sp : SearchPath) (ext : String) (mod : Name) : IO (Option FilePath) := do\n if let some path ← findWithExt sp ext mod then\n if ← path.pathExists then\n return some path\n return none",
"start": [
57,
1
],
"end": [
62,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SearchPath.findAllWithExt",
"code": "def findAllWithExt (sp : SearchPath) (ext : String) : IO (Array FilePath) := do\n let mut paths := #[]\n for p in sp do\n if (← p.isDir) then\n paths := paths ++ (← p.walkDir).filter (·.extension == some ext)\n return paths",
"start": [
64,
1
],
"end": [
69,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBuildDir",
"code": "@[export lean_get_prefix]\ndef getBuildDir : IO FilePath := do\n return (← IO.appDir).parent |>.get!",
"start": [
75,
1
],
"end": [
77,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getLibDir",
"code": "@[export lean_get_libdir]\ndef getLibDir (leanSysroot : FilePath) : IO FilePath := do\n let mut buildDir := leanSysroot\n if Internal.isStage0 () then\n buildDir := buildDir / \"..\" / \"stage1\"\n return buildDir / \"lib\" / \"lean\"",
"start": [
79,
1
],
"end": [
85,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBuiltinSearchPath",
"code": "def getBuiltinSearchPath (leanSysroot : FilePath) : IO SearchPath :=\n return [← getLibDir leanSysroot]",
"start": [
87,
1
],
"end": [
88,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addSearchPathFromEnv",
"code": "def addSearchPathFromEnv (sp : SearchPath) : IO SearchPath := do\n let val ← IO.getEnv \"LEAN_PATH\"\n match val with\n | none => pure sp\n | some val => pure <| SearchPath.parse val ++ sp",
"start": [
90,
1
],
"end": [
94,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.initSearchPath",
"code": "def initSearchPath (leanSysroot : FilePath) (sp : SearchPath := ∅) : IO Unit := do\n let sp := sp ++ (← addSearchPathFromEnv (← getBuiltinSearchPath leanSysroot))\n searchPathRef.set sp",
"start": [
96,
1
],
"end": [
102,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.initSearchPathInternal",
"code": "@[export lean_init_search_path]\nprivate def initSearchPathInternal : IO Unit := do\n initSearchPath (← getBuildDir)",
"start": [
104,
1
],
"end": [
106,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findOLean",
"code": "partial def findOLean (mod : Name) : IO FilePath := do\n let sp ← searchPathRef.get\n if let some fname ← sp.findWithExt \"olean\" mod then\n return fname\n else\n let pkg := FilePath.mk <| mod.getRoot.toString (escape := false)\n let mut msg := s!\"unknown module prefix '{pkg}'\n\nNo directory '{pkg}' or file '{pkg}.lean' in the search path entries:\n{\"\\n\".intercalate <| sp.map (·.toString)}\"\n throw <| IO.userError msg",
"start": [
108,
1
],
"end": [
118,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.moduleNameOfFileName",
"code": "@[export lean_module_name_of_file]\ndef moduleNameOfFileName (fname : FilePath) (rootDir : Option FilePath) : IO Name := do\n let fname ← IO.FS.realPath fname\n let rootDir ← match rootDir with\n | some rootDir => pure rootDir\n | none => IO.currentDir\n let mut rootDir ← realPathNormalized rootDir\n if !rootDir.toString.endsWith System.FilePath.pathSeparator.toString then\n rootDir := ⟨rootDir.toString ++ System.FilePath.pathSeparator.toString⟩\n if !rootDir.toString.isPrefixOf fname.normalize.toString then\n throw $ IO.userError s!\"input file '{fname}' must be contained in root directory ({rootDir})\"\n let fnameSuffix := fname.toString.drop rootDir.toString.length\n let modNameStr := FilePath.mk fnameSuffix |>.withExtension \"\"\n let modName := modNameStr.components.foldl Name.mkStr Name.anonymous\n pure modName",
"start": [
120,
1
],
"end": [
136,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.searchModuleNameOfFileName",
"code": "def searchModuleNameOfFileName (fname : FilePath) (rootDirs : SearchPath) : IO (Option Name) := do\n for rootDir in rootDirs do\n try\n return some <| ← moduleNameOfFileName fname <| some rootDir\n catch\n | _ => pure ()\n return none",
"start": [
138,
1
],
"end": [
145,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findSysroot",
"code": "def findSysroot (lean := \"lean\") : IO FilePath := do\n if let some root ← IO.getEnv \"LEAN_SYSROOT\" then\n return root\n let out ← IO.Process.run {\n cmd := lean\n args := #[\" }\n return out.trim",
"start": [
147,
1
],
"end": [
163,
18
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/InstantiateLevelParams.lean | [
".lake/packages/lean4/src/lean/Lean/Util/ReplaceExpr.lean"
] | [
{
"full_name": "Lean.Expr.instantiateLevelParamsCore",
"code": "@[specialize] def instantiateLevelParamsCore (s : Name → Option Level) (e : Expr) : Expr :=\n e.replace replaceFn\nwhere\n @[specialize] replaceFn (e : Expr) : Option Expr :=\n if !e.hasLevelParam then e else match e with\n | const _ us => e.updateConst! (us.map fun u => u.substParams s)\n | sort u => e.updateSort! (u.substParams s)\n | _ => none",
"start": [
11,
1
],
"end": [
21,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getParamSubst",
"code": "private def getParamSubst : List Name → List Level → Name → Option Level\n | p::ps, u::us, p' => if p == p' then some u else getParamSubst ps us p'\n | _, _, _ => none",
"start": [
23,
1
],
"end": [
25,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiateLevelParams",
"code": "def instantiateLevelParams (e : Expr) (paramNames : List Name) (lvls : List Level) : Expr :=\n if paramNames.isEmpty || lvls.isEmpty then e else\n instantiateLevelParamsCore (getParamSubst paramNames lvls) e",
"start": [
27,
1
],
"end": [
33,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiateLevelParamsNoCache",
"code": "def instantiateLevelParamsNoCache (e : Expr) (paramNames : List Name) (lvls : List Level) : Expr :=\n if paramNames.isEmpty || lvls.isEmpty then e else\n e.replaceNoCache (instantiateLevelParamsCore.replaceFn (getParamSubst paramNames lvls))",
"start": [
35,
1
],
"end": [
42,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.getParamSubstArray",
"code": "private partial def getParamSubstArray (ps : Array Name) (us : Array Level) (p' : Name) (i : Nat) : Option Level :=\n if h : i < ps.size then\n let p := ps.get ⟨i, h⟩\n if h : i < us.size then\n let u := us.get ⟨i, h⟩\n if p == p' then some u else getParamSubstArray ps us p' (i+1)\n else none\n else none",
"start": [
44,
1
],
"end": [
51,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.instantiateLevelParamsArray",
"code": "def instantiateLevelParamsArray (e : Expr) (paramNames : Array Name) (lvls : Array Level) : Expr :=\n if paramNames.isEmpty || lvls.isEmpty then e else\n e.instantiateLevelParamsCore fun p =>\n getParamSubstArray paramNames lvls p 0",
"start": [
53,
1
],
"end": [
60,
45
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Declaration.lean | [
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.ReducibilityHints",
"code": "inductive ReducibilityHints where\n | opaque : ReducibilityHints\n | abbrev : ReducibilityHints\n | regular : UInt32 → ReducibilityHints\n deriving Inhabited, BEq",
"start": [
10,
1
],
"end": [
38,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkReducibilityHintsRegularEx",
"code": "@[export lean_mk_reducibility_hints_regular]\ndef mkReducibilityHintsRegularEx (h : UInt32) : ReducibilityHints :=\n ReducibilityHints.regular h",
"start": [
40,
1
],
"end": [
42,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ReducibilityHints.getHeightEx",
"code": "@[export lean_reducibility_hints_get_height]\ndef ReducibilityHints.getHeightEx (h : ReducibilityHints) : UInt32 :=\n match h with\n | ReducibilityHints.regular h => h\n | _ => 0",
"start": [
44,
1
],
"end": [
48,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ReducibilityHints.lt",
"code": "def lt : ReducibilityHints → ReducibilityHints → Bool\n | .abbrev, .abbrev => false\n | .abbrev, _ => true\n | .regular d₁, .regular d₂ => d₁ > d₂\n | .regular _, .opaque => true\n | _, _ => false",
"start": [
53,
1
],
"end": [
58,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ReducibilityHints.compare",
"code": "protected def compare : ReducibilityHints → ReducibilityHints → Ordering\n | .abbrev, .abbrev => .eq\n | .abbrev, _ => .lt\n | .regular _, .abbrev => .gt\n | .regular d₁, .regular d₂ => Ord.compare d₂ d₁\n | .regular _, .opaque => .lt\n | .opaque, .opaque => .eq\n | .opaque, _ => .gt",
"start": [
60,
1
],
"end": [
67,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ReducibilityHints.isAbbrev",
"code": "def isAbbrev : ReducibilityHints → Bool\n | .abbrev => true\n | _ => false",
"start": [
72,
1
],
"end": [
74,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ReducibilityHints.isRegular",
"code": "def isRegular : ReducibilityHints → Bool\n | regular .. => true\n | _ => false",
"start": [
76,
1
],
"end": [
78,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantVal",
"code": "structure ConstantVal where\n name : Name\n levelParams : List Name\n type : Expr\n deriving Inhabited, BEq",
"start": [
82,
1
],
"end": [
87,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AxiomVal",
"code": "structure AxiomVal extends ConstantVal where\n isUnsafe : Bool\n deriving Inhabited, BEq",
"start": [
89,
1
],
"end": [
91,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAxiomValEx",
"code": "@[export lean_mk_axiom_val]\ndef mkAxiomValEx (name : Name) (levelParams : List Name) (type : Expr) (isUnsafe : Bool) : AxiomVal := {\n name := name,\n levelParams := levelParams,\n type := type,\n isUnsafe := isUnsafe\n}",
"start": [
93,
1
],
"end": [
99,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AxiomVal.isUnsafeEx",
"code": "@[export lean_axiom_val_is_unsafe] def AxiomVal.isUnsafeEx (v : AxiomVal) : Bool :=\n v.isUnsafe",
"start": [
101,
1
],
"end": [
102,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DefinitionSafety",
"code": "inductive DefinitionSafety where\n | «unsafe» | safe | «partial»\n deriving Inhabited, BEq, Repr",
"start": [
104,
1
],
"end": [
106,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DefinitionVal",
"code": "structure DefinitionVal extends ConstantVal where\n value : Expr\n hints : ReducibilityHints\n safety : DefinitionSafety\n \n all : List Name := [name]\n deriving Inhabited, BEq",
"start": [
108,
1
],
"end": [
120,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkDefinitionValEx",
"code": "@[export lean_mk_definition_val]\ndef mkDefinitionValEx (name : Name) (levelParams : List Name) (type : Expr) (value : Expr) (hints : ReducibilityHints) (safety : DefinitionSafety) (all : List Name) : DefinitionVal := {\n name, levelParams, type, hints, safety, value, all\n}",
"start": [
122,
1
],
"end": [
125,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DefinitionVal.getSafetyEx",
"code": "@[export lean_definition_val_get_safety] def DefinitionVal.getSafetyEx (v : DefinitionVal) : DefinitionSafety :=\n v.safety",
"start": [
127,
1
],
"end": [
128,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TheoremVal",
"code": "structure TheoremVal extends ConstantVal where\n value : Expr\n \n all : List Name := [name]\n deriving Inhabited, BEq",
"start": [
130,
1
],
"end": [
136,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkTheoremValEx",
"code": "@[export lean_mk_theorem_val]\ndef mkTheoremValEx (name : Name) (levelParams : List Name) (type : Expr) (value : Expr) (all : List Name) : TheoremVal := {\n name, levelParams, type, value, all\n}",
"start": [
138,
1
],
"end": [
141,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.OpaqueVal",
"code": "structure OpaqueVal extends ConstantVal where\n value : Expr\n isUnsafe : Bool\n \n all : List Name := [name]\n deriving Inhabited, BEq",
"start": [
143,
1
],
"end": [
151,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkOpaqueValEx",
"code": "@[export lean_mk_opaque_val]\ndef mkOpaqueValEx (name : Name) (levelParams : List Name) (type : Expr) (value : Expr) (isUnsafe : Bool) (all : List Name) : OpaqueVal := {\n name, levelParams, type, value, isUnsafe, all\n}",
"start": [
153,
1
],
"end": [
156,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.OpaqueVal.isUnsafeEx",
"code": "@[export lean_opaque_val_is_unsafe] def OpaqueVal.isUnsafeEx (v : OpaqueVal) : Bool :=\n v.isUnsafe",
"start": [
158,
1
],
"end": [
159,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Constructor",
"code": "structure Constructor where\n name : Name\n type : Expr\n deriving Inhabited, BEq",
"start": [
161,
1
],
"end": [
164,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveType",
"code": "structure InductiveType where\n name : Name\n type : Expr\n ctors : List Constructor\n deriving Inhabited, BEq",
"start": [
166,
1
],
"end": [
170,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration",
"code": "inductive Declaration where\n | axiomDecl (val : AxiomVal)\n | defnDecl (val : DefinitionVal)\n | thmDecl (val : TheoremVal)\n | opaqueDecl (val : OpaqueVal)\n | quotDecl\n | mutualDefnDecl (defns : List DefinitionVal) | inductDecl (lparams : List Name) (nparams : Nat) (types : List InductiveType) (isUnsafe : Bool)\n deriving Inhabited, BEq",
"start": [
172,
1
],
"end": [
181,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkInductiveDeclEs",
"code": "@[export lean_mk_inductive_decl]\ndef mkInductiveDeclEs (lparams : List Name) (nparams : Nat) (types : List InductiveType) (isUnsafe : Bool) : Declaration :=\n Declaration.inductDecl lparams nparams types isUnsafe",
"start": [
183,
1
],
"end": [
185,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration.isUnsafeInductiveDeclEx",
"code": "@[export lean_is_unsafe_inductive_decl]\ndef Declaration.isUnsafeInductiveDeclEx : Declaration → Bool\n | Declaration.inductDecl _ _ _ isUnsafe => isUnsafe\n | _ => false",
"start": [
187,
1
],
"end": [
190,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration.definitionVal!",
"code": "def Declaration.definitionVal! : Declaration → DefinitionVal\n | .defnDecl val => val\n | _ => panic! \"Expected a `Declaration.defnDecl`.\"",
"start": [
192,
1
],
"end": [
194,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration.foldExprM",
"code": "@[specialize] def Declaration.foldExprM {α} {m : Type → Type} [Monad m] (d : Declaration) (f : α → Expr → m α) (a : α) : m α :=\n match d with\n | Declaration.quotDecl => pure a\n | Declaration.axiomDecl { type := type, .. } => f a type\n | Declaration.defnDecl { type := type, value := value, .. } => do let a ← f a type; f a value\n | Declaration.opaqueDecl { type := type, value := value, .. } => do let a ← f a type; f a value\n | Declaration.thmDecl { type := type, value := value, .. } => do let a ← f a type; f a value\n | Declaration.mutualDefnDecl vals => vals.foldlM (fun a v => do let a ← f a v.type; f a v.value) a\n | Declaration.inductDecl _ _ inductTypes _ =>\n inductTypes.foldlM\n (fun a inductType => do\n let a ← f a inductType.type\n inductType.ctors.foldlM (fun a ctor => f a ctor.type) a)\n a",
"start": [
196,
1
],
"end": [
209,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration.forExprM",
"code": "@[inline] def Declaration.forExprM {m : Type → Type} [Monad m] (d : Declaration) (f : Expr → m Unit) : m Unit :=\n d.foldExprM (fun _ a => f a) ()",
"start": [
211,
1
],
"end": [
212,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveVal",
"code": "structure InductiveVal extends ConstantVal where\n \n numParams : Nat\n \n numIndices : Nat\n \n all : List Name\n \n ctors : List Name\n \n isRec : Bool\n \n isUnsafe : Bool\n \n isReflexive : Bool\n \n isNested : Bool\n deriving Inhabited",
"start": [
214,
1
],
"end": [
263,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkInductiveValEx",
"code": "@[export lean_mk_inductive_val]\ndef mkInductiveValEx (name : Name) (levelParams : List Name) (type : Expr) (numParams numIndices : Nat)\n (all ctors : List Name) (isRec isUnsafe isReflexive isNested : Bool) : InductiveVal := {\n name := name\n levelParams := levelParams\n type := type\n numParams := numParams\n numIndices := numIndices\n all := all\n ctors := ctors\n isRec := isRec\n isUnsafe := isUnsafe\n isReflexive := isReflexive\n isNested := isNested\n}",
"start": [
265,
1
],
"end": [
279,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveVal.isRecEx",
"code": "@[export lean_inductive_val_is_rec] def InductiveVal.isRecEx (v : InductiveVal) : Bool := v.isRec",
"start": [
281,
1
],
"end": [
281,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveVal.isUnsafeEx",
"code": "@[export lean_inductive_val_is_unsafe] def InductiveVal.isUnsafeEx (v : InductiveVal) : Bool := v.isUnsafe",
"start": [
282,
1
],
"end": [
282,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveVal.isReflexiveEx",
"code": "@[export lean_inductive_val_is_reflexive] def InductiveVal.isReflexiveEx (v : InductiveVal) : Bool := v.isReflexive",
"start": [
283,
1
],
"end": [
283,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveVal.isNestedEx",
"code": "@[export lean_inductive_val_is_nested] def InductiveVal.isNestedEx (v : InductiveVal) : Bool := v.isNested",
"start": [
284,
1
],
"end": [
284,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InductiveVal.numCtors",
"code": "def InductiveVal.numCtors (v : InductiveVal) : Nat := v.ctors.length",
"start": [
286,
1
],
"end": [
286,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstructorVal",
"code": "structure ConstructorVal extends ConstantVal where\n \n induct : Name\n \n cidx : Nat\n \n numParams : Nat\n \n numFields : Nat\n isUnsafe : Bool\n deriving Inhabited, BEq",
"start": [
288,
1
],
"end": [
298,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkConstructorValEx",
"code": "@[export lean_mk_constructor_val]\ndef mkConstructorValEx (name : Name) (levelParams : List Name) (type : Expr) (induct : Name) (cidx numParams numFields : Nat) (isUnsafe : Bool) : ConstructorVal := {\n name := name,\n levelParams := levelParams,\n type := type,\n induct := induct,\n cidx := cidx,\n numParams := numParams,\n numFields := numFields,\n isUnsafe := isUnsafe\n}",
"start": [
300,
1
],
"end": [
310,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstructorVal.isUnsafeEx",
"code": "@[export lean_constructor_val_is_unsafe] def ConstructorVal.isUnsafeEx (v : ConstructorVal) : Bool := v.isUnsafe",
"start": [
312,
1
],
"end": [
312,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorRule",
"code": "structure RecursorRule where\n \n ctor : Name\n \n nfields : Nat\n \n rhs : Expr\n deriving Inhabited, BEq",
"start": [
314,
1
],
"end": [
322,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal",
"code": "structure RecursorVal extends ConstantVal where\n \n all : List Name\n \n numParams : Nat\n \n numIndices : Nat\n \n numMotives : Nat\n \n numMinors : Nat\n \n rules : List RecursorRule\n \n k : Bool\n isUnsafe : Bool\n deriving Inhabited, BEq",
"start": [
324,
1
],
"end": [
348,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkRecursorValEx",
"code": "@[export lean_mk_recursor_val]\ndef mkRecursorValEx (name : Name) (levelParams : List Name) (type : Expr) (all : List Name) (numParams numIndices numMotives numMinors : Nat)\n (rules : List RecursorRule) (k isUnsafe : Bool) : RecursorVal := {\n name := name, levelParams := levelParams, type := type, all := all, numParams := numParams, numIndices := numIndices,\n numMotives := numMotives, numMinors := numMinors, rules := rules, k := k, isUnsafe := isUnsafe\n}",
"start": [
350,
1
],
"end": [
355,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal.kEx",
"code": "@[export lean_recursor_k] def RecursorVal.kEx (v : RecursorVal) : Bool := v.k",
"start": [
357,
1
],
"end": [
357,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal.isUnsafeEx",
"code": "@[export lean_recursor_is_unsafe] def RecursorVal.isUnsafeEx (v : RecursorVal) : Bool := v.isUnsafe",
"start": [
358,
1
],
"end": [
358,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal.getMajorIdx",
"code": "def RecursorVal.getMajorIdx (v : RecursorVal) : Nat :=\n v.numParams + v.numMotives + v.numMinors + v.numIndices",
"start": [
360,
1
],
"end": [
361,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal.getFirstIndexIdx",
"code": "def RecursorVal.getFirstIndexIdx (v : RecursorVal) : Nat :=\n v.numParams + v.numMotives + v.numMinors",
"start": [
363,
1
],
"end": [
364,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal.getFirstMinorIdx",
"code": "def RecursorVal.getFirstMinorIdx (v : RecursorVal) : Nat :=\n v.numParams + v.numMotives",
"start": [
366,
1
],
"end": [
367,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.RecursorVal.getInduct",
"code": "def RecursorVal.getInduct (v : RecursorVal) : Name :=\n v.name.getPrefix",
"start": [
369,
1
],
"end": [
370,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.QuotKind",
"code": "inductive QuotKind where\n | type | ctor | lift | ind deriving Inhabited",
"start": [
372,
1
],
"end": [
377,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.QuotVal",
"code": "structure QuotVal extends ConstantVal where\n kind : QuotKind\n deriving Inhabited",
"start": [
379,
1
],
"end": [
381,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkQuotValEx",
"code": "@[export lean_mk_quot_val]\ndef mkQuotValEx (name : Name) (levelParams : List Name) (type : Expr) (kind : QuotKind) : QuotVal := {\n name := name, levelParams := levelParams, type := type, kind := kind\n}",
"start": [
383,
1
],
"end": [
386,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.QuotVal.kindEx",
"code": "@[export lean_quot_val_kind] def QuotVal.kindEx (v : QuotVal) : QuotKind := v.kind",
"start": [
388,
1
],
"end": [
388,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo",
"code": "inductive ConstantInfo where\n | axiomInfo (val : AxiomVal)\n | defnInfo (val : DefinitionVal)\n | thmInfo (val : TheoremVal)\n | opaqueInfo (val : OpaqueVal)\n | quotInfo (val : QuotVal)\n | inductInfo (val : InductiveVal)\n | ctorInfo (val : ConstructorVal)\n | recInfo (val : RecursorVal)\n deriving Inhabited",
"start": [
390,
1
],
"end": [
400,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.toConstantVal",
"code": "def toConstantVal : ConstantInfo → ConstantVal\n | defnInfo {toConstantVal := d, ..} => d\n | axiomInfo {toConstantVal := d, ..} => d\n | thmInfo {toConstantVal := d, ..} => d\n | opaqueInfo {toConstantVal := d, ..} => d\n | quotInfo {toConstantVal := d, ..} => d\n | inductInfo {toConstantVal := d, ..} => d\n | ctorInfo {toConstantVal := d, ..} => d\n | recInfo {toConstantVal := d, ..} => d",
"start": [
404,
1
],
"end": [
412,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.isUnsafe",
"code": "def isUnsafe : ConstantInfo → Bool\n | defnInfo v => v.safety == .unsafe\n | axiomInfo v => v.isUnsafe\n | thmInfo _ => false\n | opaqueInfo v => v.isUnsafe\n | quotInfo _ => false\n | inductInfo v => v.isUnsafe\n | ctorInfo v => v.isUnsafe\n | recInfo v => v.isUnsafe",
"start": [
414,
1
],
"end": [
422,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.isPartial",
"code": "def isPartial : ConstantInfo → Bool\n | defnInfo v => v.safety == .partial\n | _ => false",
"start": [
424,
1
],
"end": [
426,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.name",
"code": "def name (d : ConstantInfo) : Name :=\n d.toConstantVal.name",
"start": [
428,
1
],
"end": [
429,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.levelParams",
"code": "def levelParams (d : ConstantInfo) : List Name :=\n d.toConstantVal.levelParams",
"start": [
431,
1
],
"end": [
432,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.numLevelParams",
"code": "def numLevelParams (d : ConstantInfo) : Nat :=\n d.levelParams.length",
"start": [
434,
1
],
"end": [
435,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.type",
"code": "def type (d : ConstantInfo) : Expr :=\n d.toConstantVal.type",
"start": [
437,
1
],
"end": [
438,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.value?",
"code": "def value? : ConstantInfo → Option Expr\n | defnInfo {value := r, ..} => some r\n | thmInfo {value := r, ..} => some r\n | _ => none",
"start": [
440,
1
],
"end": [
443,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.hasValue",
"code": "def hasValue : ConstantInfo → Bool\n | defnInfo _ => true\n | thmInfo _ => true\n | _ => false",
"start": [
445,
1
],
"end": [
448,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.value!",
"code": "def value! : ConstantInfo → Expr\n | defnInfo {value := r, ..} => r\n | thmInfo {value := r, ..} => r\n | _ => panic! \"declaration with value expected\"",
"start": [
450,
1
],
"end": [
453,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.hints",
"code": "def hints : ConstantInfo → ReducibilityHints\n | defnInfo {hints := r, ..} => r\n | _ => ReducibilityHints.opaque",
"start": [
455,
1
],
"end": [
457,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.isCtor",
"code": "def isCtor : ConstantInfo → Bool\n | ctorInfo _ => true\n | _ => false",
"start": [
459,
1
],
"end": [
461,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.isInductive",
"code": "def isInductive : ConstantInfo → Bool\n | inductInfo _ => true\n | _ => false",
"start": [
463,
1
],
"end": [
465,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.inductiveVal!",
"code": "def inductiveVal! : ConstantInfo → InductiveVal\n | .inductInfo val => val\n | _ => panic! \"Expected a `ConstantInfo.inductInfo`.\"",
"start": [
467,
1
],
"end": [
469,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.all",
"code": "def all : ConstantInfo → List Name\n | inductInfo val => val.all\n | defnInfo val => val.all\n | thmInfo val => val.all\n | opaqueInfo val => val.all\n | info => [info.name]",
"start": [
471,
1
],
"end": [
479,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkRecName",
"code": "def mkRecName (declName : Name) : Name :=\n Name.mkStr declName \"rec\"",
"start": [
483,
1
],
"end": [
484,
28
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Stream.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/Subarray.lean",
".lake/packages/lean4/src/lean/Init/Data/Range.lean"
] | [
{
"full_name": "ToStream",
"code": "class ToStream (collection : Type u) (stream : outParam (Type u)) : Type u where\n toStream : collection → stream",
"start": [
25,
1
],
"end": [
44,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Stream",
"code": "class Stream (stream : Type u) (value : outParam (Type v)) : Type (max u v) where\n next? : stream → Option (value × stream)",
"start": [
48,
1
],
"end": [
49,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Stream.forIn",
"code": "protected partial def Stream.forIn [Stream ρ α] [Monad m] (s : ρ) (b : β) (f : α → β → m (ForInStep β)) : m β := do\n let _ : Inhabited (m β) := ⟨pure b⟩\n let rec visit (s : ρ) (b : β) : m β := do\n match Stream.next? s with\n | some (a, s) => match (← f a b) with\n | ForInStep.done b => return b\n | ForInStep.yield b => visit s b\n | none => return b\n visit s b",
"start": [
51,
1
],
"end": [
59,
12
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/Profile.lean | [
".lake/packages/lean4/src/lean/Init/Data/OfScientific.lean",
".lake/packages/lean4/src/lean/Lean/Data/Options.lean"
] | [
{
"full_name": "Lean.get_profiler",
"code": "@[export lean_get_profiler]\nprivate def get_profiler (o : Options) : Bool :=\n profiler.get o",
"start": [
26,
1
],
"end": [
28,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.profiler.threshold.getSecs",
"code": "@[export lean_get_profiler_threshold]\ndef profiler.threshold.getSecs (o : Options) : Float :=\n (profiler.threshold.get o).toFloat / 1000",
"start": [
30,
1
],
"end": [
32,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.profileit",
"code": "@[extern \"lean_profileit\"]\ndef profileit {α : Type} (category : @& String) (opts : @& Options) (fn : Unit → α) (decl := Name.anonymous) : α := fn ()",
"start": [
34,
1
],
"end": [
36,
122
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.profileitIOUnsafe",
"code": "unsafe def profileitIOUnsafe {ε α : Type} (category : String) (opts : Options) (act : EIO ε α) (decl := Name.anonymous) : EIO ε α :=\n match profileit (decl := decl) category opts fun _ => unsafeEIO act with\n | Except.ok a => pure a\n | Except.error e => throw e",
"start": [
38,
1
],
"end": [
41,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.profileitIO",
"code": "@[implemented_by profileitIOUnsafe]\ndef profileitIO {ε α : Type} (category : String) (opts : Options) (act : EIO ε α) (decl := Name.anonymous) : EIO ε α := act",
"start": [
43,
1
],
"end": [
44,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.profileitM",
"code": "def profileitM {m : Type → Type} (ε : Type) [MonadFunctorT (EIO ε) m] {α : Type} (category : String) (opts : Options) (act : m α) (decl := Name.anonymous) : m α :=\n monadMap (fun {β} => profileitIO (ε := ε) (α := β) (decl := decl) category opts) act",
"start": [
47,
1
],
"end": [
48,
87
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Init/Data/Array/BinSearch.lean | [
".lake/packages/lean4/src/lean/Init/Data/Array/Basic.lean"
] | [
{
"full_name": "Array.binSearchAux",
"code": "@[specialize] partial def binSearchAux {α : Type u} {β : Type v} [Inhabited β] (lt : α → α → Bool) (found : Option α → β) (as : Array α) (k : α) : Nat → Nat → β\n | lo, hi =>\n if lo <= hi then\n let _ := Inhabited.mk k\n let m := (lo + hi)/2\n let a := as.get! m\n if lt a k then binSearchAux lt found as k (m+1) hi\n else if lt k a then\n if m == 0 then found none\n else binSearchAux lt found as k lo (m-1)\n else found (some a)\n else found none",
"start": [
16,
1
],
"end": [
27,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.binSearch",
"code": "@[inline] def binSearch {α : Type} (as : Array α) (k : α) (lt : α → α → Bool) (lo := 0) (hi := as.size - 1) : Option α :=\n if lo < as.size then\n let hi := if hi < as.size then hi else as.size - 1\n binSearchAux lt id as k lo hi\n else\n none",
"start": [
29,
1
],
"end": [
34,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.binSearchContains",
"code": "@[inline] def binSearchContains {α : Type} (as : Array α) (k : α) (lt : α → α → Bool) (lo := 0) (hi := as.size - 1) : Bool :=\n if lo < as.size then\n let hi := if hi < as.size then hi else as.size - 1\n binSearchAux lt Option.isSome as k lo hi\n else\n false",
"start": [
36,
1
],
"end": [
41,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.binInsertAux",
"code": "@[specialize] private partial def binInsertAux {α : Type u} {m : Type u → Type v} [Monad m]\n (lt : α → α → Bool)\n (merge : α → m α)\n (add : Unit → m α)\n (as : Array α)\n (k : α) : Nat → Nat → m (Array α)\n | lo, hi =>\n let _ := Inhabited.mk k\n let mid := (lo + hi)/2\n let midVal := as.get! mid\n if lt midVal k then\n if mid == lo then do let v ← add (); pure <| as.insertAt! (lo+1) v\n else binInsertAux lt merge add as k mid hi\n else if lt k midVal then\n binInsertAux lt merge add as k lo mid\n else do\n as.modifyM mid <| fun v => merge v",
"start": [
43,
1
],
"end": [
60,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.binInsertM",
"code": "@[specialize] def binInsertM {α : Type u} {m : Type u → Type v} [Monad m]\n (lt : α → α → Bool)\n (merge : α → m α)\n (add : Unit → m α)\n (as : Array α)\n (k : α) : m (Array α) :=\n let _ := Inhabited.mk k\n if as.isEmpty then do let v ← add (); pure <| as.push v\n else if lt k (as.get! 0) then do let v ← add (); pure <| as.insertAt! 0 v\n else if !lt (as.get! 0) k then as.modifyM 0 <| merge\n else if lt as.back k then do let v ← add (); pure <| as.push v\n else if !lt k as.back then as.modifyM (as.size - 1) <| merge\n else binInsertAux lt merge add as k 0 (as.size - 1)",
"start": [
62,
1
],
"end": [
74,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Array.binInsert",
"code": "@[inline] def binInsert {α : Type u} (lt : α → α → Bool) (as : Array α) (k : α) : Array α :=\n Id.run <| binInsertM lt (fun _ => k) (fun _ => k) as k",
"start": [
76,
1
],
"end": [
77,
57
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/LocalContext.lean | [
".lake/packages/lean4/src/lean/Init/Data/Nat/Control.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean",
".lake/packages/lean4/src/lean/Lean/Data/PersistentArray.lean",
".lake/packages/lean4/src/lean/Lean/Hygiene.lean"
] | [
{
"full_name": "Lean.LocalDeclKind",
"code": "inductive LocalDeclKind\n \n | default\n \n | implDetail\n \n | auxDecl\n deriving Inhabited, Repr, DecidableEq, Hashable",
"start": [
14,
1
],
"end": [
43,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl",
"code": "inductive LocalDecl where\n | cdecl (index : Nat) (fvarId : FVarId) (userName : Name) (type : Expr) (bi : BinderInfo) (kind : LocalDeclKind)\n | ldecl (index : Nat) (fvarId : FVarId) (userName : Name) (type : Expr) (value : Expr) (nonDep : Bool) (kind : LocalDeclKind)\n deriving Inhabited",
"start": [
45,
1
],
"end": [
56,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLocalDeclEx",
"code": "@[export lean_mk_local_decl]\ndef mkLocalDeclEx (index : Nat) (fvarId : FVarId) (userName : Name) (type : Expr) (bi : BinderInfo) : LocalDecl :=\n .cdecl index fvarId userName type bi .default",
"start": [
58,
1
],
"end": [
60,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkLetDeclEx",
"code": "@[export lean_mk_let_decl]\ndef mkLetDeclEx (index : Nat) (fvarId : FVarId) (userName : Name) (type : Expr) (val : Expr) : LocalDecl :=\n .ldecl index fvarId userName type val false .default",
"start": [
61,
1
],
"end": [
63,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.binderInfoEx",
"code": "@[export lean_local_decl_binder_info]\ndef LocalDecl.binderInfoEx : LocalDecl → BinderInfo\n | .cdecl _ _ _ _ bi _ => bi\n | _ => BinderInfo.default",
"start": [
64,
1
],
"end": [
67,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.isLet",
"code": "def isLet : LocalDecl → Bool\n | cdecl .. => false\n | ldecl .. => true",
"start": [
70,
1
],
"end": [
72,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.index",
"code": "def index : LocalDecl → Nat\n | cdecl (index := i) .. => i\n | ldecl (index := i) .. => i",
"start": [
74,
1
],
"end": [
76,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.setIndex",
"code": "def setIndex : LocalDecl → Nat → LocalDecl\n | cdecl _ id n t bi k, idx => cdecl idx id n t bi k\n | ldecl _ id n t v nd k, idx => ldecl idx id n t v nd k",
"start": [
78,
1
],
"end": [
80,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.fvarId",
"code": "def fvarId : LocalDecl → FVarId\n | cdecl (fvarId := id) .. => id\n | ldecl (fvarId := id) .. => id",
"start": [
82,
1
],
"end": [
84,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.userName",
"code": "def userName : LocalDecl → Name\n | cdecl (userName := n) .. => n\n | ldecl (userName := n) .. => n",
"start": [
86,
1
],
"end": [
88,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.type",
"code": "def type : LocalDecl → Expr\n | cdecl (type := t) .. => t\n | ldecl (type := t) .. => t",
"start": [
90,
1
],
"end": [
92,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.setType",
"code": "def setType : LocalDecl → Expr → LocalDecl\n | cdecl idx id n _ bi k, t => cdecl idx id n t bi k\n | ldecl idx id n _ v nd k, t => ldecl idx id n t v nd k",
"start": [
94,
1
],
"end": [
96,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.binderInfo",
"code": "def binderInfo : LocalDecl → BinderInfo\n | cdecl (bi := bi) .. => bi\n | ldecl .. => BinderInfo.default",
"start": [
98,
1
],
"end": [
100,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.kind",
"code": "def kind : LocalDecl → LocalDeclKind\n | cdecl .. | ldecl .. => ‹_›",
"start": [
102,
1
],
"end": [
103,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.isAuxDecl",
"code": "def isAuxDecl (d : LocalDecl) : Bool :=\n d.kind = .auxDecl",
"start": [
105,
1
],
"end": [
106,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.isImplementationDetail",
"code": "def isImplementationDetail (d : LocalDecl) : Bool :=\n d.kind != .default",
"start": [
108,
1
],
"end": [
113,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.value?",
"code": "def value? : LocalDecl → Option Expr\n | cdecl .. => none\n | ldecl (value := v) .. => some v",
"start": [
115,
1
],
"end": [
117,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.value",
"code": "def value : LocalDecl → Expr\n | cdecl .. => panic! \"let declaration expected\"\n | ldecl (value := v) .. => v",
"start": [
119,
1
],
"end": [
121,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.hasValue",
"code": "def hasValue : LocalDecl → Bool\n | cdecl .. => false\n | ldecl .. => true",
"start": [
123,
1
],
"end": [
125,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.setValue",
"code": "def setValue : LocalDecl → Expr → LocalDecl\n | ldecl idx id n t _ nd k, v => ldecl idx id n t v nd k\n | d, _ => d",
"start": [
127,
1
],
"end": [
129,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.setUserName",
"code": "def setUserName : LocalDecl → Name → LocalDecl\n | cdecl index id _ type bi k, userName => cdecl index id userName type bi k\n | ldecl index id _ type val nd k, userName => ldecl index id userName type val nd k",
"start": [
131,
1
],
"end": [
133,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.setBinderInfo",
"code": "def setBinderInfo : LocalDecl → BinderInfo → LocalDecl\n | cdecl index id n type _ k, bi => cdecl index id n type bi k\n | ldecl .., _ => panic! \"unexpected let declaration\"",
"start": [
135,
1
],
"end": [
137,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.toExpr",
"code": "def toExpr (decl : LocalDecl) : Expr :=\n mkFVar decl.fvarId",
"start": [
139,
1
],
"end": [
140,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.hasExprMVar",
"code": "def hasExprMVar : LocalDecl → Bool\n | cdecl (type := t) .. => t.hasExprMVar\n | ldecl (type := t) (value := v) .. => t.hasExprMVar || v.hasExprMVar",
"start": [
142,
1
],
"end": [
144,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.setKind",
"code": "def setKind : LocalDecl → LocalDeclKind → LocalDecl\n | cdecl index fvarId userName type bi _, kind =>\n cdecl index fvarId userName type bi kind\n | ldecl index fvarId userName type value nonDep _, kind =>\n ldecl index fvarId userName type value nonDep kind",
"start": [
146,
1
],
"end": [
153,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext",
"code": "structure LocalContext where\n fvarIdToDecl : PersistentHashMap FVarId LocalDecl := {}\n decls : PersistentArray (Option LocalDecl) := {}\n deriving Inhabited",
"start": [
157,
1
],
"end": [
167,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkEmpty",
"code": "@[export lean_mk_empty_local_ctx]\ndef mkEmpty : Unit → LocalContext := fun _ => {}",
"start": [
171,
1
],
"end": [
172,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.empty",
"code": "def empty : LocalContext := {}",
"start": [
174,
1
],
"end": [
174,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.isEmpty",
"code": "@[export lean_local_ctx_is_empty]\ndef isEmpty (lctx : LocalContext) : Bool :=\n lctx.fvarIdToDecl.isEmpty",
"start": [
176,
1
],
"end": [
178,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkLocalDecl",
"code": "def mkLocalDecl (lctx : LocalContext) (fvarId : FVarId) (userName : Name) (type : Expr) (bi : BinderInfo := BinderInfo.default) (kind : LocalDeclKind := .default) : LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n let idx := decls.size\n let decl := LocalDecl.cdecl idx fvarId userName type bi kind\n { fvarIdToDecl := map.insert fvarId decl, decls := decls.push decl }",
"start": [
180,
1
],
"end": [
189,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkLocalDeclExported",
"code": "@[export lean_local_ctx_mk_local_decl]\nprivate def mkLocalDeclExported (lctx : LocalContext) (fvarId : FVarId) (userName : Name) (type : Expr) (bi : BinderInfo) : LocalContext :=\n mkLocalDecl lctx fvarId userName type bi",
"start": [
192,
1
],
"end": [
194,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkLetDecl",
"code": "def mkLetDecl (lctx : LocalContext) (fvarId : FVarId) (userName : Name) (type : Expr) (value : Expr) (nonDep := false) (kind : LocalDeclKind := default) : LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n let idx := decls.size\n let decl := LocalDecl.ldecl idx fvarId userName type value nonDep kind\n { fvarIdToDecl := map.insert fvarId decl, decls := decls.push decl }",
"start": [
196,
1
],
"end": [
202,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkLetDeclExported",
"code": "@[export lean_local_ctx_mk_let_decl]\nprivate def mkLetDeclExported (lctx : LocalContext) (fvarId : FVarId) (userName : Name) (type : Expr) (value : Expr) (nonDep : Bool) : LocalContext :=\n mkLetDecl lctx fvarId userName type value nonDep",
"start": [
204,
1
],
"end": [
206,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.addDecl",
"code": "def addDecl (lctx : LocalContext) (newDecl : LocalDecl) : LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n let idx := decls.size\n let newDecl := newDecl.setIndex idx\n { fvarIdToDecl := map.insert newDecl.fvarId newDecl, decls := decls.push newDecl }",
"start": [
208,
1
],
"end": [
215,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.find?",
"code": "@[export lean_local_ctx_find]\ndef find? (lctx : LocalContext) (fvarId : FVarId) : Option LocalDecl :=\n lctx.fvarIdToDecl.find? fvarId",
"start": [
217,
1
],
"end": [
219,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.findFVar?",
"code": "def findFVar? (lctx : LocalContext) (e : Expr) : Option LocalDecl :=\n lctx.find? e.fvarId!",
"start": [
221,
1
],
"end": [
222,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.get!",
"code": "def get! (lctx : LocalContext) (fvarId : FVarId) : LocalDecl :=\n match lctx.find? fvarId with\n | some d => d\n | none => panic! \"unknown free variable\"",
"start": [
224,
1
],
"end": [
227,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getFVar!",
"code": "def getFVar! (lctx : LocalContext) (e : Expr) : LocalDecl :=\n lctx.get! e.fvarId!",
"start": [
229,
1
],
"end": [
232,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.contains",
"code": "def contains (lctx : LocalContext) (fvarId : FVarId) : Bool :=\n lctx.fvarIdToDecl.contains fvarId",
"start": [
234,
1
],
"end": [
235,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.containsFVar",
"code": "def containsFVar (lctx : LocalContext) (e : Expr) : Bool :=\n lctx.contains e.fvarId!",
"start": [
237,
1
],
"end": [
240,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getFVarIds",
"code": "def getFVarIds (lctx : LocalContext) : Array FVarId :=\n lctx.decls.foldl (init := #[]) fun r decl? => match decl? with\n | some decl => r.push decl.fvarId\n | none => r",
"start": [
242,
1
],
"end": [
245,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getFVars",
"code": "def getFVars (lctx : LocalContext) : Array Expr :=\n lctx.getFVarIds.map mkFVar",
"start": [
247,
1
],
"end": [
249,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.popTailNoneAux",
"code": "private partial def popTailNoneAux (a : PArray (Option LocalDecl)) : PArray (Option LocalDecl) :=\n if a.size == 0 then a\n else match a.get! (a.size - 1) with\n | none => popTailNoneAux a.pop\n | some _ => a",
"start": [
251,
1
],
"end": [
255,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.erase",
"code": "@[export lean_local_ctx_erase]\ndef erase (lctx : LocalContext) (fvarId : FVarId) : LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n match map.find? fvarId with\n | none => lctx\n | some decl => { fvarIdToDecl := map.erase fvarId, decls := popTailNoneAux (decls.set decl.index none) }",
"start": [
257,
1
],
"end": [
263,
109
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.pop",
"code": "def pop (lctx : LocalContext): LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n if decls.size == 0 then lctx\n else match decls.get! (decls.size - 1) with\n | none => lctx | some decl => { fvarIdToDecl := map.erase decl.fvarId, decls := popTailNoneAux decls.pop }",
"start": [
265,
1
],
"end": [
271,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.findFromUserName?",
"code": "def findFromUserName? (lctx : LocalContext) (userName : Name) : Option LocalDecl :=\n lctx.decls.findSomeRev? fun decl =>\n match decl with\n | none => none\n | some decl => if decl.userName == userName then some decl else none",
"start": [
273,
1
],
"end": [
277,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.usesUserName",
"code": "def usesUserName (lctx : LocalContext) (userName : Name) : Bool :=\n (lctx.findFromUserName? userName).isSome",
"start": [
279,
1
],
"end": [
280,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getUnusedNameAux",
"code": "private partial def getUnusedNameAux (lctx : LocalContext) (suggestion : Name) (i : Nat) : Name × Nat :=\n let curr := suggestion.appendIndexAfter i\n if lctx.usesUserName curr then getUnusedNameAux lctx suggestion (i + 1)\n else (curr, i + 1)",
"start": [
282,
1
],
"end": [
285,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getUnusedName",
"code": "def getUnusedName (lctx : LocalContext) (suggestion : Name) : Name :=\n let suggestion := suggestion.eraseMacroScopes\n if lctx.usesUserName suggestion then (getUnusedNameAux lctx suggestion 1).1\n else suggestion",
"start": [
287,
1
],
"end": [
290,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.lastDecl",
"code": "def lastDecl (lctx : LocalContext) : Option LocalDecl :=\n lctx.decls.get! (lctx.decls.size - 1)",
"start": [
292,
1
],
"end": [
293,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.setUserName",
"code": "def setUserName (lctx : LocalContext) (fvarId : FVarId) (userName : Name) : LocalContext :=\n let decl := lctx.get! fvarId\n let decl := decl.setUserName userName\n { fvarIdToDecl := lctx.fvarIdToDecl.insert decl.fvarId decl,\n decls := lctx.decls.set decl.index decl }",
"start": [
295,
1
],
"end": [
299,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.renameUserName",
"code": "def renameUserName (lctx : LocalContext) (fromName : Name) (toName : Name) : LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n match lctx.findFromUserName? fromName with\n | none => lctx\n | some decl =>\n let decl := decl.setUserName toName;\n { fvarIdToDecl := map.insert decl.fvarId decl,\n decls := decls.set decl.index decl }",
"start": [
301,
1
],
"end": [
309,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.modifyLocalDecl",
"code": "@[inline] def modifyLocalDecl (lctx : LocalContext) (fvarId : FVarId) (f : LocalDecl → LocalDecl) : LocalContext :=\n match lctx with\n | { fvarIdToDecl := map, decls := decls } =>\n match lctx.find? fvarId with\n | none => lctx\n | some decl =>\n let decl := f decl\n { fvarIdToDecl := map.insert decl.fvarId decl\n decls := decls.set decl.index decl }",
"start": [
311,
1
],
"end": [
323,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.setKind",
"code": "def setKind (lctx : LocalContext) (fvarId : FVarId)\n (kind : LocalDeclKind) : LocalContext :=\n lctx.modifyLocalDecl fvarId (·.setKind kind)",
"start": [
325,
1
],
"end": [
330,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.setBinderInfo",
"code": "def setBinderInfo (lctx : LocalContext) (fvarId : FVarId) (bi : BinderInfo) : LocalContext :=\n modifyLocalDecl lctx fvarId fun decl => decl.setBinderInfo bi",
"start": [
332,
1
],
"end": [
333,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.numIndices",
"code": "@[export lean_local_ctx_num_indices]\ndef numIndices (lctx : LocalContext) : Nat :=\n lctx.decls.size",
"start": [
335,
1
],
"end": [
337,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getAt?",
"code": "def getAt? (lctx : LocalContext) (i : Nat) : Option LocalDecl :=\n lctx.decls.get! i",
"start": [
339,
1
],
"end": [
340,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.foldlM",
"code": "@[specialize] def foldlM [Monad m] (lctx : LocalContext) (f : β → LocalDecl → m β) (init : β) (start : Nat := 0) : m β :=\n lctx.decls.foldlM (init := init) (start := start) fun b decl => match decl with\n | none => pure b\n | some decl => f b decl",
"start": [
342,
1
],
"end": [
345,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.foldrM",
"code": "@[specialize] def foldrM [Monad m] (lctx : LocalContext) (f : LocalDecl → β → m β) (init : β) : m β :=\n lctx.decls.foldrM (init := init) fun decl b => match decl with\n | none => pure b\n | some decl => f decl b",
"start": [
347,
1
],
"end": [
350,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.forM",
"code": "@[specialize] def forM [Monad m] (lctx : LocalContext) (f : LocalDecl → m PUnit) : m PUnit :=\n lctx.decls.forM fun decl => match decl with\n | none => pure PUnit.unit\n | some decl => f decl",
"start": [
352,
1
],
"end": [
355,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.findDeclM?",
"code": "@[specialize] def findDeclM? [Monad m] (lctx : LocalContext) (f : LocalDecl → m (Option β)) : m (Option β) :=\n lctx.decls.findSomeM? fun decl => match decl with\n | none => pure none\n | some decl => f decl",
"start": [
357,
1
],
"end": [
360,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.findDeclRevM?",
"code": "@[specialize] def findDeclRevM? [Monad m] (lctx : LocalContext) (f : LocalDecl → m (Option β)) : m (Option β) :=\n lctx.decls.findSomeRevM? fun decl => match decl with\n | none => pure none\n | some decl => f decl",
"start": [
362,
1
],
"end": [
365,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.foldl",
"code": "@[inline] def foldl (lctx : LocalContext) (f : β → LocalDecl → β) (init : β) (start : Nat := 0) : β :=\n Id.run <| lctx.foldlM f init start",
"start": [
372,
1
],
"end": [
373,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.foldr",
"code": "@[inline] def foldr (lctx : LocalContext) (f : LocalDecl → β → β) (init : β) : β :=\n Id.run <| lctx.foldrM f init",
"start": [
375,
1
],
"end": [
376,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.size",
"code": "def size (lctx : LocalContext) : Nat :=\n lctx.foldl (fun n _ => n+1) 0",
"start": [
378,
1
],
"end": [
379,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.findDecl?",
"code": "@[inline] def findDecl? (lctx : LocalContext) (f : LocalDecl → Option β) : Option β :=\n Id.run <| lctx.findDeclM? f",
"start": [
381,
1
],
"end": [
382,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.findDeclRev?",
"code": "@[inline] def findDeclRev? (lctx : LocalContext) (f : LocalDecl → Option β) : Option β :=\n Id.run <| lctx.findDeclRevM? f",
"start": [
384,
1
],
"end": [
385,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.isSubPrefixOfAux",
"code": "partial def isSubPrefixOfAux (a₁ a₂ : PArray (Option LocalDecl)) (exceptFVars : Array Expr) (i j : Nat) : Bool :=\n if i < a₁.size then\n match a₁[i]! with\n | none => isSubPrefixOfAux a₁ a₂ exceptFVars (i+1) j\n | some decl₁ =>\n if exceptFVars.any fun fvar => fvar.fvarId! == decl₁.fvarId then\n isSubPrefixOfAux a₁ a₂ exceptFVars (i+1) j\n else if j < a₂.size then\n match a₂[j]! with\n | none => isSubPrefixOfAux a₁ a₂ exceptFVars i (j+1)\n | some decl₂ => if decl₁.fvarId == decl₂.fvarId then isSubPrefixOfAux a₁ a₂ exceptFVars (i+1) (j+1) else isSubPrefixOfAux a₁ a₂ exceptFVars i (j+1)\n else false\n else true",
"start": [
387,
1
],
"end": [
399,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.isSubPrefixOf",
"code": "def isSubPrefixOf (lctx₁ lctx₂ : LocalContext) (exceptFVars : Array Expr := #[]) : Bool :=\n isSubPrefixOfAux lctx₁.decls lctx₂.decls exceptFVars 0 0",
"start": [
401,
1
],
"end": [
405,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkBinding",
"code": "@[inline] def mkBinding (isLambda : Bool) (lctx : LocalContext) (xs : Array Expr) (b : Expr) : Expr :=\n let b := b.abstract xs\n xs.size.foldRev (init := b) fun i b =>\n let x := xs[i]!\n match lctx.findFVar? x with\n | some (.cdecl _ _ n ty bi _) =>\n let ty := ty.abstractRange i xs;\n if isLambda then\n Lean.mkLambda n bi ty b\n else\n Lean.mkForall n bi ty b\n | some (.ldecl _ _ n ty val nonDep _) =>\n if b.hasLooseBVar 0 then\n let ty := ty.abstractRange i xs\n let val := val.abstractRange i xs\n mkLet n ty val b nonDep\n else\n b.lowerLooseBVars 1 1\n | none => panic! \"unknown free variable\"",
"start": [
407,
1
],
"end": [
425,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkLambda",
"code": "def mkLambda (lctx : LocalContext) (xs : Array Expr) (b : Expr) : Expr :=\n mkBinding true lctx xs b",
"start": [
427,
1
],
"end": [
430,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.mkForall",
"code": "def mkForall (lctx : LocalContext) (xs : Array Expr) (b : Expr) : Expr :=\n mkBinding false lctx xs b",
"start": [
432,
1
],
"end": [
435,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.anyM",
"code": "@[inline] def anyM [Monad m] (lctx : LocalContext) (p : LocalDecl → m Bool) : m Bool :=\n lctx.decls.anyM fun d => match d with\n | some decl => p decl\n | none => pure false",
"start": [
437,
1
],
"end": [
440,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.allM",
"code": "@[inline] def allM [Monad m] (lctx : LocalContext) (p : LocalDecl → m Bool) : m Bool :=\n lctx.decls.allM fun d => match d with\n | some decl => p decl\n | none => pure true",
"start": [
442,
1
],
"end": [
445,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.any",
"code": "@[inline] def any (lctx : LocalContext) (p : LocalDecl → Bool) : Bool :=\n Id.run <| lctx.anyM p",
"start": [
447,
1
],
"end": [
449,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.all",
"code": "@[inline] def all (lctx : LocalContext) (p : LocalDecl → Bool) : Bool :=\n Id.run <| lctx.allM p",
"start": [
451,
1
],
"end": [
453,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.sanitizeNames",
"code": "def sanitizeNames (lctx : LocalContext) : StateM NameSanitizerState LocalContext := do\n let st ← get\n if !getSanitizeNames st.options then pure lctx else\n StateT.run' (s := ({} : NameSet)) <|\n lctx.decls.size.foldRevM (init := lctx) fun i lctx => do\n match lctx.decls[i]! with\n | none => pure lctx\n | some decl =>\n if decl.userName.hasMacroScopes || (← get).contains decl.userName then do\n modify fun s => s.insert decl.userName\n let userNameNew ← liftM <| sanitizeName decl.userName\n pure <| lctx.setUserName decl.fvarId userNameNew\n else\n modify fun s => s.insert decl.userName\n pure lctx",
"start": [
455,
1
],
"end": [
470,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.getRoundtrippingUserName?",
"code": "def getRoundtrippingUserName? (lctx : LocalContext) (fvarId : FVarId) : Option Name := do\n let ldecl₁ ← lctx.find? fvarId\n let ldecl₂ ← lctx.findFromUserName? ldecl₁.userName\n guard <| ldecl₁.fvarId == ldecl₂.fvarId\n some ldecl₁.userName",
"start": [
472,
1
],
"end": [
480,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.sortFVarsByContextOrder",
"code": "def sortFVarsByContextOrder (lctx : LocalContext) (hyps : Array FVarId) : Array FVarId :=\n let hyps := hyps.map fun fvarId =>\n match lctx.fvarIdToDecl.find? fvarId with\n | none => (0, fvarId)\n | some ldecl => (ldecl.index, fvarId)\n hyps.qsort (fun h i => h.fst < i.fst) |>.map (·.snd)",
"start": [
482,
1
],
"end": [
491,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadLCtx",
"code": "class MonadLCtx (m : Type → Type) where\n getLCtx : m LocalContext",
"start": [
495,
1
],
"end": [
497,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getLocalHyps",
"code": "def getLocalHyps [Monad m] [MonadLCtx m] : m (Array Expr) := do\n let mut hs := #[]\n for d in ← getLCtx do\n if !d.isImplementationDetail then hs := hs.push d.toExpr\n return hs",
"start": [
504,
1
],
"end": [
509,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalDecl.replaceFVarId",
"code": "def LocalDecl.replaceFVarId (fvarId : FVarId) (e : Expr) (d : LocalDecl) : LocalDecl :=\n if d.fvarId == fvarId then d\n else match d with\n | .cdecl idx id n type bi k => .cdecl idx id n (type.replaceFVarId fvarId e) bi k\n | .ldecl idx id n type val nonDep k => .ldecl idx id n (type.replaceFVarId fvarId e) (val.replaceFVarId fvarId e) nonDep k",
"start": [
511,
1
],
"end": [
515,
127
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalContext.replaceFVarId",
"code": "def LocalContext.replaceFVarId (fvarId : FVarId) (e : Expr) (lctx : LocalContext) : LocalContext :=\n let lctx := lctx.erase fvarId\n { fvarIdToDecl := lctx.fvarIdToDecl.map (·.replaceFVarId fvarId e)\n decls := lctx.decls.map fun localDecl? => localDecl?.map (·.replaceFVarId fvarId e) }",
"start": [
517,
1
],
"end": [
520,
90
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Server/Rpc/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Json.lean",
".lake/packages/lean4/src/lean/Init/Dynamic.lean"
] | [
{
"full_name": "Lean.Lsp.RpcRef",
"code": "structure RpcRef where\n \n p : USize\n deriving BEq, Hashable, FromJson, ToJson",
"start": [
22,
1
],
"end": [
27,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Server.RpcObjectStore",
"code": "structure RpcObjectStore : Type where\n \n aliveRefs : PersistentHashMap Lsp.RpcRef Dynamic := {}\n \n nextRef : USize := 0",
"start": [
36,
1
],
"end": [
46,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Server.rpcStoreRef",
"code": "def rpcStoreRef (any : Dynamic) : StateM RpcObjectStore Lsp.RpcRef := do\n let st ← get\n set { st with\n aliveRefs := st.aliveRefs.insert ⟨st.nextRef⟩ any\n nextRef := st.nextRef + 1\n }\n return ⟨st.nextRef⟩",
"start": [
48,
1
],
"end": [
54,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Server.rpcGetRef",
"code": "def rpcGetRef (r : Lsp.RpcRef) : ReaderT RpcObjectStore Id (Option Dynamic) :=\n return (← read).aliveRefs.find? r",
"start": [
56,
1
],
"end": [
57,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Server.rpcReleaseRef",
"code": "def rpcReleaseRef (r : Lsp.RpcRef) : StateM RpcObjectStore Bool := do\n let st ← get\n if st.aliveRefs.contains r then\n set { st with aliveRefs := st.aliveRefs.erase r }\n return true\n else\n return false",
"start": [
59,
1
],
"end": [
65,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Server.RpcEncodable",
"code": "class RpcEncodable (α : Type) where\n rpcEncode : α → StateM RpcObjectStore Json\n rpcDecode : Json → ExceptT String (ReaderT RpcObjectStore Id) α",
"start": [
67,
1
],
"end": [
92,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Server.WithRpcRef",
"code": "structure WithRpcRef (α : Type u) where\n val : α\n deriving Inhabited",
"start": [
124,
1
],
"end": [
129,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ToExpr.lean | [
".lake/packages/lean4/src/lean/Init/Data/BitVec/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean"
] | [
{
"full_name": "Lean.ToExpr",
"code": "class ToExpr (α : Type u) where\n \n toExpr : α → Expr\n \n toTypeExpr : Expr",
"start": [
13,
1
],
"end": [
25,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Name.toExprAux",
"code": "private def Name.toExprAux (n : Name) : Expr :=\n if isSimple n 0 then\n mkStr n 0 #[]\n else\n go n\nwhere\n isSimple (n : Name) (sz : Nat) : Bool :=\n match n with\n | .anonymous => 0 < sz && sz <= 8\n | .str p _ => isSimple p (sz+1)\n | _ => false\n\n mkStr (n : Name) (sz : Nat) (args : Array Expr) : Expr :=\n match n with\n | .anonymous => mkAppN (mkConst (.str ``Lean.Name (\"mkStr\" ++ toString sz))) args.reverse\n | .str p s => mkStr p (sz+1) (args.push (toExpr s))\n | _ => unreachable!\n\n go : Name → Expr\n | .anonymous => mkConst ``Lean.Name.anonymous\n | .str p s ..=> mkApp2 (mkConst ``Lean.Name.str) (go p) (toExpr s)\n | .num p n ..=> mkApp2 (mkConst ``Lean.Name.num) (go p) (toExpr n)",
"start": [
109,
1
],
"end": [
130,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.List.toExprAux",
"code": "private def List.toExprAux [ToExpr α] (nilFn : Expr) (consFn : Expr) : List α → Expr\n | [] => nilFn\n | a::as => mkApp2 consFn (toExpr a) (toExprAux nilFn consFn as)",
"start": [
143,
1
],
"end": [
145,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.toCtorIfLit",
"code": "def Expr.toCtorIfLit : Expr → Expr\n | .lit (.natVal v) =>\n if v == 0 then mkConst ``Nat.zero\n else mkApp (mkConst ``Nat.succ) (mkRawNatLit (v-1))\n | .lit (.strVal v) =>\n mkApp (mkConst ``String.mk) (toExpr v.toList)\n | e => e",
"start": [
181,
1
],
"end": [
187,
11
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/MonadCache.lean | [
".lake/packages/lean4/src/lean/Lean/Data/HashMap.lean",
".lake/packages/lean4/src/lean/Init/Control/StateRef.lean"
] | [
{
"full_name": "Lean.MonadCache",
"code": "class MonadCache (α β : Type) (m : Type → Type) where\n findCached? : α → m (Option β)\n cache : α → β → m Unit",
"start": [
11,
1
],
"end": [
14,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.checkCache",
"code": "@[always_inline, inline]\ndef checkCache {α β : Type} {m : Type → Type} [MonadCache α β m] [Monad m] (a : α) (f : Unit → m β) : m β := do\n match (← MonadCache.findCached? a) with\n | some b => pure b\n | none => do\n let b ← f ()\n MonadCache.cache a b\n pure b",
"start": [
16,
1
],
"end": [
25,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadHashMapCacheAdapter",
"code": "class MonadHashMapCacheAdapter (α β : Type) (m : Type → Type) [BEq α] [Hashable α] where\n getCache : m (HashMap α β)\n modifyCache : (HashMap α β → HashMap α β) → m Unit",
"start": [
36,
1
],
"end": [
40,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadHashMapCacheAdapter.findCached?",
"code": "@[always_inline, inline]\ndef findCached? {α β : Type} {m : Type → Type} [BEq α] [Hashable α] [Monad m] [MonadHashMapCacheAdapter α β m] (a : α) : m (Option β) := do\n let c ← getCache\n pure (c.find? a)",
"start": [
44,
1
],
"end": [
47,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadHashMapCacheAdapter.cache",
"code": "@[always_inline, inline]\ndef cache {α β : Type} {m : Type → Type} [BEq α] [Hashable α] [MonadHashMapCacheAdapter α β m] (a : α) (b : β) : m Unit :=\n modifyCache fun s => s.insert a b",
"start": [
49,
1
],
"end": [
51,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadCacheT",
"code": "def MonadCacheT {ω} (α β : Type) (m : Type → Type) [STWorld ω m] [BEq α] [Hashable α] := StateRefT (HashMap α β) m",
"start": [
59,
1
],
"end": [
59,
115
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadCacheT.run",
"code": "@[inline] def run {σ} (x : MonadCacheT α β m σ) : m σ :=\n x.run' mkHashMap",
"start": [
69,
1
],
"end": [
70,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadStateCacheT",
"code": "def MonadStateCacheT (α β : Type) (m : Type → Type) [BEq α] [Hashable α] := StateT (HashMap α β) m",
"start": [
83,
1
],
"end": [
83,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadStateCacheT.run",
"code": "@[always_inline, inline] def run {σ} (x : MonadStateCacheT α β m σ) : m σ :=\n x.run' mkHashMap",
"start": [
93,
1
],
"end": [
94,
19
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Environment.lean | [
".lake/packages/lean4/src/lean/Lean/LocalContext.lean",
".lake/packages/lean4/src/lean/Lean/ImportingFlag.lean",
".lake/packages/lean4/src/lean/Init/Control/StateRef.lean",
".lake/packages/lean4/src/lean/Init/Data/Array/BinSearch.lean",
".lake/packages/lean4/src/lean/Lean/Util/Profile.lean",
".lake/packages/lean4/src/lean/Lean/Data/HashMap.lean",
".lake/packages/lean4/src/lean/Init/Data/Stream.lean",
".lake/packages/lean4/src/lean/Lean/Declaration.lean",
".lake/packages/lean4/src/lean/Lean/Util/InstantiateLevelParams.lean",
".lake/packages/lean4/src/lean/Lean/Util/Path.lean",
".lake/packages/lean4/src/lean/Lean/Data/SMap.lean",
".lake/packages/lean4/src/lean/Lean/Util/FindExpr.lean"
] | [
{
"full_name": "Lean.EnvExtensionStateSpec",
"code": "opaque EnvExtensionStateSpec : (α : Type) × Inhabited α := ⟨Unit, ⟨()⟩⟩",
"start": [
21,
1
],
"end": [
22,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionState",
"code": "def EnvExtensionState : Type := EnvExtensionStateSpec.fst",
"start": [
23,
1
],
"end": [
23,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ModuleIdx",
"code": "def ModuleIdx := Nat\n deriving BEq, ToString",
"start": [
26,
1
],
"end": [
27,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ModuleIdx.toNat",
"code": "abbrev ModuleIdx.toNat (midx : ModuleIdx) : Nat := midx",
"start": [
29,
1
],
"end": [
29,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstMap",
"code": "abbrev ConstMap := SMap Name ConstantInfo",
"start": [
33,
1
],
"end": [
33,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Import",
"code": "structure Import where\n module : Name\n runtimeOnly : Bool := false\n deriving Repr, Inhabited",
"start": [
35,
1
],
"end": [
38,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CompactedRegion",
"code": "def CompactedRegion := USize",
"start": [
44,
1
],
"end": [
48,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CompactedRegion.isMemoryMapped",
"code": "@[extern \"lean_compacted_region_is_memory_mapped\"]\nopaque CompactedRegion.isMemoryMapped : CompactedRegion → Bool",
"start": [
50,
1
],
"end": [
51,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.CompactedRegion.free",
"code": "@[extern \"lean_compacted_region_free\"]\nunsafe opaque CompactedRegion.free : CompactedRegion → IO Unit",
"start": [
53,
1
],
"end": [
55,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionEntrySpec",
"code": "opaque EnvExtensionEntrySpec : NonemptyType.{0}",
"start": [
57,
1
],
"end": [
58,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionEntry",
"code": "def EnvExtensionEntry : Type := EnvExtensionEntrySpec.type",
"start": [
59,
1
],
"end": [
59,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ModuleData",
"code": "structure ModuleData where\n imports : Array Import\n \n constNames : Array Name\n constants : Array ConstantInfo\n \n extraConstNames : Array Name\n entries : Array (Name × Array EnvExtensionEntry)\n deriving Inhabited",
"start": [
62,
1
],
"end": [
81,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvironmentHeader",
"code": "structure EnvironmentHeader where\n \n trustLevel : UInt32 := 0\n \n quotInit : Bool := false\n \n mainModule : Name := default\n \n imports : Array Import := #[]\n \n regions : Array CompactedRegion := #[]\n \n moduleNames : Array Name := #[]\n \n moduleData : Array ModuleData := #[]\n deriving Nonempty",
"start": [
83,
1
],
"end": [
107,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment",
"code": "structure Environment where\n \n private mk ::\n \n const2ModIdx : HashMap Name ModuleIdx\n \n constants : ConstMap\n \n extensions : Array EnvExtensionState\n \n extraConstNames : NameSet\n \n header : EnvironmentHeader := {}\n deriving Nonempty",
"start": [
109,
1
],
"end": [
155,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.addAux",
"code": "private def addAux (env : Environment) (cinfo : ConstantInfo) : Environment :=\n { env with constants := env.constants.insert cinfo.name cinfo }",
"start": [
159,
1
],
"end": [
160,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.addExtraName",
"code": "def addExtraName (env : Environment) (name : Name) : Environment :=\n if env.constants.contains name then\n env\n else\n { env with extraConstNames := env.extraConstNames.insert name }",
"start": [
162,
1
],
"end": [
171,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.find?",
"code": "@[export lean_environment_find]\ndef find? (env : Environment) (n : Name) : Option ConstantInfo :=\n \n env.constants.find?' n",
"start": [
173,
1
],
"end": [
176,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.contains",
"code": "def contains (env : Environment) (n : Name) : Bool :=\n env.constants.contains n",
"start": [
178,
1
],
"end": [
179,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.imports",
"code": "def imports (env : Environment) : Array Import :=\n env.header.imports",
"start": [
181,
1
],
"end": [
182,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.allImportedModuleNames",
"code": "def allImportedModuleNames (env : Environment) : Array Name :=\n env.header.moduleNames",
"start": [
184,
1
],
"end": [
185,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.setMainModule",
"code": "@[export lean_environment_set_main_module]\ndef setMainModule (env : Environment) (m : Name) : Environment :=\n { env with header := { env.header with mainModule := m } }",
"start": [
187,
1
],
"end": [
189,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.mainModule",
"code": "@[export lean_environment_main_module]\ndef mainModule (env : Environment) : Name :=\n env.header.mainModule",
"start": [
191,
1
],
"end": [
193,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.markQuotInit",
"code": "@[export lean_environment_mark_quot_init]\nprivate def markQuotInit (env : Environment) : Environment :=\n { env with header := { env.header with quotInit := true } }",
"start": [
195,
1
],
"end": [
197,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.isQuotInit",
"code": "@[export lean_environment_quot_init]\nprivate def isQuotInit (env : Environment) : Bool :=\n env.header.quotInit",
"start": [
199,
1
],
"end": [
201,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.getTrustLevel",
"code": "@[export lean_environment_trust_level]\nprivate def getTrustLevel (env : Environment) : UInt32 :=\n env.header.trustLevel",
"start": [
203,
1
],
"end": [
205,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.getModuleIdxFor?",
"code": "def getModuleIdxFor? (env : Environment) (declName : Name) : Option ModuleIdx :=\n env.const2ModIdx.find? declName",
"start": [
207,
1
],
"end": [
208,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.isConstructor",
"code": "def isConstructor (env : Environment) (declName : Name) : Bool :=\n match env.find? declName with\n | some (.ctorInfo _) => true\n | _ => false",
"start": [
210,
1
],
"end": [
213,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.isSafeDefinition",
"code": "def isSafeDefinition (env : Environment) (declName : Name) : Bool :=\n match env.find? declName with\n | some (.defnInfo { safety := .safe, .. }) => true\n | _ => false",
"start": [
215,
1
],
"end": [
218,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.getModuleIdx?",
"code": "def getModuleIdx? (env : Environment) (moduleName : Name) : Option ModuleIdx :=\n env.header.moduleNames.findIdx? (· == moduleName)",
"start": [
220,
1
],
"end": [
221,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KernelException",
"code": "inductive KernelException where\n | unknownConstant (env : Environment) (name : Name)\n | alreadyDeclared (env : Environment) (name : Name)\n | declTypeMismatch (env : Environment) (decl : Declaration) (givenType : Expr)\n | declHasMVars (env : Environment) (name : Name) (expr : Expr)\n | declHasFVars (env : Environment) (name : Name) (expr : Expr)\n | funExpected (env : Environment) (lctx : LocalContext) (expr : Expr)\n | typeExpected (env : Environment) (lctx : LocalContext) (expr : Expr)\n | letTypeMismatch (env : Environment) (lctx : LocalContext) (name : Name) (givenType : Expr) (expectedType : Expr)\n | exprTypeMismatch (env : Environment) (lctx : LocalContext) (expr : Expr) (expectedType : Expr)\n | appTypeMismatch (env : Environment) (lctx : LocalContext) (app : Expr) (funType : Expr) (argType : Expr)\n | invalidProj (env : Environment) (lctx : LocalContext) (proj : Expr)\n | thmTypeIsNotProp (env : Environment) (name : Name) (type : Expr)\n | other (msg : String)\n | deterministicTimeout\n | excessiveMemory\n | deepRecursion\n | interrupted",
"start": [
225,
1
],
"end": [
243,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.addDeclCore",
"code": "@[extern \"lean_add_decl\"]\nopaque addDeclCore (env : Environment) (maxHeartbeats : USize) (decl : @& Declaration) : Except KernelException Environment",
"start": [
247,
1
],
"end": [
251,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.addDeclWithoutChecking",
"code": "@[extern \"lean_add_decl_without_checking\"]\nopaque addDeclWithoutChecking (env : Environment) (decl : @& Declaration) : Except KernelException Environment",
"start": [
253,
1
],
"end": [
260,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.instantiateTypeLevelParams",
"code": "def instantiateTypeLevelParams (c : ConstantInfo) (ls : List Level) : Expr :=\n c.type.instantiateLevelParams c.levelParams ls",
"start": [
266,
1
],
"end": [
267,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ConstantInfo.instantiateValueLevelParams!",
"code": "def instantiateValueLevelParams! (c : ConstantInfo) (ls : List Level) : Expr :=\n c.value!.instantiateLevelParams c.levelParams ls",
"start": [
269,
1
],
"end": [
270,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterface",
"code": "structure EnvExtensionInterface where\n ext : Type → Type\n inhabitedExt : Inhabited σ → Inhabited (ext σ)\n registerExt (mkInitial : IO σ) : IO (ext σ)\n setState (e : ext σ) (exts : Array EnvExtensionState) : σ → Array EnvExtensionState\n modifyState (e : ext σ) (exts : Array EnvExtensionState) : (σ → σ) → Array EnvExtensionState\n getState [Inhabited σ] (e : ext σ) (exts : Array EnvExtensionState) : σ\n mkInitialExtStates : IO (Array EnvExtensionState)\n ensureExtensionsSize : Array EnvExtensionState → IO (Array EnvExtensionState)",
"start": [
274,
1
],
"end": [
283,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.Ext",
"code": "structure Ext (σ : Type) where\n idx : Nat\n mkInitial : IO σ\n deriving Inhabited",
"start": [
300,
1
],
"end": [
303,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.ensureExtensionsArraySize",
"code": "partial def ensureExtensionsArraySize (exts : Array EnvExtensionState) : IO (Array EnvExtensionState) := do\n loop exts.size exts\nwhere\n loop (i : Nat) (exts : Array EnvExtensionState) : IO (Array EnvExtensionState) := do\n let envExtensions ← envExtensionsRef.get\n if i < envExtensions.size then\n let s ← envExtensions[i]!.mkInitial\n let exts := exts.push s\n loop (i + 1) exts\n else\n return exts",
"start": [
307,
1
],
"end": [
324,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.invalidExtMsg",
"code": "private def invalidExtMsg := \"invalid environment extension has been accessed\"",
"start": [
326,
1
],
"end": [
326,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.setState",
"code": "unsafe def setState {σ} (ext : Ext σ) (exts : Array EnvExtensionState) (s : σ) : Array EnvExtensionState :=\n if h : ext.idx < exts.size then\n exts.set ⟨ext.idx, h⟩ (unsafeCast s)\n else\n have : Inhabited (Array EnvExtensionState) := ⟨exts⟩\n panic! invalidExtMsg",
"start": [
328,
1
],
"end": [
333,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.modifyState",
"code": "@[inline] unsafe def modifyState {σ : Type} (ext : Ext σ) (exts : Array EnvExtensionState) (f : σ → σ) : Array EnvExtensionState :=\n if ext.idx < exts.size then\n exts.modify ext.idx fun s =>\n let s : σ := unsafeCast s\n let s : σ := f s\n unsafeCast s\n else\n have : Inhabited (Array EnvExtensionState) := ⟨exts⟩\n panic! invalidExtMsg",
"start": [
335,
1
],
"end": [
343,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.getState",
"code": "unsafe def getState {σ} [Inhabited σ] (ext : Ext σ) (exts : Array EnvExtensionState) : σ :=\n if h : ext.idx < exts.size then\n let s : EnvExtensionState := exts.get ⟨ext.idx, h⟩\n unsafeCast s\n else\n panic! invalidExtMsg",
"start": [
345,
1
],
"end": [
350,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.registerExt",
"code": "unsafe def registerExt {σ} (mkInitial : IO σ) : IO (Ext σ) := do\n unless (← initializing) do\n throw (IO.userError \"failed to register environment, extensions can only be registered during initialization\")\n let exts ← envExtensionsRef.get\n let idx := exts.size\n let ext : Ext σ := {\n idx := idx,\n mkInitial := mkInitial,\n }\n envExtensionsRef.modify fun exts => exts.push (unsafeCast ext)\n pure ext",
"start": [
352,
1
],
"end": [
362,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.mkInitialExtStates",
"code": "def mkInitialExtStates : IO (Array EnvExtensionState) := do\n let exts ← envExtensionsRef.get\n exts.mapM fun ext => ext.mkInitial",
"start": [
364,
1
],
"end": [
366,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceUnsafe.imp",
"code": "unsafe def imp : EnvExtensionInterface := {\n ext := Ext\n ensureExtensionsSize := ensureExtensionsArraySize\n inhabitedExt := fun _ => ⟨default⟩\n registerExt := registerExt\n setState := setState\n modifyState := modifyState\n getState := getState\n mkInitialExtStates := mkInitialExtStates\n}",
"start": [
368,
1
],
"end": [
377,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtensionInterfaceImp",
"code": "@[implemented_by EnvExtensionInterfaceUnsafe.imp]\nopaque EnvExtensionInterfaceImp : EnvExtensionInterface",
"start": [
381,
1
],
"end": [
382,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtension",
"code": "def EnvExtension (σ : Type) : Type := EnvExtensionInterfaceImp.ext σ",
"start": [
384,
1
],
"end": [
384,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ensureExtensionsArraySize",
"code": "private def ensureExtensionsArraySize (env : Environment) : IO Environment := do\n let exts ← EnvExtensionInterfaceImp.ensureExtensionsSize env.extensions\n return { env with extensions := exts }",
"start": [
386,
1
],
"end": [
388,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtension.setState",
"code": "def setState {σ : Type} (ext : EnvExtension σ) (env : Environment) (s : σ) : Environment :=\n { env with extensions := EnvExtensionInterfaceImp.setState ext env.extensions s }",
"start": [
393,
1
],
"end": [
394,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtension.modifyState",
"code": "def modifyState {σ : Type} (ext : EnvExtension σ) (env : Environment) (f : σ → σ) : Environment :=\n { env with extensions := EnvExtensionInterfaceImp.modifyState ext env.extensions f }",
"start": [
396,
1
],
"end": [
397,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnvExtension.getState",
"code": "def getState {σ : Type} [Inhabited σ] (ext : EnvExtension σ) (env : Environment) : σ :=\n EnvExtensionInterfaceImp.getState ext env.extensions",
"start": [
399,
1
],
"end": [
400,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerEnvExtension",
"code": "def registerEnvExtension {σ : Type} (mkInitial : IO σ) : IO (EnvExtension σ) := EnvExtensionInterfaceImp.registerExt mkInitial",
"start": [
404,
1
],
"end": [
411,
127
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkInitialExtensionStates",
"code": "private def mkInitialExtensionStates : IO (Array EnvExtensionState) := EnvExtensionInterfaceImp.mkInitialExtStates",
"start": [
412,
1
],
"end": [
412,
115
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkEmptyEnvironment",
"code": "@[export lean_mk_empty_environment]\ndef mkEmptyEnvironment (trustLevel : UInt32 := 0) : IO Environment := do\n let initializing ← IO.initializing\n if initializing then throw (IO.userError \"environment objects cannot be created during initialization\")\n let exts ← mkInitialExtensionStates\n pure {\n const2ModIdx := {}\n constants := {}\n header := { trustLevel := trustLevel }\n extraConstNames := {}\n extensions := exts\n }",
"start": [
414,
1
],
"end": [
425,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtensionState",
"code": "structure PersistentEnvExtensionState (α : Type) (σ : Type) where\n importedEntries : Array (Array α) state : σ",
"start": [
427,
1
],
"end": [
429,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ImportM.Context",
"code": "structure ImportM.Context where\n env : Environment\n opts : Options",
"start": [
431,
1
],
"end": [
433,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ImportM",
"code": "abbrev ImportM := ReaderT Lean.ImportM.Context IO",
"start": [
435,
1
],
"end": [
435,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtension",
"code": "structure PersistentEnvExtension (α : Type) (β : Type) (σ : Type) where\n toEnvExtension : EnvExtension (PersistentEnvExtensionState α σ)\n name : Name\n addImportedFn : Array (Array α) → ImportM σ\n addEntryFn : σ → β → σ\n exportEntriesFn : σ → Array α\n statsFn : σ → Format",
"start": [
437,
1
],
"end": [
488,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtension.getModuleEntries",
"code": "def getModuleEntries {α β σ : Type} [Inhabited σ] (ext : PersistentEnvExtension α β σ) (env : Environment) (m : ModuleIdx) : Array α :=\n (ext.toEnvExtension.getState env).importedEntries.get! m",
"start": [
505,
1
],
"end": [
506,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtension.addEntry",
"code": "def addEntry {α β σ : Type} (ext : PersistentEnvExtension α β σ) (env : Environment) (b : β) : Environment :=\n ext.toEnvExtension.modifyState env fun s =>\n let state := ext.addEntryFn s.state b;\n { s with state := state }",
"start": [
508,
1
],
"end": [
511,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtension.getState",
"code": "def getState {α β σ : Type} [Inhabited σ] (ext : PersistentEnvExtension α β σ) (env : Environment) : σ :=\n (ext.toEnvExtension.getState env).state",
"start": [
513,
1
],
"end": [
515,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtension.setState",
"code": "def setState {α β σ : Type} (ext : PersistentEnvExtension α β σ) (env : Environment) (s : σ) : Environment :=\n ext.toEnvExtension.modifyState env fun ps => { ps with state := s }",
"start": [
517,
1
],
"end": [
519,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtension.modifyState",
"code": "def modifyState {α β σ : Type} (ext : PersistentEnvExtension α β σ) (env : Environment) (f : σ → σ) : Environment :=\n ext.toEnvExtension.modifyState env fun ps => { ps with state := f (ps.state) }",
"start": [
521,
1
],
"end": [
523,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PersistentEnvExtensionDescr",
"code": "structure PersistentEnvExtensionDescr (α β σ : Type) where\n name : Name := by exact decl_name%\n mkInitial : IO σ\n addImportedFn : Array (Array α) → ImportM σ\n addEntryFn : σ → β → σ\n exportEntriesFn : σ → Array α\n statsFn : σ → Format := fun _ => Format.nil",
"start": [
529,
1
],
"end": [
535,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerPersistentEnvExtensionUnsafe",
"code": "unsafe def registerPersistentEnvExtensionUnsafe {α β σ : Type} [Inhabited σ] (descr : PersistentEnvExtensionDescr α β σ) : IO (PersistentEnvExtension α β σ) := do\n let pExts ← persistentEnvExtensionsRef.get\n if pExts.any (fun ext => ext.name == descr.name) then throw (IO.userError s!\"invalid environment extension, '{descr.name}' has already been used\")\n let ext ← registerEnvExtension do\n let initial ← descr.mkInitial\n let s : PersistentEnvExtensionState α σ := {\n importedEntries := #[],\n state := initial\n }\n pure s\n let pExt : PersistentEnvExtension α β σ := {\n toEnvExtension := ext,\n name := descr.name,\n addImportedFn := descr.addImportedFn,\n addEntryFn := descr.addEntryFn,\n exportEntriesFn := descr.exportEntriesFn,\n statsFn := descr.statsFn\n }\n persistentEnvExtensionsRef.modify fun pExts => pExts.push (unsafeCast pExt)\n return pExt",
"start": [
537,
1
],
"end": [
556,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerPersistentEnvExtension",
"code": "@[implemented_by registerPersistentEnvExtensionUnsafe]\nopaque registerPersistentEnvExtension {α β σ : Type} [Inhabited σ] (descr : PersistentEnvExtensionDescr α β σ) : IO (PersistentEnvExtension α β σ)",
"start": [
558,
1
],
"end": [
559,
147
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimplePersistentEnvExtension",
"code": "def SimplePersistentEnvExtension (α σ : Type) := PersistentEnvExtension α α (List α × σ)",
"start": [
561,
1
],
"end": [
562,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkStateFromImportedEntries",
"code": "@[specialize] def mkStateFromImportedEntries {α σ : Type} (addEntryFn : σ → α → σ) (initState : σ) (as : Array (Array α)) : σ :=\n as.foldl (fun r es => es.foldl (fun r e => addEntryFn r e) r) initState",
"start": [
564,
1
],
"end": [
565,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimplePersistentEnvExtensionDescr",
"code": "structure SimplePersistentEnvExtensionDescr (α σ : Type) where\n name : Name := by exact decl_name%\n addEntryFn : σ → α → σ\n addImportedFn : Array (Array α) → σ\n toArrayFn : List α → Array α := fun es => es.toArray",
"start": [
567,
1
],
"end": [
571,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerSimplePersistentEnvExtension",
"code": "def registerSimplePersistentEnvExtension {α σ : Type} [Inhabited σ] (descr : SimplePersistentEnvExtensionDescr α σ) : IO (SimplePersistentEnvExtension α σ) :=\n registerPersistentEnvExtension {\n name := descr.name,\n mkInitial := pure ([], descr.addImportedFn #[]),\n addImportedFn := fun as => pure ([], descr.addImportedFn as),\n addEntryFn := fun s e => match s with\n | (entries, s) => (e::entries, descr.addEntryFn s e),\n exportEntriesFn := fun s => descr.toArrayFn s.1.reverse,\n statsFn := fun s => format \"number of local entries: \" ++ format s.1.length\n }",
"start": [
573,
1
],
"end": [
582,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimplePersistentEnvExtension.getEntries",
"code": "def getEntries {α σ : Type} [Inhabited σ] (ext : SimplePersistentEnvExtension α σ) (env : Environment) : List α :=\n (PersistentEnvExtension.getState ext env).1",
"start": [
589,
1
],
"end": [
592,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimplePersistentEnvExtension.getState",
"code": "def getState {α σ : Type} [Inhabited σ] (ext : SimplePersistentEnvExtension α σ) (env : Environment) : σ :=\n (PersistentEnvExtension.getState ext env).2",
"start": [
594,
1
],
"end": [
596,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimplePersistentEnvExtension.setState",
"code": "def setState {α σ : Type} (ext : SimplePersistentEnvExtension α σ) (env : Environment) (s : σ) : Environment :=\n PersistentEnvExtension.modifyState ext env (fun ⟨entries, _⟩ => (entries, s))",
"start": [
598,
1
],
"end": [
600,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimplePersistentEnvExtension.modifyState",
"code": "def modifyState {α σ : Type} (ext : SimplePersistentEnvExtension α σ) (env : Environment) (f : σ → σ) : Environment :=\n PersistentEnvExtension.modifyState ext env (fun ⟨entries, s⟩ => (entries, f s))",
"start": [
602,
1
],
"end": [
604,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TagDeclarationExtension",
"code": "def TagDeclarationExtension := SimplePersistentEnvExtension Name NameSet",
"start": [
608,
1
],
"end": [
610,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkTagDeclarationExtension",
"code": "def mkTagDeclarationExtension (name : Name := by exact decl_name%) : IO TagDeclarationExtension :=\n registerSimplePersistentEnvExtension {\n name := name,\n addImportedFn := fun _ => {},\n addEntryFn := fun s n => s.insert n,\n toArrayFn := fun es => es.toArray.qsort Name.quickLt\n }",
"start": [
612,
1
],
"end": [
618,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TagDeclarationExtension.tag",
"code": "def tag (ext : TagDeclarationExtension) (env : Environment) (declName : Name) : Environment :=\n have : Inhabited Environment := ⟨env⟩\n assert! env.getModuleIdxFor? declName |>.isNone ext.addEntry env declName",
"start": [
625,
1
],
"end": [
628,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TagDeclarationExtension.isTagged",
"code": "def isTagged (ext : TagDeclarationExtension) (env : Environment) (declName : Name) : Bool :=\n match env.getModuleIdxFor? declName with\n | some modIdx => (ext.getModuleEntries env modIdx).binSearchContains declName Name.quickLt\n | none => (ext.getState env).contains declName",
"start": [
630,
1
],
"end": [
633,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MapDeclarationExtension",
"code": "def MapDeclarationExtension (α : Type) := SimplePersistentEnvExtension (Name × α) (NameMap α)",
"start": [
637,
1
],
"end": [
640,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkMapDeclarationExtension",
"code": "def mkMapDeclarationExtension (name : Name := by exact decl_name%) : IO (MapDeclarationExtension α) :=\n registerSimplePersistentEnvExtension {\n name := name,\n addImportedFn := fun _ => {},\n addEntryFn := fun s n => s.insert n.1 n.2 ,\n toArrayFn := fun es => es.toArray.qsort (fun a b => Name.quickLt a.1 b.1)\n }",
"start": [
642,
1
],
"end": [
648,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MapDeclarationExtension.insert",
"code": "def insert (ext : MapDeclarationExtension α) (env : Environment) (declName : Name) (val : α) : Environment :=\n have : Inhabited Environment := ⟨env⟩\n assert! env.getModuleIdxFor? declName |>.isNone ext.addEntry env (declName, val)",
"start": [
655,
1
],
"end": [
658,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MapDeclarationExtension.find?",
"code": "def find? [Inhabited α] (ext : MapDeclarationExtension α) (env : Environment) (declName : Name) : Option α :=\n match env.getModuleIdxFor? declName with\n | some modIdx =>\n match (ext.getModuleEntries env modIdx).binSearch (declName, default) (fun a b => Name.quickLt a.1 b.1) with\n | some e => some e.2\n | none => none\n | none => (ext.getState env).find? declName",
"start": [
660,
1
],
"end": [
666,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MapDeclarationExtension.contains",
"code": "def contains [Inhabited α] (ext : MapDeclarationExtension α) (env : Environment) (declName : Name) : Bool :=\n match env.getModuleIdxFor? declName with\n | some modIdx => (ext.getModuleEntries env modIdx).binSearchContains (declName, default) (fun a b => Name.quickLt a.1 b.1)\n | none => (ext.getState env).contains declName",
"start": [
668,
1
],
"end": [
671,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.saveModuleData",
"code": "@[extern \"lean_save_module_data\"]\nopaque saveModuleData (fname : @& System.FilePath) (mod : @& Name) (data : @& ModuleData) : IO Unit",
"start": [
675,
1
],
"end": [
676,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.readModuleData",
"code": "@[extern \"lean_read_module_data\"]\nopaque readModuleData (fname : @& System.FilePath) : IO (ModuleData × CompactedRegion)",
"start": [
677,
1
],
"end": [
678,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.freeRegions",
"code": "@[noinline, export lean_environment_free_regions]\nunsafe def Environment.freeRegions (env : Environment) : IO Unit :=\n \n env.header.regions.forM CompactedRegion.free",
"start": [
680,
1
],
"end": [
700,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkModuleData",
"code": "def mkModuleData (env : Environment) : IO ModuleData := do\n let pExts ← persistentEnvExtensionsRef.get\n let entries := pExts.map fun pExt =>\n let state := pExt.getState env\n (pExt.name, pExt.exportEntriesFn state)\n let constNames := env.constants.foldStage2 (fun names name _ => names.push name) #[]\n let constants := env.constants.foldStage2 (fun cs _ c => cs.push c) #[]\n return {\n imports := env.header.imports\n extraConstNames := env.extraConstNames.toArray\n constNames, constants, entries\n }",
"start": [
702,
1
],
"end": [
713,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.writeModule",
"code": "@[export lean_write_module]\ndef writeModule (env : Environment) (fname : System.FilePath) : IO Unit := do\n saveModuleData fname env.mainModule (← mkModuleData env)",
"start": [
715,
1
],
"end": [
717,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkExtNameMap",
"code": "def mkExtNameMap (startingAt : Nat) : IO (HashMap Name Nat) := do\n let descrs ← persistentEnvExtensionsRef.get\n let mut result := {}\n for h : i in [startingAt : descrs.size] do\n have : i < descrs.size := h.upper\n let descr := descrs[i]\n result := result.insert descr.name i\n return result",
"start": [
719,
1
],
"end": [
730,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setImportedEntries",
"code": "private def setImportedEntries (env : Environment) (mods : Array ModuleData) (startingAt : Nat := 0) : IO Environment := do\n let mut env := env\n let extDescrs ← persistentEnvExtensionsRef.get\n \n for extDescr in extDescrs[startingAt:] do\n env := extDescr.toEnvExtension.modifyState env fun s => { s with importedEntries := mkArray mods.size #[] }\n \n let extNameIdx ← mkExtNameMap startingAt\n for h : modIdx in [:mods.size] do\n have : modIdx < mods.size := h.upper\n let mod := mods[modIdx]\n for (extName, entries) in mod.entries do\n if let some entryIdx := extNameIdx.find? extName then\n env := extDescrs[entryIdx]!.toEnvExtension.modifyState env fun s => { s with importedEntries := s.importedEntries.set! modIdx entries }\n return env",
"start": [
732,
1
],
"end": [
746,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.updateEnvAttributes",
"code": "@[extern 2 \"lean_update_env_attributes\"] opaque updateEnvAttributes : Environment → IO Environment",
"start": [
748,
1
],
"end": [
757,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getNumBuiltinAttributes",
"code": "@[extern 1 \"lean_get_num_attributes\"] opaque getNumBuiltinAttributes : IO Nat",
"start": [
758,
1
],
"end": [
759,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.finalizePersistentExtensions",
"code": "private partial def finalizePersistentExtensions (env : Environment) (mods : Array ModuleData) (opts : Options) : IO Environment := do\n loop 0 env\nwhere\n loop (i : Nat) (env : Environment) : IO Environment := do\n let pExtDescrs ← persistentEnvExtensionsRef.get\n if i < pExtDescrs.size then\n let extDescr := pExtDescrs[i]!\n let s := extDescr.toEnvExtension.getState env\n let prevSize := (← persistentEnvExtensionsRef.get).size\n let prevAttrSize ← getNumBuiltinAttributes\n let newState ← extDescr.addImportedFn s.importedEntries { env := env, opts := opts }\n let mut env := extDescr.toEnvExtension.setState env { s with state := newState }\n env ← ensureExtensionsArraySize env\n if (← persistentEnvExtensionsRef.get).size > prevSize || (← getNumBuiltinAttributes) > prevAttrSize then\n env ← setImportedEntries env mods prevSize\n env ← updateEnvAttributes env\n loop (i + 1) env\n else\n return env",
"start": [
761,
1
],
"end": [
784,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ImportState",
"code": "structure ImportState where\n moduleNameSet : NameHashSet := {}\n moduleNames : Array Name := #[]\n moduleData : Array ModuleData := #[]\n regions : Array CompactedRegion := #[]",
"start": [
786,
1
],
"end": [
790,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.throwAlreadyImported",
"code": "def throwAlreadyImported (s : ImportState) (const2ModIdx : HashMap Name ModuleIdx) (modIdx : Nat) (cname : Name) : IO α := do\n let modName := s.moduleNames[modIdx]!\n let constModName := s.moduleNames[const2ModIdx[cname].get!.toNat]!\n throw <| IO.userError s!\"import {modName} failed, environment already contains '{cname}' from {constModName}\"",
"start": [
792,
1
],
"end": [
795,
112
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ImportStateM",
"code": "abbrev ImportStateM := StateRefT ImportState IO",
"start": [
797,
1
],
"end": [
797,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ImportStateM.run",
"code": "@[inline] nonrec def ImportStateM.run (x : ImportStateM α) (s : ImportState := {}) : IO (α × ImportState) :=\n x.run s",
"start": [
799,
1
],
"end": [
800,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.importModulesCore",
"code": "partial def importModulesCore (imports : Array Import) : ImportStateM Unit := do\n for i in imports do\n if i.runtimeOnly || (← get).moduleNameSet.contains i.module then\n continue\n modify fun s => { s with moduleNameSet := s.moduleNameSet.insert i.module }\n let mFile ← findOLean i.module\n unless (← mFile.pathExists) do\n throw <| IO.userError s!\"object file '{mFile}' of module {i.module} does not exist\"\n let (mod, region) ← readModuleData mFile\n importModulesCore mod.imports\n modify fun s => { s with\n moduleData := s.moduleData.push mod\n regions := s.regions.push region\n moduleNames := s.moduleNames.push i.module\n }",
"start": [
802,
1
],
"end": [
816,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.equivInfo",
"code": "private def equivInfo (cinfo₁ cinfo₂ : ConstantInfo) : Bool := Id.run do\n let .thmInfo tval₁ := cinfo₁ | false\n let .thmInfo tval₂ := cinfo₂ | false\n return tval₁.name == tval₂.name\n && tval₁.type == tval₂.type\n && tval₁.levelParams == tval₂.levelParams\n && tval₁.all == tval₂.all",
"start": [
818,
1
],
"end": [
843,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.finalizeImport",
"code": "def finalizeImport (s : ImportState) (imports : Array Import) (opts : Options) (trustLevel : UInt32 := 0)\n (leakEnv := false) : IO Environment := do\n let numConsts := s.moduleData.foldl (init := 0) fun numConsts mod =>\n numConsts + mod.constants.size + mod.extraConstNames.size\n let mut const2ModIdx : HashMap Name ModuleIdx := mkHashMap (capacity := numConsts)\n let mut constantMap : HashMap Name ConstantInfo := mkHashMap (capacity := numConsts)\n for h:modIdx in [0:s.moduleData.size] do\n let mod := s.moduleData[modIdx]'h.upper\n for cname in mod.constNames, cinfo in mod.constants do\n match constantMap.insertIfNew cname cinfo with\n | (constantMap', cinfoPrev?) =>\n constantMap := constantMap'\n if let some cinfoPrev := cinfoPrev? then\n unless equivInfo cinfoPrev cinfo do\n throwAlreadyImported s const2ModIdx modIdx cname\n const2ModIdx := const2ModIdx.insert cname modIdx\n for cname in mod.extraConstNames do\n const2ModIdx := const2ModIdx.insert cname modIdx\n let constants : ConstMap := SMap.fromHashMap constantMap false\n let exts ← mkInitialExtensionStates\n let mut env : Environment := {\n const2ModIdx := const2ModIdx\n constants := constants\n extraConstNames := {}\n extensions := exts\n header := {\n quotInit := !imports.isEmpty trustLevel := trustLevel\n imports := imports\n regions := s.regions\n moduleNames := s.moduleNames\n moduleData := s.moduleData\n }\n }\n env ← setImportedEntries env s.moduleData\n if leakEnv then\n \n env := Runtime.markPersistent env\n env ← finalizePersistentExtensions env s.moduleData opts\n if leakEnv then\n \n env := Runtime.markPersistent env\n pure env",
"start": [
845,
1
],
"end": [
907,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.importModules",
"code": "@[export lean_import_modules]\ndef importModules (imports : Array Import) (opts : Options) (trustLevel : UInt32 := 0)\n (leakEnv := false) : IO Environment := profileitIO \"import\" opts do\n for imp in imports do\n if imp.module matches .anonymous then\n throw <| IO.userError \"import failed, trying to import module with anonymous name\"\n withImporting do\n let (_, s) ← importModulesCore imports |>.run\n finalizeImport (leakEnv := leakEnv) s imports opts trustLevel",
"start": [
909,
1
],
"end": [
917,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withImportModules",
"code": "unsafe def withImportModules {α : Type} (imports : Array Import) (opts : Options) (trustLevel : UInt32 := 0) (act : Environment → IO α) : IO α := do\n let env ← importModules imports opts trustLevel\n try act env finally env.freeRegions",
"start": [
919,
1
],
"end": [
924,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.Diagnostics",
"code": "structure Kernel.Diagnostics where\n \n unfoldCounter : PHashMap Name Nat := {}\n \n enabled : Bool := false\n deriving Inhabited",
"start": [
944,
1
],
"end": [
949,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.Diagnostics.isEnabled",
"code": "@[export lean_kernel_diag_is_enabled]\ndef Kernel.Diagnostics.isEnabled (d : Diagnostics) : Bool :=\n d.enabled",
"start": [
963,
1
],
"end": [
965,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.enableDiag",
"code": "def Kernel.enableDiag (env : Environment) (flag : Bool) : Environment :=\n diagExt.modifyState env fun s => { s with enabled := flag }",
"start": [
967,
1
],
"end": [
969,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.isDiagnosticsEnabled",
"code": "def Kernel.isDiagnosticsEnabled (env : Environment) : Bool :=\n diagExt.getState env |>.enabled",
"start": [
971,
1
],
"end": [
972,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.resetDiag",
"code": "def Kernel.resetDiag (env : Environment) : Environment :=\n diagExt.modifyState env fun s => { s with unfoldCounter := {} }",
"start": [
974,
1
],
"end": [
975,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.Diagnostics.recordUnfold",
"code": "@[export lean_kernel_record_unfold]\ndef Kernel.Diagnostics.recordUnfold (d : Diagnostics) (declName : Name) : Diagnostics :=\n if d.enabled then\n let cNew := if let some c := d.unfoldCounter.find? declName then c + 1 else 1\n { d with unfoldCounter := d.unfoldCounter.insert declName cNew }\n else\n d",
"start": [
977,
1
],
"end": [
983,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.getDiagnostics",
"code": "@[export lean_kernel_get_diag]\ndef Kernel.getDiagnostics (env : Environment) : Diagnostics :=\n diagExt.getState env",
"start": [
985,
1
],
"end": [
987,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.setDiagnostics",
"code": "@[export lean_kernel_set_diag]\ndef Kernel.setDiagnostics (env : Environment) (diag : Diagnostics) : Environment :=\n diagExt.setState env diag",
"start": [
989,
1
],
"end": [
991,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.registerNamespace",
"code": "def registerNamespace (env : Environment) (n : Name) : Environment :=\n if (namespacesExt.getState env).contains n then env else namespacesExt.addEntry env n",
"start": [
995,
1
],
"end": [
997,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.isNamespace",
"code": "def isNamespace (env : Environment) (n : Name) : Bool :=\n (namespacesExt.getState env).contains n",
"start": [
999,
1
],
"end": [
1001,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.getNamespaceSet",
"code": "def getNamespaceSet (env : Environment) : NameSSet :=\n namespacesExt.getState env",
"start": [
1003,
1
],
"end": [
1005,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.isNamespaceName",
"code": "private def isNamespaceName : Name → Bool\n | .str .anonymous _ => true\n | .str p _ => isNamespaceName p\n | _ => false",
"start": [
1007,
1
],
"end": [
1010,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.registerNamePrefixes",
"code": "private def registerNamePrefixes : Environment → Name → Environment\n | env, .str p _ => if isNamespaceName p then registerNamePrefixes (registerNamespace env p) p else env\n | env, _ => env",
"start": [
1012,
1
],
"end": [
1014,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.add",
"code": "@[export lean_environment_add]\nprivate def add (env : Environment) (cinfo : ConstantInfo) : Environment :=\n let env := registerNamePrefixes env cinfo.name\n env.addAux cinfo",
"start": [
1016,
1
],
"end": [
1019,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.displayStats",
"code": "@[export lean_display_stats]\ndef displayStats (env : Environment) : IO Unit := do\n let pExtDescrs ← persistentEnvExtensionsRef.get\n IO.println (\"direct imports: \" ++ toString env.header.imports);\n IO.println (\"number of imported modules: \" ++ toString env.header.regions.size);\n IO.println (\"number of memory-mapped modules: \" ++ toString (env.header.regions.filter (·.isMemoryMapped) |>.size));\n IO.println (\"number of buckets for imported consts: \" ++ toString env.constants.numBuckets);\n IO.println (\"trust level: \" ++ toString env.header.trustLevel);\n IO.println (\"number of extensions: \" ++ toString env.extensions.size);\n pExtDescrs.forM fun extDescr => do\n IO.println (\"extension '\" ++ toString extDescr.name ++ \"'\")\n let s := extDescr.toEnvExtension.getState env\n let fmt := extDescr.statsFn s.state\n unless fmt.isNil do IO.println (\" \" ++ toString (Format.nest 2 (extDescr.statsFn s.state)))\n IO.println (\" number of imported entries: \" ++ toString (s.importedEntries.foldl (fun sum es => sum + es.size) 0))",
"start": [
1021,
1
],
"end": [
1035,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.evalConst",
"code": "@[extern \"lean_eval_const\"]\nunsafe opaque evalConst (α) (env : @& Environment) (opts : @& Options) (constName : @& Name) : Except String α",
"start": [
1037,
1
],
"end": [
1042,
111
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.throwUnexpectedType",
"code": "private def throwUnexpectedType {α} (typeName : Name) (constName : Name) : ExceptT String Id α :=\n throw (\"unexpected type at '\" ++ toString constName ++ \"', `\" ++ toString typeName ++ \"` expected\")",
"start": [
1044,
1
],
"end": [
1045,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.evalConstCheck",
"code": "unsafe def evalConstCheck (α) (env : Environment) (opts : Options) (typeName : Name) (constName : Name) : ExceptT String Id α :=\n match env.find? constName with\n | none => throw (\"unknown constant '\" ++ toString constName ++ \"'\")\n | some info =>\n match info.type with\n | Expr.const c _ =>\n if c != typeName then throwUnexpectedType typeName constName\n else env.evalConst α opts constName\n | _ => throwUnexpectedType typeName constName",
"start": [
1047,
1
],
"end": [
1057,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.hasUnsafe",
"code": "def hasUnsafe (env : Environment) (e : Expr) : Bool :=\n let c? := e.find? fun e => match e with\n | Expr.const c _ =>\n match env.find? c with\n | some cinfo => cinfo.isUnsafe\n | none => false\n | _ => false;\n c?.isSome",
"start": [
1059,
1
],
"end": [
1066,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.isDefEq",
"code": "@[extern \"lean_kernel_is_def_eq\"]\nopaque isDefEq (env : Environment) (lctx : LocalContext) (a b : Expr) : Except KernelException Bool",
"start": [
1073,
1
],
"end": [
1078,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.isDefEqGuarded",
"code": "def isDefEqGuarded (env : Environment) (lctx : LocalContext) (a b : Expr) : Bool :=\n if let .ok result := isDefEq env lctx a b then result else false",
"start": [
1080,
1
],
"end": [
1081,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Kernel.whnf",
"code": "@[extern \"lean_kernel_whnf\"]\nopaque whnf (env : Environment) (lctx : LocalContext) (a : Expr) : Except KernelException Expr",
"start": [
1083,
1
],
"end": [
1088,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadEnv",
"code": "class MonadEnv (m : Type → Type) where\n getEnv : m Environment\n modifyEnv : (Environment → Environment) → m Unit",
"start": [
1092,
1
],
"end": [
1094,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkDefinitionValInferrringUnsafe",
"code": "def mkDefinitionValInferrringUnsafe [Monad m] [MonadEnv m] (name : Name) (levelParams : List Name)\n (type : Expr) (value : Expr) (hints : ReducibilityHints) : m DefinitionVal := do\n let env ← getEnv\n let safety := if env.hasUnsafe type || env.hasUnsafe value then DefinitionSafety.unsafe else DefinitionSafety.safe\n return { name, levelParams, type, value, hints, safety }",
"start": [
1103,
1
],
"end": [
1108,
59
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Widget/Types.lean | [
".lake/packages/lean4/src/lean/Lean/Server/Rpc/Basic.lean"
] | [
{
"full_name": "Lean.Widget.WidgetInstance",
"code": "structure WidgetInstance where\n \n id : Name\n \n javascriptHash : UInt64\n \n props : StateM Server.RpcObjectStore Json\n deriving Server.RpcEncodable",
"start": [
12,
1
],
"end": [
29,
31
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Position.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Format.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json.lean",
".lake/packages/lean4/src/lean/Lean/ToExpr.lean"
] | [
{
"full_name": "Lean.Position",
"code": "structure Position where\n line : Nat\n column : Nat\n deriving Inhabited, DecidableEq, Repr, ToJson, FromJson",
"start": [
13,
1
],
"end": [
16,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Position.lt",
"code": "protected def lt : Position → Position → Bool\n | ⟨l₁, c₁⟩, ⟨l₂, c₂⟩ => Prod.lexLt (l₁, c₁) (l₂, c₂)",
"start": [
19,
1
],
"end": [
20,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap",
"code": "structure FileMap where\n \n source : String\n \n positions : Array String.Pos\n deriving Inhabited",
"start": [
34,
1
],
"end": [
42,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadFileMap",
"code": "class MonadFileMap (m : Type → Type) where\n getFileMap : m FileMap",
"start": [
44,
1
],
"end": [
45,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.getLastLine",
"code": "def getLastLine (fmap : FileMap) : Nat :=\n fmap.positions.size - 1",
"start": [
51,
1
],
"end": [
53,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.getLine",
"code": "def getLine (fmap : FileMap) (x : Nat) : Nat :=\n min (x + 1) fmap.getLastLine",
"start": [
55,
1
],
"end": [
59,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.ofString",
"code": "partial def ofString (s : String) : FileMap :=\n let rec loop (i : String.Pos) (line : Nat) (ps : Array String.Pos) : FileMap :=\n if s.atEnd i then { source := s, positions := ps.push i }\n else\n let c := s.get i\n let i := s.next i\n if c == '\\n' then loop i (line+1) (ps.push i)\n else loop i line ps\n loop 0 1 (#[0])",
"start": [
61,
1
],
"end": [
69,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.toPosition",
"code": "partial def toPosition (fmap : FileMap) (pos : String.Pos) : Position :=\n match fmap with\n | { source := str, positions := ps } =>\n if ps.size >= 2 && pos <= ps.back then\n let rec toColumn (i : String.Pos) (c : Nat) : Nat :=\n if i == pos || str.atEnd i then c\n else toColumn (str.next i) (c+1)\n let rec loop (b e : Nat) :=\n let posB := ps[b]!\n if e == b + 1 then { line := fmap.getLine b, column := toColumn posB 0 }\n else\n let m := (b + e) / 2;\n let posM := ps.get! m;\n if pos == posM then { line := fmap.getLine m, column := 0 }\n else if pos > posM then loop m e\n else loop b m\n loop 0 (ps.size -1)\n else if ps.isEmpty then\n ⟨0, 0⟩\n else\n ⟨fmap.getLastLine, (pos - ps.back).byteIdx⟩",
"start": [
71,
1
],
"end": [
94,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.ofPosition",
"code": "def ofPosition (text : FileMap) (pos : Position) : String.Pos :=\n let colPos :=\n if h : pos.line - 1 < text.positions.size then\n text.positions.get ⟨pos.line - 1, h⟩\n else if text.positions.isEmpty then\n 0\n else\n text.positions.back\n String.Iterator.nextn ⟨text.source, colPos⟩ pos.column |>.pos",
"start": [
96,
1
],
"end": [
105,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FileMap.lineStart",
"code": "def lineStart (map : FileMap) (line : Nat) : String.Pos :=\n if h : line - 1 < map.positions.size then\n map.positions.get ⟨line - 1, h⟩\n else map.positions.back?.getD 0",
"start": [
107,
1
],
"end": [
114,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "String.toFileMap",
"code": "def String.toFileMap (s : String) : Lean.FileMap :=\n Lean.FileMap.ofString s",
"start": [
119,
1
],
"end": [
120,
26
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/OpenDecl.lean | [
".lake/packages/lean4/src/lean/Init/Meta.lean"
] | [
{
"full_name": "Lean.OpenDecl",
"code": "inductive OpenDecl where\n | simple (ns : Name) (except : List Name)\n | explicit (id : Name) (declName : Name)\n deriving BEq",
"start": [
11,
1
],
"end": [
15,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.rootNamespace",
"code": "def rootNamespace := `_root_",
"start": [
27,
1
],
"end": [
27,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.removeRoot",
"code": "def removeRoot (n : Name) : Name :=\n n.replacePrefix rootNamespace Name.anonymous",
"start": [
29,
1
],
"end": [
30,
47
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/MetavarContext.lean | [
".lake/packages/lean4/src/lean/Lean/LocalContext.lean",
".lake/packages/lean4/src/lean/Lean/Util/MonadCache.lean"
] | [
{
"full_name": "Lean.LocalInstance",
"code": "structure LocalInstance where\n className : Name\n fvar : Expr\n deriving Inhabited",
"start": [
229,
1
],
"end": [
238,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalInstances",
"code": "abbrev LocalInstances := Array LocalInstance",
"start": [
240,
1
],
"end": [
240,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LocalInstances.erase",
"code": "def LocalInstances.erase (localInsts : LocalInstances) (fvarId : FVarId) : LocalInstances :=\n match localInsts.findIdx? (fun inst => inst.fvar.fvarId! == fvarId) with\n | some idx => localInsts.eraseIdx idx\n | _ => localInsts",
"start": [
248,
1
],
"end": [
252,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarKind",
"code": "inductive MetavarKind where\n \n | natural\n \n | synthetic\n \n | syntheticOpaque\n deriving Inhabited, Repr",
"start": [
254,
1
],
"end": [
263,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarKind.isSyntheticOpaque",
"code": "def MetavarKind.isSyntheticOpaque : MetavarKind → Bool\n | MetavarKind.syntheticOpaque => true\n | _ => false",
"start": [
265,
1
],
"end": [
267,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarKind.isNatural",
"code": "def MetavarKind.isNatural : MetavarKind → Bool\n | MetavarKind.natural => true\n | _ => false",
"start": [
269,
1
],
"end": [
271,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarDecl",
"code": "structure MetavarDecl where\n \n userName : Name := Name.anonymous\n \n lctx : LocalContext\n \n type : Expr\n \n depth : Nat\n localInstances : LocalInstances\n kind : MetavarKind\n \n numScopeArgs : Nat := 0\n \n index : Nat\n deriving Inhabited",
"start": [
273,
1
],
"end": [
295,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DelayedMetavarAssignment",
"code": "structure DelayedMetavarAssignment where\n fvars : Array Expr\n mvarIdPending : MVarId",
"start": [
297,
1
],
"end": [
313,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext",
"code": "structure MetavarContext where\n \n depth : Nat := 0\n \n levelAssignDepth : Nat := 0\n \n mvarCounter : Nat := 0\n lDepth : PersistentHashMap LMVarId Nat := {}\n \n decls : PersistentHashMap MVarId MetavarDecl := {}\n \n userNames : PersistentHashMap Name MVarId := {}\n \n lAssignment : PersistentHashMap LMVarId Level := {}\n \n eAssignment : PersistentHashMap MVarId Expr := {}\n \n dAssignment : PersistentHashMap MVarId DelayedMetavarAssignment := {}",
"start": [
315,
1
],
"end": [
337,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadMCtx",
"code": "class MonadMCtx (m : Type → Type) where\n getMCtx : m MetavarContext\n modifyMCtx : (MetavarContext → MetavarContext) → m Unit",
"start": [
339,
1
],
"end": [
342,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setMCtx",
"code": "abbrev setMCtx [MonadMCtx m] (mctx : MetavarContext) : m Unit :=\n modifyMCtx fun _ => mctx",
"start": [
355,
1
],
"end": [
356,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getLevelMVarAssignment?",
"code": "abbrev getLevelMVarAssignment? [Monad m] [MonadMCtx m] (mvarId : LMVarId) : m (Option Level) :=\n return (← getMCtx).lAssignment.find? mvarId",
"start": [
358,
1
],
"end": [
359,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.getExprAssignmentCore?",
"code": "def MetavarContext.getExprAssignmentCore? (m : MetavarContext) (mvarId : MVarId) : Option Expr :=\n m.eAssignment.find? mvarId",
"start": [
361,
1
],
"end": [
362,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExprMVarAssignment?",
"code": "def getExprMVarAssignment? [Monad m] [MonadMCtx m] (mvarId : MVarId) : m (Option Expr) :=\n return (← getMCtx).getExprAssignmentCore? mvarId",
"start": [
364,
1
],
"end": [
365,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.getDelayedMVarAssignmentCore?",
"code": "def MetavarContext.getDelayedMVarAssignmentCore? (mctx : MetavarContext) (mvarId : MVarId) : Option DelayedMetavarAssignment :=\n mctx.dAssignment.find? mvarId",
"start": [
367,
1
],
"end": [
368,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getDelayedMVarAssignment?",
"code": "def getDelayedMVarAssignment? [Monad m] [MonadMCtx m] (mvarId : MVarId) : m (Option DelayedMetavarAssignment) :=\n return (← getMCtx).getDelayedMVarAssignmentCore? mvarId",
"start": [
370,
1
],
"end": [
371,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getDelayedMVarRoot",
"code": "partial def getDelayedMVarRoot [Monad m] [MonadMCtx m] (mvarId : MVarId) : m MVarId := do\n match (← getDelayedMVarAssignment? mvarId) with\n | some d => getDelayedMVarRoot d.mvarIdPending\n | none => return mvarId",
"start": [
373,
1
],
"end": [
384,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isLevelMVarAssigned",
"code": "def isLevelMVarAssigned [Monad m] [MonadMCtx m] (mvarId : LMVarId) : m Bool :=\n return (← getMCtx).lAssignment.contains mvarId",
"start": [
386,
1
],
"end": [
387,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isAssigned",
"code": "def _root_.Lean.MVarId.isAssigned [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Bool :=\n return (← getMCtx).eAssignment.contains mvarId",
"start": [
389,
1
],
"end": [
391,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isExprMVarAssigned",
"code": "@[deprecated MVarId.isAssigned (since := \"2022-07-15\")]\ndef isExprMVarAssigned [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Bool := do\n mvarId.isAssigned",
"start": [
393,
1
],
"end": [
395,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isDelayedAssigned",
"code": "def _root_.Lean.MVarId.isDelayedAssigned [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Bool :=\n return (← getMCtx).dAssignment.contains mvarId",
"start": [
397,
1
],
"end": [
398,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isMVarDelayedAssigned",
"code": "@[deprecated MVarId.isDelayedAssigned (since := \"2022-07-15\")]\ndef isMVarDelayedAssigned [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Bool := do\n mvarId.isDelayedAssigned",
"start": [
400,
1
],
"end": [
402,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isAssignedOrDelayedAssigned",
"code": "def _root_.Lean.MVarId.isAssignedOrDelayedAssigned [Monad m] [MonadMCtx m] (mvarId : MVarId) :\n m Bool := do\n let mctx ← getMCtx\n return mctx.eAssignment.contains mvarId || mctx.dAssignment.contains mvarId",
"start": [
404,
1
],
"end": [
414,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isLevelMVarAssignable",
"code": "def isLevelMVarAssignable [Monad m] [MonadMCtx m] (mvarId : LMVarId) : m Bool := do\n let mctx ← getMCtx\n match mctx.lDepth.find? mvarId with\n | some d => return d >= mctx.levelAssignDepth\n | _ => panic! \"unknown universe metavariable\"",
"start": [
416,
1
],
"end": [
420,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.getDecl",
"code": "def MetavarContext.getDecl (mctx : MetavarContext) (mvarId : MVarId) : MetavarDecl :=\n match mctx.decls.find? mvarId with\n | some decl => decl\n | none => panic! \"unknown metavariable\"",
"start": [
422,
1
],
"end": [
425,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isAssignable",
"code": "def _root_.Lean.MVarId.isAssignable [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Bool := do\n let mctx ← getMCtx\n let decl := mctx.getDecl mvarId\n return decl.depth == mctx.depth",
"start": [
427,
1
],
"end": [
430,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isExprMVarAssignable",
"code": "@[deprecated MVarId.isAssignable (since := \"2022-07-15\")]\ndef isExprMVarAssignable [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Bool := do\n mvarId.isAssignable",
"start": [
432,
1
],
"end": [
434,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasAssignedLevelMVar",
"code": "def hasAssignedLevelMVar [Monad m] [MonadMCtx m] : Level → m Bool\n | .succ lvl => pure lvl.hasMVar <&&> hasAssignedLevelMVar lvl\n | .max lvl₁ lvl₂ => (pure lvl₁.hasMVar <&&> hasAssignedLevelMVar lvl₁) <||> (pure lvl₂.hasMVar <&&> hasAssignedLevelMVar lvl₂)\n | .imax lvl₁ lvl₂ => (pure lvl₁.hasMVar <&&> hasAssignedLevelMVar lvl₁) <||> (pure lvl₂.hasMVar <&&> hasAssignedLevelMVar lvl₂)\n | .mvar mvarId => isLevelMVarAssigned mvarId\n | .zero => pure false\n | .param _ => pure false",
"start": [
436,
1
],
"end": [
443,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasAssignedMVar",
"code": "def hasAssignedMVar [Monad m] [MonadMCtx m] : Expr → m Bool\n | .const _ lvls => lvls.anyM hasAssignedLevelMVar\n | .sort lvl => hasAssignedLevelMVar lvl\n | .app f a => (pure f.hasMVar <&&> hasAssignedMVar f) <||> (pure a.hasMVar <&&> hasAssignedMVar a)\n | .letE _ t v b _ => (pure t.hasMVar <&&> hasAssignedMVar t) <||> (pure v.hasMVar <&&> hasAssignedMVar v) <||> (pure b.hasMVar <&&> hasAssignedMVar b)\n | .forallE _ d b _ => (pure d.hasMVar <&&> hasAssignedMVar d) <||> (pure b.hasMVar <&&> hasAssignedMVar b)\n | .lam _ d b _ => (pure d.hasMVar <&&> hasAssignedMVar d) <||> (pure b.hasMVar <&&> hasAssignedMVar b)\n | .fvar _ => return false\n | .bvar _ => return false\n | .lit _ => return false\n | .mdata _ e => pure e.hasMVar <&&> hasAssignedMVar e\n | .proj _ _ e => pure e.hasMVar <&&> hasAssignedMVar e\n | .mvar mvarId => mvarId.isAssigned <||> mvarId.isDelayedAssigned",
"start": [
445,
1
],
"end": [
458,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasAssignableLevelMVar",
"code": "def hasAssignableLevelMVar [Monad m] [MonadMCtx m] : Level → m Bool\n | .succ lvl => pure lvl.hasMVar <&&> hasAssignableLevelMVar lvl\n | .max lvl₁ lvl₂ => (pure lvl₁.hasMVar <&&> hasAssignableLevelMVar lvl₁) <||> (pure lvl₂.hasMVar <&&> hasAssignableLevelMVar lvl₂)\n | .imax lvl₁ lvl₂ => (pure lvl₁.hasMVar <&&> hasAssignableLevelMVar lvl₁) <||> (pure lvl₂.hasMVar <&&> hasAssignableLevelMVar lvl₂)\n | .mvar mvarId => isLevelMVarAssignable mvarId\n | .zero => return false\n | .param _ => return false",
"start": [
460,
1
],
"end": [
467,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasAssignableMVar",
"code": "def hasAssignableMVar [Monad m] [MonadMCtx m] : Expr → m Bool\n | .const _ lvls => lvls.anyM hasAssignableLevelMVar\n | .sort lvl => hasAssignableLevelMVar lvl\n | .app f a => (pure f.hasMVar <&&> hasAssignableMVar f) <||> (pure a.hasMVar <&&> hasAssignableMVar a)\n | .letE _ t v b _ => (pure t.hasMVar <&&> hasAssignableMVar t) <||> (pure v.hasMVar <&&> hasAssignableMVar v) <||> (pure b.hasMVar <&&> hasAssignableMVar b)\n | .forallE _ d b _ => (pure d.hasMVar <&&> hasAssignableMVar d) <||> (pure b.hasMVar <&&> hasAssignableMVar b)\n | .lam _ d b _ => (pure d.hasMVar <&&> hasAssignableMVar d) <||> (pure b.hasMVar <&&> hasAssignableMVar b)\n | .fvar _ => return false\n | .bvar _ => return false\n | .lit _ => return false\n | .mdata _ e => pure e.hasMVar <&&> hasAssignableMVar e\n | .proj _ _ e => pure e.hasMVar <&&> hasAssignableMVar e\n | .mvar mvarId => mvarId.isAssignable",
"start": [
469,
1
],
"end": [
482,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.assignLevelMVar",
"code": "def assignLevelMVar [MonadMCtx m] (mvarId : LMVarId) (val : Level) : m Unit :=\n modifyMCtx fun m => { m with lAssignment := m.lAssignment.insert mvarId val }",
"start": [
484,
1
],
"end": [
491,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.assign",
"code": "def _root_.Lean.MVarId.assign [MonadMCtx m] (mvarId : MVarId) (val : Expr) : m Unit :=\n modifyMCtx fun m => { m with eAssignment := m.eAssignment.insert mvarId val }",
"start": [
493,
1
],
"end": [
500,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.assignExprMVar",
"code": "@[deprecated MVarId.assign (since := \"2022-07-15\")]\ndef assignExprMVar [MonadMCtx m] (mvarId : MVarId) (val : Expr) : m Unit :=\n mvarId.assign val",
"start": [
502,
1
],
"end": [
504,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.assignDelayedMVar",
"code": "def assignDelayedMVar [MonadMCtx m] (mvarId : MVarId) (fvars : Array Expr) (mvarIdPending : MVarId) : m Unit :=\n modifyMCtx fun m => { m with dAssignment := m.dAssignment.insert mvarId { fvars, mvarIdPending } }",
"start": [
506,
1
],
"end": [
511,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateLevelMVars",
"code": "partial def instantiateLevelMVars [Monad m] [MonadMCtx m] : Level → m Level\n | lvl@(Level.succ lvl₁) => return Level.updateSucc! lvl (← instantiateLevelMVars lvl₁)\n | lvl@(Level.max lvl₁ lvl₂) => return Level.updateMax! lvl (← instantiateLevelMVars lvl₁) (← instantiateLevelMVars lvl₂)\n | lvl@(Level.imax lvl₁ lvl₂) => return Level.updateIMax! lvl (← instantiateLevelMVars lvl₁) (← instantiateLevelMVars lvl₂)\n | lvl@(Level.mvar mvarId) => do\n match (← getLevelMVarAssignment? mvarId) with\n | some newLvl =>\n if !newLvl.hasMVar then pure newLvl\n else do\n let newLvl' ← instantiateLevelMVars newLvl\n assignLevelMVar mvarId newLvl'\n pure newLvl'\n | none => pure lvl\n | lvl => pure lvl",
"start": [
535,
1
],
"end": [
548,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateExprMVars",
"code": "partial def instantiateExprMVars [Monad m] [MonadMCtx m] [STWorld ω m] [MonadLiftT (ST ω) m] (e : Expr) : MonadCacheT ExprStructEq Expr m Expr :=\n if !e.hasMVar then\n pure e\n else checkCache { val := e : ExprStructEq } fun _ => do match e with\n | .proj _ _ s => return e.updateProj! (← instantiateExprMVars s)\n | .forallE _ d b _ => return e.updateForallE! (← instantiateExprMVars d) (← instantiateExprMVars b)\n | .lam _ d b _ => return e.updateLambdaE! (← instantiateExprMVars d) (← instantiateExprMVars b)\n | .letE _ t v b _ => return e.updateLet! (← instantiateExprMVars t) (← instantiateExprMVars v) (← instantiateExprMVars b)\n | .const _ lvls => return e.updateConst! (← lvls.mapM instantiateLevelMVars)\n | .sort lvl => return e.updateSort! (← instantiateLevelMVars lvl)\n | .mdata _ b => return e.updateMData! (← instantiateExprMVars b)\n | .app .. => e.withApp fun f args => do\n let instArgs (f : Expr) : MonadCacheT ExprStructEq Expr m Expr := do\n let args ← args.mapM instantiateExprMVars\n pure (mkAppN f args)\n let instApp : MonadCacheT ExprStructEq Expr m Expr := do\n let wasMVar := f.isMVar\n let f ← instantiateExprMVars f\n if wasMVar && f.isLambda then\n \n instantiateExprMVars (f.betaRev args.reverse (useZeta := true))\n else\n instArgs f\n match f with\n | .mvar mvarId =>\n match (← getDelayedMVarAssignment? mvarId) with\n | none => instApp\n | some { fvars, mvarIdPending } =>\n \n if fvars.size > args.size then\n \n instArgs f\n else\n let newVal ← instantiateExprMVars (mkMVar mvarIdPending)\n if newVal.hasExprMVar then\n instArgs f\n else do\n let args ← args.mapM instantiateExprMVars\n \n let newVal := newVal.abstract fvars\n let result := newVal.instantiateRevRange 0 fvars.size args\n let result := mkAppRange result fvars.size args.size args\n pure result\n | _ => instApp\n | e@(.mvar mvarId) => checkCache { val := e : ExprStructEq } fun _ => do\n match (← getExprMVarAssignment? mvarId) with\n | some newE => do\n let newE' ← instantiateExprMVars newE\n mvarId.assign newE'\n pure newE'\n | none => pure e\n | e => pure e",
"start": [
550,
1
],
"end": [
623,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateMVarsCore",
"code": "def instantiateMVarsCore (mctx : MetavarContext) (e : Expr) : Expr × MetavarContext :=\n let instantiate {ω} (e : Expr) : (MonadCacheT ExprStructEq Expr <| StateRefT MetavarContext (ST ω)) Expr :=\n instantiateExprMVars e\n runST fun _ => instantiate e |>.run |>.run mctx",
"start": [
629,
1
],
"end": [
632,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateMVars",
"code": "def instantiateMVars [Monad m] [MonadMCtx m] (e : Expr) : m Expr := do\n if !e.hasMVar then\n return e\n else\n let (r, mctx) := instantiateMVarsCore (← getMCtx) e\n modifyMCtx fun _ => mctx\n return r",
"start": [
650,
1
],
"end": [
656,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateLCtxMVars",
"code": "def instantiateLCtxMVars [Monad m] [MonadMCtx m] (lctx : LocalContext) : m LocalContext :=\n lctx.foldlM (init := {}) fun lctx ldecl => do\n match ldecl with\n | .cdecl _ fvarId userName type bi k =>\n let type ← instantiateMVars type\n return lctx.mkLocalDecl fvarId userName type bi k\n | .ldecl _ fvarId userName type value nonDep k =>\n let type ← instantiateMVars type\n let value ← instantiateMVars value\n return lctx.mkLetDecl fvarId userName type value nonDep k",
"start": [
658,
1
],
"end": [
667,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateMVarDeclMVars",
"code": "def instantiateMVarDeclMVars [Monad m] [MonadMCtx m] (mvarId : MVarId) : m Unit := do\n let mvarDecl := (← getMCtx).getDecl mvarId\n let lctx ← instantiateLCtxMVars mvarDecl.lctx\n let type ← instantiateMVars mvarDecl.type\n modifyMCtx fun mctx => { mctx with decls := mctx.decls.insert mvarId { mvarDecl with lctx, type } }",
"start": [
669,
1
],
"end": [
673,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.instantiateLocalDeclMVars",
"code": "def instantiateLocalDeclMVars [Monad m] [MonadMCtx m] (localDecl : LocalDecl) : m LocalDecl := do\n match localDecl with\n | .cdecl idx id n type bi k =>\n return .cdecl idx id n (← instantiateMVars type) bi k\n | .ldecl idx id n type val nonDep k =>\n return .ldecl idx id n (← instantiateMVars type) (← instantiateMVars val) nonDep k",
"start": [
675,
1
],
"end": [
680,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DependsOn.State",
"code": "structure State where\n visited : ExprSet := {}\n mctx : MetavarContext",
"start": [
684,
1
],
"end": [
686,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DependsOn.M",
"code": "private abbrev M := StateM State",
"start": [
688,
1
],
"end": [
688,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DependsOn.shouldVisit",
"code": "private def shouldVisit (e : Expr) : M Bool := do\n if !e.hasMVar && !e.hasFVar then\n return false\n else if (← get).visited.contains e then\n return false\n else\n modify fun s => { s with visited := s.visited.insert e }\n return true",
"start": [
694,
1
],
"end": [
701,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DependsOn.dep",
"code": "@[specialize] private partial def dep (pf : FVarId → Bool) (pm : MVarId → Bool) (e : Expr) : M Bool :=\n let rec\n visit (e : Expr) : M Bool := do\n if !(← shouldVisit e) then\n pure false\n else\n visitMain e,\n visitApp : Expr → M Bool\n | .app f a .. => visitApp f <||> visit a\n | e => visit e,\n visitMain : Expr → M Bool\n | .proj _ _ s => visit s\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 | .mdata _ b => visit b\n | e@(.app ..) => do\n let f := e.getAppFn\n if f.isMVar then\n let e' ← instantiateMVars e\n if e'.getAppFn != f then\n visitMain e'\n else if pm f.mvarId! then\n return true\n else\n visitApp e\n else\n visitApp e\n | .mvar mvarId => do\n match (← getExprMVarAssignment? mvarId) with\n | some a => visit a\n | none =>\n if pm mvarId then\n return true\n else\n let lctx := (← getMCtx).getDecl mvarId |>.lctx\n return lctx.any fun decl => pf decl.fvarId\n | .fvar fvarId => return pf fvarId\n | _ => pure false\n visit e",
"start": [
703,
1
],
"end": [
742,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DependsOn.main",
"code": "@[inline] partial def main (pf : FVarId → Bool) (pm : MVarId → Bool) (e : Expr) : M Bool :=\n if !e.hasFVar && !e.hasMVar then pure false else dep pf pm e",
"start": [
744,
1
],
"end": [
745,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findExprDependsOn",
"code": "@[inline] def findExprDependsOn [Monad m] [MonadMCtx m] (e : Expr) (pf : FVarId → Bool := fun _ => false) (pm : MVarId → Bool := fun _ => false) : m Bool := do\n let (result, { mctx, .. }) := DependsOn.main pf pm e |>.run { mctx := (← getMCtx) }\n setMCtx mctx\n return result",
"start": [
749,
1
],
"end": [
758,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findLocalDeclDependsOn",
"code": "@[inline] def findLocalDeclDependsOn [Monad m] [MonadMCtx m] (localDecl : LocalDecl) (pf : FVarId → Bool := fun _ => false) (pm : MVarId → Bool := fun _ => false) : m Bool := do\n match localDecl with\n | .cdecl (type := t) .. => findExprDependsOn t pf pm\n | .ldecl (type := t) (value := v) .. =>\n let (result, { mctx, .. }) := (DependsOn.main pf pm t <||> DependsOn.main pf pm v).run { mctx := (← getMCtx) }\n setMCtx mctx\n return result",
"start": [
760,
1
],
"end": [
769,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.exprDependsOn",
"code": "def exprDependsOn [Monad m] [MonadMCtx m] (e : Expr) (fvarId : FVarId) : m Bool :=\n findExprDependsOn e (fvarId == ·)",
"start": [
771,
1
],
"end": [
772,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.dependsOn",
"code": "def dependsOn [Monad m] [MonadMCtx m] (e : Expr) (fvarId : FVarId) : m Bool :=\n exprDependsOn e fvarId",
"start": [
774,
1
],
"end": [
776,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.localDeclDependsOn",
"code": "def localDeclDependsOn [Monad m] [MonadMCtx m] (localDecl : LocalDecl) (fvarId : FVarId) : m Bool :=\n findLocalDeclDependsOn localDecl (fvarId == ·)",
"start": [
778,
1
],
"end": [
780,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.exprDependsOn'",
"code": "def exprDependsOn' [Monad m] [MonadMCtx m] (e : Expr) (x : Expr) : m Bool :=\n if x.isFVar then\n findExprDependsOn e (x.fvarId! == ·)\n else if x.isMVar then\n findExprDependsOn e (pm := (x.mvarId! == ·))\n else\n return false",
"start": [
782,
1
],
"end": [
789,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.localDeclDependsOn'",
"code": "def localDeclDependsOn' [Monad m] [MonadMCtx m] (localDecl : LocalDecl) (x : Expr) : m Bool :=\n if x.isFVar then\n findLocalDeclDependsOn localDecl (x.fvarId! == ·)\n else if x.isMVar then\n findLocalDeclDependsOn localDecl (pm := (x.mvarId! == ·))\n else\n return false",
"start": [
791,
1
],
"end": [
798,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.dependsOnPred",
"code": "def dependsOnPred [Monad m] [MonadMCtx m] (e : Expr) (pf : FVarId → Bool := fun _ => false) (pm : MVarId → Bool := fun _ => false) : m Bool :=\n findExprDependsOn e pf pm",
"start": [
800,
1
],
"end": [
802,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.localDeclDependsOnPred",
"code": "def localDeclDependsOnPred [Monad m] [MonadMCtx m] (localDecl : LocalDecl) (pf : FVarId → Bool := fun _ => false) (pm : MVarId → Bool := fun _ => false) : m Bool := do\n findLocalDeclDependsOn localDecl pf pm",
"start": [
804,
1
],
"end": [
806,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.mkMetavarContext",
"code": "@[export lean_mk_metavar_ctx]\ndef mkMetavarContext : Unit → MetavarContext := fun _ => {}",
"start": [
813,
1
],
"end": [
814,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.addExprMVarDecl",
"code": "def addExprMVarDecl (mctx : MetavarContext)\n (mvarId : MVarId)\n (userName : Name)\n (lctx : LocalContext)\n (localInstances : LocalInstances)\n (type : Expr)\n (kind : MetavarKind := MetavarKind.natural)\n (numScopeArgs : Nat := 0) : MetavarContext :=\n { mctx with\n mvarCounter := mctx.mvarCounter + 1\n decls := mctx.decls.insert mvarId {\n depth := mctx.depth\n index := mctx.mvarCounter\n userName\n lctx\n localInstances\n type\n kind\n numScopeArgs }\n userNames := if userName.isAnonymous then mctx.userNames else mctx.userNames.insert userName mvarId }",
"start": [
816,
1
],
"end": [
838,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.addExprMVarDeclExp",
"code": "def addExprMVarDeclExp (mctx : MetavarContext) (mvarId : MVarId) (userName : Name) (lctx : LocalContext) (localInstances : LocalInstances)\n (type : Expr) (kind : MetavarKind) : MetavarContext :=\n addExprMVarDecl mctx mvarId userName lctx localInstances type kind",
"start": [
840,
1
],
"end": [
842,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.addLevelMVarDecl",
"code": "def addLevelMVarDecl (mctx : MetavarContext) (mvarId : LMVarId) : MetavarContext :=\n { mctx with lDepth := mctx.lDepth.insert mvarId mctx.depth }",
"start": [
844,
1
],
"end": [
848,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.findDecl?",
"code": "def findDecl? (mctx : MetavarContext) (mvarId : MVarId) : Option MetavarDecl :=\n mctx.decls.find? mvarId",
"start": [
850,
1
],
"end": [
851,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.findUserName?",
"code": "def findUserName? (mctx : MetavarContext) (userName : Name) : Option MVarId :=\n mctx.userNames.find? userName",
"start": [
853,
1
],
"end": [
854,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.modifyExprMVarDecl",
"code": "def modifyExprMVarDecl (mctx : MetavarContext) (mvarId : MVarId)\n (f : MetavarDecl → MetavarDecl) : MetavarContext :=\n if let some mdecl := mctx.decls.find? mvarId then\n { mctx with decls := mctx.decls.insert mvarId (f mdecl) }\n else\n mctx",
"start": [
856,
1
],
"end": [
868,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.setMVarKind",
"code": "def setMVarKind (mctx : MetavarContext) (mvarId : MVarId) (kind : MetavarKind) : MetavarContext :=\n let decl := mctx.getDecl mvarId\n { mctx with decls := mctx.decls.insert mvarId { decl with kind := kind } }",
"start": [
870,
1
],
"end": [
872,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.setMVarUserName",
"code": "def setMVarUserName (mctx : MetavarContext) (mvarId : MVarId) (userName : Name) : MetavarContext :=\n let decl := mctx.getDecl mvarId\n { mctx with\n decls := mctx.decls.insert mvarId { decl with userName := userName }\n userNames :=\n let userNames := mctx.userNames.erase decl.userName\n if userName.isAnonymous then userNames else userNames.insert userName mvarId }",
"start": [
874,
1
],
"end": [
883,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.setMVarUserNameTemporarily",
"code": "def setMVarUserNameTemporarily (mctx : MetavarContext) (mvarId : MVarId) (userName : Name) : MetavarContext :=\n let decl := mctx.getDecl mvarId\n { mctx with decls := mctx.decls.insert mvarId { decl with userName := userName } }",
"start": [
885,
1
],
"end": [
893,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.setMVarType",
"code": "def setMVarType (mctx : MetavarContext) (mvarId : MVarId) (type : Expr) : MetavarContext :=\n let decl := mctx.getDecl mvarId\n { mctx with decls := mctx.decls.insert mvarId { decl with type := type } }",
"start": [
895,
1
],
"end": [
899,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.modifyExprMVarLCtx",
"code": "def modifyExprMVarLCtx (mctx : MetavarContext) (mvarId : MVarId)\n (f : LocalContext → LocalContext) : MetavarContext :=\n mctx.modifyExprMVarDecl mvarId fun mdecl => { mdecl with lctx := f mdecl.lctx }",
"start": [
901,
1
],
"end": [
910,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.setFVarKind",
"code": "def setFVarKind (mctx : MetavarContext) (mvarId : MVarId) (fvarId : FVarId)\n (kind : LocalDeclKind) : MetavarContext :=\n mctx.modifyExprMVarLCtx mvarId (·.setKind fvarId kind)",
"start": [
912,
1
],
"end": [
919,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.setFVarBinderInfo",
"code": "def setFVarBinderInfo (mctx : MetavarContext) (mvarId : MVarId)\n (fvarId : FVarId) (bi : BinderInfo) : MetavarContext :=\n mctx.modifyExprMVarLCtx mvarId (·.setBinderInfo fvarId bi)",
"start": [
921,
1
],
"end": [
928,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.findLevelDepth?",
"code": "def findLevelDepth? (mctx : MetavarContext) (mvarId : LMVarId) : Option Nat :=\n mctx.lDepth.find? mvarId",
"start": [
930,
1
],
"end": [
931,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.getLevelDepth",
"code": "def getLevelDepth (mctx : MetavarContext) (mvarId : LMVarId) : Nat :=\n match mctx.findLevelDepth? mvarId with\n | some d => d\n | none => panic! \"unknown metavariable\"",
"start": [
933,
1
],
"end": [
936,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.isAnonymousMVar",
"code": "def isAnonymousMVar (mctx : MetavarContext) (mvarId : MVarId) : Bool :=\n match mctx.findDecl? mvarId with\n | none => false\n | some mvarDecl => mvarDecl.userName.isAnonymous",
"start": [
938,
1
],
"end": [
941,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.incDepth",
"code": "def incDepth (mctx : MetavarContext) (allowLevelAssignments := false) : MetavarContext :=\n let depth := mctx.depth + 1\n let levelAssignDepth :=\n if allowLevelAssignments then mctx.levelAssignDepth else depth\n { mctx with depth, levelAssignDepth }",
"start": [
943,
1
],
"end": [
947,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.Exception",
"code": "inductive Exception where\n | revertFailure (mctx : MetavarContext) (lctx : LocalContext) (toRevert : Array Expr) (varName : String)",
"start": [
955,
1
],
"end": [
956,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.State",
"code": "structure State where\n mctx : MetavarContext\n nextMacroScope : MacroScope\n ngen : NameGenerator\n cache : HashMap ExprStructEq Expr := {}",
"start": [
966,
1
],
"end": [
975,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.Context",
"code": "structure Context where\n mainModule : Name\n preserveOrder : Bool\n \n binderInfoForMVars : BinderInfo := BinderInfo.implicit\n \n mvarIdsToAbstract : MVarIdSet := {}",
"start": [
977,
1
],
"end": [
983,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.MCore",
"code": "abbrev MCore := EStateM Exception State",
"start": [
985,
1
],
"end": [
985,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.M",
"code": "abbrev M := ReaderT Context MCore",
"start": [
986,
1
],
"end": [
986,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.mkFreshBinderName",
"code": "private def mkFreshBinderName (n : Name := `x) : M Name := do\n let fresh ← modifyGet fun s => (s.nextMacroScope, { s with nextMacroScope := s.nextMacroScope + 1 })\n return addMacroScope (← read).mainModule n fresh",
"start": [
992,
1
],
"end": [
994,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.preserveOrder",
"code": "def preserveOrder : M Bool :=\n return (← read).preserveOrder",
"start": [
996,
1
],
"end": [
997,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.getLocalDeclWithSmallestIdx",
"code": "private def getLocalDeclWithSmallestIdx (lctx : LocalContext) (xs : Array Expr) : LocalDecl := Id.run do\n let mut d : LocalDecl := lctx.getFVar! xs[0]!\n for x in xs[1:] do\n if x.isFVar then\n let curr := lctx.getFVar! x\n if curr.index < d.index then\n d := curr\n return d",
"start": [
1003,
1
],
"end": [
1011,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.collectForwardDeps",
"code": "def collectForwardDeps (lctx : LocalContext) (toRevert : Array Expr) : M (Array Expr) := do\n if toRevert.size == 0 then\n pure toRevert\n else\n if (← preserveOrder) then\n toRevert.size.forM fun i => do\n let fvar := toRevert[i]!\n i.forM fun j => do\n let prevFVar := toRevert[j]!\n let prevDecl := lctx.getFVar! prevFVar\n if (← localDeclDependsOn prevDecl fvar.fvarId!) then\n throw (Exception.revertFailure (← getMCtx) lctx toRevert prevDecl.userName.toString)\n let newToRevert := if (← preserveOrder) then toRevert else Array.mkEmpty toRevert.size\n let firstDeclToVisit := getLocalDeclWithSmallestIdx lctx toRevert\n let initSize := newToRevert.size\n lctx.foldlM (init := newToRevert) (start := firstDeclToVisit.index) fun (newToRevert : Array Expr) decl => do\n if initSize.any fun i => decl.fvarId == newToRevert[i]!.fvarId! then\n return newToRevert\n else if toRevert.any fun x => decl.fvarId == x.fvarId! then\n return newToRevert.push decl.toExpr\n else if (← findLocalDeclDependsOn decl (newToRevert.any fun x => x.fvarId! == ·)) then\n return newToRevert.push decl.toExpr\n else\n return newToRevert",
"start": [
1013,
1
],
"end": [
1073,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.reduceLocalContext",
"code": "def reduceLocalContext (lctx : LocalContext) (toRevert : Array Expr) : LocalContext :=\n toRevert.foldr (init := lctx) fun x lctx =>\n if x.isFVar then lctx.erase x.fvarId! else lctx",
"start": [
1075,
1
],
"end": [
1079,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.getInScope",
"code": "private def getInScope (lctx : LocalContext) (xs : Array Expr) : Array Expr :=\n xs.foldl (init := #[]) fun scope x =>\n if !x.isFVar then\n scope\n else if lctx.contains x.fvarId! then\n scope.push x\n else\n scope",
"start": [
1081,
1
],
"end": [
1089,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.withFreshCache",
"code": "@[inline] private def withFreshCache (x : M α) : M α := do\n let cache ← modifyGet fun s => (s.cache, { s with cache := {} })\n let a ← x\n modify fun s => { s with cache := cache }\n pure a",
"start": [
1091,
1
],
"end": [
1096,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.mkMVarApp",
"code": "private def mkMVarApp (lctx : LocalContext) (mvar : Expr) (xs : Array Expr) (kind : MetavarKind) : Expr :=\n xs.foldl (init := mvar) fun e x =>\n if !x.isFVar then\n e\n else\n match kind with\n | MetavarKind.syntheticOpaque => mkApp e x\n | _ => if (lctx.getFVar! x).isLet then e else mkApp e x",
"start": [
1098,
1
],
"end": [
1109,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.visit",
"code": "private partial def visit (xs : Array Expr) (e : Expr) : M Expr :=\n if !e.hasMVar then pure e else checkCache { val := e : ExprStructEq } fun _ => elim xs e",
"start": [
1113,
3
],
"end": [
1114,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.elim",
"code": "private partial def elim (xs : Array Expr) (e : Expr) : M Expr :=\n match e with\n | .proj _ _ s => return e.updateProj! (← visit xs s)\n | .forallE _ d b _ => return e.updateForallE! (← visit xs d) (← visit xs b)\n | .lam _ d b _ => return e.updateLambdaE! (← visit xs d) (← visit xs b)\n | .letE _ t v b _ => return e.updateLet! (← visit xs t) (← visit xs v) (← visit xs b)\n | .mdata _ b => return e.updateMData! (← visit xs b)\n | .app .. => e.withApp fun f args => elimApp xs f args\n | .mvar _ => elimApp xs e #[]\n | e => return e",
"start": [
1116,
3
],
"end": [
1125,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.mkAuxMVarType",
"code": "private partial def mkAuxMVarType (lctx : LocalContext) (xs : Array Expr) (kind : MetavarKind) (e : Expr) : M Expr := do\n let e ← abstractRangeAux xs xs.size e\n xs.size.foldRevM (init := e) fun i e => do\n let x := xs[i]!\n if x.isFVar then\n match lctx.getFVar! x with\n | LocalDecl.cdecl _ _ n type bi _ =>\n let type := type.headBeta\n let type ← abstractRangeAux xs i type\n return Lean.mkForall n bi type e\n | LocalDecl.ldecl _ _ n type value nonDep _ =>\n let type := type.headBeta\n let type ← abstractRangeAux xs i type\n let value ← abstractRangeAux xs i value\n let e := mkLet n type value e nonDep\n match kind with\n | MetavarKind.syntheticOpaque =>\n let e := e.liftLooseBVars 0 1\n return mkForall n BinderInfo.default type e\n | _ => pure e\n else\n let mvarDecl := (← get).mctx.getDecl x.mvarId!\n let type := mvarDecl.type.headBeta\n let type ← abstractRangeAux xs i type\n let id ← if mvarDecl.userName.isAnonymous then mkFreshBinderName else pure mvarDecl.userName\n return Lean.mkForall id (← read).binderInfoForMVars type e\n where\n abstractRangeAux (xs : Array Expr) (i : Nat) (e : Expr) : M Expr := do\n let e ← elim xs e\n pure (e.abstractRange i xs)",
"start": [
1127,
3
],
"end": [
1166,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.elimMVar",
"code": "private partial def elimMVar (xs : Array Expr) (mvarId : MVarId) (args : Array Expr) : M (Expr × Array Expr) := do\n let mvarDecl := (← getMCtx).getDecl mvarId\n let mvarLCtx := mvarDecl.lctx\n let toRevert := getInScope mvarLCtx xs\n if toRevert.size == 0 then\n let args ← args.mapM (visit xs)\n return (mkAppN (mkMVar mvarId) args, #[])\n else\n \n let newMVarKind := if !(← mvarId.isAssignable) then MetavarKind.syntheticOpaque else mvarDecl.kind\n let args ← args.mapM (visit xs)\n let toRevert ← collectForwardDeps mvarLCtx toRevert\n let newMVarLCtx := reduceLocalContext mvarLCtx toRevert\n let newLocalInsts := mvarDecl.localInstances.filter fun inst => toRevert.all fun x => inst.fvar != x\n let newMVarType ← withFreshCache do mkAuxMVarType mvarLCtx toRevert newMVarKind mvarDecl.type\n let newMVarId := { name := (← get).ngen.curr }\n let newMVar := mkMVar newMVarId\n let result := mkMVarApp mvarLCtx newMVar toRevert newMVarKind\n let numScopeArgs := mvarDecl.numScopeArgs + result.getAppNumArgs\n modify fun s => { s with\n mctx := s.mctx.addExprMVarDecl newMVarId Name.anonymous newMVarLCtx newLocalInsts newMVarType newMVarKind numScopeArgs,\n ngen := s.ngen.next\n }\n if !mvarDecl.kind.isSyntheticOpaque then\n mvarId.assign result\n else\n \n let (mvarIdPending, nestedFVars) ← match (← getDelayedMVarAssignment? mvarId) with\n | none => pure (mvarId, #[])\n | some { fvars, mvarIdPending } => pure (mvarIdPending, fvars)\n assignDelayedMVar newMVarId (toRevert ++ nestedFVars) mvarIdPending\n return (mkAppN result args, toRevert)",
"start": [
1168,
3
],
"end": [
1227,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.elimApp",
"code": "private partial def elimApp (xs : Array Expr) (f : Expr) (args : Array Expr) : M Expr := do\n match f with\n | Expr.mvar mvarId =>\n match (← getExprMVarAssignment? mvarId) with\n | some newF =>\n if newF.isLambda then\n let args ← args.mapM (visit xs)\n \n elim xs <| newF.betaRev args.reverse\n else\n elimApp xs newF args\n | none =>\n if (← read).mvarIdsToAbstract.contains mvarId then\n return mkAppN f (← args.mapM (visit xs))\n else\n return (← elimMVar xs mvarId args).1\n | _ =>\n return mkAppN (← visit xs f) (← args.mapM (visit xs))",
"start": [
1229,
3
],
"end": [
1246,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.elimMVarDeps",
"code": "partial def elimMVarDeps (xs : Array Expr) (e : Expr) : M Expr :=\n if !e.hasMVar then\n return e\n else\n withFreshCache do\n elim xs e",
"start": [
1250,
1
],
"end": [
1255,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.revert",
"code": "partial def revert (xs : Array Expr) (mvarId : MVarId) : M (Expr × Array Expr) :=\n withFreshCache do\n elimMVar xs mvarId #[]",
"start": [
1257,
1
],
"end": [
1266,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.abstractRange",
"code": "@[inline] def abstractRange (xs : Array Expr) (i : Nat) (e : Expr) : M Expr := do\n let e ← elimMVarDeps xs e\n pure (e.abstractRange i xs)",
"start": [
1268,
1
],
"end": [
1275,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.mkLambda'",
"code": "private def mkLambda' (x : Name) (bi : BinderInfo) (t : Expr) (b : Expr) (etaReduce : Bool) : Expr :=\n if etaReduce then\n match b with\n | .app f (.bvar 0) =>\n if !f.hasLooseBVar 0 then\n f.lowerLooseBVars 1 1\n else\n mkLambda x bi t b\n | _ => mkLambda x bi t b\n else\n mkLambda x bi t b",
"start": [
1277,
1
],
"end": [
1287,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBinding.mkBinding",
"code": "@[specialize] def mkBinding (isLambda : Bool) (lctx : LocalContext) (xs : Array Expr) (e : Expr) (usedOnly : Bool) (usedLetOnly : Bool) (etaReduce : Bool) : M Expr := do\n let e ← abstractRange xs xs.size e\n xs.size.foldRevM (init := e) fun i e => do\n let x := xs[i]!\n if x.isFVar then\n match lctx.getFVar! x with\n | LocalDecl.cdecl _ _ n type bi _ =>\n if !usedOnly || e.hasLooseBVar 0 then\n let type := type.headBeta;\n let type ← abstractRange xs i type\n if isLambda then\n return mkLambda' n bi type e etaReduce\n else\n return Lean.mkForall n bi type e\n else\n return e.lowerLooseBVars 1 1\n | LocalDecl.ldecl _ _ n type value nonDep _ =>\n if !usedLetOnly || e.hasLooseBVar 0 then\n let type ← abstractRange xs i type\n let value ← abstractRange xs i value\n return mkLet n type value e nonDep\n else\n return e.lowerLooseBVars 1 1\n else\n let mvarDecl := (← get).mctx.getDecl x.mvarId!\n let type := mvarDecl.type.headBeta\n let type ← abstractRange xs i type\n let id ← if mvarDecl.userName.isAnonymous then mkFreshBinderName else pure mvarDecl.userName\n if isLambda then\n return mkLambda' id (← read).binderInfoForMVars type e etaReduce\n else\n return Lean.mkForall id (← read).binderInfoForMVars type e",
"start": [
1289,
1
],
"end": [
1324,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBindingM.Context",
"code": "structure MkBindingM.Context where\n mainModule : Name\n lctx : LocalContext",
"start": [
1328,
1
],
"end": [
1330,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.MkBindingM",
"code": "abbrev MkBindingM := ReaderT MkBindingM.Context MkBinding.MCore",
"start": [
1332,
1
],
"end": [
1332,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.elimMVarDeps",
"code": "def elimMVarDeps (xs : Array Expr) (e : Expr) (preserveOrder : Bool) : MkBindingM Expr := fun ctx =>\n MkBinding.elimMVarDeps xs e { preserveOrder, mainModule := ctx.mainModule }",
"start": [
1334,
1
],
"end": [
1335,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.revert",
"code": "def revert (xs : Array Expr) (mvarId : MVarId) (preserveOrder : Bool) : MkBindingM (Expr × Array Expr) := fun ctx =>\n MkBinding.revert xs mvarId { preserveOrder, mainModule := ctx.mainModule }",
"start": [
1337,
1
],
"end": [
1338,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.mkBinding",
"code": "def mkBinding (isLambda : Bool) (xs : Array Expr) (e : Expr) (usedOnly : Bool := false) (usedLetOnly : Bool := true) (etaReduce := false) (binderInfoForMVars := BinderInfo.implicit) : MkBindingM Expr := fun ctx =>\n let mvarIdsToAbstract := xs.foldl (init := {}) fun s x => if x.isMVar then s.insert x.mvarId! else s\n MkBinding.mkBinding isLambda ctx.lctx xs e usedOnly usedLetOnly etaReduce { preserveOrder := false, binderInfoForMVars, mvarIdsToAbstract, mainModule := ctx.mainModule }",
"start": [
1340,
1
],
"end": [
1342,
172
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.mkLambda",
"code": "@[inline] def mkLambda (xs : Array Expr) (e : Expr) (usedOnly : Bool := false) (usedLetOnly : Bool := true) (etaReduce := false) (binderInfoForMVars := BinderInfo.implicit) : MkBindingM Expr :=\n return ← mkBinding (isLambda := true) xs e usedOnly usedLetOnly etaReduce binderInfoForMVars",
"start": [
1344,
1
],
"end": [
1345,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.mkForall",
"code": "@[inline] def mkForall (xs : Array Expr) (e : Expr) (usedOnly : Bool := false) (usedLetOnly : Bool := true) (binderInfoForMVars := BinderInfo.implicit) : MkBindingM Expr :=\n return ← mkBinding (isLambda := false) xs e usedOnly usedLetOnly false binderInfoForMVars",
"start": [
1347,
1
],
"end": [
1348,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.abstractRange",
"code": "@[inline] def abstractRange (e : Expr) (n : Nat) (xs : Array Expr) : MkBindingM Expr := fun ctx =>\n MkBinding.abstractRange xs n e { preserveOrder := false, mainModule := ctx.mainModule }",
"start": [
1350,
1
],
"end": [
1351,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.collectForwardDeps",
"code": "@[inline] def collectForwardDeps (toRevert : Array Expr) (preserveOrder : Bool) : MkBindingM (Array Expr) := fun ctx =>\n MkBinding.collectForwardDeps ctx.lctx toRevert { preserveOrder, mainModule := ctx.mainModule }",
"start": [
1353,
1
],
"end": [
1354,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.isWellFormed",
"code": "partial def isWellFormed [Monad m] [MonadMCtx m] (lctx : LocalContext) : Expr → m Bool\n | .mdata _ e => isWellFormed lctx e\n | .proj _ _ e => isWellFormed lctx e\n | e@(.app f a) => pure (!e.hasExprMVar && !e.hasFVar) <||> (isWellFormed lctx f <&&> isWellFormed lctx a)\n | e@(.lam _ d b _) => pure (!e.hasExprMVar && !e.hasFVar) <||> (isWellFormed lctx d <&&> isWellFormed lctx b)\n | e@(.forallE _ d b _) => pure (!e.hasExprMVar && !e.hasFVar) <||> (isWellFormed lctx d <&&> isWellFormed lctx b)\n | e@(.letE _ t v b _) => pure (!e.hasExprMVar && !e.hasFVar) <||> (isWellFormed lctx t <&&> isWellFormed lctx v <&&> isWellFormed lctx b)\n | .const .. => return true\n | .bvar .. => return true\n | .sort .. => return true\n | .lit .. => return true\n | .mvar mvarId => do\n let mvarDecl := (← getMCtx).getDecl mvarId;\n if mvarDecl.lctx.isSubPrefixOf lctx then\n return true\n else match (← getExprMVarAssignment? mvarId) with\n | none => return false\n | some v => isWellFormed lctx v\n | .fvar fvarId => return lctx.contains fvarId",
"start": [
1356,
1
],
"end": [
1378,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.LevelMVarToParam.Context",
"code": "structure Context where\n paramNamePrefix : Name\n alreadyUsedPred : Name → Bool\n except : LMVarId → Bool",
"start": [
1382,
1
],
"end": [
1385,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.LevelMVarToParam.State",
"code": "structure State where\n mctx : MetavarContext\n paramNames : Array Name := #[]\n nextParamIdx : Nat\n cache : HashMap ExprStructEq Expr := {}",
"start": [
1387,
1
],
"end": [
1391,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.LevelMVarToParam.M",
"code": "abbrev M := ReaderT Context <| StateM State",
"start": [
1393,
1
],
"end": [
1393,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.LevelMVarToParam.mkParamName",
"code": "partial def mkParamName : M Name := do\n let ctx ← read\n let s ← get\n let newParamName := ctx.paramNamePrefix.appendIndexAfter s.nextParamIdx\n if ctx.alreadyUsedPred newParamName then\n modify fun s => { s with nextParamIdx := s.nextParamIdx + 1 }\n mkParamName\n else do\n modify fun s => { s with nextParamIdx := s.nextParamIdx + 1, paramNames := s.paramNames.push newParamName }\n pure newParamName",
"start": [
1403,
1
],
"end": [
1412,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.LevelMVarToParam.visitLevel",
"code": "partial def visitLevel (u : Level) : M Level := do\n match u with\n | .succ v => return u.updateSucc! (← visitLevel v)\n | .max v₁ v₂ => return u.updateMax! (← visitLevel v₁) (← visitLevel v₂)\n | .imax v₁ v₂ => return u.updateIMax! (← visitLevel v₁) (← visitLevel v₂)\n | .zero => return u\n | .param .. => return u\n | .mvar mvarId =>\n match (← getLevelMVarAssignment? mvarId) with\n | some v => visitLevel v\n | none =>\n if (← read).except mvarId then\n return u\n else\n let p ← mkParamName\n let p := mkLevelParam p\n assignLevelMVar mvarId p\n return p",
"start": [
1414,
1
],
"end": [
1431,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.LevelMVarToParam.main",
"code": "partial def main (e : Expr) : M Expr :=\n if !e.hasMVar then\n return e\n else\n checkCache { val := e : ExprStructEq } fun _ => do\n match e with\n | .proj _ _ s => return e.updateProj! (← main s)\n | .forallE _ d b _ => return e.updateForallE! (← main d) (← main b)\n | .lam _ d b _ => return e.updateLambdaE! (← main d) (← main b)\n | .letE _ t v b _ => return e.updateLet! (← main t) (← main v) (← main b)\n | .app .. => e.withApp fun f args => visitApp f args\n | .mdata _ b => return e.updateMData! (← main b)\n | .const _ us => return e.updateConst! (← us.mapM visitLevel)\n | .sort u => return e.updateSort! (← visitLevel u)\n | .mvar .. => visitApp e #[]\n | e => return e\nwhere\n visitApp (f : Expr) (args : Array Expr) : M Expr := do\n match f with\n | .mvar mvarId .. =>\n match (← getExprMVarAssignment? mvarId) with\n | some v => return (← visitApp v args).headBeta\n | none => return mkAppN f (← args.mapM main)\n | _ => return mkAppN (← main f) (← args.mapM main)",
"start": [
1433,
1
],
"end": [
1456,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.UnivMVarParamResult",
"code": "structure UnivMVarParamResult where\n mctx : MetavarContext\n newParamNames : Array Name\n nextParamIdx : Nat\n expr : Expr",
"start": [
1460,
1
],
"end": [
1464,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.levelMVarToParam",
"code": "def levelMVarToParam (mctx : MetavarContext) (alreadyUsedPred : Name → Bool) (except : LMVarId → Bool) (e : Expr) (paramNamePrefix : Name := `u) (nextParamIdx : Nat := 1)\n : UnivMVarParamResult :=\n let (e, s) := LevelMVarToParam.main e { except, paramNamePrefix, alreadyUsedPred } { mctx, nextParamIdx }\n { mctx := s.mctx\n newParamNames := s.paramNames\n nextParamIdx := s.nextParamIdx\n expr := e }",
"start": [
1466,
1
],
"end": [
1472,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MetavarContext.getExprAssignmentDomain",
"code": "def getExprAssignmentDomain (mctx : MetavarContext) : Array MVarId :=\n mctx.eAssignment.foldl (init := #[]) fun a mvarId _ => Array.push a mvarId",
"start": [
1474,
1
],
"end": [
1475,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.modifyDecl",
"code": "def modifyDecl [MonadMCtx m] (mvarId : MVarId)\n (f : MetavarDecl → MetavarDecl) : m Unit :=\n modifyMCtx (·.modifyExprMVarDecl mvarId f)",
"start": [
1481,
1
],
"end": [
1490,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.modifyLCtx",
"code": "def modifyLCtx [MonadMCtx m] (mvarId : MVarId)\n (f : LocalContext → LocalContext) : m Unit :=\n modifyMCtx (·.modifyExprMVarLCtx mvarId f)",
"start": [
1492,
1
],
"end": [
1501,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.setFVarKind",
"code": "def setFVarKind [MonadMCtx m] (mvarId : MVarId) (fvarId : FVarId)\n (kind : LocalDeclKind) : m Unit :=\n modifyMCtx (·.setFVarKind mvarId fvarId kind)",
"start": [
1503,
1
],
"end": [
1509,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.setFVarBinderInfo",
"code": "def setFVarBinderInfo [MonadMCtx m] (mvarId : MVarId) (fvarId : FVarId)\n (bi : BinderInfo) : m Unit :=\n modifyMCtx (·.setFVarBinderInfo mvarId fvarId bi)",
"start": [
1511,
1
],
"end": [
1517,
52
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Types.lean | [
".lake/packages/lean4/src/lean/Lean/MetavarContext.lean",
".lake/packages/lean4/src/lean/Lean/Data/OpenDecl.lean",
".lake/packages/lean4/src/lean/Lean/Data/Json.lean",
".lake/packages/lean4/src/lean/Lean/Data/Position.lean",
".lake/packages/lean4/src/lean/Lean/Server/Rpc/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Widget/Types.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.Elab.CommandContextInfo",
"code": "structure CommandContextInfo where\n env : Environment\n fileMap : FileMap\n mctx : MetavarContext := {}\n options : Options := {}\n currNamespace : Name := Name.anonymous\n openDecls : List OpenDecl := []\n ngen : NameGenerator",
"start": [
18,
1
],
"end": [
30,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.ContextInfo",
"code": "structure ContextInfo extends CommandContextInfo where\n parentDecl? : Option Name := none",
"start": [
32,
1
],
"end": [
38,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.PartialContextInfo",
"code": "inductive PartialContextInfo where\n | commandCtx (info : CommandContextInfo)\n \n | parentDeclCtx (parentDecl : Name)",
"start": [
40,
1
],
"end": [
53,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.ElabInfo",
"code": "structure ElabInfo where\n \n elaborator : Name\n \n stx : Syntax\n deriving Inhabited",
"start": [
57,
1
],
"end": [
64,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.TermInfo",
"code": "structure TermInfo extends ElabInfo where\n lctx : LocalContext expectedType? : Option Expr\n expr : Expr\n isBinder : Bool := false\n deriving Inhabited",
"start": [
66,
1
],
"end": [
71,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.CommandInfo",
"code": "structure CommandInfo extends ElabInfo where\n deriving Inhabited",
"start": [
73,
1
],
"end": [
74,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.CompletionInfo",
"code": "inductive CompletionInfo where\n | dot (termInfo : TermInfo) (expectedType? : Option Expr)\n | id (stx : Syntax) (id : Name) (danglingDot : Bool) (lctx : LocalContext) (expectedType? : Option Expr)\n | dotId (stx : Syntax) (id : Name) (lctx : LocalContext) (expectedType? : Option Expr)\n | fieldId (stx : Syntax) (id : Name) (lctx : LocalContext) (structName : Name)\n | namespaceId (stx : Syntax)\n | option (stx : Syntax)\n | endSection (stx : Syntax) (scopeNames : List String)\n | tactic (stx : Syntax) (goals : List MVarId)",
"start": [
76,
1
],
"end": [
86,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.OptionInfo",
"code": "structure OptionInfo where\n stx : Syntax\n optionName : Name\n declName : Name",
"start": [
89,
1
],
"end": [
93,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.FieldInfo",
"code": "structure FieldInfo where\n \n projName : Name\n \n fieldName : Name\n lctx : LocalContext\n val : Expr\n stx : Syntax\n deriving Inhabited",
"start": [
95,
1
],
"end": [
103,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.TacticInfo",
"code": "structure TacticInfo extends ElabInfo where\n mctxBefore : MetavarContext\n goalsBefore : List MVarId\n mctxAfter : MetavarContext\n goalsAfter : List MVarId\n deriving Inhabited",
"start": [
105,
1
],
"end": [
115,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.MacroExpansionInfo",
"code": "structure MacroExpansionInfo where\n lctx : LocalContext stx : Syntax\n output : Syntax\n deriving Inhabited",
"start": [
117,
1
],
"end": [
121,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.CustomInfo",
"code": "structure CustomInfo where\n stx : Syntax\n value : Dynamic",
"start": [
123,
1
],
"end": [
126,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.UserWidgetInfo",
"code": "structure UserWidgetInfo extends Widget.WidgetInstance where\n stx : Syntax",
"start": [
128,
1
],
"end": [
133,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.FVarAliasInfo",
"code": "structure FVarAliasInfo where\n userName : Name\n id : FVarId\n baseId : FVarId",
"start": [
135,
1
],
"end": [
144,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.FieldRedeclInfo",
"code": "structure FieldRedeclInfo where\n stx : Syntax",
"start": [
146,
1
],
"end": [
156,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.OmissionInfo",
"code": "structure OmissionInfo extends TermInfo where\n reason : String",
"start": [
158,
1
],
"end": [
166,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.Info",
"code": "inductive Info where\n | ofTacticInfo (i : TacticInfo)\n | ofTermInfo (i : TermInfo)\n | ofCommandInfo (i : CommandInfo)\n | ofMacroExpansionInfo (i : MacroExpansionInfo)\n | ofOptionInfo (i : OptionInfo)\n | ofFieldInfo (i : FieldInfo)\n | ofCompletionInfo (i : CompletionInfo)\n | ofUserWidgetInfo (i : UserWidgetInfo)\n | ofCustomInfo (i : CustomInfo)\n | ofFVarAliasInfo (i : FVarAliasInfo)\n | ofFieldRedeclInfo (i : FieldRedeclInfo)\n | ofOmissionInfo (i : OmissionInfo)\n deriving Inhabited",
"start": [
168,
1
],
"end": [
182,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.InfoTree",
"code": "inductive InfoTree where\n \n | context (i : PartialContextInfo) (t : InfoTree)\n \n | node (i : Info) (children : PersistentArray InfoTree)\n \n | hole (mvarId : MVarId)\n deriving Inhabited",
"start": [
184,
1
],
"end": [
212,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.InfoState",
"code": "structure InfoState where\n \n enabled : Bool := true\n \n assignment : PersistentHashMap MVarId InfoTree := {}\n \n trees : PersistentArray InfoTree := {}\n deriving Inhabited",
"start": [
214,
1
],
"end": [
231,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.MonadInfoTree",
"code": "class MonadInfoTree (m : Type → Type) where\n getInfoState : m InfoState\n modifyInfoState : (InfoState → InfoState) → m Unit",
"start": [
233,
1
],
"end": [
235,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.setInfoState",
"code": "def setInfoState [MonadInfoTree m] (s : InfoState) : m Unit :=\n modifyInfoState fun _ => s",
"start": [
243,
1
],
"end": [
244,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.MonadParentDecl",
"code": "class MonadParentDecl (m : Type → Type) where\n getParentDeclName? : m (Option Name)",
"start": [
246,
1
],
"end": [
247,
39
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/PPExt.lean | [
".lake/packages/lean4/src/lean/Lean/Data/OpenDecl.lean",
".lake/packages/lean4/src/lean/Lean/MetavarContext.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean",
".lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Types.lean"
] | [
{
"full_name": "Lean.PPContext",
"code": "structure PPContext where\n env : Environment\n mctx : MetavarContext := {}\n lctx : LocalContext := {}\n opts : Options := {}\n currNamespace : Name := Name.anonymous\n openDecls : List OpenDecl := []",
"start": [
34,
1
],
"end": [
40,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrettyPrinter.InfoPerPos",
"code": "abbrev PrettyPrinter.InfoPerPos := RBMap Nat Elab.Info compare",
"start": [
42,
1
],
"end": [
42,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FormatWithInfos",
"code": "structure FormatWithInfos where\n fmt : Format\n infos : PrettyPrinter.InfoPerPos",
"start": [
43,
1
],
"end": [
49,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PPFns",
"code": "structure PPFns where\n ppExprWithInfos : PPContext → Expr → IO FormatWithInfos\n ppTerm : PPContext → Term → IO Format\n ppLevel : PPContext → Level → IO Format\n ppGoal : PPContext → MVarId → IO Format\n deriving Inhabited",
"start": [
53,
1
],
"end": [
58,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppExprWithInfos",
"code": "def ppExprWithInfos (ctx : PPContext) (e : Expr) : IO FormatWithInfos := do\n let e := instantiateMVarsCore ctx.mctx e |>.1\n if pp.raw.get ctx.opts then\n return format (toString e)\n else\n try\n ppExt.getState ctx.env |>.ppExprWithInfos ctx e\n catch ex =>\n if pp.rawOnError.get ctx.opts then\n pure f!\"[Error pretty printing expression: {ex}. Falling back to raw printer.]{Format.line}{e}\"\n else\n pure f!\"failed to pretty print expression (use 'set_option pp.rawOnError true' for raw representation)\"",
"start": [
71,
1
],
"end": [
82,
112
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppTerm",
"code": "def ppTerm (ctx : PPContext) (stx : Term) : IO Format :=\n let fmtRaw := fun () => stx.raw.formatStx (some <| pp.raw.maxDepth.get ctx.opts) (pp.raw.showInfo.get ctx.opts)\n if pp.raw.get ctx.opts then\n return fmtRaw ()\n else\n try\n ppExt.getState ctx.env |>.ppTerm ctx stx\n catch ex =>\n if pp.rawOnError.get ctx.opts then\n pure f!\"[Error pretty printing syntax: {ex}. Falling back to raw printer.]{Format.line}{fmtRaw ()}\"\n else\n pure f!\"failed to pretty print term (use 'set_option pp.rawOnError true' for raw representation)\"",
"start": [
84,
1
],
"end": [
95,
106
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppLevel",
"code": "def ppLevel (ctx : PPContext) (l : Level) : IO Format :=\n ppExt.getState ctx.env |>.ppLevel ctx l",
"start": [
97,
1
],
"end": [
98,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ppGoal",
"code": "def ppGoal (ctx : PPContext) (mvarId : MVarId) : IO Format :=\n ppExt.getState ctx.env |>.ppGoal ctx mvarId",
"start": [
100,
1
],
"end": [
101,
46
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/Sorry.lean | [
".lake/packages/lean4/src/lean/Lean/Util/FindExpr.lean",
".lake/packages/lean4/src/lean/Lean/Declaration.lean"
] | [
{
"full_name": "Lean.Expr.isSorry",
"code": "def Expr.isSorry : Expr → Bool\n | app (app (.const ``sorryAx ..) ..) .. => true\n | _ => false",
"start": [
12,
1
],
"end": [
14,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isSyntheticSorry",
"code": "def Expr.isSyntheticSorry : Expr → Bool\n | app (app (const ``sorryAx ..) ..) (const ``Bool.true ..) => true\n | _ => false",
"start": [
16,
1
],
"end": [
18,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.isNonSyntheticSorry",
"code": "def Expr.isNonSyntheticSorry : Expr → Bool\n | app (app (const ``sorryAx ..) ..) (const ``Bool.false ..) => true\n | _ => false",
"start": [
20,
1
],
"end": [
22,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasSorry",
"code": "def Expr.hasSorry (e : Expr) : Bool :=\n Option.isSome <| e.find? (·.isConstOf ``sorryAx)",
"start": [
24,
1
],
"end": [
25,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasSyntheticSorry",
"code": "def Expr.hasSyntheticSorry (e : Expr) : Bool :=\n Option.isSome <| e.find? (·.isSyntheticSorry)",
"start": [
27,
1
],
"end": [
28,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.hasNonSyntheticSorry",
"code": "def Expr.hasNonSyntheticSorry (e : Expr) : Bool :=\n Option.isSome <| e.find? (·.isNonSyntheticSorry)",
"start": [
30,
1
],
"end": [
31,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration.hasSorry",
"code": "def Declaration.hasSorry (d : Declaration) : Bool := Id.run do\n d.foldExprM (fun r e => r || e.hasSorry) false",
"start": [
33,
1
],
"end": [
34,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Declaration.hasNonSyntheticSorry",
"code": "def Declaration.hasNonSyntheticSorry (d : Declaration) : Bool := Id.run do\n d.foldExprM (fun r e => r || e.hasNonSyntheticSorry) false",
"start": [
36,
1
],
"end": [
37,
61
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/InternalExceptionId.lean | [
".lake/packages/lean4/src/lean/Init/System/IO.lean"
] | [
{
"full_name": "Lean.InternalExceptionId",
"code": "structure InternalExceptionId where\n idx : Nat := 0\n deriving Inhabited, BEq",
"start": [
10,
1
],
"end": [
13,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerInternalExceptionId",
"code": "def registerInternalExceptionId (name : Name) : IO InternalExceptionId := do\n let exs ← internalExceptionsRef.get\n if exs.contains name then throw <| IO.userError s!\"invalid internal exception id, '{name}' has already been used\"\n let nextIdx := exs.size\n internalExceptionsRef.modify fun a => a.push name\n pure { idx := nextIdx }",
"start": [
18,
1
],
"end": [
29,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InternalExceptionId.toString",
"code": "def InternalExceptionId.toString (id : InternalExceptionId) : String :=\n s!\"internal exception #{id.idx}\"",
"start": [
31,
1
],
"end": [
33,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.InternalExceptionId.getName",
"code": "def InternalExceptionId.getName (id : InternalExceptionId) : IO Name := do\n let exs ← internalExceptionsRef.get\n let i := id.idx;\n if h : i < exs.size then\n return exs.get ⟨i, h⟩\n else\n throw <| IO.userError \"invalid internal exception id\"",
"start": [
35,
1
],
"end": [
42,
58
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Message.lean | [
".lake/packages/lean4/src/lean/Lean/MetavarContext.lean",
".lake/packages/lean4/src/lean/Lean/Util/Sorry.lean",
".lake/packages/lean4/src/lean/Lean/Data/OpenDecl.lean",
".lake/packages/lean4/src/lean/Lean/Data/Position.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean",
".lake/packages/lean4/src/lean/Lean/Util/PPExt.lean"
] | [
{
"full_name": "Lean.mkErrorStringWithPos",
"code": "def mkErrorStringWithPos (fileName : String) (pos : Position) (msg : String) (endPos : Option Position := none) : String :=\n let endPos := match endPos with\n | some endPos => s!\"-{endPos.line}:{endPos.column}\"\n | none => \"\"\n s!\"{fileName}:{pos.line}:{pos.column}{endPos}: {msg}\"",
"start": [
18,
1
],
"end": [
22,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageSeverity",
"code": "inductive MessageSeverity where\n | information | warning | error\n deriving Inhabited, BEq, ToJson, FromJson",
"start": [
24,
1
],
"end": [
26,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageDataContext",
"code": "structure MessageDataContext where\n env : Environment\n mctx : MetavarContext\n lctx : LocalContext\n opts : Options",
"start": [
28,
1
],
"end": [
32,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NamingContext",
"code": "structure NamingContext where\n currNamespace : Name\n openDecls : List OpenDecl",
"start": [
34,
1
],
"end": [
40,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TraceData",
"code": "structure TraceData where\n \n cls : Name\n \n startTime : Float := 0\n \n stopTime : Float := startTime\n \n collapsed : Bool := true\n \n tag : String := \"\"",
"start": [
42,
1
],
"end": [
52,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData",
"code": "inductive MessageData where\n \n | ofFormatWithInfos : FormatWithInfos → MessageData\n | ofGoal : MVarId → MessageData\n \n | ofWidget : Widget.WidgetInstance → MessageData → MessageData\n \n | withContext : MessageDataContext → MessageData → MessageData\n | withNamingContext : NamingContext → MessageData → MessageData\n \n | nest : Nat → MessageData → MessageData\n \n | group : MessageData → MessageData\n \n | compose : MessageData → MessageData → MessageData\n \n | tagged : Name → MessageData → MessageData\n | trace (data : TraceData) (msg : MessageData) (children : Array MessageData)\n \n | ofLazy (f : Option PPContext → IO Dynamic) (hasSyntheticSorry : MetavarContext → Bool)\n deriving Inhabited, TypeName",
"start": [
54,
1
],
"end": [
95,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofFormat",
"code": "def ofFormat (fmt : Format) : MessageData := .ofFormatWithInfos ⟨fmt, .empty⟩",
"start": [
99,
1
],
"end": [
100,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.lazy",
"code": "def lazy (f : PPContext → IO MessageData)\n (hasSyntheticSorry : MetavarContext → Bool := fun _ => false) : MessageData :=\n .ofLazy (hasSyntheticSorry := hasSyntheticSorry) fun ctx? => do\n let msg ← match ctx? with\n | .none =>\n pure (.ofFormat \"(invalid MessageData.lazy, missing context)\") | .some ctx => f ctx\n return Dynamic.mk msg",
"start": [
102,
1
],
"end": [
113,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.hasTag",
"code": "partial def hasTag : MessageData → Bool\n | withContext _ msg => hasTag msg\n | withNamingContext _ msg => hasTag msg\n | nest _ msg => hasTag msg\n | group msg => hasTag msg\n | compose msg₁ msg₂ => hasTag msg₁ || hasTag msg₂\n | tagged n msg => p n || hasTag msg\n | trace data msg msgs => p data.cls || hasTag msg || msgs.any hasTag\n | _ => false",
"start": [
116,
1
],
"end": [
131,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.nil",
"code": "def nil : MessageData :=\n ofFormat Format.nil",
"start": [
133,
1
],
"end": [
135,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.mkPPContext",
"code": "def mkPPContext (nCtx : NamingContext) (ctx : MessageDataContext) : PPContext := {\n env := ctx.env, mctx := ctx.mctx, lctx := ctx.lctx, opts := ctx.opts,\n currNamespace := nCtx.currNamespace, openDecls := nCtx.openDecls\n}",
"start": [
137,
1
],
"end": [
140,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofSyntax",
"code": "def ofSyntax (stx : Syntax) : MessageData :=\n let stx := stx.copyHeadTailInfoFrom .missing\n .ofLazy\n (fun ctx? => do\n let msg ← ofFormat <$> match ctx? with\n | .none => pure stx.formatStx\n | .some ctx => ppTerm ctx ⟨stx⟩ return Dynamic.mk msg)\n (fun _ => false)",
"start": [
142,
1
],
"end": [
151,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofExpr",
"code": "def ofExpr (e : Expr) : MessageData :=\n .ofLazy\n (fun ctx? => do\n let msg ← ofFormatWithInfos <$> match ctx? with\n | .none => pure (format (toString e))\n | .some ctx => ppExprWithInfos ctx e\n return Dynamic.mk msg)\n (fun mctx => instantiateMVarsCore mctx e |>.1.hasSyntheticSorry)",
"start": [
153,
1
],
"end": [
160,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofLevel",
"code": "def ofLevel (l : Level) : MessageData :=\n .ofLazy\n (fun ctx? => do\n let msg ← ofFormat <$> match ctx? with\n | .none => pure (format l)\n | .some ctx => ppLevel ctx l\n return Dynamic.mk msg)\n (fun _ => false)",
"start": [
162,
1
],
"end": [
169,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofName",
"code": "def ofName (n : Name) : MessageData := ofFormat (format n)",
"start": [
171,
1
],
"end": [
171,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.hasSyntheticSorry",
"code": "partial def hasSyntheticSorry (msg : MessageData) : Bool :=\n visit none msg\nwhere\n visit (mctx? : Option MetavarContext) : MessageData → Bool\n | ofLazy _ f => f (mctx?.getD {})\n | withContext ctx msg => visit ctx.mctx msg\n | withNamingContext _ msg => visit mctx? msg\n | nest _ msg => visit mctx? msg\n | group msg => visit mctx? msg\n | compose msg₁ msg₂ => visit mctx? msg₁ || visit mctx? msg₂\n | tagged _ msg => visit mctx? msg\n | trace _ msg msgs => visit mctx? msg || msgs.any (visit mctx?)\n | _ => false",
"start": [
173,
1
],
"end": [
185,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.formatAux",
"code": "partial def formatAux : NamingContext → Option MessageDataContext → MessageData → IO Format\n | _, _, ofFormatWithInfos fmt => return fmt.1\n | _, none, ofGoal mvarId => return \"goal \" ++ format (mkMVar mvarId)\n | nCtx, some ctx, ofGoal mvarId => ppGoal (mkPPContext nCtx ctx) mvarId\n | nCtx, ctx, ofWidget _ d => formatAux nCtx ctx d\n | nCtx, _, withContext ctx d => formatAux nCtx ctx d\n | _, ctx, withNamingContext nCtx d => formatAux nCtx ctx d\n | nCtx, ctx, tagged _ d => formatAux nCtx ctx d\n | nCtx, ctx, nest n d => Format.nest n <$> formatAux nCtx ctx d\n | nCtx, ctx, compose d₁ d₂ => return (← formatAux nCtx ctx d₁) ++ (← formatAux nCtx ctx d₂)\n | nCtx, ctx, group d => Format.group <$> formatAux nCtx ctx d\n | nCtx, ctx, trace data header children => do\n let mut msg := f!\"[{data.cls}]\"\n if data.startTime != 0 then\n msg := f!\"{msg} [{data.stopTime - data.startTime}]\"\n msg := f!\"{msg} {(← formatAux nCtx ctx header).nest 2}\"\n let children ← children.mapM (formatAux nCtx ctx)\n return .nest 2 (.joinSep (msg::children.toList) \"\\n\")\n | nCtx, ctx?, ofLazy pp _ => do\n let dyn ← pp (ctx?.map (mkPPContext nCtx))\n let some msg := dyn.get? MessageData\n | panic! s!\"MessageData.ofLazy: expected MessageData in Dynamic, got {dyn.typeName}\"\n formatAux nCtx ctx? msg",
"start": [
187,
1
],
"end": [
209,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.format",
"code": "protected def format (msgData : MessageData) : IO Format :=\n formatAux { currNamespace := Name.anonymous, openDecls := [] } none msgData",
"start": [
211,
1
],
"end": [
212,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.toString",
"code": "protected def toString (msgData : MessageData) : IO String := do\n return toString (← msgData.format)",
"start": [
214,
1
],
"end": [
215,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.arrayExpr.toMessageData",
"code": "partial def arrayExpr.toMessageData (es : Array Expr) (i : Nat) (acc : MessageData) : MessageData :=\n if h : i < es.size then\n let e := es.get ⟨i, h⟩;\n let acc := if i == 0 then acc ++ ofExpr e else acc ++ \", \" ++ ofExpr e;\n toMessageData es (i+1) acc\n else\n acc ++ \"]\"",
"start": [
228,
1
],
"end": [
234,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.bracket",
"code": "def bracket (l : String) (f : MessageData) (r : String) : MessageData := group (nest l.length <| l ++ f ++ r)",
"start": [
238,
1
],
"end": [
239,
110
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.paren",
"code": "def paren (f : MessageData) : MessageData := bracket \"(\" f \")\"",
"start": [
240,
1
],
"end": [
241,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.sbracket",
"code": "def sbracket (f : MessageData) : MessageData := bracket \"[\" f \"]\"",
"start": [
242,
1
],
"end": [
243,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.joinSep",
"code": "def joinSep : List MessageData → MessageData → MessageData\n | [], _ => Format.nil\n | [a], _ => a\n | a::as, sep => a ++ sep ++ joinSep as sep",
"start": [
244,
1
],
"end": [
248,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofList",
"code": "def ofList : List MessageData → MessageData\n | [] => \"[]\"\n | xs => sbracket <| joinSep xs (ofFormat \",\" ++ Format.line)",
"start": [
250,
1
],
"end": [
253,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.ofArray",
"code": "def ofArray (msgs : Array MessageData) : MessageData :=\n ofList msgs.toList",
"start": [
255,
1
],
"end": [
257,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.BaseMessage",
"code": "structure BaseMessage (α : Type u) where\n fileName : String\n pos : Position\n endPos : Option Position := none\n \n keepFullRange : Bool := false\n severity : MessageSeverity := MessageSeverity.error\n caption : String := \"\"\n \n data : α\n deriving Inhabited, ToJson, FromJson",
"start": [
264,
1
],
"end": [
282,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Message",
"code": "abbrev Message := BaseMessage MessageData",
"start": [
284,
1
],
"end": [
286,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SerialMessage",
"code": "abbrev SerialMessage := BaseMessage String",
"start": [
288,
1
],
"end": [
291,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SerialMessage.toMessage",
"code": "@[inline] def toMessage (msg : SerialMessage) : Message :=\n {msg with data := msg.data}",
"start": [
295,
1
],
"end": [
296,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SerialMessage.toString",
"code": "protected def toString (msg : SerialMessage) (includeEndPos := false) : String := Id.run do\n let mut str := msg.data\n let endPos := if includeEndPos then msg.endPos else none\n unless msg.caption == \"\" do\n str := msg.caption ++ \":\\n\" ++ str\n match msg.severity with\n | .information => pure ()\n | .warning => str := mkErrorStringWithPos msg.fileName msg.pos (endPos := endPos) \"warning: \" ++ str\n | .error => str := mkErrorStringWithPos msg.fileName msg.pos (endPos := endPos) \"error: \" ++ str\n if str.isEmpty || str.back != '\\n' then\n str := str ++ \"\\n\"\n return str",
"start": [
298,
1
],
"end": [
309,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Message.serialize",
"code": "@[inline] def serialize (msg : Message) : IO SerialMessage := do\n return {msg with data := ← msg.data.toString}",
"start": [
317,
1
],
"end": [
318,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Message.toString",
"code": "protected def toString (msg : Message) (includeEndPos := false) : IO String := do\n return inline <| (← msg.serialize).toString includeEndPos",
"start": [
320,
1
],
"end": [
322,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Message.toJson",
"code": "protected def toJson (msg : Message) : IO Json := do\n return inline <| toJson (← msg.serialize)",
"start": [
324,
1
],
"end": [
326,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog",
"code": "structure MessageLog where\n \n \n hadErrors : Bool := false\n \n unreported : PersistentArray Message := {}\n deriving Inhabited",
"start": [
330,
1
],
"end": [
353,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.empty",
"code": "def empty : MessageLog := {}",
"start": [
356,
1
],
"end": [
356,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.msgs",
"code": "@[deprecated \"renamed to `unreported`; direct access should in general be avoided in favor of \\\nusing `MessageLog.toList/toArray`\"]\ndef msgs : MessageLog → PersistentArray Message := unreported",
"start": [
358,
1
],
"end": [
360,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.hasUnreported",
"code": "def hasUnreported (log : MessageLog) : Bool :=\n !log.unreported.isEmpty",
"start": [
362,
1
],
"end": [
363,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.add",
"code": "def add (msg : Message) (log : MessageLog) : MessageLog :=\n { log with unreported := log.unreported.push msg }",
"start": [
365,
1
],
"end": [
366,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.append",
"code": "protected def append (l₁ l₂ : MessageLog) : MessageLog :=\n { hadErrors := l₁.hadErrors || l₂.hadErrors, unreported := l₁.unreported ++ l₂.unreported }",
"start": [
368,
1
],
"end": [
369,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.hasErrors",
"code": "def hasErrors (log : MessageLog) : Bool :=\n log.hadErrors || log.unreported.any (·.severity matches .error)",
"start": [
374,
1
],
"end": [
375,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.errorsToWarnings",
"code": "def errorsToWarnings (log : MessageLog) : MessageLog :=\n { unreported := log.unreported.map (fun m => match m.severity with | MessageSeverity.error => { m with severity := MessageSeverity.warning } | _ => m) }",
"start": [
377,
1
],
"end": [
378,
155
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.getInfoMessages",
"code": "def getInfoMessages (log : MessageLog) : MessageLog :=\n { unreported := log.unreported.filter fun m => match m.severity with | MessageSeverity.information => true | _ => false }",
"start": [
380,
1
],
"end": [
381,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.forM",
"code": "def forM {m : Type → Type} [Monad m] (log : MessageLog) (f : Message → m Unit) : m Unit :=\n log.unreported.forM f",
"start": [
383,
1
],
"end": [
384,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.toList",
"code": "def toList (log : MessageLog) : List Message :=\n log.unreported.toList",
"start": [
386,
1
],
"end": [
388,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageLog.toArray",
"code": "def toArray (log : MessageLog) : Array Message :=\n log.unreported.toArray",
"start": [
390,
1
],
"end": [
392,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MessageData.nestD",
"code": "def MessageData.nestD (msg : MessageData) : MessageData :=\n MessageData.nest 2 msg",
"start": [
396,
1
],
"end": [
397,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.indentD",
"code": "def indentD (msg : MessageData) : MessageData :=\n MessageData.nestD (Format.line ++ msg)",
"start": [
399,
1
],
"end": [
400,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.indentExpr",
"code": "def indentExpr (e : Expr) : MessageData :=\n indentD e",
"start": [
402,
1
],
"end": [
403,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AddMessageContext",
"code": "class AddMessageContext (m : Type → Type) where\n \n addMessageContext : MessageData → m MessageData",
"start": [
405,
1
],
"end": [
413,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addMessageContextPartial",
"code": "def addMessageContextPartial {m} [Monad m] [MonadEnv m] [MonadOptions m] (msgData : MessageData) : m MessageData := do\n let env ← getEnv\n let opts ← getOptions\n return MessageData.withContext { env := env, mctx := {}, lctx := {}, opts := opts } msgData",
"start": [
420,
1
],
"end": [
423,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addMessageContextFull",
"code": "def addMessageContextFull {m} [Monad m] [MonadEnv m] [MonadMCtx m] [MonadLCtx m] [MonadOptions m] (msgData : MessageData) : m MessageData := do\n let env ← getEnv\n let mctx ← getMCtx\n let lctx ← getLCtx\n let opts ← getOptions\n return MessageData.withContext { env := env, mctx := mctx, lctx := lctx, opts := opts } msgData",
"start": [
425,
1
],
"end": [
430,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ToMessageData",
"code": "class ToMessageData (α : Type) where\n toMessageData : α → MessageData",
"start": [
432,
1
],
"end": [
433,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.stringToMessageData",
"code": "def stringToMessageData (str : String) : MessageData :=\n let lines := str.split (· == '\\n')\n let lines := lines.map (MessageData.ofFormat ∘ format)\n MessageData.joinSep lines (MessageData.ofFormat Format.line)",
"start": [
437,
1
],
"end": [
440,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.toMessageList",
"code": "def toMessageList (msgs : Array MessageData) : MessageData :=\n indentD (MessageData.joinSep msgs.toList m!\"\\n\\n\")",
"start": [
465,
1
],
"end": [
466,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KernelException.mkCtx",
"code": "private def mkCtx (env : Environment) (lctx : LocalContext) (opts : Options) (msg : MessageData) : MessageData :=\n MessageData.withContext { env := env, mctx := {}, lctx := lctx, opts := opts } msg",
"start": [
470,
1
],
"end": [
471,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KernelException.toMessageData",
"code": "def toMessageData (e : KernelException) (opts : Options) : MessageData :=\n match e with\n | unknownConstant env constName => mkCtx env {} opts m!\"(kernel) unknown constant '{constName}'\"\n | alreadyDeclared env constName => mkCtx env {} opts m!\"(kernel) constant has already been declared '{constName}'\"\n | declTypeMismatch env decl givenType =>\n mkCtx env {} opts <|\n let process (n : Name) (expectedType : Expr) : MessageData :=\n m!\"(kernel) declaration type mismatch, '{n}' has type{indentExpr givenType}\\nbut it is expected to have type{indentExpr expectedType}\";\n match decl with\n | Declaration.defnDecl { name := n, type := type, .. } => process n type\n | Declaration.thmDecl { name := n, type := type, .. } => process n type\n | _ => \"(kernel) declaration type mismatch\" | declHasMVars env constName _ => mkCtx env {} opts m!\"(kernel) declaration has metavariables '{constName}'\"\n | declHasFVars env constName _ => mkCtx env {} opts m!\"(kernel) declaration has free variables '{constName}'\"\n | funExpected env lctx e => mkCtx env lctx opts m!\"(kernel) function expected{indentExpr e}\"\n | typeExpected env lctx e => mkCtx env lctx opts m!\"(kernel) type expected{indentExpr e}\"\n | letTypeMismatch env lctx n _ _ => mkCtx env lctx opts m!\"(kernel) let-declaration type mismatch '{n}'\"\n | exprTypeMismatch env lctx e _ => mkCtx env lctx opts m!\"(kernel) type mismatch at{indentExpr e}\"\n | appTypeMismatch env lctx e fnType argType =>\n mkCtx env lctx opts m!\"application type mismatch{indentExpr e}\\nargument has type{indentExpr argType}\\nbut function has type{indentExpr fnType}\"\n | invalidProj env lctx e => mkCtx env lctx opts m!\"(kernel) invalid projection{indentExpr e}\"\n | thmTypeIsNotProp env constName type => mkCtx env {} opts m!\"(kernel) type of theorem '{constName}' is not a proposition{indentExpr type}\"\n | other msg => m!\"(kernel) {msg}\"\n | deterministicTimeout => \"(kernel) deterministic timeout\"\n | excessiveMemory => \"(kernel) excessive memory consumption detected\"\n | deepRecursion => \"(kernel) deep recursion detected\"\n | interrupted => \"(kernel) interrupted\"",
"start": [
473,
1
],
"end": [
499,
66
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Exception.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Options.lean",
".lake/packages/lean4/src/lean/Lean/Message.lean",
".lake/packages/lean4/src/lean/Lean/Util/MonadCache.lean",
".lake/packages/lean4/src/lean/Lean/InternalExceptionId.lean"
] | [
{
"full_name": "Lean.Exception",
"code": "inductive Exception where\n \n | error (ref : Syntax) (msg : MessageData)\n \n | internal (id : InternalExceptionId) (extra : KVMap := {})",
"start": [
14,
1
],
"end": [
22,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.toMessageData",
"code": "def Exception.toMessageData : Exception → MessageData\n | .error _ msg => msg\n | .internal id _ => id.toString",
"start": [
24,
1
],
"end": [
27,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.hasSyntheticSorry",
"code": "def Exception.hasSyntheticSorry : Exception → Bool\n | Exception.error _ msg => msg.hasSyntheticSorry\n | _ => false",
"start": [
29,
1
],
"end": [
31,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.getRef",
"code": "def Exception.getRef : Exception → Syntax\n | .error ref _ => ref\n | .internal _ _ => Syntax.missing",
"start": [
33,
1
],
"end": [
39,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AddErrorMessageContext",
"code": "class AddErrorMessageContext (m : Type → Type) where\n add : Syntax → MessageData → m (Syntax × MessageData)",
"start": [
43,
1
],
"end": [
48,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.throwError",
"code": "protected def throwError [Monad m] [MonadError m] (msg : MessageData) : m α := do\n let ref ← getRef\n let (ref, msg) ← AddErrorMessageContext.add ref msg\n throw <| Exception.error ref msg",
"start": [
62,
1
],
"end": [
70,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.throwUnknownConstant",
"code": "def throwUnknownConstant [Monad m] [MonadError m] (constName : Name) : m α :=\n Lean.throwError m!\"unknown constant '{mkConst constName}'\"",
"start": [
72,
1
],
"end": [
74,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.throwErrorAt",
"code": "protected def throwErrorAt [Monad m] [MonadError m] (ref : Syntax) (msg : MessageData) : m α := do\n withRef ref <| Lean.throwError msg",
"start": [
76,
1
],
"end": [
78,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ofExcept",
"code": "def ofExcept [Monad m] [MonadError m] [ToString ε] (x : Except ε α) : m α :=\n match x with\n | .ok a => return a\n | .error e => Lean.throwError <| toString e",
"start": [
80,
1
],
"end": [
87,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.throwKernelException",
"code": "def throwKernelException [Monad m] [MonadError m] [MonadOptions m] (ex : KernelException) : m α := do\n Lean.throwError <| ex.toMessageData (← getOptions)",
"start": [
89,
1
],
"end": [
93,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ofExceptKernelException",
"code": "def ofExceptKernelException [Monad m] [MonadError m] [MonadOptions m] (x : Except KernelException α) : m α :=\n match x with\n | .ok a => return a\n | .error e => throwKernelException e",
"start": [
95,
1
],
"end": [
99,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadRecDepth",
"code": "class MonadRecDepth (m : Type → Type) where\n withRecDepth {α} : Nat → m α → m α\n getRecDepth : m Nat\n getMaxRecDepth : m Nat",
"start": [
103,
1
],
"end": [
106,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.throwMaxRecDepthAt",
"code": "def throwMaxRecDepthAt [MonadError m] (ref : Syntax) : m α :=\n throw <| .error ref (MessageData.ofFormat (Std.Format.text maxRecDepthErrorMessage))",
"start": [
119,
1
],
"end": [
123,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.isMaxRecDepth",
"code": "def Exception.isMaxRecDepth (ex : Exception) : Bool :=\n match ex with\n | error _ (MessageData.ofFormatWithInfos ⟨Std.Format.text msg, _⟩) => msg == maxRecDepthErrorMessage\n | _ => false",
"start": [
125,
1
],
"end": [
134,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withIncRecDepth",
"code": "@[inline] def withIncRecDepth [Monad m] [MonadError m] [MonadRecDepth m] (x : m α) : m α := do\n let curr ← MonadRecDepth.getRecDepth\n let max ← MonadRecDepth.getMaxRecDepth\n if curr == max then\n throwMaxRecDepthAt (← getRef)\n else\n MonadRecDepth.withRecDepth (curr+1) x",
"start": [
136,
1
],
"end": [
147,
42
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Modifiers.lean | [
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.addProtected",
"code": "def addProtected (env : Environment) (n : Name) : Environment :=\n protectedExt.tag env n",
"start": [
13,
1
],
"end": [
14,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isProtected",
"code": "def isProtected (env : Environment) (n : Name) : Bool :=\n protectedExt.isTagged env n",
"start": [
16,
1
],
"end": [
17,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.privateHeader",
"code": "def privateHeader : Name := `_private",
"start": [
30,
1
],
"end": [
30,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkPrivateName",
"code": "def mkPrivateName (env : Environment) (n : Name) : Name :=\n Name.mkNum (privateHeader ++ env.mainModule) 0 ++ n",
"start": [
32,
1
],
"end": [
33,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isPrivateName",
"code": "def isPrivateName : Name → Bool\n | n@(.str p _) => n == privateHeader || isPrivateName p\n | .num p _ => isPrivateName p\n | _ => false",
"start": [
35,
1
],
"end": [
38,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isPrivateNameExport",
"code": "@[export lean_is_private_name]\ndef isPrivateNameExport (n : Name) : Bool :=\n isPrivateName n",
"start": [
40,
1
],
"end": [
42,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isPrivatePrefix",
"code": "def isPrivatePrefix (n : Name) : Bool :=\n match n with\n | .num p 0 => go p\n | _ => false\nwhere\n go (n : Name) : Bool :=\n n == privateHeader ||\n match n with\n | .str p _ => go p\n | _ => false",
"start": [
44,
1
],
"end": [
57,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.privateToUserNameAux",
"code": "private def privateToUserNameAux (n : Name) : Name :=\n match n with\n | .str p s => .str (privateToUserNameAux p) s\n | .num p i => if isPrivatePrefix n then .anonymous else .num (privateToUserNameAux p) i\n | _ => .anonymous",
"start": [
59,
1
],
"end": [
63,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.privateToUserName?",
"code": "@[export lean_private_to_user_name]\ndef privateToUserName? (n : Name) : Option Name :=\n if isPrivateName n then privateToUserNameAux n\n else none",
"start": [
65,
1
],
"end": [
68,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isPrivateNameFromImportedModule",
"code": "def isPrivateNameFromImportedModule (env : Environment) (n : Name) : Bool :=\n match privateToUserName? n with\n | some userName => mkPrivateName env userName != n\n | _ => false",
"start": [
70,
1
],
"end": [
73,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.privatePrefixAux",
"code": "private def privatePrefixAux : Name → Name\n | .str p _ => privatePrefixAux p\n | n => n",
"start": [
75,
1
],
"end": [
77,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.privatePrefix?",
"code": "@[export lean_private_prefix]\ndef privatePrefix? (n : Name) : Option Name :=\n if isPrivateName n then privatePrefixAux n\n else none",
"start": [
79,
1
],
"end": [
82,
12
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Log.lean | [
".lake/packages/lean4/src/lean/Lean/Message.lean",
".lake/packages/lean4/src/lean/Lean/Util/Sorry.lean"
] | [
{
"full_name": "Lean.MonadLog",
"code": "class MonadLog (m : Type → Type) extends MonadFileMap m where\n \n getRef : m Syntax\n \n getFileName : m String\n \n hasErrors : m Bool\n \n logMessage : Message → m Unit",
"start": [
12,
1
],
"end": [
23,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getRefPos",
"code": "def getRefPos : m String.Pos := do\n let ref ← MonadLog.getRef\n return ref.getPos?.getD 0",
"start": [
36,
1
],
"end": [
41,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getRefPosition",
"code": "def getRefPosition : m Position := do\n let fileMap ← getFileMap\n return fileMap.toPosition (← getRefPos)",
"start": [
43,
1
],
"end": [
48,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logAt",
"code": "def logAt (ref : Syntax) (msgData : MessageData) (severity : MessageSeverity := MessageSeverity.error) : m Unit :=\n unless severity == .error && msgData.hasSyntheticSorry do\n let severity := if severity == .warning && warningAsError.get (← getOptions) then .error else severity\n let ref := replaceRef ref (← MonadLog.getRef)\n let pos := ref.getPos?.getD 0\n let endPos := ref.getTailPos?.getD pos\n let fileMap ← getFileMap\n let msgData ← addMessageContext msgData\n logMessage { fileName := (← getFileName), pos := fileMap.toPosition pos, endPos := fileMap.toPosition endPos, data := msgData, severity := severity }",
"start": [
56,
1
],
"end": [
69,
154
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logErrorAt",
"code": "def logErrorAt (ref : Syntax) (msgData : MessageData) : m Unit :=\n logAt ref msgData MessageSeverity.error",
"start": [
71,
1
],
"end": [
73,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logWarningAt",
"code": "def logWarningAt [MonadOptions m] (ref : Syntax) (msgData : MessageData) : m Unit := do\n logAt ref msgData .warning",
"start": [
75,
1
],
"end": [
77,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logInfoAt",
"code": "def logInfoAt (ref : Syntax) (msgData : MessageData) : m Unit :=\n logAt ref msgData MessageSeverity.information",
"start": [
79,
1
],
"end": [
81,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.log",
"code": "def log (msgData : MessageData) (severity : MessageSeverity := MessageSeverity.error): m Unit := do\n let ref ← MonadLog.getRef\n logAt ref msgData severity",
"start": [
83,
1
],
"end": [
86,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logError",
"code": "def logError (msgData : MessageData) : m Unit :=\n log msgData MessageSeverity.error",
"start": [
88,
1
],
"end": [
90,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logWarning",
"code": "def logWarning [MonadOptions m] (msgData : MessageData) : m Unit := do\n log msgData (if warningAsError.get (← getOptions) then .error else .warning)",
"start": [
92,
1
],
"end": [
94,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logInfo",
"code": "def logInfo (msgData : MessageData) : m Unit :=\n log msgData MessageSeverity.information",
"start": [
96,
1
],
"end": [
98,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.logUnknownDecl",
"code": "def logUnknownDecl (declName : Name) : m Unit :=\n logError m!\"unknown declaration '{declName}'\"",
"start": [
100,
1
],
"end": [
102,
48
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/AuxRecursor.lean | [
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.casesOnSuffix",
"code": "def casesOnSuffix := \"casesOn\"",
"start": [
11,
1
],
"end": [
11,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.recOnSuffix",
"code": "def recOnSuffix := \"recOn\"",
"start": [
12,
1
],
"end": [
12,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.brecOnSuffix",
"code": "def brecOnSuffix := \"brecOn\"",
"start": [
13,
1
],
"end": [
13,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.binductionOnSuffix",
"code": "def binductionOnSuffix := \"binductionOn\"",
"start": [
14,
1
],
"end": [
14,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.belowSuffix",
"code": "def belowSuffix := \"below\"",
"start": [
15,
1
],
"end": [
15,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ibelowSuffix",
"code": "def ibelowSuffix := \"ibelow\"",
"start": [
16,
1
],
"end": [
16,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkCasesOnName",
"code": "def mkCasesOnName (indDeclName : Name) : Name := Name.mkStr indDeclName casesOnSuffix",
"start": [
18,
1
],
"end": [
18,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkRecOnName",
"code": "def mkRecOnName (indDeclName : Name) : Name := Name.mkStr indDeclName recOnSuffix",
"start": [
19,
1
],
"end": [
19,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkBRecOnName",
"code": "def mkBRecOnName (indDeclName : Name) : Name := Name.mkStr indDeclName brecOnSuffix",
"start": [
20,
1
],
"end": [
20,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkBInductionOnName",
"code": "def mkBInductionOnName (indDeclName : Name) : Name := Name.mkStr indDeclName binductionOnSuffix",
"start": [
21,
1
],
"end": [
21,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkBelowName",
"code": "def mkBelowName (indDeclName : Name) : Name := Name.mkStr indDeclName belowSuffix",
"start": [
22,
1
],
"end": [
22,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkIBelowName",
"code": "def mkIBelowName (indDeclName : Name) : Name := Name.mkStr indDeclName ibelowSuffix",
"start": [
23,
1
],
"end": [
23,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.markAuxRecursor",
"code": "def markAuxRecursor (env : Environment) (declName : Name) : Environment :=\n auxRecExt.tag env declName",
"start": [
27,
1
],
"end": [
28,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isAuxRecursor",
"code": "@[export lean_is_aux_recursor]\ndef isAuxRecursor (env : Environment) (declName : Name) : Bool :=\n auxRecExt.isTagged env declName\n || declName == ``Eq.ndrec\n || declName == ``Eq.ndrecOn",
"start": [
30,
1
],
"end": [
36,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isAuxRecursorWithSuffix",
"code": "def isAuxRecursorWithSuffix (env : Environment) (declName : Name) (suffix : String) : Bool :=\n match declName with\n | .str _ s => s == suffix && isAuxRecursor env declName\n | _ => false",
"start": [
38,
1
],
"end": [
41,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isCasesOnRecursor",
"code": "def isCasesOnRecursor (env : Environment) (declName : Name) : Bool :=\n isAuxRecursorWithSuffix env declName casesOnSuffix",
"start": [
43,
1
],
"end": [
44,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isRecOnRecursor",
"code": "def isRecOnRecursor (env : Environment) (declName : Name) : Bool :=\n isAuxRecursorWithSuffix env declName recOnSuffix",
"start": [
46,
1
],
"end": [
47,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isBRecOnRecursor",
"code": "def isBRecOnRecursor (env : Environment) (declName : Name) : Bool :=\n isAuxRecursorWithSuffix env declName brecOnSuffix",
"start": [
49,
1
],
"end": [
50,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.markNoConfusion",
"code": "def markNoConfusion (env : Environment) (n : Name) : Environment :=\n noConfusionExt.tag env n",
"start": [
54,
1
],
"end": [
55,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isNoConfusion",
"code": "@[export lean_is_no_confusion]\ndef isNoConfusion (env : Environment) (n : Name) : Bool :=\n noConfusionExt.isTagged env n",
"start": [
57,
1
],
"end": [
59,
32
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/Old.lean | [
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.Compiler.mkEagerLambdaLiftingName",
"code": "@[export lean_mk_eager_lambda_lifting_name]\ndef mkEagerLambdaLiftingName (n : Name) (idx : Nat) : Name :=\n Name.mkStr n (\"_elambda_\" ++ toString idx)",
"start": [
14,
1
],
"end": [
16,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.isEagerLambdaLiftingName",
"code": "@[export lean_is_eager_lambda_lifting_name]\ndef isEagerLambdaLiftingName : Name → Bool\n | .str p s => \"_elambda\".isPrefixOf s || isEagerLambdaLiftingName p\n | .num p _ => isEagerLambdaLiftingName p\n | _ => false",
"start": [
18,
1
],
"end": [
22,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.getDeclNamesForCodeGen",
"code": "def getDeclNamesForCodeGen : Declaration → List Name\n | Declaration.defnDecl { name := n, .. } => [n]\n | Declaration.mutualDefnDecl defs => defs.map fun d => d.name\n | Declaration.opaqueDecl { name := n, .. } => [n]\n | Declaration.axiomDecl { name := n, .. } => [n] | _ => []",
"start": [
24,
1
],
"end": [
32,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.checkIsDefinition",
"code": "def checkIsDefinition (env : Environment) (n : Name) : Except String Unit :=\nmatch env.find? n with\n | (some (ConstantInfo.defnInfo _)) => Except.ok ()\n | (some (ConstantInfo.opaqueInfo _)) => Except.ok ()\n | none => Except.error s!\"unknow declaration '{n}'\"\n | _ => Except.error s!\"declaration is not a definition '{n}'\"",
"start": [
34,
1
],
"end": [
39,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.mkUnsafeRecName",
"code": "@[export lean_mk_unsafe_rec_name]\ndef mkUnsafeRecName (declName : Name) : Name :=\n Name.mkStr declName \"_unsafe_rec\"",
"start": [
41,
1
],
"end": [
47,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.isUnsafeRecName?",
"code": "@[export lean_is_unsafe_rec_name]\ndef isUnsafeRecName? : Name → Option Name\n | .str n \"_unsafe_rec\" => some n\n | _ => none",
"start": [
49,
1
],
"end": [
53,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.compileDecls",
"code": "@[extern \"lean_compile_decls\"]\nopaque compileDecls (env : Environment) (opt : @& Options) (decls : @& List Name) : Except KernelException Environment",
"start": [
59,
1
],
"end": [
64,
119
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.compileDecl",
"code": "def compileDecl (env : Environment) (opt : @& Options) (decl : @& Declaration) : Except KernelException Environment :=\n compileDecls env opt (Compiler.getDeclNamesForCodeGen decl)",
"start": [
66,
1
],
"end": [
68,
62
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/Trace.lean | [
".lake/packages/lean4/src/lean/Lean/Exception.lean"
] | [
{
"full_name": "Lean.TraceElem",
"code": "structure TraceElem where\n ref : Syntax\n msg : MessageData\n deriving Inhabited",
"start": [
61,
1
],
"end": [
64,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TraceState",
"code": "structure TraceState where\n traces : PersistentArray TraceElem := {}\n deriving Inhabited",
"start": [
66,
1
],
"end": [
68,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadTrace",
"code": "class MonadTrace (m : Type → Type) where\n modifyTraceState : (TraceState → TraceState) → m Unit\n getTraceState : m TraceState",
"start": [
72,
1
],
"end": [
74,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.printTraces",
"code": "def printTraces : m Unit := do\n for {msg, ..} in (← getTraceState).traces do\n IO.println (← msg.format)",
"start": [
84,
1
],
"end": [
86,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resetTraceState",
"code": "def resetTraceState : m Unit :=\n modifyTraceState (fun _ => {})",
"start": [
88,
1
],
"end": [
89,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.checkTraceOption",
"code": "private def checkTraceOption (inherited : HashSet Name) (opts : Options) (cls : Name) : Bool :=\n !opts.isEmpty && go (`trace ++ cls)\nwhere\n go (opt : Name) : Bool :=\n if let some enabled := opts.get? opt then\n enabled\n else if let .str parent _ := opt then\n inherited.contains opt && go parent\n else\n false",
"start": [
91,
1
],
"end": [
100,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isTracingEnabledFor",
"code": "def isTracingEnabledFor (cls : Name) : m Bool := do\n let inherited ← (inheritedTraceOptions.get : IO _)\n pure (checkTraceOption inherited (← getOptions) cls)",
"start": [
102,
1
],
"end": [
104,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getTraces",
"code": "@[inline] def getTraces : m (PersistentArray TraceElem) := do\n let s ← getTraceState\n pure s.traces",
"start": [
106,
1
],
"end": [
108,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.modifyTraces",
"code": "@[inline] def modifyTraces (f : PersistentArray TraceElem → PersistentArray TraceElem) : m Unit :=\n modifyTraceState fun s => { s with traces := f s.traces }",
"start": [
110,
1
],
"end": [
111,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setTraceState",
"code": "@[inline] def setTraceState (s : TraceState) : m Unit :=\n modifyTraceState fun _ => s",
"start": [
113,
1
],
"end": [
114,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getResetTraces",
"code": "private def getResetTraces : m (PersistentArray TraceElem) := do\n let oldTraces ← getTraces\n modifyTraces fun _ => {}\n pure oldTraces",
"start": [
116,
1
],
"end": [
119,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addRawTrace",
"code": "def addRawTrace (msg : MessageData) : m Unit := do\n let ref ← getRef\n let msg ← addMessageContext msg\n modifyTraces (·.push { ref, msg })",
"start": [
124,
1
],
"end": [
127,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addTrace",
"code": "def addTrace (cls : Name) (msg : MessageData) : m Unit := do\n let ref ← getRef\n let msg ← addMessageContext msg\n modifyTraces (·.push { ref, msg := .trace { collapsed := false, cls } msg #[] })",
"start": [
129,
1
],
"end": [
132,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.trace",
"code": "@[inline] def trace (cls : Name) (msg : Unit → MessageData) : m Unit := do\n if (← isTracingEnabledFor cls) then\n addTrace cls (msg ())",
"start": [
134,
1
],
"end": [
136,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.traceM",
"code": "@[inline] def traceM (cls : Name) (mkMsg : m MessageData) : m Unit := do\n if (← isTracingEnabledFor cls) then\n let msg ← mkMsg\n addTrace cls msg",
"start": [
138,
1
],
"end": [
141,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addTraceNode",
"code": "private def addTraceNode (oldTraces : PersistentArray TraceElem)\n (data : TraceData) (ref : Syntax) (msg : MessageData) : m Unit :=\n withRef ref do\n let msg := .trace data msg ((← getTraces).toArray.map (·.msg))\n let msg ← addMessageContext msg\n modifyTraces fun _ =>\n oldTraces.push { ref, msg }",
"start": [
143,
1
],
"end": [
149,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withStartStop",
"code": "@[inline] private def withStartStop [Monad m] [MonadLiftT BaseIO m] (opts : Options) (act : m α) :\n m (α × Float × Float) := do\n if trace.profiler.useHearbeats.get opts then\n let start ← IO.getNumHeartbeats\n let a ← act\n let stop ← IO.getNumHeartbeats\n return (a, start.toFloat, stop.toFloat)\n else\n let start ← IO.monoNanosNow\n let a ← act\n let stop ← IO.monoNanosNow\n return (a, start.toFloat / 1000000000, stop.toFloat / 1000000000)",
"start": [
191,
1
],
"end": [
202,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.trace.profiler.threshold.unitAdjusted",
"code": "@[inline] def trace.profiler.threshold.unitAdjusted (o : Options) : Float :=\n if trace.profiler.useHearbeats.get o then\n (trace.profiler.threshold.get o).toFloat\n else\n (trace.profiler.threshold.get o).toFloat / 1000",
"start": [
204,
1
],
"end": [
209,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadAlwaysExcept",
"code": "class MonadAlwaysExcept (ε : outParam (Type u)) (m : Type u → Type v) where\n except : MonadExceptOf ε m",
"start": [
211,
1
],
"end": [
220,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withTraceNode",
"code": "def withTraceNode [always : MonadAlwaysExcept ε m] [MonadLiftT BaseIO m] (cls : Name)\n (msg : Except ε α → m MessageData) (k : m α) (collapsed := true) (tag := \"\") : m α := do\n let _ := always.except\n let opts ← getOptions\n let clsEnabled ← isTracingEnabledFor cls\n unless clsEnabled || trace.profiler.get opts do\n return (← k)\n let oldTraces ← getResetTraces\n let (res, start, stop) ← withStartStop opts <| observing k\n let aboveThresh := trace.profiler.get opts &&\n stop - start > trace.profiler.threshold.unitAdjusted opts\n unless clsEnabled || aboveThresh do\n modifyTraces (oldTraces ++ ·)\n return (← MonadExcept.ofExcept res)\n let ref ← getRef\n let mut m ← try msg res catch _ => pure m!\"<exception thrown while producing trace node message>\"\n let mut data := { cls, collapsed, tag }\n if profiler.get opts || aboveThresh then\n data := { data with startTime := start, stopTime := stop }\n addTraceNode oldTraces data ref m\n MonadExcept.ofExcept res",
"start": [
240,
1
],
"end": [
260,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withTraceNode'",
"code": "def withTraceNode' [MonadAlwaysExcept Exception m] [MonadLiftT BaseIO m] (cls : Name)\n (k : m (α × MessageData)) (collapsed := true) (tag := \"\") : m α :=\n let msg := fun\n | .ok (_, msg) => return msg\n | .error err => return err.toMessageData\n Prod.fst <$> withTraceNode cls msg k collapsed tag",
"start": [
262,
1
],
"end": [
267,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerTraceClass",
"code": "def registerTraceClass (traceClassName : Name) (inherited := false) (ref : Name := by exact decl_name%) : IO Unit := do\n let optionName := `trace ++ traceClassName\n registerOption optionName {\n declName := ref\n group := \"trace\"\n defValue := false\n descr := \"enable/disable tracing for the given module and submodules\"\n }\n if inherited then\n inheritedTraceOptions.modify (·.insert optionName)",
"start": [
271,
1
],
"end": [
288,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.bombEmoji",
"code": "def bombEmoji := \"💥\"",
"start": [
297,
1
],
"end": [
297,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.checkEmoji",
"code": "def checkEmoji := \"✅\"",
"start": [
298,
1
],
"end": [
298,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.crossEmoji",
"code": "def crossEmoji := \"❌\"",
"start": [
299,
1
],
"end": [
299,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.exceptBoolEmoji",
"code": "def exceptBoolEmoji : Except ε Bool → String\n | .error _ => bombEmoji\n | .ok true => checkEmoji\n | .ok false => crossEmoji",
"start": [
301,
1
],
"end": [
304,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.exceptOptionEmoji",
"code": "def exceptOptionEmoji : Except ε (Option α) → String\n | .error _ => bombEmoji\n | .ok (some _) => checkEmoji\n | .ok none => crossEmoji",
"start": [
306,
1
],
"end": [
309,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.exceptEmoji",
"code": "def exceptEmoji : Except ε α → String\n | .error _ => crossEmoji\n | .ok _ => checkEmoji",
"start": [
311,
1
],
"end": [
314,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExceptToEmoji",
"code": "class ExceptToEmoji (ε α : Type) where\n toEmoji : Except ε α → String",
"start": [
316,
1
],
"end": [
317,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withTraceNodeBefore",
"code": "def withTraceNodeBefore [MonadRef m] [AddMessageContext m] [MonadOptions m]\n [always : MonadAlwaysExcept ε m] [MonadLiftT BaseIO m] [ExceptToEmoji ε α] (cls : Name)\n (msg : m MessageData) (k : m α) (collapsed := true) (tag := \"\") : m α := do\n let _ := always.except\n let opts ← getOptions\n let clsEnabled ← isTracingEnabledFor cls\n unless clsEnabled || trace.profiler.get opts do\n return (← k)\n let oldTraces ← getResetTraces\n let ref ← getRef\n let msg ← withRef ref do addMessageContext (← msg)\n let (res, start, stop) ← withStartStop opts <| observing k\n let aboveThresh := trace.profiler.get opts &&\n stop - start > trace.profiler.threshold.unitAdjusted opts\n unless clsEnabled || aboveThresh do\n modifyTraces (oldTraces ++ ·)\n return (← MonadExcept.ofExcept res)\n let mut msg := m!\"{ExceptToEmoji.toEmoji res} {msg}\"\n let mut data := { cls, collapsed, tag }\n if profiler.get opts || aboveThresh then\n data := { data with startTime := start, stopTime := stop }\n addTraceNode oldTraces data ref msg\n MonadExcept.ofExcept res",
"start": [
325,
1
],
"end": [
356,
27
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/RecDepth.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Options.lean"
] | [] |
.lake/packages/lean4/src/lean/Lean/Eval.lean | [
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.MetaEval",
"code": "class MetaEval (α : Type u) where\n eval : Environment → Options → α → (hideUnit : Bool) → IO Environment",
"start": [
13,
1
],
"end": [
19,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.runMetaEval",
"code": "def runMetaEval {α : Type u} [MetaEval α] (env : Environment) (opts : Options) (a : α) : IO (String × Except IO.Error Environment) :=\n IO.FS.withIsolatedStreams (MetaEval.eval env opts a false |>.toBaseIO)",
"start": [
24,
1
],
"end": [
25,
73
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ResolveName.lean | [
".lake/packages/lean4/src/lean/Lean/Hygiene.lean",
".lake/packages/lean4/src/lean/Lean/Data/OpenDecl.lean",
".lake/packages/lean4/src/lean/Lean/Modifiers.lean",
".lake/packages/lean4/src/lean/Lean/Exception.lean"
] | [
{
"full_name": "Lean.throwReservedNameNotAvailable",
"code": "def throwReservedNameNotAvailable [Monad m] [MonadError m] (declName : Name) (reservedName : Name) : m Unit := do\n throwError \"failed to declare `{declName}` because `{reservedName}` has already been declared\"",
"start": [
22,
1
],
"end": [
23,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ensureReservedNameAvailable",
"code": "def ensureReservedNameAvailable [Monad m] [MonadEnv m] [MonadError m] (declName : Name) (suffix : String) : m Unit := do\n let reservedName := .str declName suffix\n if (← getEnv).contains reservedName then\n throwReservedNameNotAvailable declName reservedName",
"start": [
25,
1
],
"end": [
28,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerReservedNamePredicate",
"code": "def registerReservedNamePredicate (p : Environment → Name → Bool) : IO Unit := do\n unless (← initializing) do\n throw (IO.userError \"failed to register reserved name suffix predicate, this operation can only be performed during initialization\")\n reservedNamePredicatesRef.modify fun ps => ps.push p",
"start": [
33,
1
],
"end": [
39,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isReservedName",
"code": "def isReservedName (env : Environment) (name : Name) : Bool :=\n reservedNamePredicatesExt.getState env |>.any (· env name)",
"start": [
44,
1
],
"end": [
48,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AliasState",
"code": "abbrev AliasState := SMap Name (List Name)",
"start": [
55,
1
],
"end": [
55,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AliasEntry",
"code": "abbrev AliasEntry := Name × Name",
"start": [
56,
1
],
"end": [
56,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addAliasEntry",
"code": "def addAliasEntry (s : AliasState) (e : AliasEntry) : AliasState :=\n match s.find? e.1 with\n | none => s.insert e.1 [e.2]\n | some es => if es.contains e.2 then s else s.insert e.1 (e.2 :: es)",
"start": [
58,
1
],
"end": [
61,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addAlias",
"code": "@[export lean_add_alias] def addAlias (env : Environment) (a : Name) (e : Name) : Environment :=\n aliasExtension.addEntry env (a, e)",
"start": [
69,
1
],
"end": [
71,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getAliasState",
"code": "def getAliasState (env : Environment) : AliasState :=\n aliasExtension.getState env",
"start": [
73,
1
],
"end": [
74,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getAliases",
"code": "def getAliases (env : Environment) (a : Name) (skipProtected : Bool) : List Name :=\n match aliasExtension.getState env |>.find? a with\n | none => []\n | some es =>\n if skipProtected then\n es.filter (!isProtected env ·)\n else\n es",
"start": [
76,
1
],
"end": [
87,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getRevAliases",
"code": "def getRevAliases (env : Environment) (e : Name) : List Name :=\n (aliasExtension.getState env).fold (fun as a es => if List.contains es e then a :: as else as) []",
"start": [
90,
1
],
"end": [
91,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.containsDeclOrReserved",
"code": "private def containsDeclOrReserved (env : Environment) (declName : Name) : Bool :=\n env.contains declName || isReservedName env declName",
"start": [
96,
1
],
"end": [
97,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveQualifiedName",
"code": "private def resolveQualifiedName (env : Environment) (ns : Name) (id : Name) : List Name :=\n let resolvedId := ns ++ id\n let resolvedIds := getAliases env resolvedId (skipProtected := id.isAtomic)\n if (containsDeclOrReserved env resolvedId && (!id.isAtomic || !isProtected env resolvedId)) then\n resolvedId :: resolvedIds\n else\n let resolvedIdPrv := mkPrivateName env resolvedId\n if containsDeclOrReserved env resolvedIdPrv then resolvedIdPrv :: resolvedIds\n else resolvedIds",
"start": [
99,
1
],
"end": [
110,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveUsingNamespace",
"code": "private def resolveUsingNamespace (env : Environment) (id : Name) : Name → List Name\n | ns@(.str p _) =>\n match resolveQualifiedName env ns id with\n | [] => resolveUsingNamespace env id p\n | resolvedIds => resolvedIds\n | _ => []",
"start": [
112,
1
],
"end": [
118,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveExact",
"code": "private def resolveExact (env : Environment) (id : Name) : Option Name :=\n if id.isAtomic then none\n else\n let resolvedId := id.replacePrefix rootNamespace Name.anonymous\n if containsDeclOrReserved env resolvedId then some resolvedId\n else\n let resolvedIdPrv := mkPrivateName env resolvedId\n if containsDeclOrReserved env resolvedIdPrv then some resolvedIdPrv\n else none",
"start": [
120,
1
],
"end": [
131,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveOpenDecls",
"code": "private def resolveOpenDecls (env : Environment) (id : Name) : List OpenDecl → List Name → List Name\n | [], resolvedIds => resolvedIds\n | OpenDecl.simple ns exs :: openDecls, resolvedIds =>\n if exs.contains id then\n resolveOpenDecls env id openDecls resolvedIds\n else\n let newResolvedIds := resolveQualifiedName env ns id\n resolveOpenDecls env id openDecls (newResolvedIds ++ resolvedIds)\n | OpenDecl.explicit openedId resolvedId :: openDecls, resolvedIds =>\n let resolvedIds :=\n if openedId == id then\n resolvedId :: resolvedIds\n else if openedId.isPrefixOf id then\n let candidate := id.replacePrefix openedId resolvedId\n if env.contains candidate then\n candidate :: resolvedIds\n else\n resolvedIds\n else\n resolvedIds\n resolveOpenDecls env id openDecls resolvedIds",
"start": [
133,
1
],
"end": [
154,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveGlobalName",
"code": "def resolveGlobalName (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : List (Name × List String) :=\n let extractionResult := extractMacroScopes id\n let rec loop (id : Name) (projs : List String) : List (Name × List String) :=\n match id with\n | .str p s =>\n let id := { extractionResult with name := id }.review\n match resolveUsingNamespace env id ns with\n | resolvedIds@(_ :: _) => resolvedIds.eraseDups.map fun id => (id, projs)\n | [] =>\n match resolveExact env id with\n | some newId => [(newId, projs)]\n | none =>\n let resolvedIds := if containsDeclOrReserved env id then [id] else []\n let idPrv := mkPrivateName env id\n let resolvedIds := if containsDeclOrReserved env idPrv then [idPrv] ++ resolvedIds else resolvedIds\n let resolvedIds := resolveOpenDecls env id openDecls resolvedIds\n let resolvedIds := getAliases env id (skipProtected := id.isAtomic) ++ resolvedIds\n match resolvedIds with\n | _ :: _ => resolvedIds.eraseDups.map fun id => (id, projs)\n | [] => loop p (s::projs)\n | _ => []\n loop extractionResult.name []",
"start": [
156,
1
],
"end": [
186,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveNamespaceUsingScope?",
"code": "def resolveNamespaceUsingScope? (env : Environment) (n : Name) (ns : Name) : Option Name :=\n match ns with\n | .str p _ =>\n if env.isNamespace (ns ++ n) then\n some (ns ++ n)\n else\n resolveNamespaceUsingScope? env n p\n | .anonymous =>\n let n := n.replacePrefix rootNamespace .anonymous\n if env.isNamespace n then some n else none\n | _ => unreachable!",
"start": [
190,
1
],
"end": [
200,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveNamespaceUsingOpenDecls",
"code": "def resolveNamespaceUsingOpenDecls (env : Environment) (n : Name) : List OpenDecl → List Name\n | [] => []\n | OpenDecl.simple ns exs :: ds =>\n if env.isNamespace (ns ++ n) && !exs.contains n then\n (ns ++ n) :: resolveNamespaceUsingOpenDecls env n ds\n else\n resolveNamespaceUsingOpenDecls env n ds\n | _ :: ds => resolveNamespaceUsingOpenDecls env n ds",
"start": [
202,
1
],
"end": [
209,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ResolveName.resolveNamespace",
"code": "def resolveNamespace (env : Environment) (ns : Name) (openDecls : List OpenDecl) (id : Name) : List Name :=\n match resolveNamespaceUsingScope? env id ns with\n | some ns => ns :: resolveNamespaceUsingOpenDecls env id openDecls\n | none => resolveNamespaceUsingOpenDecls env id openDecls",
"start": [
211,
1
],
"end": [
225,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadResolveName",
"code": "class MonadResolveName (m : Type → Type) where\n getCurrNamespace : m Name\n getOpenDecls : m (List OpenDecl)",
"start": [
229,
1
],
"end": [
231,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveGlobalName",
"code": "def resolveGlobalName [Monad m] [MonadResolveName m] [MonadEnv m] (id : Name) : m (List (Name × List String)) := do\n return ResolveName.resolveGlobalName (← getEnv) (← getCurrNamespace) (← getOpenDecls) id",
"start": [
239,
1
],
"end": [
263,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveNamespaceCore",
"code": "def resolveNamespaceCore [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (id : Name) (allowEmpty := false) : m (List Name) := do\n let nss := ResolveName.resolveNamespace (← getEnv) (← getCurrNamespace) (← getOpenDecls) id\n if !allowEmpty && nss.isEmpty then\n throwError s!\"unknown namespace '{id}'\"\n return nss",
"start": [
265,
1
],
"end": [
273,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveNamespace",
"code": "def resolveNamespace [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] : Ident → m (List Name)\n | stx@⟨Syntax.ident _ _ n pre⟩ => do\n let pre := pre.filterMap fun\n | .namespace ns => some ns\n | _ => none\n if pre.isEmpty then\n withRef stx <| resolveNamespaceCore n\n else\n return pre\n | stx => throwErrorAt stx s!\"expected identifier\"",
"start": [
275,
1
],
"end": [
285,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveUniqueNamespace",
"code": "def resolveUniqueNamespace [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (id : Ident) : m Name := do\n match (← resolveNamespace id) with\n | [ns] => return ns\n | nss => throwError s!\"ambiguous namespace '{id.getId}', possible interpretations: '{nss}'\"",
"start": [
287,
1
],
"end": [
291,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.filterFieldList",
"code": "def filterFieldList [Monad m] [MonadError m] (n : Name) (cs : List (Name × List String)) : m (List Name) := do\n let cs := cs.filter fun (_, fieldList) => fieldList.isEmpty\n if cs.isEmpty then throwUnknownConstant n\n return cs.map (·.1)",
"start": [
293,
1
],
"end": [
297,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveGlobalConstCore",
"code": "private def resolveGlobalConstCore [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (n : Name) : m (List Name) := do\n let cs ← resolveGlobalName n\n filterFieldList n cs",
"start": [
299,
1
],
"end": [
305,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ensureNoOverload",
"code": "def ensureNoOverload [Monad m] [MonadError m] (n : Name) (cs : List Name) : m Name := do\n match cs with\n | [c] => pure c\n | _ => throwError s!\"ambiguous identifier '{mkConst n}', possible interpretations: {cs.map mkConst}\"",
"start": [
307,
1
],
"end": [
311,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveGlobalConstNoOverloadCore",
"code": "def resolveGlobalConstNoOverloadCore [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (n : Name) : m Name := do\n ensureNoOverload n (← resolveGlobalConstCore n)",
"start": [
313,
1
],
"end": [
315,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.preprocessSyntaxAndResolve",
"code": "def preprocessSyntaxAndResolve [Monad m] [MonadEnv m] [MonadError m] (stx : Syntax) (k : Name → m (List Name)) : m (List Name) := do\n match stx with\n | .ident _ _ n pre => do\n let pre := pre.filterMap fun\n | .decl n [] => some n\n | _ => none\n if pre.isEmpty then\n withRef stx <| k n\n else\n return pre\n | _ => throwErrorAt stx s!\"expected identifier\"",
"start": [
317,
1
],
"end": [
327,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveGlobalConst",
"code": "def resolveGlobalConst [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (stx : Syntax) : m (List Name) :=\n preprocessSyntaxAndResolve stx resolveGlobalConstCore",
"start": [
329,
1
],
"end": [
355,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ensureNonAmbiguous",
"code": "def ensureNonAmbiguous [Monad m] [MonadError m] (id : Syntax) (cs : List Name) : m Name := do\n match cs with\n | [] => unreachable!\n | [c] => pure c\n | _ => throwErrorAt id s!\"ambiguous identifier '{id}', possible interpretations: {cs.map mkConst}\"",
"start": [
357,
1
],
"end": [
366,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.resolveGlobalConstNoOverload",
"code": "def resolveGlobalConstNoOverload [Monad m] [MonadResolveName m] [MonadEnv m] [MonadError m] (id : Syntax) : m Name := do\n ensureNonAmbiguous id (← resolveGlobalConst id)",
"start": [
368,
1
],
"end": [
392,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.unresolveNameGlobal",
"code": "def unresolveNameGlobal [Monad m] [MonadResolveName m] [MonadEnv m] (n₀ : Name) (fullNames := false) : m Name := do\n if n₀.hasMacroScopes then return n₀\n if fullNames then\n match (← resolveGlobalName n₀) with\n | [(potentialMatch, _)] => if (privateToUserName? potentialMatch).getD potentialMatch == n₀ then return n₀ else return rootNamespace ++ n₀\n | _ => return n₀ let mut initialNames := (getRevAliases (← getEnv) n₀).toArray\n initialNames := initialNames.push (rootNamespace ++ n₀)\n for initialName in initialNames do\n if let some n ← unresolveNameCore initialName then\n return n\n return n₀ where\n unresolveNameCore (n : Name) : m (Option Name) := do\n if n.hasMacroScopes then return none\n let mut revComponents := n.componentsRev\n let mut candidate := Name.anonymous\n for cmpt in revComponents do\n candidate := Name.appendCore cmpt candidate\n if let [(potentialMatch, _)] ← resolveGlobalName candidate then\n if potentialMatch == n₀ then\n return some candidate\n return none",
"start": [
394,
1
],
"end": [
426,
16
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/Exception.lean | [
".lake/packages/lean4/src/lean/Lean/InternalExceptionId.lean",
".lake/packages/lean4/src/lean/Lean/Exception.lean"
] | [
{
"full_name": "Lean.Elab.throwPostpone",
"code": "def throwPostpone [MonadExceptOf Exception m] : m α :=\n throw $ Exception.internal postponeExceptionId",
"start": [
19,
1
],
"end": [
20,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwUnsupportedSyntax",
"code": "def throwUnsupportedSyntax [MonadExceptOf Exception m] : m α :=\n throw $ Exception.internal unsupportedSyntaxExceptionId",
"start": [
22,
1
],
"end": [
23,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwIllFormedSyntax",
"code": "def throwIllFormedSyntax [Monad m] [MonadError m] : m α :=\n throwError \"ill-formed syntax\"",
"start": [
25,
1
],
"end": [
26,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwAutoBoundImplicitLocal",
"code": "def throwAutoBoundImplicitLocal [MonadExceptOf Exception m] (n : Name) : m α :=\n throw $ Exception.internal autoBoundImplicitExceptionId <| KVMap.empty.insert `localId n",
"start": [
28,
1
],
"end": [
29,
91
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.isAutoBoundImplicitLocalException?",
"code": "def isAutoBoundImplicitLocalException? (ex : Exception) : Option Name :=\n match ex with\n | Exception.internal id k =>\n if id == autoBoundImplicitExceptionId then\n some <| k.getName `localId `x\n else\n none\n | _ => none",
"start": [
31,
1
],
"end": [
38,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwAlreadyDeclaredUniverseLevel",
"code": "def throwAlreadyDeclaredUniverseLevel [Monad m] [MonadError m] (u : Name) : m α :=\n throwError \"a universe level named '{u}' has already been declared\"",
"start": [
40,
1
],
"end": [
41,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwAbortCommand",
"code": "def throwAbortCommand {α m} [MonadExcept Exception m] : m α :=\n throw <| Exception.internal abortCommandExceptionId",
"start": [
44,
1
],
"end": [
45,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwAbortTerm",
"code": "def throwAbortTerm {α m} [MonadExcept Exception m] : m α :=\n throw <| Exception.internal abortTermExceptionId",
"start": [
48,
1
],
"end": [
49,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.throwAbortTactic",
"code": "def throwAbortTactic {α m} [MonadExcept Exception m] : m α :=\n throw <| Exception.internal abortTacticExceptionId",
"start": [
52,
1
],
"end": [
53,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.isAbortTacticException",
"code": "def isAbortTacticException (ex : Exception) : Bool :=\n match ex with\n | Exception.internal id .. => id == abortTacticExceptionId\n | _ => false",
"start": [
55,
1
],
"end": [
58,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.isAbortExceptionId",
"code": "def isAbortExceptionId (id : InternalExceptionId) : Bool :=\n id == abortCommandExceptionId || id == abortTermExceptionId || id == abortTacticExceptionId",
"start": [
60,
1
],
"end": [
61,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.mkMessageCore",
"code": "def mkMessageCore (fileName : String) (fileMap : FileMap) (data : MessageData) (severity : MessageSeverity) (pos : String.Pos) (endPos : String.Pos) : Message :=\n let pos := fileMap.toPosition pos\n let endPos := fileMap.toPosition endPos\n { fileName, pos, endPos, data, severity }",
"start": [
63,
1
],
"end": [
66,
44
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/MonadEnv.lean | [
".lake/packages/lean4/src/lean/Lean/Exception.lean",
".lake/packages/lean4/src/lean/Lean/Declaration.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/Old.lean",
".lake/packages/lean4/src/lean/Lean/AuxRecursor.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean",
".lake/packages/lean4/src/lean/Lean/Log.lean"
] | [
{
"full_name": "Lean.setEnv",
"code": "def setEnv [MonadEnv m] (env : Environment) : m Unit :=\n modifyEnv fun _ => env",
"start": [
16,
1
],
"end": [
17,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withEnv",
"code": "def withEnv [Monad m] [MonadFinally m] [MonadEnv m] (env : Environment) (x : m α) : m α := do\n let saved ← getEnv\n try\n setEnv env\n x\n finally\n setEnv saved",
"start": [
19,
1
],
"end": [
25,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isInductive",
"code": "def isInductive [Monad m] [MonadEnv m] (declName : Name) : m Bool := do\n match (← getEnv).find? declName with\n | some (ConstantInfo.inductInfo ..) => return true\n | _ => return false",
"start": [
27,
1
],
"end": [
30,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isRecCore",
"code": "def isRecCore (env : Environment) (declName : Name) : Bool :=\n match env.find? declName with\n | some (ConstantInfo.recInfo ..) => true\n | _ => false",
"start": [
32,
1
],
"end": [
35,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isRec",
"code": "def isRec [Monad m] [MonadEnv m] (declName : Name) : m Bool :=\n return isRecCore (← getEnv) declName",
"start": [
37,
1
],
"end": [
38,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withoutModifyingEnv",
"code": "@[inline] def withoutModifyingEnv [Monad m] [MonadEnv m] [MonadFinally m] {α : Type} (x : m α) : m α := do\n let env ← getEnv\n try x finally setEnv env",
"start": [
40,
1
],
"end": [
42,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withoutModifyingEnv'",
"code": "@[inline] def withoutModifyingEnv' [Monad m] [MonadEnv m] [MonadFinally m] {α : Type} (x : m α) : m (α × Environment) := do\n let env ← getEnv\n try\n let a ← x\n return (a, ← getEnv)\n finally\n setEnv env",
"start": [
44,
1
],
"end": [
51,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.matchConst",
"code": "@[inline] def matchConst [Monad m] [MonadEnv m] (e : Expr) (failK : Unit → m α) (k : ConstantInfo → List Level → m α) : m α := do\n match e with\n | Expr.const constName us => do\n match (← getEnv).find? constName with\n | some cinfo => k cinfo us\n | none => failK ()\n | _ => failK ()",
"start": [
53,
1
],
"end": [
59,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.matchConstInduct",
"code": "@[inline] def matchConstInduct [Monad m] [MonadEnv m] (e : Expr) (failK : Unit → m α) (k : InductiveVal → List Level → m α) : m α :=\n matchConst e failK fun cinfo us =>\n match cinfo with\n | ConstantInfo.inductInfo val => k val us\n | _ => failK ()",
"start": [
61,
1
],
"end": [
65,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.matchConstCtor",
"code": "@[inline] def matchConstCtor [Monad m] [MonadEnv m] (e : Expr) (failK : Unit → m α) (k : ConstructorVal → List Level → m α) : m α :=\n matchConst e failK fun cinfo us =>\n match cinfo with\n | ConstantInfo.ctorInfo val => k val us\n | _ => failK ()",
"start": [
67,
1
],
"end": [
71,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.matchConstRec",
"code": "@[inline] def matchConstRec [Monad m] [MonadEnv m] (e : Expr) (failK : Unit → m α) (k : RecursorVal → List Level → m α) : m α :=\n matchConst e failK fun cinfo us =>\n match cinfo with\n | ConstantInfo.recInfo val => k val us\n | _ => failK ()",
"start": [
73,
1
],
"end": [
77,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasConst",
"code": "def hasConst [Monad m] [MonadEnv m] (constName : Name) : m Bool := do\n return (← getEnv).contains constName",
"start": [
79,
1
],
"end": [
80,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAuxNameAux",
"code": "private partial def mkAuxNameAux (env : Environment) (base : Name) (i : Nat) : Name :=\n let candidate := base.appendIndexAfter i\n if env.contains candidate then\n mkAuxNameAux env base (i+1)\n else\n candidate",
"start": [
82,
1
],
"end": [
87,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAuxName",
"code": "def mkAuxName [Monad m] [MonadEnv m] (baseName : Name) (idx : Nat) : m Name := do\n return mkAuxNameAux (← getEnv) baseName idx",
"start": [
89,
1
],
"end": [
90,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getConstInfo",
"code": "def getConstInfo [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m ConstantInfo := do\n match (← getEnv).find? constName with\n | some info => pure info\n | none => throwError \"unknown constant '{mkConst constName}'\"",
"start": [
92,
1
],
"end": [
95,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkConstWithLevelParams",
"code": "def mkConstWithLevelParams [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m Expr := do\n let info ← getConstInfo constName\n return mkConst constName (info.levelParams.map mkLevelParam)",
"start": [
97,
1
],
"end": [
99,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getConstInfoDefn",
"code": "def getConstInfoDefn [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m DefinitionVal := do\n match (← getConstInfo constName) with\n | ConstantInfo.defnInfo v => pure v\n | _ => throwError \"'{mkConst constName}' is not a definition\"",
"start": [
101,
1
],
"end": [
104,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getConstInfoInduct",
"code": "def getConstInfoInduct [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m InductiveVal := do\n match (← getConstInfo constName) with\n | ConstantInfo.inductInfo v => pure v\n | _ => throwError \"'{mkConst constName}' is not a inductive type\"",
"start": [
106,
1
],
"end": [
109,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getConstInfoCtor",
"code": "def getConstInfoCtor [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m ConstructorVal := do\n match (← getConstInfo constName) with\n | ConstantInfo.ctorInfo v => pure v\n | _ => throwError \"'{mkConst constName}' is not a constructor\"",
"start": [
111,
1
],
"end": [
114,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getConstInfoRec",
"code": "def getConstInfoRec [Monad m] [MonadEnv m] [MonadError m] (constName : Name) : m RecursorVal := do\n match (← getConstInfo constName) with\n | ConstantInfo.recInfo v => pure v\n | _ => throwError \"'{mkConst constName}' is not a recursor\"",
"start": [
116,
1
],
"end": [
119,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.matchConstStruct",
"code": "@[inline] def matchConstStruct [Monad m] [MonadEnv m] [MonadError m] (e : Expr) (failK : Unit → m α) (k : InductiveVal → List Level → ConstructorVal → m α) : m α :=\n matchConstInduct e failK fun ival us => do\n if ival.isRec || ival.numIndices != 0 then failK ()\n else match ival.ctors with\n | [ctor] =>\n match (← getConstInfo ctor) with\n | ConstantInfo.ctorInfo cval => k ival us cval\n | _ => failK ()\n | _ => failK ()",
"start": [
121,
1
],
"end": [
129,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.evalConst",
"code": "unsafe def evalConst [Monad m] [MonadEnv m] [MonadError m] [MonadOptions m] (α) (constName : Name) : m α := do\n ofExcept <| (← getEnv).evalConst α (← getOptions) constName",
"start": [
131,
1
],
"end": [
132,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.evalConstCheck",
"code": "unsafe def evalConstCheck [Monad m] [MonadEnv m] [MonadError m] [MonadOptions m] (α) (typeName : Name) (constName : Name) : m α := do\n ofExcept <| (← getEnv).evalConstCheck α (← getOptions) typeName constName",
"start": [
134,
1
],
"end": [
135,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findModuleOf?",
"code": "def findModuleOf? [Monad m] [MonadEnv m] [MonadError m] (declName : Name) : m (Option Name) := do\n discard <| getConstInfo declName match (← getEnv).getModuleIdxFor? declName with\n | none => return none\n | some modIdx => return some ((← getEnv).allImportedModuleNames[modIdx.toNat]!)",
"start": [
137,
1
],
"end": [
141,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isEnumType",
"code": "def isEnumType [Monad m] [MonadEnv m] [MonadError m] (declName : Name) : m Bool := do\n if let ConstantInfo.inductInfo info ← getConstInfo declName then\n if !info.type.isProp && info.all.length == 1 && info.numIndices == 0 && info.numParams == 0\n && !info.ctors.isEmpty && !info.isRec && !info.isNested && !info.isUnsafe then\n info.ctors.allM fun ctorName => do\n let ConstantInfo.ctorInfo info ← getConstInfo ctorName | return false\n return info.numFields == 0\n else\n return false\n else\n return false",
"start": [
143,
1
],
"end": [
153,
17
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/PrefixTree.lean | [
".lake/packages/lean4/src/lean/Lean/Data/RBMap.lean"
] | [
{
"full_name": "Lean.PrefixTreeNode",
"code": "inductive PrefixTreeNode (α : Type u) (β : Type v) where\n | Node : Option β → RBNode α (fun _ => PrefixTreeNode α β) → PrefixTreeNode α β",
"start": [
12,
1
],
"end": [
13,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTreeNode.empty",
"code": "def empty : PrefixTreeNode α β :=\n PrefixTreeNode.Node none RBNode.leaf",
"start": [
20,
1
],
"end": [
21,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTreeNode.insert",
"code": "@[specialize]\npartial def insert (t : PrefixTreeNode α β) (cmp : α → α → Ordering) (k : List α) (val : β) : PrefixTreeNode α β :=\n let rec insertEmpty (k : List α) : PrefixTreeNode α β :=\n match k with\n | [] => PrefixTreeNode.Node (some val) RBNode.leaf\n | k :: ks =>\n let t := insertEmpty ks\n PrefixTreeNode.Node none (RBNode.singleton k t)\n let rec loop\n | PrefixTreeNode.Node _ m, [] =>\n PrefixTreeNode.Node (some val) m | PrefixTreeNode.Node v m, k :: ks =>\n let t := match RBNode.find cmp m k with\n | none => insertEmpty ks\n | some t => loop t ks\n PrefixTreeNode.Node v (RBNode.insert cmp m k t)\n loop t k",
"start": [
23,
1
],
"end": [
39,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTreeNode.find?",
"code": "@[specialize]\npartial def find? (t : PrefixTreeNode α β) (cmp : α → α → Ordering) (k : List α) : Option β :=\n let rec loop\n | PrefixTreeNode.Node val _, [] => val\n | PrefixTreeNode.Node _ m, k :: ks =>\n match RBNode.find cmp m k with\n | none => none\n | some t => loop t ks\n loop t k",
"start": [
41,
1
],
"end": [
49,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTreeNode.foldMatchingM",
"code": "@[specialize]\npartial def foldMatchingM [Monad m] (t : PrefixTreeNode α β) (cmp : α → α → Ordering) (k : List α) (init : σ) (f : β → σ → m σ) : m σ :=\n let rec fold : PrefixTreeNode α β → σ → m σ\n | PrefixTreeNode.Node b? n, d => do\n let d ← match b? with\n | none => pure d\n | some b => f b d\n n.foldM (init := d) fun d _ t => fold t d\n let rec find : List α → PrefixTreeNode α β → σ → m σ\n | [], t, d => fold t d\n | k::ks, PrefixTreeNode.Node _ m, d =>\n match RBNode.find cmp m k with\n | none => pure init\n | some t => find ks t d\n find k t init",
"start": [
51,
1
],
"end": [
65,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTreeNode.WellFormed",
"code": "inductive WellFormed (cmp : α → α → Ordering) : PrefixTreeNode α β → Prop where\n | emptyWff : WellFormed cmp empty\n | insertWff : WellFormed cmp t → WellFormed cmp (insert t cmp k val)",
"start": [
67,
1
],
"end": [
69,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree",
"code": "def PrefixTree (α : Type u) (β : Type v) (cmp : α → α → Ordering) : Type (max u v) :=\n { t : PrefixTreeNode α β // t.WellFormed cmp }",
"start": [
73,
1
],
"end": [
74,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.empty",
"code": "def PrefixTree.empty : PrefixTree α β p :=\n ⟨PrefixTreeNode.empty, WellFormed.emptyWff⟩",
"start": [
78,
1
],
"end": [
79,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.insert",
"code": "@[inline]\ndef PrefixTree.insert (t : PrefixTree α β p) (k : List α) (v : β) : PrefixTree α β p :=\n ⟨t.val.insert p k v, WellFormed.insertWff t.property⟩",
"start": [
87,
1
],
"end": [
89,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.find?",
"code": "@[inline]\ndef PrefixTree.find? (t : PrefixTree α β p) (k : List α) : Option β :=\n t.val.find? p k",
"start": [
91,
1
],
"end": [
93,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.foldMatchingM",
"code": "@[inline]\ndef PrefixTree.foldMatchingM [Monad m] (t : PrefixTree α β p) (k : List α) (init : σ) (f : β → σ → m σ) : m σ :=\n t.val.foldMatchingM p k init f",
"start": [
95,
1
],
"end": [
97,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.foldM",
"code": "@[inline]\ndef PrefixTree.foldM [Monad m] (t : PrefixTree α β p) (init : σ) (f : β → σ → m σ) : m σ :=\n t.foldMatchingM [] init f",
"start": [
99,
1
],
"end": [
101,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.forMatchingM",
"code": "@[inline]\ndef PrefixTree.forMatchingM [Monad m] (t : PrefixTree α β p) (k : List α) (f : β → m Unit) : m Unit :=\n t.val.foldMatchingM p k () (fun b _ => f b)",
"start": [
103,
1
],
"end": [
105,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.PrefixTree.forM",
"code": "@[inline]\ndef PrefixTree.forM [Monad m] (t : PrefixTree α β p) (f : β → m Unit) : m Unit :=\n t.forMatchingM [] f",
"start": [
107,
1
],
"end": [
109,
22
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/CoreM.lean | [
".lake/packages/lean4/src/lean/Lean/MonadEnv.lean",
".lake/packages/lean4/src/lean/Lean/Elab/Exception.lean",
".lake/packages/lean4/src/lean/Lean/ResolveName.lean",
".lake/packages/lean4/src/lean/Lean/Eval.lean",
".lake/packages/lean4/src/lean/Lean/Util/RecDepth.lean",
".lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Types.lean",
".lake/packages/lean4/src/lean/Lean/Util/Trace.lean",
".lake/packages/lean4/src/lean/Lean/Log.lean"
] | [
{
"full_name": "Lean.useDiagnosticMsg",
"code": "def useDiagnosticMsg := s!\"use `set_option {diagnostics.name} true` to get diagnostic information\"",
"start": [
34,
1
],
"end": [
34,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.getMaxHeartbeats",
"code": "def getMaxHeartbeats (opts : Options) : Nat :=\n maxHeartbeats.get opts * 1000",
"start": [
40,
1
],
"end": [
41,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.InstantiateLevelCache",
"code": "abbrev InstantiateLevelCache := PersistentHashMap Name (List Level × Expr)",
"start": [
43,
1
],
"end": [
43,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.Cache",
"code": "structure Cache where\n instLevelType : InstantiateLevelCache := {}\n instLevelValue : InstantiateLevelCache := {}\n deriving Inhabited",
"start": [
45,
1
],
"end": [
49,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.State",
"code": "structure State where\n \n env : Environment\n \n nextMacroScope : MacroScope := firstFrontendMacroScope + 1\n \n ngen : NameGenerator := {}\n \n traceState : TraceState := {}\n \n cache : Cache := {}\n \n messages : MessageLog := {}\n \n infoState : Elab.InfoState := {}\n deriving Nonempty",
"start": [
51,
1
],
"end": [
67,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.Context",
"code": "structure Context where\n \n fileName : String\n \n fileMap : FileMap\n options : Options := {}\n currRecDepth : Nat := 0\n maxRecDepth : Nat := 1000\n ref : Syntax := Syntax.missing\n currNamespace : Name := Name.anonymous\n openDecls : List OpenDecl := []\n initHeartbeats : Nat := 0\n maxHeartbeats : Nat := getMaxHeartbeats options\n currMacroScope : MacroScope := firstFrontendMacroScope\n \n diag : Bool := false\n \n cancelTk? : Option IO.CancelToken := none\n \n suppressElabErrors : Bool := false\n deriving Nonempty",
"start": [
69,
1
],
"end": [
96,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.CoreM",
"code": "abbrev CoreM := ReaderT Context <| StateRefT State (EIO Exception)",
"start": [
98,
1
],
"end": [
106,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.withConsistentCtx",
"code": "@[inline] private def withConsistentCtx (x : CoreM α) : CoreM α := do\n withOptions id x",
"start": [
142,
1
],
"end": [
143,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.withFreshMacroScope",
"code": "protected def withFreshMacroScope (x : CoreM α) : CoreM α := do\n let fresh ← modifyGetThe Core.State (fun st => (st.nextMacroScope, { st with nextMacroScope := st.nextMacroScope + 1 }))\n withReader (fun ctx => { ctx with currMacroScope := fresh }) x",
"start": [
161,
1
],
"end": [
163,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.modifyCache",
"code": "@[inline] def modifyCache (f : Cache → Cache) : CoreM Unit :=\n modify fun ⟨env, next, ngen, trace, cache, messages, infoState⟩ => ⟨env, next, ngen, trace, f cache, messages, infoState⟩",
"start": [
174,
1
],
"end": [
175,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.modifyInstLevelTypeCache",
"code": "@[inline] def modifyInstLevelTypeCache (f : InstantiateLevelCache → InstantiateLevelCache) : CoreM Unit :=\n modifyCache fun ⟨c₁, c₂⟩ => ⟨f c₁, c₂⟩",
"start": [
177,
1
],
"end": [
178,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.modifyInstLevelValueCache",
"code": "@[inline] def modifyInstLevelValueCache (f : InstantiateLevelCache → InstantiateLevelCache) : CoreM Unit :=\n modifyCache fun ⟨c₁, c₂⟩ => ⟨c₁, f c₂⟩",
"start": [
180,
1
],
"end": [
181,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.instantiateTypeLevelParams",
"code": "def instantiateTypeLevelParams (c : ConstantInfo) (us : List Level) : CoreM Expr := do\n if let some (us', r) := (← get).cache.instLevelType.find? c.name then\n if us == us' then\n return r\n let r := c.instantiateTypeLevelParams us\n modifyInstLevelTypeCache fun s => s.insert c.name (us, r)\n return r",
"start": [
183,
1
],
"end": [
189,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.instantiateValueLevelParams",
"code": "def instantiateValueLevelParams (c : ConstantInfo) (us : List Level) : CoreM Expr := do\n if let some (us', r) := (← get).cache.instLevelValue.find? c.name then\n if us == us' then\n return r\n unless c.hasValue do\n throwError \"Not a definition or theorem: {c.name}\"\n let r := c.instantiateValueLevelParams! us\n modifyInstLevelValueCache fun s => s.insert c.name (us, r)\n return r",
"start": [
191,
1
],
"end": [
199,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.liftIOCore",
"code": "@[inline] def liftIOCore (x : IO α) : CoreM α := do\n let ref ← getRef\n IO.toEIO (fun (err : IO.Error) => Exception.error ref (toString err)) x",
"start": [
201,
1
],
"end": [
203,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.SavedState",
"code": "structure SavedState extends State where\n \n passedHearbeats : Nat\nderiving Nonempty",
"start": [
212,
1
],
"end": [
215,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.saveState",
"code": "def saveState : CoreM SavedState := do\n let s ← get\n return { toState := s, passedHearbeats := 0 }",
"start": [
217,
1
],
"end": [
219,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.withRestoreOrSaveFull",
"code": "@[specialize] def withRestoreOrSaveFull (reusableResult? : Option (α × SavedState))\n (act : CoreM α) : CoreM (α × SavedState) := do\n if let some (val, state) := reusableResult? then\n set state.toState\n IO.addHeartbeats state.passedHearbeats.toUInt64\n return (val, state)\n\n let startHeartbeats ← IO.getNumHeartbeats\n let a ← act\n let s ← get\n let stopHeartbeats ← IO.getNumHeartbeats\n return (a, { toState := s, passedHearbeats := stopHeartbeats - startHeartbeats })",
"start": [
221,
1
],
"end": [
246,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.SavedState.restore",
"code": "def SavedState.restore (b : SavedState) : CoreM Unit :=\n modify fun s => { s with env := b.env, messages := b.messages, infoState := b.infoState }",
"start": [
248,
1
],
"end": [
250,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.mkFreshNameImp",
"code": "private def mkFreshNameImp (n : Name) : CoreM Name := do\n let fresh ← modifyGet fun s => (s.nextMacroScope, { s with nextMacroScope := s.nextMacroScope + 1 })\n return addMacroScope (← getEnv).mainModule n fresh",
"start": [
252,
1
],
"end": [
254,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.mkFreshUserName",
"code": "def mkFreshUserName (n : Name) : CoreM Name :=\n mkFreshNameImp n",
"start": [
256,
1
],
"end": [
257,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.CoreM.run",
"code": "@[inline] def CoreM.run (x : CoreM α) (ctx : Context) (s : State) : EIO Exception (α × State) :=\n ((withConsistentCtx x) ctx).run s",
"start": [
259,
1
],
"end": [
260,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.CoreM.run'",
"code": "@[inline] def CoreM.run' (x : CoreM α) (ctx : Context) (s : State) : EIO Exception α :=\n Prod.fst <$> x.run ctx s",
"start": [
262,
1
],
"end": [
263,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.CoreM.toIO",
"code": "@[inline] def CoreM.toIO (x : CoreM α) (ctx : Context) (s : State) : IO (α × State) := do\n match (← (x.run { ctx with initHeartbeats := (← IO.getNumHeartbeats) } s).toIO') with\n | Except.error (Exception.error _ msg) => throw <| IO.userError (← msg.toString)\n | Except.error (Exception.internal id _) => throw <| IO.userError <| \"internal exception #\" ++ toString id.idx\n | Except.ok a => return a",
"start": [
265,
1
],
"end": [
269,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.withIncRecDepth",
"code": "protected def withIncRecDepth [Monad m] [MonadControlT CoreM m] (x : m α) : m α :=\n controlAt CoreM fun runInBase => withIncRecDepth (runInBase x)",
"start": [
278,
1
],
"end": [
279,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.checkInterrupted",
"code": "@[inline] def checkInterrupted : CoreM Unit := do\n if let some tk := (← read).cancelTk? then\n if (← tk.isSet) then\n throw <| .internal interruptExceptionId",
"start": [
283,
1
],
"end": [
292,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.throwMaxHeartbeat",
"code": "def throwMaxHeartbeat (moduleName : Name) (optionName : Name) (max : Nat) : CoreM Unit := do\n let includeModuleName := debug.moduleNameAtTimeout.get (← getOptions)\n let atModuleName := if includeModuleName then s!\" at `{moduleName}`\" else \"\"\n let msg := s!\"(deterministic) timeout{atModuleName}, maximum number of heartbeats ({max/1000}) has been reached\\nuse `set_option {optionName} <num>` to set the limit\\n{useDiagnosticMsg}\"\n throw <| Exception.error (← getRef) (MessageData.ofFormat (Std.Format.text msg))",
"start": [
300,
1
],
"end": [
304,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.checkMaxHeartbeatsCore",
"code": "def checkMaxHeartbeatsCore (moduleName : String) (optionName : Name) (max : Nat) : CoreM Unit := do\n unless max == 0 do\n let numHeartbeats ← IO.getNumHeartbeats\n if numHeartbeats - (← read).initHeartbeats > max then\n throwMaxHeartbeat (.mkSimple moduleName) optionName max",
"start": [
306,
1
],
"end": [
310,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.checkMaxHeartbeats",
"code": "def checkMaxHeartbeats (moduleName : String) : CoreM Unit := do\n checkMaxHeartbeatsCore moduleName `maxHeartbeats (← read).maxHeartbeats",
"start": [
312,
1
],
"end": [
313,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.checkSystem",
"code": "def checkSystem (moduleName : String) : CoreM Unit := do\n checkInterrupted\n checkMaxHeartbeats moduleName",
"start": [
315,
1
],
"end": [
318,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.withCurrHeartbeatsImp",
"code": "private def withCurrHeartbeatsImp (x : CoreM α) : CoreM α := do\n let heartbeats ← IO.getNumHeartbeats\n withReader (fun ctx => { ctx with initHeartbeats := heartbeats }) x",
"start": [
320,
1
],
"end": [
322,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.withCurrHeartbeats",
"code": "def withCurrHeartbeats [Monad m] [MonadControlT CoreM m] (x : m α) : m α :=\n controlAt CoreM fun runInBase => withCurrHeartbeatsImp (runInBase x)",
"start": [
324,
1
],
"end": [
325,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.setMessageLog",
"code": "def setMessageLog (messages : MessageLog) : CoreM Unit :=\n modify fun s => { s with messages := messages }",
"start": [
327,
1
],
"end": [
328,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.resetMessageLog",
"code": "def resetMessageLog : CoreM Unit :=\n setMessageLog {}",
"start": [
330,
1
],
"end": [
331,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.getMessageLog",
"code": "def getMessageLog : CoreM MessageLog :=\n return (← get).messages",
"start": [
333,
1
],
"end": [
334,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.getAndEmptyMessageLog",
"code": "def getAndEmptyMessageLog : CoreM MessageLog :=\n modifyGet fun s => (s.messages, { s with\n messages.unreported := {}\n messages.hadErrors := s.messages.hasErrors })",
"start": [
336,
1
],
"end": [
343,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withAtLeastMaxRecDepth",
"code": "@[inline] def withAtLeastMaxRecDepth [MonadFunctorT CoreM m] (max : Nat) : m α → m α :=\n monadMap (m := CoreM) <| withReader (fun ctx => { ctx with maxRecDepth := Nat.max max ctx.maxRecDepth })",
"start": [
365,
1
],
"end": [
366,
107
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.catchInternalId",
"code": "@[inline] def catchInternalId [Monad m] [MonadExcept Exception m] (id : InternalExceptionId) (x : m α) (h : Exception → m α) : m α := do\n try\n x\n catch ex => match ex with\n | .error .. => throw ex\n | .internal id' _ => if id == id' then h ex else throw ex",
"start": [
368,
1
],
"end": [
373,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.catchInternalIds",
"code": "@[inline] def catchInternalIds [Monad m] [MonadExcept Exception m] (ids : List InternalExceptionId) (x : m α) (h : Exception → m α) : m α := do\n try\n x\n catch ex => match ex with\n | .error .. => throw ex\n | .internal id _ => if ids.contains id then h ex else throw ex",
"start": [
375,
1
],
"end": [
380,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.isMaxHeartbeat",
"code": "def Exception.isMaxHeartbeat (ex : Exception) : Bool :=\n match ex with\n | Exception.error _ (MessageData.ofFormatWithInfos ⟨Std.Format.text msg, _⟩) =>\n \"(deterministic) timeout\".isPrefixOf msg\n | _ => false",
"start": [
382,
1
],
"end": [
390,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkArrow",
"code": "def mkArrow (d b : Expr) : CoreM Expr :=\n return Lean.mkForall (← mkFreshUserName `x) BinderInfo.default d b",
"start": [
392,
1
],
"end": [
394,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkArrowN",
"code": "def mkArrowN (ds : Array Expr) (e : Expr) : CoreM Expr := ds.foldrM mkArrow e",
"start": [
396,
1
],
"end": [
397,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.supportedRecursors",
"code": "private def supportedRecursors :=\n #[``Empty.rec, ``False.rec, ``Eq.ndrec, ``Eq.rec, ``Eq.recOn, ``Eq.casesOn, ``False.casesOn, ``Empty.casesOn, ``And.rec, ``And.casesOn]",
"start": [
399,
1
],
"end": [
400,
138
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.checkUnsupported",
"code": "private def checkUnsupported [Monad m] [MonadEnv m] [MonadError m] (decl : Declaration) : m Unit := do\n let env ← getEnv\n decl.forExprM fun e =>\n let unsupportedRecursor? := e.find? fun\n | Expr.const declName .. =>\n ((isAuxRecursor env declName && !isCasesOnRecursor env declName) || isRecCore env declName)\n && !supportedRecursors.contains declName\n | _ => false\n match unsupportedRecursor? with\n | some (Expr.const declName ..) => throwError \"code generator does not support recursor '{declName}' yet, consider using 'match ... with' and/or structural recursion\"\n | _ => pure ()",
"start": [
402,
1
],
"end": [
414,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.compileDeclsNew",
"code": "@[extern \"lean_lcnf_compile_decls\"]\nopaque compileDeclsNew (declNames : List Name) : CoreM Unit",
"start": [
423,
1
],
"end": [
424,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.compileDecl",
"code": "def compileDecl (decl : Declaration) : CoreM Unit := do\n let opts ← getOptions\n let decls := Compiler.getDeclNamesForCodeGen decl\n if compiler.enableNew.get opts then\n compileDeclsNew decls\n let res ← withTraceNode `compiler (fun _ => return m!\"compiling old: {decls}\") do\n return (← getEnv).compileDecl opts decl\n match res with\n | Except.ok env => setEnv env\n | Except.error (KernelException.other msg) =>\n checkUnsupported decl throwError msg\n | Except.error ex =>\n throwKernelException ex",
"start": [
426,
1
],
"end": [
439,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.compileDecls",
"code": "def compileDecls (decls : List Name) : CoreM Unit := do\n let opts ← getOptions\n if compiler.enableNew.get opts then\n compileDeclsNew decls\n match (← getEnv).compileDecls opts decls with\n | Except.ok env => setEnv env\n | Except.error (KernelException.other msg) =>\n throwError msg\n | Except.error ex =>\n throwKernelException ex",
"start": [
441,
1
],
"end": [
450,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getDiag",
"code": "def getDiag (opts : Options) : Bool :=\n diagnostics.get opts",
"start": [
452,
1
],
"end": [
453,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isDiagnosticsEnabled",
"code": "def isDiagnosticsEnabled : CoreM Bool :=\n return (← read).diag",
"start": [
455,
1
],
"end": [
457,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ImportM.runCoreM",
"code": "def ImportM.runCoreM (x : CoreM α) : ImportM α := do\n let ctx ← read\n let (a, _) ← (withOptions (fun _ => ctx.opts) x).toIO { fileName := \"<ImportM>\", fileMap := default } { env := ctx.env }\n return a",
"start": [
459,
1
],
"end": [
462,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.isRuntime",
"code": "def Exception.isRuntime (ex : Exception) : Bool :=\n ex.isMaxHeartbeat || ex.isMaxRecDepth",
"start": [
464,
1
],
"end": [
466,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Exception.isInterrupt",
"code": "def Exception.isInterrupt : Exception → Bool\n | Exception.internal id _ => id == Core.interruptExceptionId\n | _ => false",
"start": [
468,
1
],
"end": [
471,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.tryCatch",
"code": "@[inline] protected def Core.tryCatch (x : CoreM α) (h : Exception → CoreM α) : CoreM α := do\n try\n x\n catch ex =>\n if ex.isInterrupt || ex.isRuntime then\n throw ex\n else\n h ex",
"start": [
473,
1
],
"end": [
486,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Core.tryCatchRuntimeEx",
"code": "@[inline] protected def Core.tryCatchRuntimeEx (x : CoreM α) (h : Exception → CoreM α) : CoreM α := do\n try\n x\n catch ex =>\n if ex.isInterrupt then\n throw ex\n h ex",
"start": [
488,
1
],
"end": [
499,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MonadRuntimeException",
"code": "class MonadRuntimeException (m : Type → Type) where\n tryCatchRuntimeEx (body : m α) (handler : Exception → m α) : m α",
"start": [
505,
1
],
"end": [
506,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mapCoreM",
"code": "@[inline] def mapCoreM [MonadControlT CoreM m] [Monad m] (f : forall {α}, CoreM α → CoreM α) {α} (x : m α) : m α :=\n controlAt CoreM fun runInBase => f <| runInBase x",
"start": [
519,
1
],
"end": [
520,
52
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/NameTrie.lean | [
".lake/packages/lean4/src/lean/Lean/Data/PrefixTree.lean"
] | [
{
"full_name": "Lean.NamePart",
"code": "inductive NamePart\n | str (s : String)\n | num (n : Nat)",
"start": [
11,
1
],
"end": [
13,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NamePart.cmp",
"code": "def NamePart.cmp : NamePart → NamePart → Ordering\n | NamePart.str a, NamePart.str b => compare a b\n | NamePart.num a, NamePart.num b => compare a b\n | NamePart.num _, NamePart.str _ => Ordering.lt\n | _, _ => Ordering.gt",
"start": [
20,
1
],
"end": [
24,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NamePart.lt",
"code": "def NamePart.lt : NamePart → NamePart → Bool\n | NamePart.str a, NamePart.str b => a < b\n | NamePart.num a, NamePart.num b => a < b\n | NamePart.num _, NamePart.str _ => true\n | _, _ => false",
"start": [
26,
1
],
"end": [
30,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie",
"code": "def NameTrie (β : Type u) := PrefixTree NamePart β NamePart.cmp",
"start": [
32,
1
],
"end": [
32,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.toKey",
"code": "private def toKey (n : Name) : List NamePart :=\n loop n []\nwhere\n loop\n | Name.str p s, parts => loop p (NamePart.str s :: parts)\n | Name.num p n, parts => loop p (NamePart.num n :: parts)\n | Name.anonymous, parts => parts",
"start": [
34,
1
],
"end": [
40,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.insert",
"code": "def NameTrie.insert (t : NameTrie β) (n : Name) (b : β) : NameTrie β :=\n PrefixTree.insert t (toKey n) b",
"start": [
42,
1
],
"end": [
43,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.empty",
"code": "def NameTrie.empty : NameTrie β :=\n PrefixTree.empty",
"start": [
45,
1
],
"end": [
46,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.find?",
"code": "def NameTrie.find? (t : NameTrie β) (k : Name) : Option β :=\n PrefixTree.find? t (toKey k)",
"start": [
54,
1
],
"end": [
55,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.foldMatchingM",
"code": "@[inline]\ndef NameTrie.foldMatchingM [Monad m] (t : NameTrie β) (k : Name) (init : σ) (f : β → σ → m σ) : m σ :=\n PrefixTree.foldMatchingM t (toKey k) init f",
"start": [
57,
1
],
"end": [
59,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.foldM",
"code": "@[inline]\ndef NameTrie.foldM [Monad m] (t : NameTrie β) (init : σ) (f : β → σ → m σ) : m σ :=\n t.foldMatchingM Name.anonymous init f",
"start": [
61,
1
],
"end": [
63,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.forMatchingM",
"code": "@[inline]\ndef NameTrie.forMatchingM [Monad m] (t : NameTrie β) (k : Name) (f : β → m Unit) : m Unit :=\n PrefixTree.forMatchingM t (toKey k) f",
"start": [
65,
1
],
"end": [
67,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.forM",
"code": "@[inline]\ndef NameTrie.forM [Monad m] (t : NameTrie β) (f : β → m Unit) : m Unit :=\n t.forMatchingM Name.anonymous f",
"start": [
69,
1
],
"end": [
71,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.matchingToArray",
"code": "def NameTrie.matchingToArray (t : NameTrie β) (k : Name) : Array β :=\n Id.run <| t.foldMatchingM k #[] fun v acc => acc.push v",
"start": [
73,
1
],
"end": [
74,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.NameTrie.toArray",
"code": "def NameTrie.toArray (t : NameTrie β) : Array β :=\n Id.run <| t.foldM #[] fun v acc => acc.push v",
"start": [
76,
1
],
"end": [
77,
48
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Attributes.lean | [
".lake/packages/lean4/src/lean/Lean/MonadEnv.lean",
".lake/packages/lean4/src/lean/Lean/CoreM.lean"
] | [
{
"full_name": "Lean.AttributeApplicationTime",
"code": "inductive AttributeApplicationTime where\n | afterTypeChecking | afterCompilation | beforeElaboration\n deriving Inhabited, BEq",
"start": [
12,
1
],
"end": [
14,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttrM",
"code": "abbrev AttrM := CoreM",
"start": [
16,
1
],
"end": [
16,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeImplCore",
"code": "structure AttributeImplCore where\n \n ref : Name := by exact decl_name%\n name : Name\n descr : String\n applicationTime := AttributeApplicationTime.afterTypeChecking\n deriving Inhabited",
"start": [
21,
1
],
"end": [
27,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeKind",
"code": "inductive AttributeKind\n | global | local | scoped\n deriving BEq, Inhabited",
"start": [
29,
1
],
"end": [
42,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeImpl",
"code": "structure AttributeImpl extends AttributeImplCore where\n \n add (decl : Name) (stx : Syntax) (kind : AttributeKind) : AttrM Unit\n erase (decl : Name) : AttrM Unit := throwError \"attribute cannot be erased\"\n deriving Inhabited",
"start": [
50,
1
],
"end": [
54,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerBuiltinAttribute",
"code": "def registerBuiltinAttribute (attr : AttributeImpl) : IO Unit := do\n let m ← attributeMapRef.get\n if m.contains attr.name then throw (IO.userError (\"invalid builtin attribute declaration, '\" ++ toString attr.name ++ \"' has already been used\"))\n unless (← initializing) do\n throw (IO.userError \"failed to register attribute, attributes can only be registered during initialization\")\n attributeMapRef.modify fun m => m.insert attr.name attr",
"start": [
58,
1
],
"end": [
64,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.Builtin.ensureNoArgs",
"code": "def Attribute.Builtin.ensureNoArgs (stx : Syntax) : AttrM Unit := do\n if stx.getKind == `Lean.Parser.Attr.simple && stx[1].isNone && stx[2].isNone then\n return ()\n else if stx.getKind == `Lean.Parser.Attr.«class» then\n return ()\n else match stx with\n | Syntax.missing => return () | _ => throwErrorAt stx \"unexpected attribute argument\"",
"start": [
77,
1
],
"end": [
84,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.Builtin.getIdent?",
"code": "def Attribute.Builtin.getIdent? (stx : Syntax) : AttrM (Option Syntax) := do\n if stx.getKind == `Lean.Parser.Attr.simple then\n if !stx[1].isNone && stx[1][0].isIdent then\n return some stx[1][0]\n else\n return none\n \n else if stx.getKind == `Lean.Parser.Attr.«macro» || stx.getKind == `Lean.Parser.Attr.«export» then\n return some stx[1]\n else\n throwErrorAt stx \"unexpected attribute argument\"",
"start": [
86,
1
],
"end": [
96,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.Builtin.getIdent",
"code": "def Attribute.Builtin.getIdent (stx : Syntax) : AttrM Syntax := do\n match (← getIdent? stx) with\n | some id => return id\n | none => throwErrorAt stx \"unexpected attribute argument, identifier expected\"",
"start": [
98,
1
],
"end": [
101,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.Builtin.getId?",
"code": "def Attribute.Builtin.getId? (stx : Syntax) : AttrM (Option Name) := do\n let ident? ← getIdent? stx\n return Syntax.getId <$> ident?",
"start": [
103,
1
],
"end": [
105,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.Builtin.getId",
"code": "def Attribute.Builtin.getId (stx : Syntax) : AttrM Name := do\n return (← getIdent stx).getId",
"start": [
107,
1
],
"end": [
108,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getAttrParamOptPrio",
"code": "def getAttrParamOptPrio (optPrioStx : Syntax) : AttrM Nat :=\n if optPrioStx.isNone then\n return eval_prio default\n else match optPrioStx[0].isNatLit? with\n | some prio => return prio\n | none => throwErrorAt optPrioStx \"priority expected\"",
"start": [
110,
1
],
"end": [
115,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.Builtin.getPrio",
"code": "def Attribute.Builtin.getPrio (stx : Syntax) : AttrM Nat := do\n if stx.getKind == `Lean.Parser.Attr.simple then\n getAttrParamOptPrio stx[1]\n else\n throwErrorAt stx \"unexpected attribute argument, optional priority expected\"",
"start": [
117,
1
],
"end": [
121,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TagAttribute",
"code": "structure TagAttribute where\n attr : AttributeImpl\n ext : PersistentEnvExtension Name Name NameSet\n deriving Inhabited",
"start": [
124,
1
],
"end": [
135,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerTagAttribute",
"code": "def registerTagAttribute (name : Name) (descr : String)\n (validate : Name → AttrM Unit := fun _ => pure ()) (ref : Name := by exact decl_name%) (applicationTime := AttributeApplicationTime.afterTypeChecking) : IO TagAttribute := do\n let ext : PersistentEnvExtension Name Name NameSet ← registerPersistentEnvExtension {\n name := ref\n mkInitial := pure {}\n addImportedFn := fun _ _ => pure {}\n addEntryFn := fun (s : NameSet) n => s.insert n\n exportEntriesFn := fun es =>\n let r : Array Name := es.fold (fun a e => a.push e) #[]\n r.qsort Name.quickLt\n statsFn := fun s => \"tag attribute\" ++ Format.line ++ \"number of local entries: \" ++ format s.size\n }\n let attrImpl : AttributeImpl := {\n ref, name, descr, applicationTime\n add := fun decl stx kind => do\n Attribute.Builtin.ensureNoArgs stx\n unless kind == AttributeKind.global do throwError \"invalid attribute '{name}', must be global\"\n let env ← getEnv\n unless (env.getModuleIdxFor? decl).isNone do\n throwError \"invalid attribute '{name}', declaration is in an imported module\"\n validate decl\n modifyEnv fun env => ext.addEntry env decl\n }\n registerBuiltinAttribute attrImpl\n return { attr := attrImpl, ext := ext }",
"start": [
137,
1
],
"end": [
161,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.TagAttribute.hasTag",
"code": "def hasTag (attr : TagAttribute) (env : Environment) (decl : Name) : Bool :=\n match env.getModuleIdxFor? decl with\n | some modIdx => (attr.ext.getModuleEntries env modIdx).binSearchContains decl Name.quickLt\n | none => (attr.ext.getState env).contains decl",
"start": [
165,
1
],
"end": [
168,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParametricAttribute",
"code": "structure ParametricAttribute (α : Type) where\n attr : AttributeImpl\n ext : PersistentEnvExtension (Name × α) (Name × α) (NameMap α)\n deriving Inhabited",
"start": [
172,
1
],
"end": [
181,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParametricAttributeImpl",
"code": "structure ParametricAttributeImpl (α : Type) extends AttributeImplCore where\n getParam : Name → Syntax → AttrM α\n afterSet : Name → α → AttrM Unit := fun _ _ _ => pure ()\n afterImport : Array (Array (Name × α)) → ImportM Unit := fun _ => pure ()",
"start": [
183,
1
],
"end": [
186,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerParametricAttribute",
"code": "def registerParametricAttribute (impl : ParametricAttributeImpl α) : IO (ParametricAttribute α) := do\n let ext : PersistentEnvExtension (Name × α) (Name × α) (NameMap α) ← registerPersistentEnvExtension {\n name := impl.ref\n mkInitial := pure {}\n addImportedFn := fun s => impl.afterImport s *> pure {}\n addEntryFn := fun (s : NameMap α) (p : Name × α) => s.insert p.1 p.2\n exportEntriesFn := fun m =>\n let r : Array (Name × α) := m.fold (fun a n p => a.push (n, p)) #[]\n r.qsort (fun a b => Name.quickLt a.1 b.1)\n statsFn := fun s => \"parametric attribute\" ++ Format.line ++ \"number of local entries: \" ++ format s.size\n }\n let attrImpl : AttributeImpl := {\n impl.toAttributeImplCore with\n add := fun decl stx kind => do\n unless kind == AttributeKind.global do throwError \"invalid attribute '{impl.name}', must be global\"\n let env ← getEnv\n unless (env.getModuleIdxFor? decl).isNone do\n throwError \"invalid attribute '{impl.name}', declaration is in an imported module\"\n let val ← impl.getParam decl stx\n modifyEnv fun env => ext.addEntry env (decl, val)\n try impl.afterSet decl val catch _ => setEnv env\n }\n registerBuiltinAttribute attrImpl\n pure { attr := attrImpl, ext := ext }",
"start": [
188,
1
],
"end": [
211,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParametricAttribute.getParam?",
"code": "def getParam? [Inhabited α] (attr : ParametricAttribute α) (env : Environment) (decl : Name) : Option α :=\n match env.getModuleIdxFor? decl with\n | some modIdx =>\n match (attr.ext.getModuleEntries env modIdx).binSearch (decl, default) (fun a b => Name.quickLt a.1 b.1) with\n | some (_, val) => some val\n | none => none\n | none => (attr.ext.getState env).find? decl",
"start": [
215,
1
],
"end": [
221,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ParametricAttribute.setParam",
"code": "def setParam (attr : ParametricAttribute α) (env : Environment) (decl : Name) (param : α) : Except String Environment :=\n if (env.getModuleIdxFor? decl).isSome then\n Except.error (\"invalid '\" ++ toString attr.attr.name ++ \"'.setParam, declaration is in an imported module\")\n else if ((attr.ext.getState env).find? decl).isSome then\n Except.error (\"invalid '\" ++ toString attr.attr.name ++ \"'.setParam, attribute has already been set\")\n else\n Except.ok (attr.ext.addEntry env (decl, param))",
"start": [
223,
1
],
"end": [
229,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnumAttributes",
"code": "structure EnumAttributes (α : Type) where\n attrs : List AttributeImpl\n ext : PersistentEnvExtension (Name × α) (Name × α) (NameMap α)\n deriving Inhabited",
"start": [
233,
1
],
"end": [
240,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerEnumAttributes",
"code": "def registerEnumAttributes (attrDescrs : List (Name × String × α))\n (validate : Name → α → AttrM Unit := fun _ _ => pure ())\n (applicationTime := AttributeApplicationTime.afterTypeChecking)\n (ref : Name := by exact decl_name%) : IO (EnumAttributes α) := do\n let ext : PersistentEnvExtension (Name × α) (Name × α) (NameMap α) ← registerPersistentEnvExtension {\n name := ref\n mkInitial := pure {}\n addImportedFn := fun _ _ => pure {}\n addEntryFn := fun (s : NameMap α) (p : Name × α) => s.insert p.1 p.2\n exportEntriesFn := fun m =>\n let r : Array (Name × α) := m.fold (fun a n p => a.push (n, p)) #[]\n r.qsort (fun a b => Name.quickLt a.1 b.1)\n statsFn := fun s => \"enumeration attribute extension\" ++ Format.line ++ \"number of local entries: \" ++ format s.size\n }\n let attrs := attrDescrs.map fun (name, descr, val) => {\n ref := ref\n name := name\n descr := descr\n add := fun decl stx kind => do\n Attribute.Builtin.ensureNoArgs stx\n unless kind == AttributeKind.global do throwError \"invalid attribute '{name}', must be global\"\n let env ← getEnv\n unless (env.getModuleIdxFor? decl).isNone do\n throwError \"invalid attribute '{name}', declaration is in an imported module\"\n validate decl val\n modifyEnv fun env => ext.addEntry env (decl, val)\n applicationTime := applicationTime\n : AttributeImpl\n }\n attrs.forM registerBuiltinAttribute\n pure { ext := ext, attrs := attrs }",
"start": [
242,
1
],
"end": [
272,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnumAttributes.getValue",
"code": "def getValue [Inhabited α] (attr : EnumAttributes α) (env : Environment) (decl : Name) : Option α :=\n match env.getModuleIdxFor? decl with\n | some modIdx =>\n match (attr.ext.getModuleEntries env modIdx).binSearch (decl, default) (fun a b => Name.quickLt a.1 b.1) with\n | some (_, val) => some val\n | none => none\n | none => (attr.ext.getState env).find? decl",
"start": [
276,
1
],
"end": [
282,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.EnumAttributes.setValue",
"code": "def setValue (attrs : EnumAttributes α) (env : Environment) (decl : Name) (val : α) : Except String Environment :=\n if (env.getModuleIdxFor? decl).isSome then\n Except.error (\"invalid '\" ++ toString attrs.ext.name ++ \"'.setValue, declaration is in an imported module\")\n else if ((attrs.ext.getState env).find? decl).isSome then\n Except.error (\"invalid '\" ++ toString attrs.ext.name ++ \"'.setValue, attribute has already been set\")\n else\n Except.ok (attrs.ext.addEntry env (decl, val))",
"start": [
284,
1
],
"end": [
290,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeImplBuilder",
"code": "abbrev AttributeImplBuilder := Name → List DataValue → Except String AttributeImpl",
"start": [
298,
1
],
"end": [
298,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeImplBuilderTable",
"code": "abbrev AttributeImplBuilderTable := HashMap Name AttributeImplBuilder",
"start": [
299,
1
],
"end": [
299,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerAttributeImplBuilder",
"code": "def registerAttributeImplBuilder (builderId : Name) (builder : AttributeImplBuilder) : IO Unit := do\n let table ← attributeImplBuilderTableRef.get\n if table.contains builderId then throw (IO.userError (\"attribute implementation builder '\" ++ toString builderId ++ \"' has already been declared\"))\n attributeImplBuilderTableRef.modify fun table => table.insert builderId builder",
"start": [
303,
1
],
"end": [
306,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAttributeImplOfBuilder",
"code": "def mkAttributeImplOfBuilder (builderId ref : Name) (args : List DataValue) : IO AttributeImpl := do\n let table ← attributeImplBuilderTableRef.get\n match table.find? builderId with\n | none => throw (IO.userError (\"unknown attribute implementation builder '\" ++ toString builderId ++ \"'\"))\n | some builder => IO.ofExcept <| builder ref args",
"start": [
308,
1
],
"end": [
312,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeExtensionOLeanEntry",
"code": "inductive AttributeExtensionOLeanEntry where\n | decl (declName : Name) | builder (builderId ref : Name) (args : List DataValue)",
"start": [
314,
1
],
"end": [
316,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeExtensionState",
"code": "structure AttributeExtensionState where\n newEntries : List AttributeExtensionOLeanEntry := []\n map : HashMap Name AttributeImpl\n deriving Inhabited",
"start": [
318,
1
],
"end": [
321,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeExtension",
"code": "abbrev AttributeExtension := PersistentEnvExtension AttributeExtensionOLeanEntry (AttributeExtensionOLeanEntry × AttributeImpl) AttributeExtensionState",
"start": [
323,
1
],
"end": [
323,
152
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeExtension.mkInitial",
"code": "private def AttributeExtension.mkInitial : IO AttributeExtensionState := do\n let map ← attributeMapRef.get\n pure { map := map }",
"start": [
325,
1
],
"end": [
327,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAttributeImplOfConstantUnsafe",
"code": "unsafe def mkAttributeImplOfConstantUnsafe (env : Environment) (opts : Options) (declName : Name) : Except String AttributeImpl :=\n match env.find? declName with\n | none => throw (\"unknown constant '\" ++ toString declName ++ \"'\")\n | some info =>\n match info.type with\n | Expr.const `Lean.AttributeImpl _ => env.evalConst AttributeImpl opts declName\n | _ => throw (\"unexpected attribute implementation type at '\" ++ toString declName ++ \"' (`AttributeImpl` expected\")",
"start": [
329,
1
],
"end": [
335,
121
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAttributeImplOfConstant",
"code": "@[implemented_by mkAttributeImplOfConstantUnsafe]\nopaque mkAttributeImplOfConstant (env : Environment) (opts : Options) (declName : Name) : Except String AttributeImpl",
"start": [
337,
1
],
"end": [
338,
118
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkAttributeImplOfEntry",
"code": "def mkAttributeImplOfEntry (env : Environment) (opts : Options) (e : AttributeExtensionOLeanEntry) : IO AttributeImpl :=\n match e with\n | .decl declName => IO.ofExcept <| mkAttributeImplOfConstant env opts declName\n | .builder builderId ref args => mkAttributeImplOfBuilder builderId ref args",
"start": [
340,
1
],
"end": [
343,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.AttributeExtension.addImported",
"code": "private def AttributeExtension.addImported (es : Array (Array AttributeExtensionOLeanEntry)) : ImportM AttributeExtensionState := do\n let ctx ← read\n let map ← attributeMapRef.get\n let map ← es.foldlM\n (fun map entries =>\n entries.foldlM\n (fun (map : HashMap Name AttributeImpl) entry => do\n let attrImpl ← mkAttributeImplOfEntry ctx.env ctx.opts entry\n return map.insert attrImpl.name attrImpl)\n map)\n map\n pure { map := map }",
"start": [
345,
1
],
"end": [
356,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addAttrEntry",
"code": "private def addAttrEntry (s : AttributeExtensionState) (e : AttributeExtensionOLeanEntry × AttributeImpl) : AttributeExtensionState :=\n { s with map := s.map.insert e.2.name e.2, newEntries := e.1 :: s.newEntries }",
"start": [
358,
1
],
"end": [
359,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isBuiltinAttribute",
"code": "@[export lean_is_attribute]\ndef isBuiltinAttribute (n : Name) : IO Bool := do\n let m ← attributeMapRef.get; pure (m.contains n)",
"start": [
370,
1
],
"end": [
373,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBuiltinAttributeNames",
"code": "def getBuiltinAttributeNames : IO (List Name) :=\n return (← attributeMapRef.get).fold (init := []) fun r n _ => n::r",
"start": [
375,
1
],
"end": [
377,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBuiltinAttributeImpl",
"code": "def getBuiltinAttributeImpl (attrName : Name) : IO AttributeImpl := do\n let m ← attributeMapRef.get\n match m.find? attrName with\n | some attr => pure attr\n | none => throw (IO.userError (\"unknown attribute '\" ++ toString attrName ++ \"'\"))",
"start": [
379,
1
],
"end": [
383,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBuiltinAttributeApplicationTime",
"code": "@[export lean_attribute_application_time]\ndef getBuiltinAttributeApplicationTime (n : Name) : IO AttributeApplicationTime := do\n let attr ← getBuiltinAttributeImpl n\n pure attr.applicationTime",
"start": [
385,
1
],
"end": [
388,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isAttribute",
"code": "def isAttribute (env : Environment) (attrName : Name) : Bool :=\n (attributeExtension.getState env).map.contains attrName",
"start": [
390,
1
],
"end": [
391,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getAttributeNames",
"code": "def getAttributeNames (env : Environment) : List Name :=\n let m := (attributeExtension.getState env).map\n m.fold (fun r n _ => n::r) []",
"start": [
393,
1
],
"end": [
395,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getAttributeImpl",
"code": "def getAttributeImpl (env : Environment) (attrName : Name) : Except String AttributeImpl :=\n let m := (attributeExtension.getState env).map\n match m.find? attrName with\n | some attr => pure attr\n | none => throw (\"unknown attribute '\" ++ toString attrName ++ \"'\")",
"start": [
397,
1
],
"end": [
401,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerAttributeOfDecl",
"code": "def registerAttributeOfDecl (env : Environment) (opts : Options) (attrDeclName : Name) : Except String Environment := do\n let attrImpl ← mkAttributeImplOfConstant env opts attrDeclName\n if isAttribute env attrImpl.name then\n throw (\"invalid builtin attribute declaration, '\" ++ toString attrImpl.name ++ \"' has already been used\")\n else\n return attributeExtension.addEntry env (.decl attrDeclName, attrImpl)",
"start": [
403,
1
],
"end": [
408,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerAttributeOfBuilder",
"code": "def registerAttributeOfBuilder (env : Environment) (builderId ref : Name) (args : List DataValue) : IO Environment := do\n let attrImpl ← mkAttributeImplOfBuilder builderId ref args\n if isAttribute env attrImpl.name then\n throw (IO.userError (\"invalid builtin attribute declaration, '\" ++ toString attrImpl.name ++ \"' has already been used\"))\n else\n return attributeExtension.addEntry env (.builder builderId ref args, attrImpl)",
"start": [
410,
1
],
"end": [
415,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.add",
"code": "def Attribute.add (declName : Name) (attrName : Name) (stx : Syntax) (kind := AttributeKind.global) : AttrM Unit := do\n let attr ← ofExcept <| getAttributeImpl (← getEnv) attrName\n attr.add declName stx kind",
"start": [
417,
1
],
"end": [
419,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Attribute.erase",
"code": "def Attribute.erase (declName : Name) (attrName : Name) : AttrM Unit := do\n let attr ← ofExcept <| getAttributeImpl (← getEnv) attrName\n attr.erase declName",
"start": [
421,
1
],
"end": [
423,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.updateEnvAttributesImpl",
"code": "@[export lean_update_env_attributes]\ndef updateEnvAttributesImpl (env : Environment) : IO Environment := do\n let map ← attributeMapRef.get\n let s := attributeExtension.getState env\n let s := map.fold (init := s) fun s attrName attrImpl =>\n if s.map.contains attrName then\n s\n else\n { s with map := s.map.insert attrName attrImpl }\n return attributeExtension.setState env s",
"start": [
425,
1
],
"end": [
435,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getNumBuiltinAttributesImpl",
"code": "@[export lean_get_num_attributes] def getNumBuiltinAttributesImpl : IO Nat :=\n return (← attributeMapRef.get).size",
"start": [
437,
1
],
"end": [
439,
38
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/Data/NameTrie.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.ScopedEnvExtension.Entry",
"code": "inductive Entry (α : Type) where\n | global : α → Entry α\n | scoped : Name → α → Entry α",
"start": [
15,
1
],
"end": [
17,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.State",
"code": "structure State (σ : Type) where\n state : σ\n activeScopes : NameSet := {}",
"start": [
19,
1
],
"end": [
21,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.ScopedEntries",
"code": "structure ScopedEntries (β : Type) where\n map : SMap Name (PArray β) := {}\n deriving Inhabited",
"start": [
23,
1
],
"end": [
25,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.StateStack",
"code": "structure StateStack (α : Type) (β : Type) (σ : Type) where\n stateStack : List (State σ) := {}\n scopedEntries : ScopedEntries β := {}\n newEntries : List (Entry α) := []\n deriving Inhabited",
"start": [
27,
1
],
"end": [
31,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.Descr",
"code": "structure Descr (α : Type) (β : Type) (σ : Type) where\n name : Name := by exact decl_name%\n mkInitial : IO σ\n ofOLeanEntry : σ → α → ImportM β\n toOLeanEntry : β → α\n addEntry : σ → β → σ\n finalizeImport : σ → σ := id",
"start": [
33,
1
],
"end": [
39,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.mkInitial",
"code": "def mkInitial (descr : Descr α β σ) : IO (StateStack α β σ) :=\n return { stateStack := [ { state := (← descr.mkInitial ) } ] }",
"start": [
50,
1
],
"end": [
51,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.ScopedEntries.insert",
"code": "def ScopedEntries.insert (scopedEntries : ScopedEntries β) (ns : Name) (b : β) : ScopedEntries β :=\n match scopedEntries.map.find? ns with\n | none => { map := scopedEntries.map.insert ns <| ({} : PArray β).push b }\n | some bs => { map := scopedEntries.map.insert ns <| bs.push b }",
"start": [
53,
1
],
"end": [
56,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.addImportedFn",
"code": "def addImportedFn (descr : Descr α β σ) (as : Array (Array (Entry α))) : ImportM (StateStack α β σ) := do\n let mut s ← descr.mkInitial\n let mut scopedEntries : ScopedEntries β := {}\n for a in as do\n for e in a do\n match e with\n | Entry.global a =>\n let b ← descr.ofOLeanEntry s a\n s := descr.addEntry s b\n | Entry.scoped ns a =>\n let b ← descr.ofOLeanEntry s a\n scopedEntries := scopedEntries.insert ns b\n s := descr.finalizeImport s\n return { stateStack := [ { state := s } ], scopedEntries := scopedEntries }",
"start": [
58,
1
],
"end": [
71,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.addEntryFn",
"code": "def addEntryFn (descr : Descr α β σ) (s : StateStack α β σ) (e : Entry β) : StateStack α β σ :=\n match s with\n | { stateStack := stateStack, scopedEntries := scopedEntries, newEntries := newEntries } =>\n match e with\n | Entry.global b => {\n scopedEntries := scopedEntries\n newEntries := (Entry.global (descr.toOLeanEntry b)) :: newEntries\n stateStack := stateStack.map fun s => { s with state := descr.addEntry s.state b }\n }\n | Entry.«scoped» ns b =>\n {\n scopedEntries := scopedEntries.insert ns b\n newEntries := (Entry.«scoped» ns (descr.toOLeanEntry b)) :: newEntries\n stateStack := stateStack.map fun s =>\n if s.activeScopes.contains ns then\n { s with state := descr.addEntry s.state b }\n else\n s\n }",
"start": [
73,
1
],
"end": [
91,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.exportEntriesFn",
"code": "def exportEntriesFn (s : StateStack α β σ) : Array (Entry α) :=\n s.newEntries.toArray.reverse",
"start": [
93,
1
],
"end": [
94,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension",
"code": "structure ScopedEnvExtension (α : Type) (β : Type) (σ : Type) where\n descr : Descr α β σ\n ext : PersistentEnvExtension (Entry α) (Entry β) (StateStack α β σ)\n deriving Inhabited",
"start": [
100,
1
],
"end": [
103,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerScopedEnvExtensionUnsafe",
"code": "unsafe def registerScopedEnvExtensionUnsafe (descr : Descr α β σ) : IO (ScopedEnvExtension α β σ) := do\n let ext ← registerPersistentEnvExtension {\n name := descr.name\n mkInitial := mkInitial descr\n addImportedFn := addImportedFn descr\n addEntryFn := addEntryFn descr\n exportEntriesFn := exportEntriesFn\n statsFn := fun s => format \"number of local entries: \" ++ format s.newEntries.length\n }\n let ext := { descr := descr, ext := ext : ScopedEnvExtension α β σ }\n scopedEnvExtensionsRef.modify fun exts => exts.push (unsafeCast ext)\n return ext",
"start": [
107,
1
],
"end": [
118,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerScopedEnvExtension",
"code": "@[implemented_by registerScopedEnvExtensionUnsafe]\nopaque registerScopedEnvExtension (descr : Descr α β σ) : IO (ScopedEnvExtension α β σ)",
"start": [
120,
1
],
"end": [
121,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.pushScope",
"code": "def ScopedEnvExtension.pushScope (ext : ScopedEnvExtension α β σ) (env : Environment) : Environment :=\n let s := ext.ext.getState env\n match s.stateStack with\n | [] => env\n | state :: stack => ext.ext.setState env { s with stateStack := state :: state :: stack }",
"start": [
123,
1
],
"end": [
127,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.popScope",
"code": "def ScopedEnvExtension.popScope (ext : ScopedEnvExtension α β σ) (env : Environment) : Environment :=\n let s := ext.ext.getState env\n match s.stateStack with\n | _ :: state₂ :: stack => ext.ext.setState env { s with stateStack := state₂ :: stack }\n | _ => env",
"start": [
129,
1
],
"end": [
133,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.addEntry",
"code": "def ScopedEnvExtension.addEntry (ext : ScopedEnvExtension α β σ) (env : Environment) (b : β) : Environment :=\n ext.ext.addEntry env (Entry.global b)",
"start": [
135,
1
],
"end": [
136,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.addScopedEntry",
"code": "def ScopedEnvExtension.addScopedEntry (ext : ScopedEnvExtension α β σ) (env : Environment) (namespaceName : Name) (b : β) : Environment :=\n ext.ext.addEntry env (Entry.«scoped» namespaceName b)",
"start": [
138,
1
],
"end": [
139,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.addLocalEntry",
"code": "def ScopedEnvExtension.addLocalEntry (ext : ScopedEnvExtension α β σ) (env : Environment) (b : β) : Environment :=\n let s := ext.ext.getState env\n match s.stateStack with\n | [] => env\n | top :: states =>\n let top := { top with state := ext.descr.addEntry top.state b }\n ext.ext.setState env { s with stateStack := top :: states }",
"start": [
141,
1
],
"end": [
147,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.addCore",
"code": "def ScopedEnvExtension.addCore (env : Environment) (ext : ScopedEnvExtension α β σ) (b : β) (kind : AttributeKind) (namespaceName : Name) : Environment :=\n match kind with\n | AttributeKind.global => ext.addEntry env b\n | AttributeKind.local => ext.addLocalEntry env b\n | AttributeKind.scoped => ext.addScopedEntry env namespaceName b",
"start": [
149,
1
],
"end": [
153,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.add",
"code": "def ScopedEnvExtension.add [Monad m] [MonadResolveName m] [MonadEnv m] (ext : ScopedEnvExtension α β σ) (b : β) (kind := AttributeKind.global) : m Unit := do\n let ns ← getCurrNamespace\n modifyEnv (ext.addCore · b kind ns)",
"start": [
155,
1
],
"end": [
157,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.getState",
"code": "def ScopedEnvExtension.getState [Inhabited σ] (ext : ScopedEnvExtension α β σ) (env : Environment) : σ :=\n match ext.ext.getState env |>.stateStack with\n | top :: _ => top.state\n | _ => unreachable!",
"start": [
159,
1
],
"end": [
162,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.activateScoped",
"code": "def ScopedEnvExtension.activateScoped (ext : ScopedEnvExtension α β σ) (env : Environment) (namespaceName : Name) : Environment :=\n let s := ext.ext.getState env\n match s.stateStack with\n | top :: stack =>\n if top.activeScopes.contains namespaceName then\n env\n else\n let activeScopes := top.activeScopes.insert namespaceName\n let top :=\n match s.scopedEntries.map.find? namespaceName with\n | none =>\n { top with activeScopes := activeScopes }\n | some bs => Id.run do\n let mut state := top.state\n for b in bs do\n state := ext.descr.addEntry state b\n { state := state, activeScopes := activeScopes }\n ext.ext.setState env { s with stateStack := top :: stack }\n | _ => env",
"start": [
164,
1
],
"end": [
182,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ScopedEnvExtension.modifyState",
"code": "def ScopedEnvExtension.modifyState (ext : ScopedEnvExtension α β σ) (env : Environment) (f : σ → σ) : Environment :=\n let s := ext.ext.getState env\n match s.stateStack with\n | top :: stack => ext.ext.setState env { s with stateStack := { top with state := f top.state } :: stack }\n | _ => env",
"start": [
184,
1
],
"end": [
188,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.pushScope",
"code": "def pushScope [Monad m] [MonadEnv m] [MonadLiftT (ST IO.RealWorld) m] : m Unit := do\n for ext in (← scopedEnvExtensionsRef.get) do\n modifyEnv ext.pushScope",
"start": [
190,
1
],
"end": [
192,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.popScope",
"code": "def popScope [Monad m] [MonadEnv m] [MonadLiftT (ST IO.RealWorld) m] : m Unit := do\n for ext in (← scopedEnvExtensionsRef.get) do\n modifyEnv ext.popScope",
"start": [
194,
1
],
"end": [
196,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.activateScoped",
"code": "def activateScoped [Monad m] [MonadEnv m] [MonadLiftT (ST IO.RealWorld) m] (namespaceName : Name) : m Unit := do\n for ext in (← scopedEnvExtensionsRef.get) do\n modifyEnv (ext.activateScoped · namespaceName)",
"start": [
198,
1
],
"end": [
200,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimpleScopedEnvExtension",
"code": "abbrev SimpleScopedEnvExtension (α : Type) (σ : Type) := ScopedEnvExtension α α σ",
"start": [
202,
1
],
"end": [
202,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.SimpleScopedEnvExtension.Descr",
"code": "structure SimpleScopedEnvExtension.Descr (α : Type) (σ : Type) where\n name : Name := by exact decl_name%\n addEntry : σ → α → σ\n initial : σ\n finalizeImport : σ → σ := id",
"start": [
204,
1
],
"end": [
208,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerSimpleScopedEnvExtension",
"code": "def registerSimpleScopedEnvExtension (descr : SimpleScopedEnvExtension.Descr α σ) : IO (SimpleScopedEnvExtension α σ) := do\n registerScopedEnvExtension {\n name := descr.name\n mkInitial := return descr.initial\n addEntry := descr.addEntry\n toOLeanEntry := id\n ofOLeanEntry := fun _ a => return a\n finalizeImport := descr.finalizeImport\n }",
"start": [
210,
1
],
"end": [
218,
4
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/InlineAttrs.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean"
] | [
{
"full_name": "Lean.Compiler.InlineAttributeKind",
"code": "inductive InlineAttributeKind where\n | inline | noinline | macroInline | inlineIfReduce | alwaysInline\n deriving Inhabited, BEq, Hashable",
"start": [
12,
1
],
"end": [
14,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.isValidMacroInline",
"code": "private def isValidMacroInline (declName : Name) : CoreM Bool := do\n let .defnInfo info ← getConstInfo declName\n | return false\n unless info.all.length = 1 do\n return false\n let env ← getEnv\n let isRec (declName' : Name) : Bool :=\n isBRecOnRecursor env declName' ||\n declName' == ``WellFounded.fix ||\n declName' == declName ++ `_unary if Option.isSome <| info.value.find? fun e => e.isConst && isRec e.constName! then\n return false\n return true",
"start": [
16,
1
],
"end": [
33,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.setInlineAttribute",
"code": "def setInlineAttribute (env : Environment) (declName : Name) (kind : InlineAttributeKind) : Except String Environment :=\n inlineAttrs.setValue env declName kind",
"start": [
48,
1
],
"end": [
49,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.getInlineAttribute?",
"code": "def getInlineAttribute? (env : Environment) (declName : Name) : Option InlineAttributeKind :=\n inlineAttrs.getValue env declName",
"start": [
51,
1
],
"end": [
52,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasInlineAttrCore",
"code": "private def hasInlineAttrCore (env : Environment) (kind : InlineAttributeKind) (declName : Name) : Bool :=\n match inlineAttrs.getValue env declName with\n | some k => kind == k\n | _ => false",
"start": [
54,
1
],
"end": [
57,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasInlineAttribute",
"code": "abbrev hasInlineAttribute (env : Environment) (declName : Name) : Bool :=\n hasInlineAttrCore env .inline declName",
"start": [
59,
1
],
"end": [
60,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasInlineIfReduceAttribute",
"code": "def hasInlineIfReduceAttribute (env : Environment) (declName : Name) : Bool :=\n hasInlineAttrCore env .inlineIfReduce declName",
"start": [
62,
1
],
"end": [
63,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasNoInlineAttribute",
"code": "def hasNoInlineAttribute (env : Environment) (declName : Name) : Bool :=\n hasInlineAttrCore env .noinline declName",
"start": [
65,
1
],
"end": [
66,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasMacroInlineAttribute",
"code": "def hasMacroInlineAttribute (env : Environment) (declName : Name) : Bool :=\n hasInlineAttrCore env .macroInline declName",
"start": [
68,
1
],
"end": [
69,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasAlwaysInlineAttribute",
"code": "abbrev hasAlwaysInlineAttribute (env : Environment) (declName : Name) : Bool :=\n hasInlineAttrCore env .alwaysInline declName",
"start": [
71,
1
],
"end": [
72,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasInlineAttrAux",
"code": "private partial def hasInlineAttrAux (env : Environment) (kind : InlineAttributeKind) (n : Name) : Bool :=\n \n if isEagerLambdaLiftingName n then false\n else match inlineAttrs.getValue env n with\n | some k => kind == k\n | none => if n.isInternal then hasInlineAttrAux env kind n.getPrefix else false",
"start": [
76,
1
],
"end": [
81,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasInlineAttributeOld",
"code": "@[export lean_has_inline_attribute]\ndef hasInlineAttributeOld (env : Environment) (n : Name) : Bool :=\n hasInlineAttrAux env InlineAttributeKind.inline n",
"start": [
83,
1
],
"end": [
85,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasInlineIfReduceAttributeOld",
"code": "@[export lean_has_inline_if_reduce_attribute]\ndef hasInlineIfReduceAttributeOld (env : Environment) (n : Name) : Bool :=\n hasInlineAttrAux env InlineAttributeKind.inlineIfReduce n",
"start": [
87,
1
],
"end": [
89,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasNoInlineAttributeOld",
"code": "@[export lean_has_noinline_attribute]\ndef hasNoInlineAttributeOld (env : Environment) (n : Name) : Bool :=\n hasInlineAttrAux env InlineAttributeKind.noinline n",
"start": [
91,
1
],
"end": [
93,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Compiler.hasMacroInlineAttributeOld",
"code": "@[export lean_has_macro_inline_attribute]\ndef hasMacroInlineAttributeOld (env : Environment) (n : Name) : Bool :=\n hasInlineAttrAux env InlineAttributeKind.macroInline n",
"start": [
95,
1
],
"end": [
97,
57
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Class.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean"
] | [
{
"full_name": "Lean.ClassEntry",
"code": "structure ClassEntry where\n \n name : Name\n \n outParams : Array Nat",
"start": [
11,
1
],
"end": [
23,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ClassEntry.lt",
"code": "def lt (a b : ClassEntry) : Bool :=\n Name.quickLt a.name b.name",
"start": [
27,
1
],
"end": [
28,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ClassState",
"code": "structure ClassState where\n outParamMap : SMap Name (Array Nat) := SMap.empty\n deriving Inhabited",
"start": [
32,
1
],
"end": [
35,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ClassState.addEntry",
"code": "def addEntry (s : ClassState) (entry : ClassEntry) : ClassState :=\n { s with outParamMap := s.outParamMap.insert entry.name entry.outParams }",
"start": [
39,
1
],
"end": [
40,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ClassState.switch",
"code": "def switch (s : ClassState) : ClassState :=\n { s with outParamMap := s.outParamMap.switch }",
"start": [
42,
1
],
"end": [
48,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isClass",
"code": "@[export lean_is_class]\ndef isClass (env : Environment) (n : Name) : Bool :=\n (classExtension.getState env).outParamMap.contains n",
"start": [
62,
1
],
"end": [
65,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getOutParamPositions?",
"code": "def getOutParamPositions? (env : Environment) (declName : Name) : Option (Array Nat) :=\n (classExtension.getState env).outParamMap.find? declName",
"start": [
67,
1
],
"end": [
69,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasOutParams",
"code": "@[export lean_has_out_params]\ndef hasOutParams (env : Environment) (declName : Name) : Bool :=\n match getOutParamPositions? env declName with\n | some outParams => !outParams.isEmpty\n | none => false",
"start": [
71,
1
],
"end": [
76,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.checkOutParam",
"code": "private partial def checkOutParam (i : Nat) (outParamFVarIds : Array FVarId) (outParams : Array Nat) (type : Expr) : Except String (Array Nat) :=\n match type with\n | .forallE _ d b bi =>\n let addOutParam (_ : Unit) :=\n let fvarId := { name := Name.mkNum `_fvar outParamFVarIds.size }\n let fvar := mkFVar fvarId\n let b := b.instantiate1 fvar\n checkOutParam (i+1) (outParamFVarIds.push fvarId) (outParams.push i) b\n if d.isOutParam then\n addOutParam ()\n else if d.hasAnyFVar fun fvarId => outParamFVarIds.contains fvarId then\n if bi.isInstImplicit then\n \n addOutParam ()\n else\n Except.error s!\"invalid class, parameter #{i+1} depends on `outParam`, but it is not an `outParam`\"\n else\n checkOutParam (i+1) outParamFVarIds outParams b\n | _ => return outParams",
"start": [
78,
1
],
"end": [
108,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkOutParamArgsImplicit",
"code": "@[export lean_mk_outparam_args_implicit]\npartial def mkOutParamArgsImplicit (type : Expr) : Expr :=\n go type type #[]\nwhere\n go (type : Expr) (typeAux : Expr) (outParamFVarIds : Array FVarId) : Expr :=\n match typeAux with\n | .forallE _ d b bi =>\n let mkOutParamImplicit (dNew : Expr) :=\n let fvarId := { name := Name.mkNum `_fvar outParamFVarIds.size }\n let fvar := mkFVar fvarId\n let b := b.instantiate1 fvar\n let bNew := go type.bindingBody! b (outParamFVarIds.push fvarId)\n type.updateForall! .implicit dNew bNew\n let keepBinderInfo (_ : Unit) :=\n let bNew := go type.bindingBody! b outParamFVarIds\n type.updateForallE! type.bindingDomain! bNew\n if d.isOutParam then\n mkOutParamImplicit type.bindingDomain!.appArg! else if d.hasAnyFVar fun fvarId => outParamFVarIds.contains fvarId then\n if bi.isInstImplicit then\n mkOutParamImplicit type.bindingDomain!\n else\n keepBinderInfo ()\n else\n keepBinderInfo ()\n | _ => type",
"start": [
110,
1
],
"end": [
143,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addClass",
"code": "def addClass (env : Environment) (clsName : Name) : Except String Environment := do\n if isClass env clsName then\n throw s!\"class has already been declared '{clsName}'\"\n let some decl := env.find? clsName\n | throw s!\"unknown declaration '{clsName}'\"\n unless decl matches .inductInfo .. | .axiomInfo .. do\n throw s!\"invalid 'class', declaration '{clsName}' must be inductive datatype, structure, or constant\"\n let outParams ← checkOutParam 0 #[] #[] decl.type\n return classExtension.addEntry env { name := clsName, outParams }",
"start": [
145,
1
],
"end": [
160,
68
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Util/MonadBacktrack.lean | [
".lake/packages/lean4/src/lean/Init/Control/Except.lean"
] | [
{
"full_name": "Lean.MonadBacktrack",
"code": "class MonadBacktrack (s : outParam Type) (m : Type → Type) where\n saveState : m s\n restoreState : s → m Unit",
"start": [
11,
1
],
"end": [
14,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.commitWhenSome?",
"code": "def commitWhenSome? [Monad m] [MonadBacktrack s m] [MonadExcept ε m] (x? : m (Option α)) : m (Option α) := do\n let s ← saveState\n try\n match (← x?) with\n | some a => return some a\n | none =>\n restoreState s\n return none\n catch ex =>\n restoreState s\n throw ex",
"start": [
18,
1
],
"end": [
31,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.commitWhenSomeNoEx?",
"code": "def commitWhenSomeNoEx? [Monad m] [MonadBacktrack s m] [MonadExcept ε m] (x? : m (Option α)) : m (Option α) :=\n try\n commitWhenSome? x?\n catch _ =>\n return none",
"start": [
33,
1
],
"end": [
42,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.commitWhen",
"code": "def commitWhen [Monad m] [MonadBacktrack s m] [MonadExcept ε m] (x : m Bool) : m Bool := do\n let s ← saveState\n try\n match (← x) with\n | true => pure true\n | false =>\n restoreState s\n pure false\n catch ex =>\n restoreState s\n throw ex",
"start": [
44,
1
],
"end": [
54,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.commitIfNoEx",
"code": "def commitIfNoEx [Monad m] [MonadBacktrack s m] [MonadExcept ε m] (x : m α) : m α := do\n let s ← saveState\n try\n x\n catch ex =>\n restoreState s\n throw ex",
"start": [
56,
1
],
"end": [
62,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.withoutModifyingState",
"code": "def withoutModifyingState [Monad m] [MonadFinally m] [MonadBacktrack s m] (x : m α) : m α := do\n let s ← saveState\n try\n x\n finally\n restoreState s",
"start": [
64,
1
],
"end": [
69,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.observing?",
"code": "def observing? [Monad m] [MonadBacktrack s m] [MonadExcept ε m] (x : m α) : m (Option α) := do\n let s ← saveState\n try\n x\n catch _ =>\n restoreState s\n return none",
"start": [
71,
1
],
"end": [
77,
16
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ReducibilityAttrs.lean | [
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean"
] | [
{
"full_name": "Lean.ReducibilityStatus",
"code": "inductive ReducibilityStatus where\n | reducible | semireducible | irreducible\n deriving Inhabited, Repr, BEq",
"start": [
12,
1
],
"end": [
17,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ReducibilityStatus.toAttrString",
"code": "def ReducibilityStatus.toAttrString : ReducibilityStatus → String\n | .reducible => \"[reducible]\"\n | .irreducible => \"[irreducible]\"\n | .semireducible => \"[semireducible]\"",
"start": [
19,
1
],
"end": [
22,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getReducibilityStatusCore",
"code": "@[export lean_get_reducibility_status]\ndef getReducibilityStatusCore (env : Environment) (declName : Name) : ReducibilityStatus :=\n let m := reducibilityExtraExt.getState env\n if let some status := m.find? declName then\n status\n else match env.getModuleIdxFor? declName with\n | some modIdx =>\n match (reducibilityCoreExt.getModuleEntries env modIdx).binSearch (declName, .semireducible) (fun a b => Name.quickLt a.1 b.1) with\n | some (_, status) => status\n | none => .semireducible\n | none => (reducibilityCoreExt.getState env).find? declName |>.getD .semireducible",
"start": [
44,
1
],
"end": [
54,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setReducibilityStatusCore",
"code": "private def setReducibilityStatusCore (env : Environment) (declName : Name) (status : ReducibilityStatus) (attrKind : AttributeKind) (currNamespace : Name) : Environment :=\n if attrKind matches .global then\n match env.getModuleIdxFor? declName with\n | some _ =>\n reducibilityExtraExt.addEntry env (declName, status)\n | none =>\n reducibilityCoreExt.addEntry env (declName, status)\n else\n reducibilityExtraExt.addCore env (declName, status) attrKind currNamespace",
"start": [
56,
1
],
"end": [
67,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setReducibilityStatusImp",
"code": "@[export lean_set_reducibility_status]\nprivate def setReducibilityStatusImp (env : Environment) (declName : Name) (status : ReducibilityStatus) : Environment :=\n setReducibilityStatusCore env declName status .global .anonymous",
"start": [
69,
1
],
"end": [
71,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.validate",
"code": "private def validate (declName : Name) (status : ReducibilityStatus) (attrKind : AttributeKind) : CoreM Unit := do\n let suffix := \"use `set_option allowUnsafeReducibility true` to override reducibility status validation\"\n unless allowUnsafeReducibility.get (← getOptions) do\n match (← getConstInfo declName) with\n | .defnInfo _ =>\n let statusOld := getReducibilityStatusCore (← getEnv) declName\n match attrKind with\n | .scoped =>\n throwError \"failed to set reducibility status for `{declName}`, the `scoped` modifier is not recommended for this kind of attribute\\n{suffix}\"\n | .global =>\n if (← getEnv).getModuleIdxFor? declName matches some _ then\n throwError \"failed to set reducibility status, `{declName}` has not been defined in this file, consider using the `local` modifier\\n{suffix}\"\n match status with\n | .reducible =>\n unless statusOld matches .semireducible do\n throwError \"failed to set `[reducible]`, `{declName}` is not currently `[semireducible]`, but `{statusOld.toAttrString}`\\n{suffix}\"\n | .irreducible =>\n unless statusOld matches .semireducible do\n throwError \"failed to set `[irreducible]`, `{declName}` is not currently `[semireducible]`, but `{statusOld.toAttrString}`\\n{suffix}\"\n | .semireducible =>\n throwError \"failed to set `[semireducible]` for `{declName}`, declarations are `[semireducible]` by default\\n{suffix}\"\n | .local =>\n match status with\n | .reducible =>\n throwError \"failed to set `[local reducible]` for `{declName}`, recall that `[reducible]` affects the term indexing datastructures used by `simp` and type class resolution\\n{suffix}\"\n | .irreducible =>\n unless statusOld matches .semireducible do\n throwError \"failed to set `[local irreducible]`, `{declName}` is currently `{statusOld.toAttrString}`, `[semireducible]` expected\\n{suffix}\"\n | .semireducible =>\n unless statusOld matches .irreducible do\n throwError \"failed to set `[local semireducible]`, `{declName}` is currently `{statusOld.toAttrString}`, `[irreducible]` expected\\n{suffix}\"\n | _ => throwError \"failed to set reducibility status, `{declName}` is not a definition\\n{suffix}\"",
"start": [
97,
1
],
"end": [
128,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addAttr",
"code": "private def addAttr (status : ReducibilityStatus) (declName : Name) (stx : Syntax) (attrKind : AttributeKind) : AttrM Unit := do\n Attribute.Builtin.ensureNoArgs stx\n validate declName status attrKind\n let ns ← getCurrNamespace\n modifyEnv fun env => setReducibilityStatusCore env declName status attrKind ns",
"start": [
130,
1
],
"end": [
134,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getReducibilityStatus",
"code": "def getReducibilityStatus [Monad m] [MonadEnv m] (declName : Name) : m ReducibilityStatus := do\n return getReducibilityStatusCore (← getEnv) declName",
"start": [
163,
1
],
"end": [
165,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setReducibilityStatus",
"code": "def setReducibilityStatus [MonadEnv m] (declName : Name) (s : ReducibilityStatus) : m Unit :=\n modifyEnv fun env => setReducibilityStatusCore env declName s .global .anonymous",
"start": [
167,
1
],
"end": [
169,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setReducibleAttribute",
"code": "def setReducibleAttribute [MonadEnv m] (declName : Name) : m Unit :=\n setReducibilityStatus declName ReducibilityStatus.reducible",
"start": [
171,
1
],
"end": [
173,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isReducible",
"code": "def isReducible [Monad m] [MonadEnv m] (declName : Name) : m Bool := do\n match (← getReducibilityStatus declName) with\n | .reducible => return true\n | _ => return false",
"start": [
175,
1
],
"end": [
179,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isIrreducible",
"code": "def isIrreducible [Monad m] [MonadEnv m] (declName : Name) : m Bool := do\n match (← getReducibilityStatus declName) with\n | .irreducible => return true\n | _ => return false",
"start": [
181,
1
],
"end": [
185,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setIrreducibleAttribute",
"code": "def setIrreducibleAttribute [MonadEnv m] (declName : Name) : m Unit :=\n setReducibilityStatus declName ReducibilityStatus.irreducible",
"start": [
187,
1
],
"end": [
189,
64
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/TransparencyMode.lean | [
".lake/packages/lean4/src/lean/Init/Data/UInt/Basic.lean"
] | [
{
"full_name": "Lean.Meta.TransparencyMode.hash",
"code": "def hash : TransparencyMode → UInt64\n | all => 7\n | default => 11\n | reducible => 13\n | instances => 17",
"start": [
12,
1
],
"end": [
16,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.TransparencyMode.lt",
"code": "def lt : TransparencyMode → TransparencyMode → Bool\n | reducible, default => true\n | reducible, all => true\n | reducible, instances => true\n | instances, default => true\n | instances, all => true\n | default, all => true\n | _, _ => false",
"start": [
20,
1
],
"end": [
27,
34
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/LOption.lean | [
".lake/packages/lean4/src/lean/Init/Data/ToString/Basic.lean"
] | [
{
"full_name": "Lean.LOption",
"code": "inductive LOption (α : Type u) where\n | none : LOption α\n | some : α → LOption α\n | undef : LOption α\n deriving Inhabited, BEq",
"start": [
12,
1
],
"end": [
16,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Option.toLOption",
"code": "def Option.toLOption {α : Type u} : Option α → Lean.LOption α\n | none => .none\n | some a => .some a",
"start": [
26,
1
],
"end": [
28,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "toLOptionM",
"code": "@[inline] def toLOptionM {α} {m : Type → Type} [Monad m] (x : m (Option α)) : m (Lean.LOption α) := do\n let b ← x\n return b.toLOption",
"start": [
30,
1
],
"end": [
32,
21
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/LBool.lean | [
".lake/packages/lean4/src/lean/Init/Data/ToString/Basic.lean"
] | [
{
"full_name": "Lean.LBool",
"code": "inductive LBool where\n | false\n | true\n | undef\n deriving Inhabited, BEq",
"start": [
11,
1
],
"end": [
15,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LBool.neg",
"code": "def neg : LBool → LBool\n | true => false\n | false => true\n | undef => undef",
"start": [
19,
1
],
"end": [
22,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LBool.and",
"code": "def and : LBool → LBool → LBool\n | true, b => b\n | a, _ => a",
"start": [
24,
1
],
"end": [
26,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LBool.toString",
"code": "def toString : LBool → String\n | true => \"true\"\n | false => \"false\"\n | undef => \"undef\"",
"start": [
28,
1
],
"end": [
31,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Bool.toLBool",
"code": "def Bool.toLBool : Bool → Lean.LBool\n | true => Lean.LBool.true\n | false => Lean.LBool.false",
"start": [
39,
1
],
"end": [
41,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "toLBoolM",
"code": "@[inline] def toLBoolM {m : Type → Type} [Monad m] (x : m Bool) : m Lean.LBool := do\n let b ← x\n pure b.toLBool",
"start": [
43,
1
],
"end": [
45,
17
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Data/LOption.lean",
".lake/packages/lean4/src/lean/Lean/Util/ReplaceExpr.lean",
".lake/packages/lean4/src/lean/Lean/Meta/TransparencyMode.lean",
".lake/packages/lean4/src/lean/Lean/ReducibilityAttrs.lean",
".lake/packages/lean4/src/lean/Lean/Util/MonadBacktrack.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean",
".lake/packages/lean4/src/lean/Lean/Class.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/InlineAttrs.lean"
] | [
{
"full_name": "Lean.Meta.Config",
"code": "structure Config where\n \n foApprox : Bool := false\n \n ctxApprox : Bool := false\n \n quasiPatternApprox : Bool := false\n \n constApprox : Bool := false\n \n isDefEqStuckEx : Bool := false\n \n unificationHints : Bool := true\n \n proofIrrelevance : Bool := true\n \n assignSyntheticOpaque : Bool := false\n \n offsetCnstrs : Bool := true\n \n transparency : TransparencyMode := TransparencyMode.default\n \n trackZetaDelta : Bool := false\n \n etaStruct : EtaStructMode := .all\n \n univApprox : Bool := true",
"start": [
30,
1
],
"end": [
120,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ParamInfo",
"code": "structure ParamInfo where\n \n binderInfo : BinderInfo := BinderInfo.default\n \n hasFwdDeps : Bool := false\n \n backDeps : Array Nat := #[]\n \n isProp : Bool := false\n \n isDecInst : Bool := false\n \n higherOrderOutParam : Bool := false\n \n dependsOnHigherOrderOutParam : Bool := false\n deriving Inhabited",
"start": [
122,
1
],
"end": [
167,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ParamInfo.isImplicit",
"code": "def ParamInfo.isImplicit (p : ParamInfo) : Bool :=\n p.binderInfo == BinderInfo.implicit",
"start": [
169,
1
],
"end": [
170,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ParamInfo.isInstImplicit",
"code": "def ParamInfo.isInstImplicit (p : ParamInfo) : Bool :=\n p.binderInfo == BinderInfo.instImplicit",
"start": [
172,
1
],
"end": [
173,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ParamInfo.isStrictImplicit",
"code": "def ParamInfo.isStrictImplicit (p : ParamInfo) : Bool :=\n p.binderInfo == BinderInfo.strictImplicit",
"start": [
175,
1
],
"end": [
176,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ParamInfo.isExplicit",
"code": "def ParamInfo.isExplicit (p : ParamInfo) : Bool :=\n p.binderInfo == BinderInfo.default",
"start": [
178,
1
],
"end": [
179,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FunInfo",
"code": "structure FunInfo where\n \n paramInfo : Array ParamInfo := #[]\n \n resultDeps : Array Nat := #[]",
"start": [
182,
1
],
"end": [
192,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.InfoCacheKey",
"code": "structure InfoCacheKey where\n \n transparency : TransparencyMode\n \n expr : Expr\n \n nargs? : Option Nat\n deriving Inhabited, BEq",
"start": [
194,
1
],
"end": [
208,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstanceCacheKey",
"code": "structure SynthInstanceCacheKey where\n localInsts : LocalInstances\n type : Expr\n \n synthPendingDepth : Nat\n deriving Hashable, BEq",
"start": [
215,
1
],
"end": [
223,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.AbstractMVarsResult",
"code": "structure AbstractMVarsResult where\n paramNames : Array Name\n numMVars : Nat\n expr : Expr\n deriving Inhabited, BEq",
"start": [
225,
1
],
"end": [
230,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SynthInstanceCache",
"code": "abbrev SynthInstanceCache := PersistentHashMap SynthInstanceCacheKey (Option AbstractMVarsResult)",
"start": [
232,
1
],
"end": [
232,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.InferTypeCache",
"code": "abbrev InferTypeCache := PersistentExprStructMap Expr",
"start": [
234,
1
],
"end": [
234,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.FunInfoCache",
"code": "abbrev FunInfoCache := PersistentHashMap InfoCacheKey FunInfo",
"start": [
235,
1
],
"end": [
235,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.WhnfCache",
"code": "abbrev WhnfCache := PersistentExprStructMap Expr",
"start": [
236,
1
],
"end": [
236,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DefEqCache",
"code": "structure DefEqCache where\n reducible : PersistentHashMap (Expr × Expr) Bool := {}\n instances : PersistentHashMap (Expr × Expr) Bool := {}\n default : PersistentHashMap (Expr × Expr) Bool := {}\n all : PersistentHashMap (Expr × Expr) Bool := {}\n deriving Inhabited",
"start": [
238,
1
],
"end": [
247,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Cache",
"code": "structure Cache where\n inferType : InferTypeCache := {}\n funInfo : FunInfoCache := {}\n synthInstance : SynthInstanceCache := {}\n whnfDefault : WhnfCache := {} whnfAll : WhnfCache := {} defEqTrans : DefEqCache := {} defEqPerm : DefEqCache := {} deriving Inhabited",
"start": [
249,
1
],
"end": [
260,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.DefEqContext",
"code": "structure DefEqContext where\n lhs : Expr\n rhs : Expr\n lctx : LocalContext\n localInstances : LocalInstances",
"start": [
262,
1
],
"end": [
270,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.PostponedEntry",
"code": "structure PostponedEntry where\n \n ref : Syntax\n lhs : Level\n rhs : Level\n \n ctx? : Option DefEqContext\n deriving Inhabited",
"start": [
272,
1
],
"end": [
284,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Diagnostics",
"code": "structure Diagnostics where\n \n unfoldCounter : PHashMap Name Nat := {}\n \n heuristicCounter : PHashMap Name Nat := {}\n \n instanceCounter : PHashMap Name Nat := {}\n \n synthPendingFailures : PHashMap Expr MessageData := {}\n deriving Inhabited",
"start": [
286,
1
],
"end": [
295,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.State",
"code": "structure State where\n mctx : MetavarContext := {}\n cache : Cache := {}\n \n zetaDeltaFVarIds : FVarIdSet := {}\n \n postponed : PersistentArray PostponedEntry := {}\n diag : Diagnostics := {}\n deriving Inhabited",
"start": [
297,
1
],
"end": [
308,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SavedState",
"code": "structure SavedState where\n core : Core.SavedState\n meta : State\n deriving Nonempty",
"start": [
310,
1
],
"end": [
316,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.Context",
"code": "structure Context where\n config : Config := {}\n \n lctx : LocalContext := {}\n \n localInstances : LocalInstances := #[]\n \n defEqCtx? : Option DefEqContext := none\n \n synthPendingDepth : Nat := 0\n \n canUnfold? : Option (Config → ConstantInfo → CoreM Bool) := none\n \n univApprox : Bool := false\n \n inTypeClassResolution : Bool := false",
"start": [
323,
1
],
"end": [
355,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.MetaM",
"code": "abbrev MetaM := ReaderT Context $ StateRefT State CoreM",
"start": [
357,
1
],
"end": [
395,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.saveState",
"code": "protected def saveState : MetaM SavedState :=\n return { core := (← Core.saveState), meta := (← get) }",
"start": [
419,
1
],
"end": [
420,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.SavedState.restore",
"code": "def SavedState.restore (b : SavedState) : MetaM Unit := do\n b.core.restore\n modify fun s => { s with mctx := b.meta.mctx, zetaDeltaFVarIds := b.meta.zetaDeltaFVarIds, postponed := b.meta.postponed }",
"start": [
422,
1
],
"end": [
425,
125
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withRestoreOrSaveFull",
"code": "@[specialize, inherit_doc Core.withRestoreOrSaveFull]\ndef withRestoreOrSaveFull (reusableResult? : Option (α × SavedState)) (act : MetaM α) :\n MetaM (α × SavedState) := do\n if let some (_, state) := reusableResult? then\n set state.meta\n let reusableResult? := reusableResult?.map (fun (val, state) => (val, state.core))\n let (a, core) ← controlAt CoreM fun runInBase => do\n Core.withRestoreOrSaveFull reusableResult? <| runInBase act\n return (a, { core, meta := (← get) })",
"start": [
427,
1
],
"end": [
435,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.MetaM.run",
"code": "@[inline] def MetaM.run (x : MetaM α) (ctx : Context := {}) (s : State := {}) : CoreM (α × State) :=\n x ctx |>.run s",
"start": [
441,
1
],
"end": [
442,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.MetaM.run'",
"code": "@[inline] def MetaM.run' (x : MetaM α) (ctx : Context := {}) (s : State := {}) : CoreM α :=\n Prod.fst <$> x.run ctx s",
"start": [
444,
1
],
"end": [
445,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.MetaM.toIO",
"code": "@[inline] def MetaM.toIO (x : MetaM α) (ctxCore : Core.Context) (sCore : Core.State) (ctx : Context := {}) (s : State := {}) : IO (α × Core.State × State) := do\n let ((a, s), sCore) ← (x.run ctx s).toIO ctxCore sCore\n pure (a, sCore, s)",
"start": [
447,
1
],
"end": [
449,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwIsDefEqStuck",
"code": "protected def throwIsDefEqStuck : MetaM α :=\n throw <| Exception.internal isDefEqStuckExceptionId",
"start": [
454,
1
],
"end": [
455,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.liftMetaM",
"code": "@[inline] def liftMetaM [MonadLiftT MetaM m] (x : MetaM α) : m α :=\n liftM x",
"start": [
463,
1
],
"end": [
464,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mapMetaM",
"code": "@[inline] def mapMetaM [MonadControlT MetaM m] [Monad m] (f : forall {α}, MetaM α → MetaM α) {α} (x : m α) : m α :=\n controlAt MetaM fun runInBase => f <| runInBase x",
"start": [
466,
1
],
"end": [
467,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.map1MetaM",
"code": "@[inline] def map1MetaM [MonadControlT MetaM m] [Monad m] (f : forall {α}, (β → MetaM α) → MetaM α) {α} (k : β → m α) : m α :=\n controlAt MetaM fun runInBase => f fun b => runInBase <| k b",
"start": [
469,
1
],
"end": [
470,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.map2MetaM",
"code": "@[inline] def map2MetaM [MonadControlT MetaM m] [Monad m] (f : forall {α}, (β → γ → MetaM α) → MetaM α) {α} (k : β → γ → m α) : m α :=\n controlAt MetaM fun runInBase => f fun b c => runInBase <| k b c",
"start": [
472,
1
],
"end": [
473,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyCache",
"code": "@[inline] def modifyCache (f : Cache → Cache) : MetaM Unit :=\n modify fun { mctx, cache, zetaDeltaFVarIds, postponed, diag } => { mctx, cache := f cache, zetaDeltaFVarIds, postponed, diag }",
"start": [
478,
1
],
"end": [
479,
129
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyInferTypeCache",
"code": "@[inline] def modifyInferTypeCache (f : InferTypeCache → InferTypeCache) : MetaM Unit :=\n modifyCache fun ⟨ic, c1, c2, c3, c4, c5, c6⟩ => ⟨f ic, c1, c2, c3, c4, c5, c6⟩",
"start": [
481,
1
],
"end": [
482,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyDefEqTransientCache",
"code": "@[inline] def modifyDefEqTransientCache (f : DefEqCache → DefEqCache) : MetaM Unit :=\n modifyCache fun ⟨c1, c2, c3, c4, c5, defeqTrans, c6⟩ => ⟨c1, c2, c3, c4, c5, f defeqTrans, c6⟩",
"start": [
484,
1
],
"end": [
485,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyDefEqPermCache",
"code": "@[inline] def modifyDefEqPermCache (f : DefEqCache → DefEqCache) : MetaM Unit :=\n modifyCache fun ⟨c1, c2, c3, c4, c5, c6, defeqPerm⟩ => ⟨c1, c2, c3, c4, c5, c6, f defeqPerm⟩",
"start": [
487,
1
],
"end": [
488,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.resetDefEqPermCaches",
"code": "@[inline] def resetDefEqPermCaches : MetaM Unit :=\n modifyDefEqPermCache fun _ => {}",
"start": [
490,
1
],
"end": [
491,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyDiag",
"code": "@[inline] def modifyDiag (f : Diagnostics → Diagnostics) : MetaM Unit := do\n if (← isDiagnosticsEnabled) then\n modify fun { mctx, cache, zetaDeltaFVarIds, postponed, diag } => { mctx, cache, zetaDeltaFVarIds, postponed, diag := f diag }",
"start": [
493,
1
],
"end": [
495,
130
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.recordUnfold",
"code": "def recordUnfold (declName : Name) : MetaM Unit := do\n modifyDiag fun { unfoldCounter, heuristicCounter, instanceCounter, synthPendingFailures } =>\n let newC := if let some c := unfoldCounter.find? declName then c + 1 else 1\n { unfoldCounter := unfoldCounter.insert declName newC, heuristicCounter, instanceCounter, synthPendingFailures }",
"start": [
497,
1
],
"end": [
501,
117
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.recordDefEqHeuristic",
"code": "def recordDefEqHeuristic (declName : Name) : MetaM Unit := do\n modifyDiag fun { unfoldCounter, heuristicCounter, instanceCounter, synthPendingFailures } =>\n let newC := if let some c := heuristicCounter.find? declName then c + 1 else 1\n { unfoldCounter, heuristicCounter := heuristicCounter.insert declName newC, instanceCounter, synthPendingFailures }",
"start": [
503,
1
],
"end": [
507,
120
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.recordInstance",
"code": "def recordInstance (declName : Name) : MetaM Unit := do\n modifyDiag fun { unfoldCounter, heuristicCounter, instanceCounter, synthPendingFailures } =>\n let newC := if let some c := instanceCounter.find? declName then c + 1 else 1\n { unfoldCounter, heuristicCounter, instanceCounter := instanceCounter.insert declName newC, synthPendingFailures }",
"start": [
509,
1
],
"end": [
513,
119
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.recordSynthPendingFailure",
"code": "def recordSynthPendingFailure (type : Expr) : MetaM Unit := do\n if (← isDiagnosticsEnabled) then\n unless (← get).diag.synthPendingFailures.contains type do\n let msg ← addMessageContextFull m!\"{type}\"\n modifyDiag fun { unfoldCounter, heuristicCounter, instanceCounter, synthPendingFailures } =>\n { unfoldCounter, heuristicCounter, instanceCounter, synthPendingFailures := synthPendingFailures.insert type msg }",
"start": [
515,
1
],
"end": [
522,
123
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getLocalInstances",
"code": "def getLocalInstances : MetaM LocalInstances :=\n return (← read).localInstances",
"start": [
524,
1
],
"end": [
525,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getConfig",
"code": "def getConfig : MetaM Config :=\n return (← read).config",
"start": [
527,
1
],
"end": [
528,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.resetZetaDeltaFVarIds",
"code": "def resetZetaDeltaFVarIds : MetaM Unit :=\n modify fun s => { s with zetaDeltaFVarIds := {} }",
"start": [
530,
1
],
"end": [
531,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getZetaDeltaFVarIds",
"code": "def getZetaDeltaFVarIds : MetaM FVarIdSet :=\n return (← get).zetaDeltaFVarIds",
"start": [
533,
1
],
"end": [
534,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getPostponed",
"code": "def getPostponed : MetaM (PersistentArray PostponedEntry) :=\n return (← get).postponed",
"start": [
536,
1
],
"end": [
538,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setPostponed",
"code": "def setPostponed (postponed : PersistentArray PostponedEntry) : MetaM Unit :=\n modify fun s => { s with postponed := postponed }",
"start": [
540,
1
],
"end": [
542,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.modifyPostponed",
"code": "@[inline] def modifyPostponed (f : PersistentArray PostponedEntry → PersistentArray PostponedEntry) : MetaM Unit :=\n modify fun s => { s with postponed := f s.postponed }",
"start": [
544,
1
],
"end": [
546,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.useEtaStruct",
"code": "def useEtaStruct (inductName : Name) : MetaM Bool := do\n match (← getConfig).etaStruct with\n | .none => return false\n | .all => return true\n | .notClasses => return !isClass (← getEnv) inductName",
"start": [
548,
1
],
"end": [
561,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnf",
"code": "@[extern 6 \"lean_whnf\"] opaque whnf : Expr → MetaM Expr",
"start": [
568,
1
],
"end": [
571,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferType",
"code": "@[extern 6 \"lean_infer_type\"] opaque inferType : Expr → MetaM Expr",
"start": [
572,
1
],
"end": [
573,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isExprDefEqAux",
"code": "@[extern 7 \"lean_is_expr_def_eq\"] opaque isExprDefEqAux : Expr → Expr → MetaM Bool",
"start": [
574,
1
],
"end": [
574,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isLevelDefEqAux",
"code": "@[extern 7 \"lean_is_level_def_eq\"] opaque isLevelDefEqAux : Level → Level → MetaM Bool",
"start": [
575,
1
],
"end": [
575,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.synthPending",
"code": "@[extern 6 \"lean_synth_pending\"] protected opaque synthPending : MVarId → MetaM Bool",
"start": [
576,
1
],
"end": [
576,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfForall",
"code": "def whnfForall (e : Expr) : MetaM Expr := do\n let e' ← whnf e\n if e'.isForall then pure e' else pure e",
"start": [
578,
1
],
"end": [
580,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withIncRecDepth",
"code": "protected def withIncRecDepth (x : n α) : n α :=\n mapMetaM (withIncRecDepth (m := MetaM)) x",
"start": [
583,
1
],
"end": [
584,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVarAtCore",
"code": "private def mkFreshExprMVarAtCore\n (mvarId : MVarId) (lctx : LocalContext) (localInsts : LocalInstances) (type : Expr) (kind : MetavarKind) (userName : Name) (numScopeArgs : Nat) : MetaM Expr := do\n modifyMCtx fun mctx => mctx.addExprMVarDecl mvarId userName lctx localInsts type kind numScopeArgs;\n return mkMVar mvarId",
"start": [
586,
1
],
"end": [
589,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVarAt",
"code": "def mkFreshExprMVarAt\n (lctx : LocalContext) (localInsts : LocalInstances) (type : Expr)\n (kind : MetavarKind := MetavarKind.natural) (userName : Name := Name.anonymous) (numScopeArgs : Nat := 0)\n : MetaM Expr := do\n mkFreshExprMVarAtCore (← mkFreshMVarId) lctx localInsts type kind userName numScopeArgs",
"start": [
591,
1
],
"end": [
595,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshLevelMVar",
"code": "def mkFreshLevelMVar : MetaM Level := do\n let mvarId ← mkFreshLMVarId\n modifyMCtx fun mctx => mctx.addLevelMVarDecl mvarId;\n return mkLevelMVar mvarId",
"start": [
597,
1
],
"end": [
600,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVarCore",
"code": "private def mkFreshExprMVarCore (type : Expr) (kind : MetavarKind) (userName : Name) : MetaM Expr := do\n mkFreshExprMVarAt (← getLCtx) (← getLocalInstances) type kind userName",
"start": [
602,
1
],
"end": [
603,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVarImpl",
"code": "private def mkFreshExprMVarImpl (type? : Option Expr) (kind : MetavarKind) (userName : Name) : MetaM Expr :=\n match type? with\n | some type => mkFreshExprMVarCore type kind userName\n | none => do\n let u ← mkFreshLevelMVar\n let type ← mkFreshExprMVarCore (mkSort u) MetavarKind.natural Name.anonymous\n mkFreshExprMVarCore type kind userName",
"start": [
605,
1
],
"end": [
611,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVar",
"code": "def mkFreshExprMVar (type? : Option Expr) (kind := MetavarKind.natural) (userName := Name.anonymous) : MetaM Expr :=\n mkFreshExprMVarImpl type? kind userName",
"start": [
613,
1
],
"end": [
614,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshTypeMVar",
"code": "def mkFreshTypeMVar (kind := MetavarKind.natural) (userName := Name.anonymous) : MetaM Expr := do\n let u ← mkFreshLevelMVar\n mkFreshExprMVar (mkSort u) kind userName",
"start": [
616,
1
],
"end": [
618,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVarWithIdCore",
"code": "private def mkFreshExprMVarWithIdCore (mvarId : MVarId) (type : Expr)\n (kind : MetavarKind := MetavarKind.natural) (userName : Name := Name.anonymous) (numScopeArgs : Nat := 0)\n : MetaM Expr := do\n mkFreshExprMVarAtCore mvarId (← getLCtx) (← getLocalInstances) type kind userName numScopeArgs",
"start": [
620,
1
],
"end": [
625,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshExprMVarWithId",
"code": "def mkFreshExprMVarWithId (mvarId : MVarId) (type? : Option Expr := none) (kind : MetavarKind := MetavarKind.natural) (userName := Name.anonymous) : MetaM Expr :=\n match type? with\n | some type => mkFreshExprMVarWithIdCore mvarId type kind userName\n | none => do\n let u ← mkFreshLevelMVar\n let type ← mkFreshExprMVar (mkSort u)\n mkFreshExprMVarWithIdCore mvarId type kind userName",
"start": [
627,
1
],
"end": [
633,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshLevelMVars",
"code": "def mkFreshLevelMVars (num : Nat) : MetaM (List Level) :=\n num.foldM (init := []) fun _ us =>\n return (← mkFreshLevelMVar)::us",
"start": [
635,
1
],
"end": [
637,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFreshLevelMVarsFor",
"code": "def mkFreshLevelMVarsFor (info : ConstantInfo) : MetaM (List Level) :=\n mkFreshLevelMVars info.numLevelParams",
"start": [
639,
1
],
"end": [
640,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkConstWithFreshMVarLevels",
"code": "def mkConstWithFreshMVarLevels (declName : Name) : MetaM Expr := do\n let info ← getConstInfo declName\n return mkConst declName (← mkFreshLevelMVarsFor info)",
"start": [
642,
1
],
"end": [
648,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getTransparency",
"code": "def getTransparency : MetaM TransparencyMode :=\n return (← getConfig).transparency",
"start": [
650,
1
],
"end": [
652,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.shouldReduceAll",
"code": "def shouldReduceAll : MetaM Bool :=\n return (← getTransparency) == TransparencyMode.all",
"start": [
654,
1
],
"end": [
655,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.shouldReduceReducibleOnly",
"code": "def shouldReduceReducibleOnly : MetaM Bool :=\n return (← getTransparency) == TransparencyMode.reducible",
"start": [
657,
1
],
"end": [
658,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.findDecl?",
"code": "def _root_.Lean.MVarId.findDecl? (mvarId : MVarId) : MetaM (Option MetavarDecl) :=\n return (← getMCtx).findDecl? mvarId",
"start": [
660,
1
],
"end": [
665,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.findMVarDecl?",
"code": "@[deprecated MVarId.findDecl? (since := \"2022-07-15\")]\ndef findMVarDecl? (mvarId : MVarId) : MetaM (Option MetavarDecl) :=\n mvarId.findDecl?",
"start": [
667,
1
],
"end": [
669,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.getDecl",
"code": "def _root_.Lean.MVarId.getDecl (mvarId : MVarId) : MetaM MetavarDecl := do\n match (← mvarId.findDecl?) with\n | some d => pure d\n | none => throwError \"unknown metavariable '?{mvarId.name}'\"",
"start": [
671,
1
],
"end": [
678,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarDecl",
"code": "@[deprecated MVarId.getDecl (since := \"2022-07-15\")]\ndef getMVarDecl (mvarId : MVarId) : MetaM MetavarDecl := do\n mvarId.getDecl",
"start": [
680,
1
],
"end": [
682,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.getKind",
"code": "def _root_.Lean.MVarId.getKind (mvarId : MVarId) : MetaM MetavarKind :=\n return (← mvarId.getDecl).kind",
"start": [
684,
1
],
"end": [
688,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getMVarDeclKind",
"code": "@[deprecated MVarId.getKind (since := \"2022-07-15\")]\ndef getMVarDeclKind (mvarId : MVarId) : MetaM MetavarKind :=\n mvarId.getKind",
"start": [
690,
1
],
"end": [
692,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isSyntheticMVar",
"code": "def isSyntheticMVar (e : Expr) : MetaM Bool := do\n if e.isMVar then\n return (← e.mvarId!.getKind) matches .synthetic | .syntheticOpaque\n else\n return false",
"start": [
694,
1
],
"end": [
699,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.setKind",
"code": "def _root_.Lean.MVarId.setKind (mvarId : MVarId) (kind : MetavarKind) : MetaM Unit :=\n modifyMCtx fun mctx => mctx.setMVarKind mvarId kind",
"start": [
701,
1
],
"end": [
705,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setMVarKind",
"code": "@[deprecated MVarId.setKind (since := \"2022-07-15\")]\ndef setMVarKind (mvarId : MVarId) (kind : MetavarKind) : MetaM Unit :=\n mvarId.setKind kind",
"start": [
707,
1
],
"end": [
709,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.setType",
"code": "def _root_.Lean.MVarId.setType (mvarId : MVarId) (type : Expr) : MetaM Unit := do\n modifyMCtx fun mctx => mctx.setMVarType mvarId type",
"start": [
711,
1
],
"end": [
714,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setMVarType",
"code": "@[deprecated MVarId.setType (since := \"2022-07-15\")]\ndef setMVarType (mvarId : MVarId) (type : Expr) : MetaM Unit := do\n mvarId.setType type",
"start": [
716,
1
],
"end": [
718,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isReadOnly",
"code": "def _root_.Lean.MVarId.isReadOnly (mvarId : MVarId) : MetaM Bool := do\n return (← mvarId.getDecl).depth != (← getMCtx).depth",
"start": [
720,
1
],
"end": [
725,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isReadOnlyExprMVar",
"code": "@[deprecated MVarId.isReadOnly (since := \"2022-07-15\")]\ndef isReadOnlyExprMVar (mvarId : MVarId) : MetaM Bool := do\n mvarId.isReadOnly",
"start": [
727,
1
],
"end": [
729,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.isReadOnlyOrSyntheticOpaque",
"code": "def _root_.Lean.MVarId.isReadOnlyOrSyntheticOpaque (mvarId : MVarId) : MetaM Bool := do\n let mvarDecl ← mvarId.getDecl\n if mvarDecl.depth != (← getMCtx).depth then\n return true\n else\n match mvarDecl.kind with\n | MetavarKind.syntheticOpaque => return !(← getConfig).assignSyntheticOpaque\n | _ => return false",
"start": [
731,
1
],
"end": [
743,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isReadOnlyOrSyntheticOpaqueExprMVar",
"code": "@[deprecated MVarId.isReadOnlyOrSyntheticOpaque (since := \"2022-07-15\")]\ndef isReadOnlyOrSyntheticOpaqueExprMVar (mvarId : MVarId) : MetaM Bool := do\n mvarId.isReadOnlyOrSyntheticOpaque",
"start": [
745,
1
],
"end": [
747,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LMVarId.getLevel",
"code": "def _root_.Lean.LMVarId.getLevel (mvarId : LMVarId) : MetaM Nat := do\n match (← getMCtx).findLevelDepth? mvarId with\n | some depth => return depth\n | _ => throwError \"unknown universe metavariable '?{mvarId.name}'\"",
"start": [
749,
1
],
"end": [
755,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getLevelMVarDepth",
"code": "@[deprecated LMVarId.getLevel (since := \"2022-07-15\")]\ndef getLevelMVarDepth (mvarId : LMVarId) : MetaM Nat :=\n mvarId.getLevel",
"start": [
757,
1
],
"end": [
759,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.LMVarId.isReadOnly",
"code": "def _root_.Lean.LMVarId.isReadOnly (mvarId : LMVarId) : MetaM Bool :=\n return (← mvarId.getLevel) < (← getMCtx).levelAssignDepth",
"start": [
761,
1
],
"end": [
766,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isReadOnlyLevelMVar",
"code": "@[deprecated LMVarId.isReadOnly (since := \"2022-07-15\")]\ndef isReadOnlyLevelMVar (mvarId : LMVarId) : MetaM Bool := do\n mvarId.isReadOnly",
"start": [
768,
1
],
"end": [
770,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.setUserName",
"code": "def _root_.Lean.MVarId.setUserName (mvarId : MVarId) (newUserName : Name) : MetaM Unit :=\n modifyMCtx fun mctx => mctx.setMVarUserName mvarId newUserName",
"start": [
772,
1
],
"end": [
776,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setMVarUserName",
"code": "@[deprecated MVarId.setUserName (since := \"2022-07-15\")]\ndef setMVarUserName (mvarId : MVarId) (userNameNew : Name) : MetaM Unit :=\n mvarId.setUserName userNameNew",
"start": [
778,
1
],
"end": [
780,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.throwUnknown",
"code": "def _root_.Lean.FVarId.throwUnknown (fvarId : FVarId) : CoreM α :=\n throwError \"unknown free variable '{mkFVar fvarId}'\"",
"start": [
782,
1
],
"end": [
786,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwUnknownFVar",
"code": "@[deprecated FVarId.throwUnknown (since := \"2022-07-15\")]\ndef throwUnknownFVar (fvarId : FVarId) : MetaM α :=\n fvarId.throwUnknown",
"start": [
788,
1
],
"end": [
790,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.findDecl?",
"code": "def _root_.Lean.FVarId.findDecl? (fvarId : FVarId) : MetaM (Option LocalDecl) :=\n return (← getLCtx).find? fvarId",
"start": [
792,
1
],
"end": [
796,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.findLocalDecl?",
"code": "@[deprecated FVarId.findDecl? (since := \"2022-07-15\")]\ndef findLocalDecl? (fvarId : FVarId) : MetaM (Option LocalDecl) :=\n fvarId.findDecl?",
"start": [
798,
1
],
"end": [
800,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.getDecl",
"code": "def _root_.Lean.FVarId.getDecl (fvarId : FVarId) : MetaM LocalDecl := do\n match (← getLCtx).find? fvarId with\n | some d => return d\n | none => fvarId.throwUnknown",
"start": [
802,
1
],
"end": [
809,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getLocalDecl",
"code": "@[deprecated FVarId.getDecl (since := \"2022-07-15\")]\ndef getLocalDecl (fvarId : FVarId) : MetaM LocalDecl := do\n fvarId.getDecl",
"start": [
811,
1
],
"end": [
813,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.getType",
"code": "def _root_.Lean.FVarId.getType (fvarId : FVarId) : MetaM Expr :=\n return (← fvarId.getDecl).type",
"start": [
815,
1
],
"end": [
817,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.getBinderInfo",
"code": "def _root_.Lean.FVarId.getBinderInfo (fvarId : FVarId) : MetaM BinderInfo :=\n return (← fvarId.getDecl).binderInfo",
"start": [
819,
1
],
"end": [
821,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.getValue?",
"code": "def _root_.Lean.FVarId.getValue? (fvarId : FVarId) : MetaM (Option Expr) :=\n return (← fvarId.getDecl).value?",
"start": [
823,
1
],
"end": [
825,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.getUserName",
"code": "def _root_.Lean.FVarId.getUserName (fvarId : FVarId) : MetaM Name :=\n return (← fvarId.getDecl).userName",
"start": [
827,
1
],
"end": [
829,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.isLetVar",
"code": "def _root_.Lean.FVarId.isLetVar (fvarId : FVarId) : MetaM Bool :=\n return (← fvarId.getDecl).isLet",
"start": [
831,
1
],
"end": [
833,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFVarLocalDecl",
"code": "def getFVarLocalDecl (fvar : Expr) : MetaM LocalDecl :=\n fvar.fvarId!.getDecl",
"start": [
835,
1
],
"end": [
838,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.FVarId.hasForwardDeps",
"code": "def _root_.Lean.FVarId.hasForwardDeps (fvarId : FVarId) : MetaM Bool := do\n let decl ← fvarId.getDecl\n (← getLCtx).foldlM (init := false) (start := decl.index + 1) fun found other =>\n if found then\n return true\n else\n localDeclDependsOn other fvarId",
"start": [
840,
1
],
"end": [
849,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getLocalDeclFromUserName",
"code": "def getLocalDeclFromUserName (userName : Name) : MetaM LocalDecl := do\n match (← getLCtx).findFromUserName? userName with\n | some d => pure d\n | none => throwError \"unknown local declaration '{userName}'\"",
"start": [
851,
1
],
"end": [
858,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getFVarFromUserName",
"code": "def getFVarFromUserName (userName : Name) : MetaM Expr := do\n let d ← getLocalDeclFromUserName userName\n return Expr.fvar d.fvarId",
"start": [
860,
1
],
"end": [
863,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.liftMkBindingM",
"code": "@[inline] def liftMkBindingM (x : MetavarContext.MkBindingM α) : MetaM α := do\n match x { lctx := (← getLCtx), mainModule := (← getEnv).mainModule } { mctx := (← getMCtx), ngen := (← getNGen), nextMacroScope := (← getThe Core.State).nextMacroScope } with\n | .ok e sNew => do\n setMCtx sNew.mctx\n modifyThe Core.State fun s => { s with ngen := sNew.ngen, nextMacroScope := sNew.nextMacroScope }\n pure e\n | .error (.revertFailure ..) sNew => do\n setMCtx sNew.mctx\n modifyThe Core.State fun s => { s with ngen := sNew.ngen, nextMacroScope := sNew.nextMacroScope }\n throwError \"failed to create binder due to failure when reverting variable dependencies\"",
"start": [
865,
1
],
"end": [
877,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.abstractRangeM",
"code": "def _root_.Lean.Expr.abstractRangeM (e : Expr) (n : Nat) (xs : Array Expr) : MetaM Expr :=\n liftMkBindingM <| MetavarContext.abstractRange e n xs",
"start": [
879,
1
],
"end": [
887,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.abstractRange",
"code": "@[deprecated Expr.abstractRangeM (since := \"2022-07-15\")]\ndef abstractRange (e : Expr) (n : Nat) (xs : Array Expr) : MetaM Expr :=\n e.abstractRangeM n xs",
"start": [
889,
1
],
"end": [
891,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Expr.abstractM",
"code": "def _root_.Lean.Expr.abstractM (e : Expr) (xs : Array Expr) : MetaM Expr :=\n e.abstractRangeM xs.size xs",
"start": [
893,
1
],
"end": [
898,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.abstract",
"code": "@[deprecated Expr.abstractM (since := \"2022-07-15\")]\ndef abstract (e : Expr) (xs : Array Expr) : MetaM Expr :=\n e.abstractM xs",
"start": [
900,
1
],
"end": [
902,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.collectForwardDeps",
"code": "def collectForwardDeps (toRevert : Array Expr) (preserveOrder : Bool) : MetaM (Array Expr) := do\n liftMkBindingM <| MetavarContext.collectForwardDeps toRevert preserveOrder",
"start": [
904,
1
],
"end": [
909,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkForallFVars",
"code": "def mkForallFVars (xs : Array Expr) (e : Expr) (usedOnly : Bool := false) (usedLetOnly : Bool := true) (binderInfoForMVars := BinderInfo.implicit) : MetaM Expr :=\n if xs.isEmpty then return e else liftMkBindingM <| MetavarContext.mkForall xs e usedOnly usedLetOnly binderInfoForMVars",
"start": [
911,
1
],
"end": [
917,
122
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLambdaFVars",
"code": "def mkLambdaFVars (xs : Array Expr) (e : Expr) (usedOnly : Bool := false) (usedLetOnly : Bool := true) (etaReduce : Bool := false) (binderInfoForMVars := BinderInfo.implicit) : MetaM Expr :=\n if xs.isEmpty then return e else liftMkBindingM <| MetavarContext.mkLambda xs e usedOnly usedLetOnly etaReduce binderInfoForMVars",
"start": [
919,
1
],
"end": [
923,
132
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLetFVars",
"code": "def mkLetFVars (xs : Array Expr) (e : Expr) (usedLetOnly := true) (binderInfoForMVars := BinderInfo.implicit) : MetaM Expr :=\n mkLambdaFVars xs e (usedLetOnly := usedLetOnly) (binderInfoForMVars := binderInfoForMVars)",
"start": [
925,
1
],
"end": [
926,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkFunUnit",
"code": "def mkFunUnit (a : Expr) : MetaM Expr :=\n return Lean.mkLambda (← mkFreshUserName `x) BinderInfo.default (mkConst ``Unit) a",
"start": [
928,
1
],
"end": [
930,
84
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.elimMVarDeps",
"code": "def elimMVarDeps (xs : Array Expr) (e : Expr) (preserveOrder : Bool := false) : MetaM Expr :=\n if xs.isEmpty then pure e else liftMkBindingM <| MetavarContext.elimMVarDeps xs e preserveOrder",
"start": [
932,
1
],
"end": [
933,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withConfig",
"code": "@[inline] def withConfig (f : Config → Config) : n α → n α :=\n mapMetaM <| withReader (fun ctx => { ctx with config := f ctx.config })",
"start": [
935,
1
],
"end": [
937,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withTrackingZetaDelta",
"code": "@[inline] def withTrackingZetaDelta (x : n α) : n α :=\n withConfig (fun cfg => { cfg with trackZetaDelta := true }) x",
"start": [
939,
1
],
"end": [
943,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withoutProofIrrelevance",
"code": "@[inline] def withoutProofIrrelevance (x : n α) : n α :=\n withConfig (fun cfg => { cfg with proofIrrelevance := false }) x",
"start": [
945,
1
],
"end": [
946,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withTransparency",
"code": "@[inline] def withTransparency (mode : TransparencyMode) : n α → n α :=\n mapMetaM <| withConfig (fun config => { config with transparency := mode })",
"start": [
948,
1
],
"end": [
949,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withDefault",
"code": "@[inline] def withDefault (x : n α) : n α :=\n withTransparency TransparencyMode.default x",
"start": [
951,
1
],
"end": [
953,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withReducible",
"code": "@[inline] def withReducible (x : n α) : n α :=\n withTransparency TransparencyMode.reducible x",
"start": [
955,
1
],
"end": [
957,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withReducibleAndInstances",
"code": "@[inline] def withReducibleAndInstances (x : n α) : n α :=\n withTransparency TransparencyMode.instances x",
"start": [
959,
1
],
"end": [
964,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withAtLeastTransparency",
"code": "@[inline] def withAtLeastTransparency (mode : TransparencyMode) (x : n α) : n α :=\n withConfig\n (fun config =>\n let oldMode := config.transparency\n let mode := if oldMode.lt mode then mode else oldMode\n { config with transparency := mode })\n x",
"start": [
966,
1
],
"end": [
976,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withAssignableSyntheticOpaque",
"code": "@[inline] def withAssignableSyntheticOpaque (x : n α) : n α :=\n withConfig (fun config => { config with assignSyntheticOpaque := true }) x",
"start": [
978,
1
],
"end": [
980,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.savingCacheImpl",
"code": "@[inline] private def savingCacheImpl (x : MetaM α) : MetaM α := do\n let savedCache := (← get).cache\n try x finally modify fun s => { s with cache := savedCache }",
"start": [
982,
1
],
"end": [
985,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.savingCache",
"code": "@[inline] def savingCache : n α → n α :=\n mapMetaM savingCacheImpl",
"start": [
987,
1
],
"end": [
988,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getTheoremInfo",
"code": "def getTheoremInfo (info : ConstantInfo) : MetaM (Option ConstantInfo) := do\n if (← shouldReduceAll) then\n return some info\n else\n return none",
"start": [
990,
1
],
"end": [
994,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getDefInfoTemp",
"code": "private def getDefInfoTemp (info : ConstantInfo) : MetaM (Option ConstantInfo) := do\n match (← getTransparency) with\n | TransparencyMode.all => return some info\n | TransparencyMode.default => return some info\n | _ =>\n if (← isReducible info.name) then\n return some info\n else\n return none",
"start": [
996,
1
],
"end": [
1004,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getConstTemp?",
"code": "private def getConstTemp? (constName : Name) : MetaM (Option ConstantInfo) := do\n match (← getEnv).find? constName with\n | some (info@(ConstantInfo.thmInfo _)) => getTheoremInfo info\n | some (info@(ConstantInfo.defnInfo _)) => getDefInfoTemp info\n | some info => pure (some info)\n | none => throwUnknownConstant constName",
"start": [
1006,
1
],
"end": [
1015,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isClassQuickConst?",
"code": "private def isClassQuickConst? (constName : Name) : MetaM (LOption Name) := do\n if isClass (← getEnv) constName then\n return .some constName\n else\n match (← getConstTemp? constName) with\n | some (.defnInfo ..) => return .undef | _ => return .none",
"start": [
1017,
1
],
"end": [
1023,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isClassQuick?",
"code": "private partial def isClassQuick? : Expr → MetaM (LOption Name)\n | .bvar .. => return .none\n | .lit .. => return .none\n | .fvar .. => return .none\n | .sort .. => return .none\n | .lam .. => return .none\n | .letE .. => return .undef\n | .proj .. => return .undef\n | .forallE _ _ b _ => isClassQuick? b\n | .mdata _ e => isClassQuick? e\n | .const n _ => isClassQuickConst? n\n | .mvar mvarId => do\n let some val ← getExprMVarAssignment? mvarId | return .none\n isClassQuick? val\n | .app f _ => do\n match f.getAppFn with\n | .const n .. => isClassQuickConst? n\n | .lam .. => return .undef\n | .mvar mvarId =>\n let some val ← getExprMVarAssignment? mvarId | return .none\n match val.getAppFn with\n | .const n .. => isClassQuickConst? n\n | _ => return .undef\n | _ => return .none",
"start": [
1025,
1
],
"end": [
1048,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewLocalInstanceImp",
"code": "private def withNewLocalInstanceImp (className : Name) (fvar : Expr) (k : MetaM α) : MetaM α := do\n let localDecl ← getFVarLocalDecl fvar\n if localDecl.isImplementationDetail then\n k\n else\n withReader (fun ctx => { ctx with localInstances := ctx.localInstances.push { className := className, fvar := fvar } }) k",
"start": [
1050,
1
],
"end": [
1055,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewLocalInstance",
"code": "def withNewLocalInstance (className : Name) (fvar : Expr) : n α → n α :=\n mapMetaM <| withNewLocalInstanceImp className fvar",
"start": [
1057,
1
],
"end": [
1060,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.fvarsSizeLtMaxFVars",
"code": "private def fvarsSizeLtMaxFVars (fvars : Array Expr) (maxFVars? : Option Nat) : Bool :=\n match maxFVars? with\n | some maxFVars => fvars.size < maxFVars\n | none => true",
"start": [
1062,
1
],
"end": [
1065,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewLocalInstancesImp",
"code": "private partial def withNewLocalInstancesImp\n (fvars : Array Expr) (i : Nat) (k : MetaM α) : MetaM α := do\n if h : i < fvars.size then\n let fvar := fvars.get ⟨i, h⟩\n let decl ← getFVarLocalDecl fvar\n match (← isClassQuick? decl.type) with\n | .none => withNewLocalInstancesImp fvars (i+1) k\n | .undef =>\n match (← isClassExpensive? decl.type) with\n | none => withNewLocalInstancesImp fvars (i+1) k\n | some c => withNewLocalInstance c fvar <| withNewLocalInstancesImp fvars (i+1) k\n | .some c => withNewLocalInstance c fvar <| withNewLocalInstancesImp fvars (i+1) k\n else\n k",
"start": [
1068,
3
],
"end": [
1087,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallTelescopeReducingAuxAux",
"code": "private partial def forallTelescopeReducingAuxAux\n (reducing : Bool) (maxFVars? : Option Nat)\n (type : Expr)\n (k : Array Expr → Expr → MetaM α) (cleanupAnnotations : Bool) : MetaM α := do\n let rec process (lctx : LocalContext) (fvars : Array Expr) (j : Nat) (type : Expr) : MetaM α := do\n match type with\n | .forallE n d b bi =>\n if fvarsSizeLtMaxFVars fvars maxFVars? then\n let d := d.instantiateRevRange j fvars.size fvars\n let d := if cleanupAnnotations then d.cleanupAnnotations else d\n let fvarId ← mkFreshFVarId\n let lctx := lctx.mkLocalDecl fvarId n d bi\n let fvar := mkFVar fvarId\n let fvars := fvars.push fvar\n process lctx fvars j b\n else\n let type := type.instantiateRevRange j fvars.size fvars;\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewLocalInstancesImp fvars j do\n k fvars type\n | _ =>\n let type := type.instantiateRevRange j fvars.size fvars;\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewLocalInstancesImp fvars j do\n if reducing && fvarsSizeLtMaxFVars fvars maxFVars? then\n let newType ← whnf type\n if newType.isForall then\n process lctx fvars fvars.size newType\n else\n k fvars type\n else\n k fvars type\n process (← getLCtx) #[] 0 type",
"start": [
1089,
3
],
"end": [
1149,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallTelescopeReducingAux",
"code": "private partial def forallTelescopeReducingAux (type : Expr) (maxFVars? : Option Nat) (k : Array Expr → Expr → MetaM α) (cleanupAnnotations : Bool) : MetaM α := do\n match maxFVars? with\n | some 0 => k #[] type\n | _ => do\n let newType ← whnf type\n if newType.isForall then\n forallTelescopeReducingAuxAux true maxFVars? newType k cleanupAnnotations\n else\n k #[] type",
"start": [
1151,
3
],
"end": [
1159,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isClassApp?",
"code": "private partial def isClassApp? (type : Expr) (instantiated := false) : MetaM (Option Name) := do\n match type.getAppFn with\n | .const c _ =>\n let env ← getEnv\n if isClass env c then\n return some c\n else\n match (← whnf type).getAppFn with\n | .const c _ => if isClass env c then return some c else return none\n | _ => return none\n | .mvar .. =>\n if instantiated then return none\n isClassApp? (← instantiateMVars type) true\n | _ => return none",
"start": [
1163,
3
],
"end": [
1177,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isClassExpensive?",
"code": "private partial def isClassExpensive? (type : Expr) : MetaM (Option Name) :=\n withReducible do forallTelescopeReducingAux type none (cleanupAnnotations := false) fun _ type => isClassApp? type",
"start": [
1179,
3
],
"end": [
1181,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isClassImp?",
"code": "private partial def isClassImp? (type : Expr) : MetaM (Option Name) := do\n match (← isClassQuick? type) with\n | .none => return none\n | .some c => return (some c)\n | .undef => isClassExpensive? type",
"start": [
1183,
3
],
"end": [
1187,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isClass?",
"code": "def isClass? (type : Expr) : MetaM (Option Name) :=\n try isClassImp? type catch _ => return none",
"start": [
1191,
1
],
"end": [
1202,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewLocalInstancesImpAux",
"code": "private def withNewLocalInstancesImpAux (fvars : Array Expr) (j : Nat) : n α → n α :=\n mapMetaM <| withNewLocalInstancesImp fvars j",
"start": [
1204,
1
],
"end": [
1205,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewLocalInstances",
"code": "partial def withNewLocalInstances (fvars : Array Expr) (j : Nat) : n α → n α :=\n mapMetaM <| withNewLocalInstancesImpAux fvars j",
"start": [
1207,
1
],
"end": [
1208,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallTelescopeImp",
"code": "@[inline] private def forallTelescopeImp (type : Expr) (k : Array Expr → Expr → MetaM α) (cleanupAnnotations : Bool) : MetaM α := do\n forallTelescopeReducingAuxAux (reducing := false) (maxFVars? := none) type k cleanupAnnotations",
"start": [
1210,
1
],
"end": [
1211,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallTelescope",
"code": "def forallTelescope (type : Expr) (k : Array Expr → Expr → n α) (cleanupAnnotations := false) : n α :=\n map2MetaM (fun k => forallTelescopeImp type k cleanupAnnotations) k",
"start": [
1213,
1
],
"end": [
1221,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mapForallTelescope'",
"code": "def mapForallTelescope' (f : Expr → Expr → MetaM Expr) (forallTerm : Expr) : MetaM Expr := do\n forallTelescope (← inferType forallTerm) fun xs ty => do\n mkLambdaFVars xs (← f ty (mkAppN forallTerm xs))",
"start": [
1223,
1
],
"end": [
1230,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mapForallTelescope",
"code": "def mapForallTelescope (f : Expr → MetaM Expr) (forallTerm : Expr) : MetaM Expr := do\n mapForallTelescope' (fun _ e => f e) forallTerm",
"start": [
1232,
1
],
"end": [
1238,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallTelescopeReducingImp",
"code": "private def forallTelescopeReducingImp (type : Expr) (k : Array Expr → Expr → MetaM α) (cleanupAnnotations : Bool) : MetaM α :=\n forallTelescopeReducingAux type (maxFVars? := none) k cleanupAnnotations",
"start": [
1240,
1
],
"end": [
1241,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallTelescopeReducing",
"code": "def forallTelescopeReducing (type : Expr) (k : Array Expr → Expr → n α) (cleanupAnnotations := false) : n α :=\n map2MetaM (fun k => forallTelescopeReducingImp type k cleanupAnnotations) k",
"start": [
1243,
1
],
"end": [
1250,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallBoundedTelescopeImp",
"code": "private def forallBoundedTelescopeImp (type : Expr) (maxFVars? : Option Nat) (k : Array Expr → Expr → MetaM α) (cleanupAnnotations : Bool) : MetaM α :=\n forallTelescopeReducingAux type maxFVars? k cleanupAnnotations",
"start": [
1252,
1
],
"end": [
1253,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallBoundedTelescope",
"code": "def forallBoundedTelescope (type : Expr) (maxFVars? : Option Nat) (k : Array Expr → Expr → n α) (cleanupAnnotations := false) : n α :=\n map2MetaM (fun k => forallBoundedTelescopeImp type maxFVars? k cleanupAnnotations) k",
"start": [
1255,
1
],
"end": [
1262,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.lambdaTelescopeImp",
"code": "private partial def lambdaTelescopeImp (e : Expr) (consumeLet : Bool) (k : Array Expr → Expr → MetaM α) (cleanupAnnotations := false) : MetaM α := do\n process consumeLet (← getLCtx) #[] 0 e\nwhere\n process (consumeLet : Bool) (lctx : LocalContext) (fvars : Array Expr) (j : Nat) (e : Expr) : MetaM α := do\n match consumeLet, e with\n | _, .lam n d b bi =>\n let d := d.instantiateRevRange j fvars.size fvars\n let d := if cleanupAnnotations then d.cleanupAnnotations else d\n let fvarId ← mkFreshFVarId\n let lctx := lctx.mkLocalDecl fvarId n d bi\n let fvar := mkFVar fvarId\n process consumeLet lctx (fvars.push fvar) j b\n | true, .letE n t v b _ => do\n let t := t.instantiateRevRange j fvars.size fvars\n let t := if cleanupAnnotations then t.cleanupAnnotations else t\n let v := v.instantiateRevRange j fvars.size fvars\n let fvarId ← mkFreshFVarId\n let lctx := lctx.mkLetDecl fvarId n t v\n let fvar := mkFVar fvarId\n process true lctx (fvars.push fvar) j b\n | _, e =>\n let e := e.instantiateRevRange j fvars.size fvars\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewLocalInstancesImp fvars j do\n k fvars e",
"start": [
1264,
1
],
"end": [
1288,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.lambdaLetTelescope",
"code": "def lambdaLetTelescope (e : Expr) (k : Array Expr → Expr → n α) (cleanupAnnotations := false) : n α :=\n map2MetaM (fun k => lambdaTelescopeImp e true k (cleanupAnnotations := cleanupAnnotations)) k",
"start": [
1290,
1
],
"end": [
1296,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.lambdaTelescope",
"code": "def lambdaTelescope (e : Expr) (k : Array Expr → Expr → n α) (cleanupAnnotations := false) : n α :=\n map2MetaM (fun k => lambdaTelescopeImp e false k (cleanupAnnotations := cleanupAnnotations)) k",
"start": [
1298,
1
],
"end": [
1306,
97
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getParamNames",
"code": "def getParamNames (declName : Name) : MetaM (Array Name) := do\n forallTelescopeReducing (← getConstInfo declName).type fun xs _ => do\n xs.mapM fun x => do\n let localDecl ← x.fvarId!.getDecl\n return localDecl.userName",
"start": [
1308,
1
],
"end": [
1313,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallMetaTelescopeReducingAux",
"code": "private partial def forallMetaTelescopeReducingAux\n (e : Expr) (reducing : Bool) (maxMVars? : Option Nat) (kind : MetavarKind) : MetaM (Array Expr × Array BinderInfo × Expr) :=\n process #[] #[] 0 e\nwhere\n process (mvars : Array Expr) (bis : Array BinderInfo) (j : Nat) (type : Expr) : MetaM (Array Expr × Array BinderInfo × Expr) := do\n if maxMVars?.isEqSome mvars.size then\n let type := type.instantiateRevRange j mvars.size mvars;\n return (mvars, bis, type)\n else\n match type with\n | .forallE n d b bi =>\n let d := d.instantiateRevRange j mvars.size mvars\n let k := if bi.isInstImplicit then MetavarKind.synthetic else kind\n let mvar ← mkFreshExprMVar d k n\n let mvars := mvars.push mvar\n let bis := bis.push bi\n process mvars bis j b\n | _ =>\n let type := type.instantiateRevRange j mvars.size mvars;\n if reducing then do\n let newType ← whnf type;\n if newType.isForall then\n process mvars bis mvars.size newType\n else\n return (mvars, bis, type)\n else\n return (mvars, bis, type)",
"start": [
1316,
1
],
"end": [
1342,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallMetaTelescope",
"code": "def forallMetaTelescope (e : Expr) (kind := MetavarKind.natural) : MetaM (Array Expr × Array BinderInfo × Expr) :=\n forallMetaTelescopeReducingAux e (reducing := false) (maxMVars? := none) kind",
"start": [
1344,
1
],
"end": [
1352,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallMetaTelescopeReducing",
"code": "def forallMetaTelescopeReducing (e : Expr) (maxMVars? : Option Nat := none) (kind := MetavarKind.natural) : MetaM (Array Expr × Array BinderInfo × Expr) :=\n forallMetaTelescopeReducingAux e (reducing := true) maxMVars? kind",
"start": [
1354,
1
],
"end": [
1357,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.forallMetaBoundedTelescope",
"code": "def forallMetaBoundedTelescope (e : Expr) (maxMVars : Nat) (kind : MetavarKind := MetavarKind.natural) : MetaM (Array Expr × Array BinderInfo × Expr) :=\n forallMetaTelescopeReducingAux e (reducing := true) (maxMVars? := some maxMVars) (kind := kind)",
"start": [
1359,
1
],
"end": [
1362,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.lambdaMetaTelescope",
"code": "partial def lambdaMetaTelescope (e : Expr) (maxMVars? : Option Nat := none) : MetaM (Array Expr × Array BinderInfo × Expr) :=\n process #[] #[] 0 e\nwhere\n process (mvars : Array Expr) (bis : Array BinderInfo) (j : Nat) (type : Expr) : MetaM (Array Expr × Array BinderInfo × Expr) := do\n let finalize : Unit → MetaM (Array Expr × Array BinderInfo × Expr) := fun _ => do\n let type := type.instantiateRevRange j mvars.size mvars\n return (mvars, bis, type)\n if maxMVars?.isEqSome mvars.size then\n finalize ()\n else\n match type with\n | .lam _ d b bi =>\n let d := d.instantiateRevRange j mvars.size mvars\n let mvar ← mkFreshExprMVar d\n let mvars := mvars.push mvar\n let bis := bis.push bi\n process mvars bis j b\n | _ => finalize ()",
"start": [
1364,
1
],
"end": [
1382,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewFVar",
"code": "private def withNewFVar (fvar fvarType : Expr) (k : Expr → MetaM α) : MetaM α := do\n if let some c ← isClass? fvarType then\n withNewLocalInstance c fvar <| k fvar\n else\n k fvar",
"start": [
1384,
1
],
"end": [
1388,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalDeclImp",
"code": "private def withLocalDeclImp (n : Name) (bi : BinderInfo) (type : Expr) (k : Expr → MetaM α) (kind : LocalDeclKind) : MetaM α := do\n let fvarId ← mkFreshFVarId\n let ctx ← read\n let lctx := ctx.lctx.mkLocalDecl fvarId n type bi kind\n let fvar := mkFVar fvarId\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewFVar fvar type k",
"start": [
1390,
1
],
"end": [
1396,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalDecl",
"code": "def withLocalDecl (name : Name) (bi : BinderInfo) (type : Expr) (k : Expr → n α) (kind : LocalDeclKind := .default) : n α :=\n map1MetaM (fun k => withLocalDeclImp name bi type k kind) k",
"start": [
1398,
1
],
"end": [
1401,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalDeclD",
"code": "def withLocalDeclD (name : Name) (type : Expr) (k : Expr → n α) : n α :=\n withLocalDecl name BinderInfo.default type k",
"start": [
1403,
1
],
"end": [
1404,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalDecls",
"code": "partial def withLocalDecls\n [Inhabited α]\n (declInfos : Array (Name × BinderInfo × (Array Expr → n Expr)))\n (k : (xs : Array Expr) → n α)\n : n α :=\n loop #[]\nwhere\n loop [Inhabited α] (acc : Array Expr) : n α := do\n if acc.size < declInfos.size then\n let (name, bi, typeCtor) := declInfos[acc.size]!\n withLocalDecl name bi (←typeCtor acc) fun x => loop (acc.push x)\n else\n k acc",
"start": [
1406,
1
],
"end": [
1425,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalDeclsD",
"code": "def withLocalDeclsD [Inhabited α] (declInfos : Array (Name × (Array Expr → n Expr))) (k : (xs : Array Expr) → n α) : n α :=\n withLocalDecls\n (declInfos.map (fun (name, typeCtor) => (name, BinderInfo.default, typeCtor))) k",
"start": [
1427,
1
],
"end": [
1429,
85
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewBinderInfosImp",
"code": "private def withNewBinderInfosImp (bs : Array (FVarId × BinderInfo)) (k : MetaM α) : MetaM α := do\n let lctx := bs.foldl (init := (← getLCtx)) fun lctx (fvarId, bi) =>\n lctx.setBinderInfo fvarId bi\n withReader (fun ctx => { ctx with lctx := lctx }) k",
"start": [
1431,
1
],
"end": [
1434,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewBinderInfos",
"code": "def withNewBinderInfos (bs : Array (FVarId × BinderInfo)) (k : n α) : n α :=\n mapMetaM (fun k => withNewBinderInfosImp bs k) k",
"start": [
1436,
1
],
"end": [
1437,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withInstImplicitAsImplict",
"code": "def withInstImplicitAsImplict (xs : Array Expr) (k : MetaM α) : MetaM α := do\n let newBinderInfos ← xs.filterMapM fun x => do\n let bi ← x.fvarId!.getBinderInfo\n if bi == .instImplicit then\n return some (x.fvarId!, .implicit)\n else\n return none\n withNewBinderInfos newBinderInfos k",
"start": [
1439,
1
],
"end": [
1449,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLetDeclImp",
"code": "private def withLetDeclImp (n : Name) (type : Expr) (val : Expr) (k : Expr → MetaM α) (kind : LocalDeclKind) : MetaM α := do\n let fvarId ← mkFreshFVarId\n let ctx ← read\n let lctx := ctx.lctx.mkLetDecl fvarId n type val (nonDep := false) kind\n let fvar := mkFVar fvarId\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withNewFVar fvar type k",
"start": [
1451,
1
],
"end": [
1457,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLetDecl",
"code": "def withLetDecl (name : Name) (type : Expr) (val : Expr) (k : Expr → n α) (kind : LocalDeclKind := .default) : n α :=\n map1MetaM (fun k => withLetDeclImp name type val k kind) k",
"start": [
1459,
1
],
"end": [
1464,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalInstancesImp",
"code": "def withLocalInstancesImp (decls : List LocalDecl) (k : MetaM α) : MetaM α := do\n let mut localInsts := (← read).localInstances\n let size := localInsts.size\n for decl in decls do\n unless decl.isImplementationDetail do\n if let some className ← isClass? decl.type then\n unless localInsts.any fun localInst => localInst.fvar.fvarId! == decl.fvarId do\n localInsts := localInsts.push { className, fvar := decl.toExpr }\n if localInsts.size == size then\n k\n else\n withReader (fun ctx => { ctx with localInstances := localInsts }) k",
"start": [
1466,
1
],
"end": [
1478,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalInstances",
"code": "def withLocalInstances (decls : List LocalDecl) : n α → n α :=\n mapMetaM <| withLocalInstancesImp decls",
"start": [
1480,
1
],
"end": [
1482,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withExistingLocalDeclsImp",
"code": "private def withExistingLocalDeclsImp (decls : List LocalDecl) (k : MetaM α) : MetaM α := do\n let ctx ← read\n let lctx := decls.foldl (fun (lctx : LocalContext) decl => lctx.addDecl decl) ctx.lctx\n withReader (fun ctx => { ctx with lctx := lctx }) do\n withLocalInstancesImp decls k",
"start": [
1484,
1
],
"end": [
1488,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withExistingLocalDecls",
"code": "def withExistingLocalDecls (decls : List LocalDecl) : n α → n α :=\n mapMetaM <| withExistingLocalDeclsImp decls",
"start": [
1490,
1
],
"end": [
1501,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewMCtxDepthImp",
"code": "private def withNewMCtxDepthImp (allowLevelAssignments : Bool) (x : MetaM α) : MetaM α := do\n let saved ← get\n modify fun s => { s with mctx := s.mctx.incDepth allowLevelAssignments, postponed := {} }\n try\n x\n finally\n modify fun s => { s with mctx := saved.mctx, postponed := saved.postponed }",
"start": [
1503,
1
],
"end": [
1509,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withReplaceFVarId",
"code": "def withReplaceFVarId {α} (fvarId : FVarId) (e : Expr) : MetaM α → MetaM α :=\n withReader fun ctx => { ctx with\n lctx := ctx.lctx.replaceFVarId fvarId e\n localInstances := ctx.localInstances.erase fvarId }",
"start": [
1511,
1
],
"end": [
1519,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withNewMCtxDepth",
"code": "def withNewMCtxDepth (k : n α) (allowLevelAssignments := false) : n α :=\n mapMetaM (withNewMCtxDepthImp allowLevelAssignments) k",
"start": [
1521,
1
],
"end": [
1529,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalContextImp",
"code": "private def withLocalContextImp (lctx : LocalContext) (localInsts : LocalInstances) (x : MetaM α) : MetaM α := do\n withReader (fun ctx => { ctx with lctx := lctx, localInstances := localInsts }) do\n x",
"start": [
1531,
1
],
"end": [
1533,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLCtx",
"code": "def withLCtx (lctx : LocalContext) (localInsts : LocalInstances) : n α → n α :=\n mapMetaM <| withLocalContextImp lctx localInsts",
"start": [
1535,
1
],
"end": [
1541,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withMVarContextImp",
"code": "private def withMVarContextImp (mvarId : MVarId) (x : MetaM α) : MetaM α := do\n let mvarDecl ← mvarId.getDecl\n withLocalContextImp mvarDecl.lctx mvarDecl.localInstances x",
"start": [
1543,
1
],
"end": [
1545,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.withContext",
"code": "def _root_.Lean.MVarId.withContext (mvarId : MVarId) : n α → n α :=\n mapMetaM <| withMVarContextImp mvarId",
"start": [
1547,
1
],
"end": [
1552,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withMVarContext",
"code": "@[deprecated MVarId.withContext (since := \"2022-07-15\")]\ndef withMVarContext (mvarId : MVarId) : n α → n α :=\n mvarId.withContext",
"start": [
1554,
1
],
"end": [
1556,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withMCtxImp",
"code": "private def withMCtxImp (mctx : MetavarContext) (x : MetaM α) : MetaM α := do\n let mctx' ← getMCtx\n setMCtx mctx\n try x finally setMCtx mctx'",
"start": [
1558,
1
],
"end": [
1561,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withMCtx",
"code": "def withMCtx (mctx : MetavarContext) : n α → n α :=\n mapMetaM <| withMCtxImp mctx",
"start": [
1563,
1
],
"end": [
1569,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.approxDefEqImp",
"code": "@[inline] private def approxDefEqImp (x : MetaM α) : MetaM α :=\n withConfig (fun config => { config with foApprox := true, ctxApprox := true, quasiPatternApprox := true}) x",
"start": [
1571,
1
],
"end": [
1572,
110
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.approxDefEq",
"code": "@[inline] def approxDefEq : n α → n α :=\n mapMetaM approxDefEqImp",
"start": [
1574,
1
],
"end": [
1576,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.fullApproxDefEqImp",
"code": "@[inline] private def fullApproxDefEqImp (x : MetaM α) : MetaM α :=\n withConfig (fun config => { config with foApprox := true, ctxApprox := true, quasiPatternApprox := true, constApprox := true }) x",
"start": [
1578,
1
],
"end": [
1579,
132
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.fullApproxDefEq",
"code": "@[inline] def fullApproxDefEq : n α → n α :=\n mapMetaM fullApproxDefEqImp",
"start": [
1581,
1
],
"end": [
1589,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.normalizeLevel",
"code": "def normalizeLevel (u : Level) : MetaM Level := do\n let u ← instantiateLevelMVars u\n pure u.normalize",
"start": [
1591,
1
],
"end": [
1594,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfR",
"code": "def whnfR (e : Expr) : MetaM Expr :=\n withTransparency TransparencyMode.reducible <| whnf e",
"start": [
1596,
1
],
"end": [
1598,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfD",
"code": "def whnfD (e : Expr) : MetaM Expr :=\n withTransparency TransparencyMode.default <| whnf e",
"start": [
1600,
1
],
"end": [
1602,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfI",
"code": "def whnfI (e : Expr) : MetaM Expr :=\n withTransparency TransparencyMode.instances <| whnf e",
"start": [
1604,
1
],
"end": [
1606,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.whnfAtMostI",
"code": "def whnfAtMostI (e : Expr) : MetaM Expr := do\n match (← getTransparency) with\n | .all | .default => withTransparency TransparencyMode.instances <| whnf e\n | _ => whnf e",
"start": [
1608,
1
],
"end": [
1612,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.setInlineAttribute",
"code": "def setInlineAttribute (declName : Name) (kind := Compiler.InlineAttributeKind.inline): MetaM Unit := do\n let env ← getEnv\n match Compiler.setInlineAttribute env declName kind with\n | .ok env => setEnv env\n | .error msg => throwError msg",
"start": [
1614,
1
],
"end": [
1624,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.instantiateForallAux",
"code": "private partial def instantiateForallAux (ps : Array Expr) (i : Nat) (e : Expr) : MetaM Expr := do\n if h : i < ps.size then\n let p := ps.get ⟨i, h⟩\n match (← whnf e) with\n | .forallE _ _ b _ => instantiateForallAux ps (i+1) (b.instantiate1 p)\n | _ => throwError \"invalid instantiateForall, too many parameters\"\n else\n return e",
"start": [
1626,
1
],
"end": [
1633,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.instantiateForall",
"code": "def instantiateForall (e : Expr) (ps : Array Expr) : MetaM Expr :=\n instantiateForallAux ps 0 e",
"start": [
1635,
1
],
"end": [
1637,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.instantiateLambdaAux",
"code": "private partial def instantiateLambdaAux (ps : Array Expr) (i : Nat) (e : Expr) : MetaM Expr := do\n if h : i < ps.size then\n let p := ps.get ⟨i, h⟩\n match (← whnf e) with\n | .lam _ _ b _ => instantiateLambdaAux ps (i+1) (b.instantiate1 p)\n | _ => throwError \"invalid instantiateLambda, too many parameters\"\n else\n return e",
"start": [
1639,
1
],
"end": [
1646,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.instantiateLambda",
"code": "def instantiateLambda (e : Expr) (ps : Array Expr) : MetaM Expr :=\n instantiateLambdaAux ps 0 e",
"start": [
1648,
1
],
"end": [
1651,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ppExprWithInfos",
"code": "def ppExprWithInfos (e : Expr) : MetaM FormatWithInfos := do\n let ctxCore ← readThe Core.Context\n Lean.ppExprWithInfos { env := (← getEnv), mctx := (← getMCtx), lctx := (← getLCtx), opts := (← getOptions), currNamespace := ctxCore.currNamespace, openDecls := ctxCore.openDecls } e",
"start": [
1653,
1
],
"end": [
1656,
185
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ppExpr",
"code": "def ppExpr (e : Expr) : MetaM Format := (·.fmt) <$> ppExprWithInfos e",
"start": [
1658,
1
],
"end": [
1659,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.orElse",
"code": "@[inline] protected def orElse (x : MetaM α) (y : Unit → MetaM α) : MetaM α := do\n let s ← saveState\n try x catch _ => s.restore; y ()",
"start": [
1661,
1
],
"end": [
1663,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.orelseMergeErrorsImp",
"code": "@[inline] private def orelseMergeErrorsImp (x y : MetaM α)\n (mergeRef : Syntax → Syntax → Syntax := fun r₁ _ => r₁)\n (mergeMsg : MessageData → MessageData → MessageData := fun m₁ m₂ => m₁ ++ Format.line ++ m₂) : MetaM α := do\n let env ← getEnv\n let mctx ← getMCtx\n try\n x\n catch ex =>\n setEnv env\n setMCtx mctx\n match ex with\n | Exception.error ref₁ m₁ =>\n try\n y\n catch\n | Exception.error ref₂ m₂ => throw <| Exception.error (mergeRef ref₁ ref₂) (mergeMsg m₁ m₂)\n | ex => throw ex\n | ex => throw ex",
"start": [
1671,
1
],
"end": [
1688,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.orelseMergeErrors",
"code": "@[inline] def orelseMergeErrors [MonadControlT MetaM m] [Monad m] (x y : m α)\n (mergeRef : Syntax → Syntax → Syntax := fun r₁ _ => r₁)\n (mergeMsg : MessageData → MessageData → MessageData := fun m₁ m₂ => m₁ ++ Format.line ++ Format.line ++ m₂) : m α := do\n controlAt MetaM fun runInBase => orelseMergeErrorsImp (runInBase x) (runInBase y) mergeRef mergeMsg",
"start": [
1690,
1
],
"end": [
1697,
102
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mapErrorImp",
"code": "def mapErrorImp (x : MetaM α) (f : MessageData → MessageData) : MetaM α := do\n try\n x\n catch\n | Exception.error ref msg => throw <| Exception.error ref <| f msg\n | ex => throw ex",
"start": [
1699,
1
],
"end": [
1705,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mapError",
"code": "@[inline] def mapError [MonadControlT MetaM m] [Monad m] (x : m α) (f : MessageData → MessageData) : m α :=\n controlAt MetaM fun runInBase => mapErrorImp (runInBase x) f",
"start": [
1707,
1
],
"end": [
1708,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.sortFVarIds",
"code": "def sortFVarIds (fvarIds : Array FVarId) : MetaM (Array FVarId) := do\n let lctx ← getLCtx\n return fvarIds.qsort fun fvarId₁ fvarId₂ =>\n match lctx.find? fvarId₁, lctx.find? fvarId₂ with\n | some d₁, some d₂ => d₁.index < d₂.index\n | some _, none => false\n | none, some _ => true\n | none, none => Name.quickLt fvarId₁.name fvarId₂.name",
"start": [
1710,
1
],
"end": [
1720,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isInductivePredicate",
"code": "def isInductivePredicate (declName : Name) : MetaM Bool := do\n match (← getEnv).find? declName with\n | some (.inductInfo { type := type, ..}) =>\n forallTelescopeReducing type fun _ type => do\n match (← whnfD type) with\n | .sort u .. => return u == levelZero\n | _ => return false\n | _ => return false",
"start": [
1724,
1
],
"end": [
1732,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isListLevelDefEqAux",
"code": "def isListLevelDefEqAux : List Level → List Level → MetaM Bool\n | [], [] => return true\n | u::us, v::vs => isLevelDefEqAux u v <&&> isListLevelDefEqAux us vs\n | _, _ => return false",
"start": [
1734,
1
],
"end": [
1737,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getNumPostponed",
"code": "def getNumPostponed : MetaM Nat := do\n return (← getPostponed).size",
"start": [
1739,
1
],
"end": [
1740,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getResetPostponed",
"code": "def getResetPostponed : MetaM (PersistentArray PostponedEntry) := do\n let ps ← getPostponed\n setPostponed {}\n return ps",
"start": [
1742,
1
],
"end": [
1745,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.exposeRelevantUniverses",
"code": "private def exposeRelevantUniverses (e : Expr) (p : Level → Bool) : Expr :=\n e.replace fun e =>\n match e with\n | .const _ us => if us.any p then some (e.setPPUniverses true) else none\n | .sort u => if p u then some (e.setPPUniverses true) else none\n | _ => none",
"start": [
1747,
1
],
"end": [
1753,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLeveErrorMessageCore",
"code": "private def mkLeveErrorMessageCore (header : String) (entry : PostponedEntry) : MetaM MessageData := do\n match entry.ctx? with\n | none =>\n return m!\"{header}{indentD m!\"{entry.lhs} =?= {entry.rhs}\"}\"\n | some ctx =>\n withLCtx ctx.lctx ctx.localInstances do\n let s := entry.lhs.collectMVars entry.rhs.collectMVars\n \n let p (u : Level) := u.any fun | .mvar m => s.contains m | _ => false\n let lhs := exposeRelevantUniverses (← instantiateMVars ctx.lhs) p\n let rhs := exposeRelevantUniverses (← instantiateMVars ctx.rhs) p\n try\n addMessageContext m!\"{header}{indentD m!\"{entry.lhs} =?= {entry.rhs}\"}\\nwhile trying to unify{indentD m!\"{lhs} : {← inferType lhs}\"}\\nwith{indentD m!\"{rhs} : {← inferType rhs}\"}\"\n catch _ =>\n addMessageContext m!\"{header}{indentD m!\"{entry.lhs} =?= {entry.rhs}\"}\\nwhile trying to unify{indentD lhs}\\nwith{indentD rhs}\"",
"start": [
1755,
1
],
"end": [
1769,
135
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLevelStuckErrorMessage",
"code": "def mkLevelStuckErrorMessage (entry : PostponedEntry) : MetaM MessageData := do\n mkLeveErrorMessageCore \"stuck at solving universe constraint\" entry",
"start": [
1771,
1
],
"end": [
1772,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.mkLevelErrorMessage",
"code": "def mkLevelErrorMessage (entry : PostponedEntry) : MetaM MessageData := do\n mkLeveErrorMessageCore \"failed to solve universe constraint\" entry",
"start": [
1774,
1
],
"end": [
1775,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.processPostponedStep",
"code": "private def processPostponedStep (exceptionOnFailure : Bool) : MetaM Bool := do\n let ps ← getResetPostponed\n for p in ps do\n unless (← withReader (fun ctx => { ctx with defEqCtx? := p.ctx? }) <| isLevelDefEqAux p.lhs p.rhs) do\n if exceptionOnFailure then\n withRef p.ref do\n throwError (← mkLevelErrorMessage p)\n else\n return false\n return true",
"start": [
1777,
1
],
"end": [
1786,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.processPostponed",
"code": "partial def processPostponed (mayPostpone : Bool := true) (exceptionOnFailure := false) : MetaM Bool := do\n if (← getNumPostponed) == 0 then\n return true\n else\n let numPostponedBegin ← getNumPostponed\n withTraceNode `Meta.isLevelDefEq.postponed\n (fun _ => return m!\"processing #{numPostponedBegin} postponed is-def-eq level constraints\") do\n let rec loop : MetaM Bool := do\n let numPostponed ← getNumPostponed\n if numPostponed == 0 then\n return true\n else\n if !(← processPostponedStep exceptionOnFailure) then\n return false\n else\n let numPostponed' ← getNumPostponed\n if numPostponed' == 0 then\n return true\n else if numPostponed' < numPostponed then\n loop\n else if !mayPostpone && (← getConfig).univApprox && !(← read).univApprox then\n withReader (fun ctx => { ctx with univApprox := true }) loop\n else\n trace[Meta.isLevelDefEq.postponed] \"no progress solving pending is-def-eq level constraints\"\n return mayPostpone\n loop",
"start": [
1788,
1
],
"end": [
1815,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkpointDefEq",
"code": "@[specialize] def checkpointDefEq (x : MetaM Bool) (mayPostpone : Bool := true) : MetaM Bool := do\n let s ← saveState\n \n modifyDefEqTransientCache fun _ => {}\n let postponed ← getResetPostponed\n try\n if (← x) then\n if (← processPostponed mayPostpone) then\n let newPostponed ← getPostponed\n setPostponed (postponed ++ newPostponed)\n return true\n else\n s.restore\n return false\n else\n s.restore\n return false\n catch ex =>\n s.restore\n throw ex",
"start": [
1817,
1
],
"end": [
1852,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isLevelDefEq",
"code": "def isLevelDefEq (u v : Level) : MetaM Bool :=\n checkpointDefEq (mayPostpone := true) <| Meta.isLevelDefEqAux u v",
"start": [
1854,
1
],
"end": [
1858,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isExprDefEq",
"code": "def isExprDefEq (t s : Expr) : MetaM Bool :=\n withReader (fun ctx => { ctx with defEqCtx? := some { lhs := t, rhs := s, lctx := ctx.lctx, localInstances := ctx.localInstances } }) do\n \n resetDefEqPermCaches\n checkpointDefEq (mayPostpone := true) <| Meta.isExprDefEqAux t s",
"start": [
1860,
1
],
"end": [
1883,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isDefEq",
"code": "abbrev isDefEq (t s : Expr) : MetaM Bool :=\n isExprDefEq t s",
"start": [
1885,
1
],
"end": [
1898,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isExprDefEqGuarded",
"code": "def isExprDefEqGuarded (a b : Expr) : MetaM Bool := do\n try isExprDefEq a b catch _ => return false",
"start": [
1900,
1
],
"end": [
1901,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isDefEqGuarded",
"code": "abbrev isDefEqGuarded (t s : Expr) : MetaM Bool :=\n isExprDefEqGuarded t s",
"start": [
1903,
1
],
"end": [
1905,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isDefEqNoConstantApprox",
"code": "def isDefEqNoConstantApprox (t s : Expr) : MetaM Bool :=\n approxDefEq <| isDefEq t s",
"start": [
1907,
1
],
"end": [
1908,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.MVarId.checkedAssign",
"code": "def _root_.Lean.MVarId.checkedAssign (mvarId : MVarId) (val : Expr) : MetaM Bool :=\n isDefEq (mkMVar mvarId) val",
"start": [
1910,
1
],
"end": [
1912,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.etaExpand",
"code": "def etaExpand (e : Expr) : MetaM Expr :=\n withDefault do forallTelescopeReducing (← inferType e) fun xs _ => mkLambdaFVars xs (mkAppN e xs)",
"start": [
1914,
1
],
"end": [
1923,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.instantiateMVarsIfMVarApp",
"code": "def instantiateMVarsIfMVarApp (e : Expr) : MetaM Expr := do\n if e.getAppFn.isMVar then\n instantiateMVars e\n else\n return e",
"start": [
1925,
1
],
"end": [
1932,
13
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ProjFns.lean | [
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.ProjectionFunctionInfo",
"code": "structure ProjectionFunctionInfo where\n \n ctorName : Name\n \n numParams : Nat\n \n i : Nat\n \n fromClass : Bool\n deriving Inhabited",
"start": [
11,
1
],
"end": [
24,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkProjectionInfoEx",
"code": "@[export lean_mk_projection_info]\ndef mkProjectionInfoEx (ctorName : Name) (numParams : Nat) (i : Nat) (fromClass : Bool) : ProjectionFunctionInfo :=\n { ctorName, numParams, i, fromClass }",
"start": [
26,
1
],
"end": [
28,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ProjectionFunctionInfo.fromClassEx",
"code": "@[export lean_projection_info_from_class]\ndef ProjectionFunctionInfo.fromClassEx (info : ProjectionFunctionInfo) : Bool :=\n info.fromClass",
"start": [
29,
1
],
"end": [
31,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addProjectionFnInfo",
"code": "@[export lean_add_projection_info]\ndef addProjectionFnInfo (env : Environment) (projName : Name) (ctorName : Name) (numParams : Nat) (i : Nat) (fromClass : Bool) : Environment :=\n projectionFnInfoExt.insert env projName { ctorName, numParams, i, fromClass }",
"start": [
35,
1
],
"end": [
37,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.getProjectionFnInfo?",
"code": "@[export lean_get_projection_info]\ndef getProjectionFnInfo? (env : Environment) (projName : Name) : Option ProjectionFunctionInfo :=\n projectionFnInfoExt.find? env projName",
"start": [
41,
1
],
"end": [
43,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.isProjectionFn",
"code": "def isProjectionFn (env : Environment) (declName : Name) : Bool :=\n projectionFnInfoExt.contains env declName",
"start": [
45,
1
],
"end": [
46,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.getProjectionStructureName?",
"code": "def getProjectionStructureName? (env : Environment) (projName : Name) : Option Name :=\n match env.getProjectionFnInfo? projName with\n | none => none\n | some projInfo =>\n match env.find? projInfo.ctorName with\n | some (ConstantInfo.ctorInfo val) => some val.induct\n | _ => none",
"start": [
48,
1
],
"end": [
55,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isProjectionFn",
"code": "def isProjectionFn [MonadEnv m] [Monad m] (declName : Name) : m Bool :=\n return (← getEnv).isProjectionFn declName",
"start": [
59,
1
],
"end": [
60,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getProjectionFnInfo?",
"code": "def getProjectionFnInfo? [MonadEnv m] [Monad m] (declName : Name) : m (Option ProjectionFunctionInfo) :=\n return (← getEnv).getProjectionFnInfo? declName",
"start": [
62,
1
],
"end": [
63,
50
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/InferType.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Data/LBool.lean"
] | [
{
"full_name": "Lean.Expr.instantiateBetaRevRange",
"code": "partial def Expr.instantiateBetaRevRange (e : Expr) (start : Nat) (stop : Nat) (args : Array Expr) : Expr :=\n if e.hasLooseBVars && stop > start then\n assert! stop ≤ args.size\n visit e 0 |>.run\n else\n e\nwhere\n visit (e : Expr) (offset : Nat) : MonadStateCacheT (ExprStructEq × Nat) Expr Id Expr :=\n if offset >= e.looseBVarRange then\n return e\n else checkCache ({ val := e : ExprStructEq }, offset) fun _ => do\n match e with\n | .forallE _ d b _ => return e.updateForallE! (← visit d offset) (← visit b (offset+1))\n | .lam _ d b _ => return e.updateLambdaE! (← visit d offset) (← visit b (offset+1))\n | .letE _ t v b _ => return e.updateLet! (← visit t offset) (← visit v offset) (← visit b (offset+1))\n | .mdata _ b => return e.updateMData! (← visit b offset)\n | .proj _ _ b => return e.updateProj! (← visit b offset)\n | .app .. =>\n e.withAppRev fun f revArgs => do\n let fNew ← visit f offset\n let revArgs ← revArgs.mapM (visit · offset)\n if f.isBVar then\n return fNew.betaRev revArgs\n else\n return mkAppRev fNew revArgs\n | Expr.bvar vidx =>\n let n := stop - start\n if vidx < offset + n then\n return args[stop - (vidx - offset) - 1]!.liftLooseBVars 0 offset\n else\n return mkBVar (vidx - n)\n | .const .. => unreachable!\n | .fvar .. => unreachable!\n | .mvar .. => unreachable!\n | .sort .. => unreachable!\n | .lit .. => unreachable!",
"start": [
12,
1
],
"end": [
66,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwFunctionExpected",
"code": "def throwFunctionExpected {α} (f : Expr) : MetaM α :=\n throwError \"function expected{indentExpr f}\"",
"start": [
70,
1
],
"end": [
71,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferAppType",
"code": "private def inferAppType (f : Expr) (args : Array Expr) : MetaM Expr := do\n let mut fType ← inferType f\n let mut j := 0\n \n for i in [:args.size] do\n match fType with\n | Expr.forallE _ _ b _ => fType := b\n | _ =>\n match (← whnf <| fType.instantiateBetaRevRange j i args) with\n | Expr.forallE _ _ b _ => j := i; fType := b\n | _ => throwFunctionExpected <| mkAppRange f 0 (i+1) args\n return fType.instantiateBetaRevRange j args.size args",
"start": [
73,
1
],
"end": [
85,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwIncorrectNumberOfLevels",
"code": "def throwIncorrectNumberOfLevels {α} (constName : Name) (us : List Level) : MetaM α :=\n throwError \"incorrect number of universe levels {mkConst constName us}\"",
"start": [
87,
1
],
"end": [
88,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferConstType",
"code": "private def inferConstType (c : Name) (us : List Level) : MetaM Expr := do\n let cinfo ← getConstInfo c\n if cinfo.levelParams.length == us.length then\n instantiateTypeLevelParams cinfo us\n else\n throwIncorrectNumberOfLevels c us",
"start": [
90,
1
],
"end": [
95,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferProjType",
"code": "private def inferProjType (structName : Name) (idx : Nat) (e : Expr) : MetaM Expr := do\n let failed {α} : Unit → MetaM α := fun _ =>\n throwError \"invalid projection{indentExpr (mkProj structName idx e)}\"\n let structType ← inferType e\n let structType ← whnf structType\n matchConstStruct structType.getAppFn failed fun structVal structLvls ctorVal =>\n let n := structVal.numParams\n let structParams := structType.getAppArgs\n if n != structParams.size then\n failed ()\n else do\n let mut ctorType ← inferAppType (mkConst ctorVal.name structLvls) structParams\n for i in [:idx] do\n ctorType ← whnf ctorType\n match ctorType with\n | Expr.forallE _ _ body _ =>\n if body.hasLooseBVars then\n ctorType := body.instantiate1 <| mkProj structName i e\n else\n ctorType := body\n | _ => failed ()\n ctorType ← whnf ctorType\n match ctorType with\n | Expr.forallE _ d _ _ => return d.consumeTypeAnnotations\n | _ => failed ()",
"start": [
97,
1
],
"end": [
121,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwTypeExcepted",
"code": "def throwTypeExcepted {α} (type : Expr) : MetaM α :=\n throwError \"type expected{indentExpr type}\"",
"start": [
123,
1
],
"end": [
124,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getLevel",
"code": "def getLevel (type : Expr) : MetaM Level := do\n let typeType ← inferType type\n let typeType ← whnfD typeType\n match typeType with\n | Expr.sort lvl => return lvl\n | Expr.mvar mvarId =>\n if (← mvarId.isReadOnlyOrSyntheticOpaque) then\n throwTypeExcepted type\n else\n let lvl ← mkFreshLevelMVar\n mvarId.assign (mkSort lvl)\n return lvl\n | _ => throwTypeExcepted type",
"start": [
126,
1
],
"end": [
138,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferForallType",
"code": "private def inferForallType (e : Expr) : MetaM Expr :=\n forallTelescope e fun xs e => do\n let lvl ← getLevel e\n let lvl ← xs.foldrM (init := lvl) fun x lvl => do\n let xType ← inferType x\n let xTypeLvl ← getLevel xType\n return mkLevelIMax' xTypeLvl lvl\n return mkSort lvl.normalize",
"start": [
140,
1
],
"end": [
147,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferLambdaType",
"code": "private def inferLambdaType (e : Expr) : MetaM Expr :=\n lambdaLetTelescope e fun xs e => do\n let type ← inferType e\n mkForallFVars xs type",
"start": [
149,
1
],
"end": [
153,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.throwUnknownMVar",
"code": "def throwUnknownMVar {α} (mvarId : MVarId) : MetaM α :=\n throwError \"unknown metavariable '?{mvarId.name}'\"",
"start": [
155,
1
],
"end": [
156,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferMVarType",
"code": "private def inferMVarType (mvarId : MVarId) : MetaM Expr := do\n match (← getMCtx).findDecl? mvarId with\n | some d => return d.type\n | none => throwUnknownMVar mvarId",
"start": [
158,
1
],
"end": [
161,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferFVarType",
"code": "private def inferFVarType (fvarId : FVarId) : MetaM Expr := do\n match (← getLCtx).find? fvarId with\n | some d => return d.type\n | none => fvarId.throwUnknown",
"start": [
163,
1
],
"end": [
166,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.checkInferTypeCache",
"code": "@[inline] private def checkInferTypeCache (e : Expr) (inferType : MetaM Expr) : MetaM Expr := do\n match (← get).cache.inferType.find? e with\n | some type => return type\n | none =>\n let type ← inferType\n unless e.hasMVar || type.hasMVar do\n modifyInferTypeCache fun c => c.insert e type\n return type",
"start": [
168,
1
],
"end": [
175,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.inferTypeImp",
"code": "@[export lean_infer_type]\ndef inferTypeImp (e : Expr) : MetaM Expr :=\n let rec infer (e : Expr) : MetaM Expr := do\n match e with\n | .const c [] => inferConstType c []\n | .const c us => checkInferTypeCache e (inferConstType c us)\n | .proj n i s => checkInferTypeCache e (inferProjType n i s)\n | .app f .. => checkInferTypeCache e (inferAppType f.getAppFn e.getAppArgs)\n | .mvar mvarId => inferMVarType mvarId\n | .fvar fvarId => inferFVarType fvarId\n | .bvar bidx => throwError \"unexpected bound variable {mkBVar bidx}\"\n | .mdata _ e => infer e\n | .lit v => return v.type\n | .sort lvl => return mkSort (mkLevelSucc lvl)\n | .forallE .. => checkInferTypeCache e (inferForallType e)\n | .lam .. => checkInferTypeCache e (inferLambdaType e)\n | .letE .. => checkInferTypeCache e (inferLambdaType e)\n withIncRecDepth <| withTransparency TransparencyMode.default (infer e)",
"start": [
177,
1
],
"end": [
194,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isAlwaysZero",
"code": "private def isAlwaysZero : Level → Bool\n | .zero .. => true\n | .mvar .. => false\n | .param .. => false\n | .succ .. => false\n | .max u v => isAlwaysZero u && isAlwaysZero v\n | .imax _ u => isAlwaysZero u",
"start": [
196,
1
],
"end": [
205,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isArrowProp",
"code": "private partial def isArrowProp : Expr → Nat → MetaM LBool\n | .sort u, 0 => return isAlwaysZero (← instantiateLevelMVars u) |>.toLBool\n | .forallE .., 0 => return LBool.false\n | .forallE _ _ b _, n+1 => isArrowProp b n\n | .letE _ _ _ b _, n => isArrowProp b n\n | .mdata _ e, n => isArrowProp e n\n | _, _ => return LBool.undef",
"start": [
207,
1
],
"end": [
217,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isPropQuickApp",
"code": "private partial def isPropQuickApp : Expr → Nat → MetaM LBool\n | .const c lvls, arity => do let constType ← inferConstType c lvls; isArrowProp constType arity\n | .fvar fvarId, arity => do let fvarType ← inferFVarType fvarId; isArrowProp fvarType arity\n | .mvar mvarId, arity => do let mvarType ← inferMVarType mvarId; isArrowProp mvarType arity\n | .app f .., arity => isPropQuickApp f (arity+1)\n | .mdata _ e, arity => isPropQuickApp e arity\n | .letE _ _ _ b _, arity => isPropQuickApp b arity\n | .lam .., 0 => return LBool.false\n | .lam _ _ b _, arity+1 => isPropQuickApp b arity\n | _, _ => return LBool.undef",
"start": [
219,
1
],
"end": [
231,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isPropQuick",
"code": "partial def isPropQuick : Expr → MetaM LBool\n | .bvar .. => return LBool.undef\n | .lit .. => return LBool.false\n | .sort .. => return LBool.false\n | .lam .. => return LBool.false\n | .letE _ _ _ b _ => isPropQuick b\n | .proj .. => return LBool.undef\n | .forallE _ _ b _ => isPropQuick b\n | .mdata _ e => isPropQuick e\n | .const c lvls => do let constType ← inferConstType c lvls; isArrowProp constType 0\n | .fvar fvarId => do let fvarType ← inferFVarType fvarId; isArrowProp fvarType 0\n | .mvar mvarId => do let mvarType ← inferMVarType mvarId; isArrowProp mvarType 0\n | .app f .. => isPropQuickApp f 1",
"start": [
233,
1
],
"end": [
248,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isProp",
"code": "def isProp (e : Expr) : MetaM Bool := do\n match (← isPropQuick e) with\n | .true => return true\n | .false => return false\n | .undef =>\n let type ← inferType e\n let type ← whnfD type\n match type with\n | Expr.sort u => return isAlwaysZero (← instantiateLevelMVars u)\n | _ => return false",
"start": [
250,
1
],
"end": [
265,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isArrowProposition",
"code": "private partial def isArrowProposition : Expr → Nat → MetaM LBool\n | .forallE _ _ b _, n+1 => isArrowProposition b n\n | .letE _ _ _ b _, n => isArrowProposition b n\n | .mdata _ e, n => isArrowProposition e n\n | type, 0 => isPropQuick type\n | _, _ => return LBool.undef",
"start": [
267,
1
],
"end": [
276,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isProofQuickApp",
"code": "private partial def isProofQuickApp : Expr → Nat → MetaM LBool\n | .const c lvls, arity => do let constType ← inferConstType c lvls; isArrowProposition constType arity\n | .fvar fvarId, arity => do let fvarType ← inferFVarType fvarId; isArrowProposition fvarType arity\n | .mvar mvarId, arity => do let mvarType ← inferMVarType mvarId; isArrowProposition mvarType arity\n | .app f _, arity => isProofQuickApp f (arity+1)\n | .mdata _ e, arity => isProofQuickApp e arity\n | .letE _ _ _ b _, arity => isProofQuickApp b arity\n | .lam _ _ b _, 0 => isProofQuick b\n | .lam _ _ b _, arity+1 => isProofQuickApp b arity\n | _, _ => return LBool.undef",
"start": [
279,
1
],
"end": [
291,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isProofQuick",
"code": "partial def isProofQuick : Expr → MetaM LBool\n | .bvar .. => return LBool.undef\n | .lit .. => return LBool.false\n | .sort .. => return LBool.false\n | .lam _ _ b _ => isProofQuick b\n | .letE _ _ _ b _ => isProofQuick b\n | .proj .. => return LBool.undef\n | .forallE .. => return LBool.false\n | .mdata _ e => isProofQuick e\n | .const c lvls => do let constType ← inferConstType c lvls; isArrowProposition constType 0\n | .fvar fvarId => do let fvarType ← inferFVarType fvarId; isArrowProposition fvarType 0\n | .mvar mvarId => do let mvarType ← inferMVarType mvarId; isArrowProposition mvarType 0\n | .app f .. => isProofQuickApp f 1",
"start": [
293,
1
],
"end": [
308,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isProof",
"code": "def isProof (e : Expr) : MetaM Bool := do\n match (← isProofQuick e) with\n | .true => return true\n | .false => return false\n | .undef => Meta.isProp (← inferType e)",
"start": [
312,
1
],
"end": [
316,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isArrowType",
"code": "private partial def isArrowType : Expr → Nat → MetaM LBool\n | .sort .., 0 => return LBool.true\n | .forallE .., 0 => return LBool.false\n | .forallE _ _ b _, n+1 => isArrowType b n\n | .letE _ _ _ b _, n => isArrowType b n\n | .mdata _ e, n => isArrowType e n\n | _, _ => return LBool.undef",
"start": [
318,
1
],
"end": [
328,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isTypeQuickApp",
"code": "private partial def isTypeQuickApp : Expr → Nat → MetaM LBool\n | .const c lvls, arity => do let constType ← inferConstType c lvls; isArrowType constType arity\n | .fvar fvarId, arity => do let fvarType ← inferFVarType fvarId; isArrowType fvarType arity\n | .mvar mvarId, arity => do let mvarType ← inferMVarType mvarId; isArrowType mvarType arity\n | .app f _, arity => isTypeQuickApp f (arity+1)\n | .mdata _ e, arity => isTypeQuickApp e arity\n | .letE _ _ _ b _, arity => isTypeQuickApp b arity\n | .lam .., 0 => return LBool.false\n | .lam _ _ b _, arity+1 => isTypeQuickApp b arity\n | _, _ => return LBool.undef",
"start": [
330,
1
],
"end": [
342,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isTypeQuick",
"code": "partial def isTypeQuick : Expr → MetaM LBool\n | .bvar .. => return LBool.undef\n | .lit .. => return LBool.false\n | .sort .. => return LBool.true\n | .lam .. => return LBool.false\n | .letE _ _ _ b _ => isTypeQuick b\n | .proj .. => return LBool.undef\n | .forallE .. => return LBool.true\n | .mdata _ e => isTypeQuick e\n | .const c lvls => do let constType ← inferConstType c lvls; isArrowType constType 0\n | .fvar fvarId => do let fvarType ← inferFVarType fvarId; isArrowType fvarType 0\n | .mvar mvarId => do let mvarType ← inferMVarType mvarId; isArrowType mvarType 0\n | .app f .. => isTypeQuickApp f 1",
"start": [
344,
1
],
"end": [
359,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isType",
"code": "def isType (e : Expr) : MetaM Bool := do\n match (← isTypeQuick e) with\n | .true => return true\n | .false => return false\n | .undef =>\n let type ← inferType e\n let type ← whnfD type\n match type with\n | .sort .. => return true\n | _ => return false",
"start": [
361,
1
],
"end": [
373,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.withLocalDecl'",
"code": "@[inline] private def withLocalDecl' {α} (name : Name) (bi : BinderInfo) (type : Expr) (x : Expr → MetaM α) : MetaM α := do\n let fvarId ← mkFreshFVarId\n withReader (fun ctx => { ctx with lctx := ctx.lctx.mkLocalDecl fvarId name type bi }) do\n x (mkFVar fvarId)",
"start": [
375,
1
],
"end": [
378,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.typeFormerTypeLevelQuick",
"code": "def typeFormerTypeLevelQuick : Expr → Option Level\n | .forallE _ _ b _ => typeFormerTypeLevelQuick b\n | .sort l => some l\n | _ => none",
"start": [
380,
1
],
"end": [
383,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.typeFormerTypeLevel",
"code": "partial def typeFormerTypeLevel (type : Expr) : MetaM (Option Level) := do\n match typeFormerTypeLevelQuick type with\n | .some l => return .some l\n | .none => savingCache <| go type #[]\nwhere\n go (type : Expr) (xs : Array Expr) : MetaM (Option Level) := do\n match type with\n | .sort l => return some l\n | .forallE n d b c => withLocalDecl' n c (d.instantiateRev xs) fun x => go b (xs.push x)\n | _ =>\n let type ← whnfD (type.instantiateRev xs)\n match type with\n | .sort l => return some l\n | .forallE .. => go type #[]\n | _ => return none",
"start": [
385,
1
],
"end": [
402,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isTypeFormerType",
"code": "partial def isTypeFormerType (type : Expr) : MetaM Bool := do\n return (← typeFormerTypeLevel type).isSome",
"start": [
404,
1
],
"end": [
408,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isPropFormerType",
"code": "partial def isPropFormerType (type : Expr) : MetaM Bool := do\n return (← typeFormerTypeLevel type) == .some .zero",
"start": [
410,
1
],
"end": [
414,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.isTypeFormer",
"code": "def isTypeFormer (e : Expr) : MetaM Bool := do\n isTypeFormerType (← inferType e)",
"start": [
416,
1
],
"end": [
421,
35
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/ExternAttr.lean | [
".lake/packages/lean4/src/lean/Lean/ProjFns.lean",
".lake/packages/lean4/src/lean/Init/Data/List/BasicAux.lean",
".lake/packages/lean4/src/lean/Lean/Meta/Basic.lean",
".lake/packages/lean4/src/lean/Lean/Expr.lean",
".lake/packages/lean4/src/lean/Lean/Attributes.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean"
] | [
{
"full_name": "Lean.ExternEntry",
"code": "inductive ExternEntry where\n | adhoc (backend : Name)\n | inline (backend : Name) (pattern : String)\n | standard (backend : Name) (fn : String)\n | foreign (backend : Name) (fn : String)",
"start": [
16,
1
],
"end": [
20,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExternAttrData",
"code": "structure ExternAttrData where\n arity? : Option Nat := none\n entries : List ExternEntry\n deriving Inhabited",
"start": [
22,
1
],
"end": [
39,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.syntaxToExternAttrData",
"code": "private def syntaxToExternAttrData (stx : Syntax) : AttrM ExternAttrData := do\n let arity? := if stx[1].isNone then none else some <| stx[1][0].isNatLit?.getD 0\n let entriesStx := stx[2].getArgs\n if entriesStx.size == 0 && arity? == none then\n return { entries := [ ExternEntry.adhoc `all ] }\n let mut entries := #[]\n for entryStx in entriesStx do\n let backend := if entryStx[0].isNone then `all else entryStx[0][0].getId\n let str ← match entryStx[2].isStrLit? with\n | none => throwErrorAt entryStx[2] \"string literal expected\"\n | some str => pure str\n if entryStx[1].isNone then\n entries := entries.push <| ExternEntry.standard backend str\n else\n entries := entries.push <| ExternEntry.inline backend str\n return { arity? := arity?, entries := entries.toList }",
"start": [
43,
1
],
"end": [
58,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addExtern",
"code": "@[extern \"lean_add_extern\"]\nopaque addExtern (env : Environment) (n : Name) : ExceptT String Id Environment",
"start": [
60,
1
],
"end": [
61,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExternAttrData?",
"code": "@[export lean_get_extern_attr_data]\ndef getExternAttrData? (env : Environment) (n : Name) : Option ExternAttrData :=\n externAttr.getParam? env n",
"start": [
78,
1
],
"end": [
80,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.parseOptNum",
"code": "private def parseOptNum : Nat → String.Iterator → Nat → String.Iterator × Nat\n | 0, it, r => (it, r)\n | n+1, it, r =>\n if !it.hasNext then (it, r)\n else\n let c := it.curr\n if '0' <= c && c <= '9'\n then parseOptNum n it.next (r*10 + (c.toNat - '0'.toNat))\n else (it, r)",
"start": [
82,
1
],
"end": [
90,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.expandExternPatternAux",
"code": "def expandExternPatternAux (args : List String) : Nat → String.Iterator → String → String\n | 0, _, r => r\n | i+1, it, r =>\n if ¬ it.hasNext then r\n else let c := it.curr\n if c ≠ '#' then expandExternPatternAux args i it.next (r.push c)\n else\n let it := it.next\n let (it, j) := parseOptNum it.remainingBytes it 0\n let j := j-1\n expandExternPatternAux args i it (r ++ args.getD j \"\")",
"start": [
92,
1
],
"end": [
102,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.expandExternPattern",
"code": "def expandExternPattern (pattern : String) (args : List String) : String :=\n expandExternPatternAux args pattern.length pattern.mkIterator \"\"",
"start": [
104,
1
],
"end": [
105,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.mkSimpleFnCall",
"code": "def mkSimpleFnCall (fn : String) (args : List String) : String :=\n fn ++ \"(\" ++ ((args.intersperse \", \").foldl (·++·) \"\") ++ \")\"",
"start": [
107,
1
],
"end": [
108,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ExternEntry.backend",
"code": "def ExternEntry.backend : ExternEntry → Name\n | ExternEntry.adhoc n => n\n | ExternEntry.inline n _ => n\n | ExternEntry.standard n _ => n\n | ExternEntry.foreign n _ => n",
"start": [
110,
1
],
"end": [
114,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExternEntryForAux",
"code": "def getExternEntryForAux (backend : Name) : List ExternEntry → Option ExternEntry\n | [] => none\n | e::es =>\n if e.backend == `all then some e\n else if e.backend == backend then some e\n else getExternEntryForAux backend es",
"start": [
116,
1
],
"end": [
121,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExternEntryFor",
"code": "def getExternEntryFor (d : ExternAttrData) (backend : Name) : Option ExternEntry :=\n getExternEntryForAux backend d.entries",
"start": [
123,
1
],
"end": [
124,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isExtern",
"code": "def isExtern (env : Environment) (fn : Name) : Bool :=\n getExternAttrData? env fn |>.isSome",
"start": [
126,
1
],
"end": [
127,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isExternC",
"code": "def isExternC (env : Environment) (fn : Name) : Bool :=\n match getExternAttrData? env fn with\n | some { entries := [ ExternEntry.standard `all _ ], .. } => true\n | _ => false",
"start": [
129,
1
],
"end": [
134,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExternNameFor",
"code": "def getExternNameFor (env : Environment) (backend : Name) (fn : Name) : Option String := do\n let data? ← getExternAttrData? env fn\n let entry ← getExternEntryFor data? backend\n match entry with\n | ExternEntry.standard _ n => pure n\n | ExternEntry.foreign _ n => pure n\n | _ => failure",
"start": [
136,
1
],
"end": [
142,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExternConstArity",
"code": "private def getExternConstArity (declName : Name) : CoreM Nat := do\n let fromSignature : Unit → CoreM Nat := fun _ => do\n let cinfo ← getConstInfo declName\n let (arity, _) ← (Meta.forallTelescopeReducing cinfo.type fun xs _ => pure xs.size : MetaM Nat).run\n return arity\n let env ← getEnv\n match getExternAttrData? env declName with\n | none => fromSignature ()\n | some data => match data.arity? with\n | some arity => return arity\n | none => fromSignature ()",
"start": [
144,
1
],
"end": [
154,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getExternConstArityExport",
"code": "@[export lean_get_extern_const_arity]\ndef getExternConstArityExport (env : Environment) (declName : Name) : IO (Option Nat) := do\n try\n let (arity, _) ← (getExternConstArity declName).toIO { fileName := \"<compiler>\", fileMap := default } { env := env }\n return some arity\n catch\n | IO.Error.userError _ => return none\n | _ => return none",
"start": [
156,
1
],
"end": [
163,
23
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/ReservedNameAction.lean | [
".lake/packages/lean4/src/lean/Lean/CoreM.lean"
] | [
{
"full_name": "Lean.ReservedNameAction",
"code": "def ReservedNameAction := Name → CoreM Bool",
"start": [
11,
1
],
"end": [
17,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerReservedNameAction",
"code": "def registerReservedNameAction (act : ReservedNameAction) : IO Unit := do\n unless (← initializing) do\n throw (IO.userError \"failed to register reserved name action, this kind of extension can only be registered during initialization\")\n reservedNameActionsRef.modify (·.push act)",
"start": [
21,
1
],
"end": [
27,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.executeReservedNameAction",
"code": "def executeReservedNameAction (name : Name) : CoreM Unit := do\n for act in (← reservedNameActionsRef.get) do\n if (← act name) then\n return ()",
"start": [
29,
1
],
"end": [
36,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.realizeGlobalName",
"code": "def realizeGlobalName (id : Name) : CoreM (List (Name × List String)) := do\n let cs ← resolveGlobalName id\n cs.filterM fun (c, _) => do\n if (← getEnv).contains c then\n return true\n else\n try\n executeReservedNameAction c\n return (← getEnv).contains c\n catch ex =>\n logError m!\"Failed to realize constant {id}:{indentD ex.toMessageData}\"\n return false",
"start": [
38,
1
],
"end": [
53,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.realizeGlobalConstCore",
"code": "def realizeGlobalConstCore (n : Name) : CoreM (List Name) := do\n let cs ← realizeGlobalName n\n filterFieldList n cs",
"start": [
55,
1
],
"end": [
60,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.realizeGlobalConstNoOverloadCore",
"code": "def realizeGlobalConstNoOverloadCore (n : Name) : CoreM Name := do\n ensureNoOverload n (← realizeGlobalConstCore n)",
"start": [
62,
1
],
"end": [
66,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.realizeGlobalConst",
"code": "def realizeGlobalConst (stx : Syntax) : CoreM (List Name) :=\n withRef stx do preprocessSyntaxAndResolve stx realizeGlobalConstCore",
"start": [
68,
1
],
"end": [
75,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.realizeGlobalConstNoOverload",
"code": "def realizeGlobalConstNoOverload (id : Syntax) : CoreM Name := do\n ensureNonAmbiguous id (← realizeGlobalConst id)",
"start": [
77,
1
],
"end": [
84,
50
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Meta/PPGoal.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/InferType.lean"
] | [
{
"full_name": "Lean.Meta.addLine",
"code": "private def addLine (fmt : Format) : Format :=\n if fmt.isNil then fmt else fmt ++ Format.line",
"start": [
35,
1
],
"end": [
36,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.getGoalPrefix",
"code": "def getGoalPrefix (mvarDecl : MetavarDecl) : String :=\n if isLHSGoal? mvarDecl.type |>.isSome then\n \"| \"\n else\n \"⊢ \"",
"start": [
38,
1
],
"end": [
43,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Meta.ppGoal",
"code": "def ppGoal (mvarId : MVarId) : MetaM Format := do\n match (← getMCtx).findDecl? mvarId with\n | none => return \"unknown goal\"\n | some mvarDecl =>\n let indent := 2 let showLetValues := pp.showLetValues.get (← getOptions)\n let ppAuxDecls := pp.auxDecls.get (← getOptions)\n let ppImplDetailHyps := pp.implementationDetailHyps.get (← getOptions)\n let lctx := mvarDecl.lctx\n let lctx := lctx.sanitizeNames.run' { options := (← getOptions) }\n withLCtx lctx mvarDecl.localInstances do\n let rec pushPending (ids : List Name) (type? : Option Expr) (fmt : Format) : MetaM Format := do\n if ids.isEmpty then\n return fmt\n else\n let fmt := addLine fmt\n match type? with\n | none => return fmt\n | some type =>\n let typeFmt ← ppExpr type\n return fmt ++ (Format.joinSep ids.reverse (format \" \") ++ \" :\" ++ Format.nest indent (Format.line ++ typeFmt)).group\n let rec ppVars (varNames : List Name) (prevType? : Option Expr) (fmt : Format) (localDecl : LocalDecl) : MetaM (List Name × Option Expr × Format) := do\n match localDecl with\n | .cdecl _ _ varName type _ _ =>\n let varName := varName.simpMacroScopes\n let type ← instantiateMVars type\n if prevType? == none || prevType? == some type then\n return (varName :: varNames, some type, fmt)\n else do\n let fmt ← pushPending varNames prevType? fmt\n return ([varName], some type, fmt)\n | .ldecl _ _ varName type val _ _ => do\n let varName := varName.simpMacroScopes\n let fmt ← pushPending varNames prevType? fmt\n let fmt := addLine fmt\n let type ← instantiateMVars type\n let typeFmt ← ppExpr type\n let mut fmtElem := format varName ++ \" : \" ++ typeFmt\n if showLetValues then\n let val ← instantiateMVars val\n let valFmt ← ppExpr val\n fmtElem := fmtElem ++ \" :=\" ++ Format.nest indent (Format.line ++ valFmt)\n let fmt := fmt ++ fmtElem.group\n return ([], none, fmt)\n let (varNames, type?, fmt) ← lctx.foldlM (init := ([], none, Format.nil)) fun (varNames, prevType?, fmt) (localDecl : LocalDecl) =>\n if !ppAuxDecls && localDecl.isAuxDecl || !ppImplDetailHyps && localDecl.isImplementationDetail then\n return (varNames, prevType?, fmt)\n else\n ppVars varNames prevType? fmt localDecl\n let fmt ← pushPending varNames type? fmt\n let fmt := addLine fmt\n let typeFmt ← ppExpr (← instantiateMVars mvarDecl.type)\n let fmt := fmt ++ getGoalPrefix mvarDecl ++ Format.nest indent typeFmt\n match mvarDecl.userName with\n | Name.anonymous => return fmt\n | name => return \"case \" ++ format name.eraseMacroScopes ++ Format.line ++ fmt",
"start": [
45,
1
],
"end": [
102,
95
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/IR/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Data/KVMap.lean",
".lake/packages/lean4/src/lean/Lean/Data/Name.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/ExternAttr.lean",
".lake/packages/lean4/src/lean/Lean/Data/Format.lean"
] | [
{
"full_name": "Lean.IR.FunId",
"code": "abbrev FunId := Name",
"start": [
21,
1
],
"end": [
22,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Index",
"code": "abbrev Index := Nat",
"start": [
23,
1
],
"end": [
23,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.VarId",
"code": "structure VarId where\n idx : Index\n deriving Inhabited, Repr",
"start": [
24,
1
],
"end": [
27,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.JoinPointId",
"code": "structure JoinPointId where\n idx : Index\n deriving Inhabited, Repr",
"start": [
29,
1
],
"end": [
32,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Index.lt",
"code": "abbrev Index.lt (a b : Index) : Bool := a < b",
"start": [
34,
1
],
"end": [
34,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.MData",
"code": "abbrev MData := KVMap",
"start": [
46,
1
],
"end": [
46,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.MData.empty",
"code": "abbrev MData.empty : MData := {}",
"start": [
47,
1
],
"end": [
47,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType",
"code": "inductive IRType where\n | float | uint8 | uint16 | uint32 | uint64 | usize\n | irrelevant | object | tobject\n | struct (leanTypeName : Option Name) (types : Array IRType) : IRType\n | union (leanTypeName : Name) (types : Array IRType) : IRType\n deriving Inhabited, Repr",
"start": [
49,
1
],
"end": [
86,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType.beq",
"code": "partial def beq : IRType → IRType → Bool\n | float, float => true\n | uint8, uint8 => true\n | uint16, uint16 => true\n | uint32, uint32 => true\n | uint64, uint64 => true\n | usize, usize => true\n | irrelevant, irrelevant => true\n | object, object => true\n | tobject, tobject => true\n | struct n₁ tys₁, struct n₂ tys₂ => n₁ == n₂ && Array.isEqv tys₁ tys₂ beq\n | union n₁ tys₁, union n₂ tys₂ => n₁ == n₂ && Array.isEqv tys₁ tys₂ beq\n | _, _ => false",
"start": [
90,
1
],
"end": [
102,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType.isScalar",
"code": "def isScalar : IRType → Bool\n | float => true\n | uint8 => true\n | uint16 => true\n | uint32 => true\n | uint64 => true\n | usize => true\n | _ => false",
"start": [
106,
1
],
"end": [
113,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType.isObj",
"code": "def isObj : IRType → Bool\n | object => true\n | tobject => true\n | _ => false",
"start": [
115,
1
],
"end": [
118,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType.isIrrelevant",
"code": "def isIrrelevant : IRType → Bool\n | irrelevant => true\n | _ => false",
"start": [
120,
1
],
"end": [
122,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType.isStruct",
"code": "def isStruct : IRType → Bool\n | struct _ _ => true\n | _ => false",
"start": [
124,
1
],
"end": [
126,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IRType.isUnion",
"code": "def isUnion : IRType → Bool\n | union _ _ => true\n | _ => false",
"start": [
128,
1
],
"end": [
130,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Arg",
"code": "inductive Arg where\n | var (id : VarId)\n | irrelevant\n deriving Inhabited",
"start": [
134,
1
],
"end": [
141,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Arg.beq",
"code": "protected def Arg.beq : Arg → Arg → Bool\n | var x, var y => x == y\n | irrelevant, irrelevant => true\n | _, _ => false",
"start": [
143,
1
],
"end": [
146,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkVarArg",
"code": "@[export lean_ir_mk_var_arg] def mkVarArg (id : VarId) : Arg := Arg.var id",
"start": [
150,
1
],
"end": [
150,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LitVal",
"code": "inductive LitVal where\n | num (v : Nat)\n | str (v : String)",
"start": [
152,
1
],
"end": [
154,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LitVal.beq",
"code": "def LitVal.beq : LitVal → LitVal → Bool\n | num v₁, num v₂ => v₁ == v₂\n | str v₁, str v₂ => v₁ == v₂\n | _, _ => false",
"start": [
156,
1
],
"end": [
159,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.CtorInfo",
"code": "structure CtorInfo where\n name : Name\n cidx : Nat\n size : Nat\n usize : Nat\n ssize : Nat\n deriving Repr",
"start": [
163,
1
],
"end": [
180,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.CtorInfo.beq",
"code": "def CtorInfo.beq : CtorInfo → CtorInfo → Bool\n | ⟨n₁, cidx₁, size₁, usize₁, ssize₁⟩, ⟨n₂, cidx₂, size₂, usize₂, ssize₂⟩ =>\n n₁ == n₂ && cidx₁ == cidx₂ && size₁ == size₂ && usize₁ == usize₂ && ssize₁ == ssize₂",
"start": [
182,
1
],
"end": [
184,
89
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.CtorInfo.isRef",
"code": "def CtorInfo.isRef (info : CtorInfo) : Bool :=\n info.size > 0 || info.usize > 0 || info.ssize > 0",
"start": [
188,
1
],
"end": [
189,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.CtorInfo.isScalar",
"code": "def CtorInfo.isScalar (info : CtorInfo) : Bool :=\n !info.isRef",
"start": [
191,
1
],
"end": [
192,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Expr",
"code": "inductive Expr where\n \n | ctor (i : CtorInfo) (ys : Array Arg)\n | reset (n : Nat) (x : VarId)\n \n | reuse (x : VarId) (i : CtorInfo) (updtHeader : Bool) (ys : Array Arg)\n \n | proj (i : Nat) (x : VarId)\n \n | uproj (i : Nat) (x : VarId)\n \n | sproj (n : Nat) (offset : Nat) (x : VarId)\n \n | fap (c : FunId) (ys : Array Arg)\n \n | pap (c : FunId) (ys : Array Arg)\n \n | ap (x : VarId) (ys : Array Arg)\n \n | box (ty : IRType) (x : VarId)\n \n | unbox (x : VarId)\n | lit (v : LitVal)\n \n | isShared (x : VarId)",
"start": [
194,
1
],
"end": [
222,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkCtorExpr",
"code": "@[export lean_ir_mk_ctor_expr] def mkCtorExpr (n : Name) (cidx : Nat) (size : Nat) (usize : Nat) (ssize : Nat) (ys : Array Arg) : Expr :=\n Expr.ctor ⟨n, cidx, size, usize, ssize⟩ ys",
"start": [
224,
1
],
"end": [
225,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkProjExpr",
"code": "@[export lean_ir_mk_proj_expr] def mkProjExpr (i : Nat) (x : VarId) : Expr := Expr.proj i x",
"start": [
226,
1
],
"end": [
226,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkUProjExpr",
"code": "@[export lean_ir_mk_uproj_expr] def mkUProjExpr (i : Nat) (x : VarId) : Expr := Expr.uproj i x",
"start": [
227,
1
],
"end": [
227,
95
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkSProjExpr",
"code": "@[export lean_ir_mk_sproj_expr] def mkSProjExpr (n : Nat) (offset : Nat) (x : VarId) : Expr := Expr.sproj n offset x",
"start": [
228,
1
],
"end": [
228,
117
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkFAppExpr",
"code": "@[export lean_ir_mk_fapp_expr] def mkFAppExpr (c : FunId) (ys : Array Arg) : Expr := Expr.fap c ys",
"start": [
229,
1
],
"end": [
229,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkPAppExpr",
"code": "@[export lean_ir_mk_papp_expr] def mkPAppExpr (c : FunId) (ys : Array Arg) : Expr := Expr.pap c ys",
"start": [
230,
1
],
"end": [
230,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkAppExpr",
"code": "@[export lean_ir_mk_app_expr] def mkAppExpr (x : VarId) (ys : Array Arg) : Expr := Expr.ap x ys",
"start": [
231,
1
],
"end": [
231,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkNumExpr",
"code": "@[export lean_ir_mk_num_expr] def mkNumExpr (v : Nat) : Expr := Expr.lit (LitVal.num v)",
"start": [
232,
1
],
"end": [
232,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkStrExpr",
"code": "@[export lean_ir_mk_str_expr] def mkStrExpr (v : String) : Expr := Expr.lit (LitVal.str v)",
"start": [
233,
1
],
"end": [
233,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Param",
"code": "structure Param where\n x : VarId\n borrow : Bool\n ty : IRType\n deriving Inhabited, Repr",
"start": [
235,
1
],
"end": [
239,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkParam",
"code": "@[export lean_ir_mk_param]\ndef mkParam (x : VarId) (borrow : Bool) (ty : IRType) : Param := ⟨x, borrow, ty⟩",
"start": [
241,
1
],
"end": [
242,
81
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.AltCore",
"code": "inductive AltCore (FnBody : Type) : Type where\n | ctor (info : CtorInfo) (b : FnBody) : AltCore FnBody\n | default (b : FnBody) : AltCore FnBody",
"start": [
244,
1
],
"end": [
246,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody",
"code": "inductive FnBody where\n \n | vdecl (x : VarId) (ty : IRType) (e : Expr) (b : FnBody)\n \n | jdecl (j : JoinPointId) (xs : Array Param) (v : FnBody) (b : FnBody)\n \n | set (x : VarId) (i : Nat) (y : Arg) (b : FnBody)\n | setTag (x : VarId) (cidx : Nat) (b : FnBody)\n \n | uset (x : VarId) (i : Nat) (y : VarId) (b : FnBody)\n \n | sset (x : VarId) (i : Nat) (offset : Nat) (y : VarId) (ty : IRType) (b : FnBody)\n \n | inc (x : VarId) (n : Nat) (c : Bool) (persistent : Bool) (b : FnBody)\n \n | dec (x : VarId) (n : Nat) (c : Bool) (persistent : Bool) (b : FnBody)\n | del (x : VarId) (b : FnBody)\n | mdata (d : MData) (b : FnBody)\n | case (tid : Name) (x : VarId) (xType : IRType) (cs : Array (AltCore FnBody))\n | ret (x : Arg)\n \n | jmp (j : JoinPointId) (ys : Array Arg)\n | unreachable",
"start": [
248,
1
],
"end": [
274,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.nil",
"code": "abbrev FnBody.nil := FnBody.unreachable",
"start": [
278,
1
],
"end": [
278,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkVDecl",
"code": "@[export lean_ir_mk_vdecl] def mkVDecl (x : VarId) (ty : IRType) (e : Expr) (b : FnBody) : FnBody := FnBody.vdecl x ty e b",
"start": [
280,
1
],
"end": [
280,
123
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkJDecl",
"code": "@[export lean_ir_mk_jdecl] def mkJDecl (j : JoinPointId) (xs : Array Param) (v : FnBody) (b : FnBody) : FnBody := FnBody.jdecl j xs v b",
"start": [
281,
1
],
"end": [
281,
136
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkUSet",
"code": "@[export lean_ir_mk_uset] def mkUSet (x : VarId) (i : Nat) (y : VarId) (b : FnBody) : FnBody := FnBody.uset x i y b",
"start": [
282,
1
],
"end": [
282,
116
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkSSet",
"code": "@[export lean_ir_mk_sset] def mkSSet (x : VarId) (i : Nat) (offset : Nat) (y : VarId) (ty : IRType) (b : FnBody) : FnBody := FnBody.sset x i offset y ty b",
"start": [
283,
1
],
"end": [
283,
155
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkCase",
"code": "@[export lean_ir_mk_case] def mkCase (tid : Name) (x : VarId) (cs : Array (AltCore FnBody)) : FnBody :=\n FnBody.case tid x IRType.object cs",
"start": [
284,
1
],
"end": [
286,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkRet",
"code": "@[export lean_ir_mk_ret] def mkRet (x : Arg) : FnBody := FnBody.ret x",
"start": [
287,
1
],
"end": [
287,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkJmp",
"code": "@[export lean_ir_mk_jmp] def mkJmp (j : JoinPointId) (ys : Array Arg) : FnBody := FnBody.jmp j ys",
"start": [
288,
1
],
"end": [
288,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkUnreachable",
"code": "@[export lean_ir_mk_unreachable] def mkUnreachable : Unit → FnBody := fun _ => FnBody.unreachable",
"start": [
289,
1
],
"end": [
289,
98
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Alt",
"code": "abbrev Alt := AltCore FnBody",
"start": [
291,
1
],
"end": [
291,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Alt.ctor",
"code": "@[match_pattern] abbrev Alt.ctor := @AltCore.ctor FnBody",
"start": [
292,
1
],
"end": [
292,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Alt.default",
"code": "@[match_pattern] abbrev Alt.default := @AltCore.default FnBody",
"start": [
293,
1
],
"end": [
293,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.isTerminal",
"code": "def FnBody.isTerminal : FnBody → Bool\n | FnBody.case _ _ _ _ => true\n | FnBody.ret _ => true\n | FnBody.jmp _ _ => true\n | FnBody.unreachable => true\n | _ => false",
"start": [
297,
1
],
"end": [
302,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.body",
"code": "def FnBody.body : FnBody → FnBody\n | FnBody.vdecl _ _ _ b => b\n | FnBody.jdecl _ _ _ b => b\n | FnBody.set _ _ _ b => b\n | FnBody.uset _ _ _ b => b\n | FnBody.sset _ _ _ _ _ b => b\n | FnBody.setTag _ _ b => b\n | FnBody.inc _ _ _ _ b => b\n | FnBody.dec _ _ _ _ b => b\n | FnBody.del _ b => b\n | FnBody.mdata _ b => b\n | other => other",
"start": [
304,
1
],
"end": [
315,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.setBody",
"code": "def FnBody.setBody : FnBody → FnBody → FnBody\n | FnBody.vdecl x t v _, b => FnBody.vdecl x t v b\n | FnBody.jdecl j xs v _, b => FnBody.jdecl j xs v b\n | FnBody.set x i y _, b => FnBody.set x i y b\n | FnBody.uset x i y _, b => FnBody.uset x i y b\n | FnBody.sset x i o y t _, b => FnBody.sset x i o y t b\n | FnBody.setTag x i _, b => FnBody.setTag x i b\n | FnBody.inc x n c p _, b => FnBody.inc x n c p b\n | FnBody.dec x n c p _, b => FnBody.dec x n c p b\n | FnBody.del x _, b => FnBody.del x b\n | FnBody.mdata d _, b => FnBody.mdata d b\n | other, _ => other",
"start": [
317,
1
],
"end": [
328,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.resetBody",
"code": "@[inline] def FnBody.resetBody (b : FnBody) : FnBody :=\n b.setBody FnBody.nil",
"start": [
330,
1
],
"end": [
331,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.split",
"code": "@[inline] def FnBody.split (b : FnBody) : FnBody × FnBody :=\n let b' := b.body\n let c := b.resetBody\n (c, b')",
"start": [
333,
1
],
"end": [
338,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.AltCore.body",
"code": "def AltCore.body : Alt → FnBody\n | Alt.ctor _ b => b\n | Alt.default b => b",
"start": [
340,
1
],
"end": [
342,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.AltCore.setBody",
"code": "def AltCore.setBody : Alt → FnBody → Alt\n | Alt.ctor c _, b => Alt.ctor c b\n | Alt.default _, b => Alt.default b",
"start": [
344,
1
],
"end": [
346,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.AltCore.modifyBody",
"code": "@[inline] def AltCore.modifyBody (f : FnBody → FnBody) : AltCore FnBody → Alt\n | Alt.ctor c b => Alt.ctor c (f b)\n | Alt.default b => Alt.default (f b)",
"start": [
348,
1
],
"end": [
350,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.AltCore.mmodifyBody",
"code": "@[inline] def AltCore.mmodifyBody {m : Type → Type} [Monad m] (f : FnBody → m FnBody) : AltCore FnBody → m Alt\n | Alt.ctor c b => Alt.ctor c <$> f b\n | Alt.default b => Alt.default <$> f b",
"start": [
352,
1
],
"end": [
354,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Alt.isDefault",
"code": "def Alt.isDefault : Alt → Bool\n | Alt.ctor _ _ => false\n | Alt.default _ => true",
"start": [
356,
1
],
"end": [
358,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.push",
"code": "def push (bs : Array FnBody) (b : FnBody) : Array FnBody :=\n let b := b.resetBody\n bs.push b",
"start": [
360,
1
],
"end": [
362,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.flattenAux",
"code": "partial def flattenAux (b : FnBody) (r : Array FnBody) : (Array FnBody) × FnBody :=\n if b.isTerminal then (r, b)\n else flattenAux b.body (push r b)",
"start": [
364,
1
],
"end": [
366,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.flatten",
"code": "def FnBody.flatten (b : FnBody) : (Array FnBody) × FnBody :=\n flattenAux b #[]",
"start": [
368,
1
],
"end": [
369,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.reshapeAux",
"code": "partial def reshapeAux (a : Array FnBody) (i : Nat) (b : FnBody) : FnBody :=\n if i == 0 then b\n else\n let i := i - 1\n let (curr, a) := a.swapAt! i default\n let b := curr.setBody b\n reshapeAux a i b",
"start": [
371,
1
],
"end": [
377,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.reshape",
"code": "def reshape (bs : Array FnBody) (term : FnBody) : FnBody :=\n reshapeAux bs bs.size term",
"start": [
379,
1
],
"end": [
380,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.modifyJPs",
"code": "@[inline] def modifyJPs (bs : Array FnBody) (f : FnBody → FnBody) : Array FnBody :=\n bs.map fun b => match b with\n | FnBody.jdecl j xs v k => FnBody.jdecl j xs (f v) k\n | other => other",
"start": [
382,
1
],
"end": [
385,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mmodifyJPs",
"code": "@[inline] def mmodifyJPs {m : Type → Type} [Monad m] (bs : Array FnBody) (f : FnBody → m FnBody) : m (Array FnBody) :=\n bs.mapM fun b => match b with\n | FnBody.jdecl j xs v k => return FnBody.jdecl j xs (← f v) k\n | other => return other",
"start": [
387,
1
],
"end": [
390,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkAlt",
"code": "@[export lean_ir_mk_alt] def mkAlt (n : Name) (cidx : Nat) (size : Nat) (usize : Nat) (ssize : Nat) (b : FnBody) : Alt :=\n Alt.ctor ⟨n, cidx, size, usize, ssize⟩ b",
"start": [
392,
1
],
"end": [
393,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.DeclInfo",
"code": "structure DeclInfo where\n \n sorryDep? : Option Name := none",
"start": [
395,
1
],
"end": [
398,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl",
"code": "inductive Decl where\n | fdecl (f : FunId) (xs : Array Param) (type : IRType) (body : FnBody) (info : DeclInfo)\n | extern (f : FunId) (xs : Array Param) (type : IRType) (ext : ExternAttrData)\n deriving Inhabited",
"start": [
400,
1
],
"end": [
403,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl.name",
"code": "def name : Decl → FunId\n | .fdecl f .. => f\n | .extern f .. => f",
"start": [
407,
1
],
"end": [
409,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl.params",
"code": "def params : Decl → Array Param\n | .fdecl (xs := xs) .. => xs\n | .extern (xs := xs) .. => xs",
"start": [
411,
1
],
"end": [
413,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl.resultType",
"code": "def resultType : Decl → IRType\n | .fdecl (type := t) .. => t\n | .extern (type := t) .. => t",
"start": [
415,
1
],
"end": [
417,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl.isExtern",
"code": "def isExtern : Decl → Bool\n | .extern .. => true\n | _ => false",
"start": [
419,
1
],
"end": [
421,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl.getInfo",
"code": "def getInfo : Decl → DeclInfo\n | .fdecl (info := info) .. => info\n | _ => {}",
"start": [
423,
1
],
"end": [
425,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Decl.updateBody!",
"code": "def updateBody! (d : Decl) (bNew : FnBody) : Decl :=\n match d with\n | Decl.fdecl f xs t _ info => Decl.fdecl f xs t bNew info\n | _ => panic! \"expected definition\"",
"start": [
427,
1
],
"end": [
430,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkDecl",
"code": "@[export lean_ir_mk_decl] def mkDecl (f : FunId) (xs : Array Param) (ty : IRType) (b : FnBody) : Decl :=\n Decl.fdecl f xs ty b {}",
"start": [
434,
1
],
"end": [
435,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkExternDecl",
"code": "@[export lean_ir_mk_extern_decl] def mkExternDecl (f : FunId) (xs : Array Param) (ty : IRType) (e : ExternAttrData) : Decl :=\n Decl.extern f xs ty e",
"start": [
437,
1
],
"end": [
438,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkDummyExternDecl",
"code": "@[export lean_ir_mk_dummy_extern_decl] def mkDummyExternDecl (f : FunId) (xs : Array Param) (ty : IRType) : Decl :=\n Decl.fdecl f xs ty FnBody.unreachable {}",
"start": [
441,
1
],
"end": [
442,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IndexSet",
"code": "abbrev IndexSet := RBTree Index compare",
"start": [
444,
1
],
"end": [
445,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkIndexSet",
"code": "def mkIndexSet (idx : Index) : IndexSet :=\n RBTree.empty.insert idx",
"start": [
448,
1
],
"end": [
449,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContextEntry",
"code": "inductive LocalContextEntry where\n | param : IRType → LocalContextEntry\n | localVar : IRType → Expr → LocalContextEntry\n | joinPoint : Array Param → FnBody → LocalContextEntry",
"start": [
451,
1
],
"end": [
454,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext",
"code": "abbrev LocalContext := RBMap Index LocalContextEntry compare",
"start": [
456,
1
],
"end": [
456,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.addLocal",
"code": "def LocalContext.addLocal (ctx : LocalContext) (x : VarId) (t : IRType) (v : Expr) : LocalContext :=\n ctx.insert x.idx (LocalContextEntry.localVar t v)",
"start": [
458,
1
],
"end": [
459,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.addJP",
"code": "def LocalContext.addJP (ctx : LocalContext) (j : JoinPointId) (xs : Array Param) (b : FnBody) : LocalContext :=\n ctx.insert j.idx (LocalContextEntry.joinPoint xs b)",
"start": [
461,
1
],
"end": [
462,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.addParam",
"code": "def LocalContext.addParam (ctx : LocalContext) (p : Param) : LocalContext :=\n ctx.insert p.x.idx (LocalContextEntry.param p.ty)",
"start": [
464,
1
],
"end": [
465,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.addParams",
"code": "def LocalContext.addParams (ctx : LocalContext) (ps : Array Param) : LocalContext :=\n ps.foldl LocalContext.addParam ctx",
"start": [
467,
1
],
"end": [
468,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.isJP",
"code": "def LocalContext.isJP (ctx : LocalContext) (idx : Index) : Bool :=\n match ctx.find? idx with\n | some (LocalContextEntry.joinPoint _ _) => true\n | _ => false",
"start": [
470,
1
],
"end": [
473,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.getJPBody",
"code": "def LocalContext.getJPBody (ctx : LocalContext) (j : JoinPointId) : Option FnBody :=\n match ctx.find? j.idx with\n | some (LocalContextEntry.joinPoint _ b) => some b\n | _ => none",
"start": [
475,
1
],
"end": [
478,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.getJPParams",
"code": "def LocalContext.getJPParams (ctx : LocalContext) (j : JoinPointId) : Option (Array Param) :=\n match ctx.find? j.idx with\n | some (LocalContextEntry.joinPoint ys _) => some ys\n | _ => none",
"start": [
480,
1
],
"end": [
483,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.isParam",
"code": "def LocalContext.isParam (ctx : LocalContext) (idx : Index) : Bool :=\n match ctx.find? idx with\n | some (LocalContextEntry.param _) => true\n | _ => false",
"start": [
485,
1
],
"end": [
488,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.isLocalVar",
"code": "def LocalContext.isLocalVar (ctx : LocalContext) (idx : Index) : Bool :=\n match ctx.find? idx with\n | some (LocalContextEntry.localVar _ _) => true\n | _ => false",
"start": [
490,
1
],
"end": [
493,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.contains",
"code": "def LocalContext.contains (ctx : LocalContext) (idx : Index) : Bool :=\n RBMap.contains ctx idx",
"start": [
495,
1
],
"end": [
496,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.eraseJoinPointDecl",
"code": "def LocalContext.eraseJoinPointDecl (ctx : LocalContext) (j : JoinPointId) : LocalContext :=\n ctx.erase j.idx",
"start": [
498,
1
],
"end": [
499,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.getType",
"code": "def LocalContext.getType (ctx : LocalContext) (x : VarId) : Option IRType :=\n match ctx.find? x.idx with\n | some (LocalContextEntry.param t) => some t\n | some (LocalContextEntry.localVar t _) => some t\n | _ => none",
"start": [
501,
1
],
"end": [
505,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LocalContext.getValue",
"code": "def LocalContext.getValue (ctx : LocalContext) (x : VarId) : Option Expr :=\n match ctx.find? x.idx with\n | some (LocalContextEntry.localVar _ v) => some v\n | _ => none",
"start": [
507,
1
],
"end": [
510,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.IndexRenaming",
"code": "abbrev IndexRenaming := RBMap Index Index compare",
"start": [
512,
1
],
"end": [
512,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.AlphaEqv",
"code": "class AlphaEqv (α : Type) where\n aeqv : IndexRenaming → α → α → Bool",
"start": [
514,
1
],
"end": [
515,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.VarId.alphaEqv",
"code": "def VarId.alphaEqv (ρ : IndexRenaming) (v₁ v₂ : VarId) : Bool :=\n match ρ.find? v₁.idx with\n | some v => v == v₂.idx\n | none => v₁ == v₂",
"start": [
519,
1
],
"end": [
522,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Arg.alphaEqv",
"code": "def Arg.alphaEqv (ρ : IndexRenaming) : Arg → Arg → Bool\n | Arg.var v₁, Arg.var v₂ => aeqv ρ v₁ v₂\n | Arg.irrelevant, Arg.irrelevant => true\n | _, _ => false",
"start": [
526,
1
],
"end": [
529,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.args.alphaEqv",
"code": "def args.alphaEqv (ρ : IndexRenaming) (args₁ args₂ : Array Arg) : Bool :=\n Array.isEqv args₁ args₂ (fun a b => aeqv ρ a b)",
"start": [
533,
1
],
"end": [
534,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Expr.alphaEqv",
"code": "def Expr.alphaEqv (ρ : IndexRenaming) : Expr → Expr → Bool\n | Expr.ctor i₁ ys₁, Expr.ctor i₂ ys₂ => i₁ == i₂ && aeqv ρ ys₁ ys₂\n | Expr.reset n₁ x₁, Expr.reset n₂ x₂ => n₁ == n₂ && aeqv ρ x₁ x₂\n | Expr.reuse x₁ i₁ u₁ ys₁, Expr.reuse x₂ i₂ u₂ ys₂ => aeqv ρ x₁ x₂ && i₁ == i₂ && u₁ == u₂ && aeqv ρ ys₁ ys₂\n | Expr.proj i₁ x₁, Expr.proj i₂ x₂ => i₁ == i₂ && aeqv ρ x₁ x₂\n | Expr.uproj i₁ x₁, Expr.uproj i₂ x₂ => i₁ == i₂ && aeqv ρ x₁ x₂\n | Expr.sproj n₁ o₁ x₁, Expr.sproj n₂ o₂ x₂ => n₁ == n₂ && o₁ == o₂ && aeqv ρ x₁ x₂\n | Expr.fap c₁ ys₁, Expr.fap c₂ ys₂ => c₁ == c₂ && aeqv ρ ys₁ ys₂\n | Expr.pap c₁ ys₁, Expr.pap c₂ ys₂ => c₁ == c₂ && aeqv ρ ys₁ ys₂\n | Expr.ap x₁ ys₁, Expr.ap x₂ ys₂ => aeqv ρ x₁ x₂ && aeqv ρ ys₁ ys₂\n | Expr.box ty₁ x₁, Expr.box ty₂ x₂ => ty₁ == ty₂ && aeqv ρ x₁ x₂\n | Expr.unbox x₁, Expr.unbox x₂ => aeqv ρ x₁ x₂\n | Expr.lit v₁, Expr.lit v₂ => v₁ == v₂\n | Expr.isShared x₁, Expr.isShared x₂ => aeqv ρ x₁ x₂\n | _, _ => false",
"start": [
538,
1
],
"end": [
552,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.addVarRename",
"code": "def addVarRename (ρ : IndexRenaming) (x₁ x₂ : Nat) :=\n if x₁ == x₂ then ρ else ρ.insert x₁ x₂",
"start": [
556,
1
],
"end": [
557,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.addParamRename",
"code": "def addParamRename (ρ : IndexRenaming) (p₁ p₂ : Param) : Option IndexRenaming :=\n if p₁.ty == p₂.ty && p₁.borrow = p₂.borrow then\n some (addVarRename ρ p₁.x.idx p₂.x.idx)\n else\n none",
"start": [
559,
1
],
"end": [
563,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.addParamsRename",
"code": "def addParamsRename (ρ : IndexRenaming) (ps₁ ps₂ : Array Param) : Option IndexRenaming := do\n if ps₁.size != ps₂.size then\n failure\n else\n let mut ρ := ρ\n for i in [:ps₁.size] do\n ρ ← addParamRename ρ ps₁[i]! ps₂[i]!\n pure ρ",
"start": [
565,
1
],
"end": [
572,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.alphaEqv",
"code": "partial def FnBody.alphaEqv : IndexRenaming → FnBody → FnBody → Bool\n | ρ, FnBody.vdecl x₁ t₁ v₁ b₁, FnBody.vdecl x₂ t₂ v₂ b₂ => t₁ == t₂ && aeqv ρ v₁ v₂ && alphaEqv (addVarRename ρ x₁.idx x₂.idx) b₁ b₂\n | ρ, FnBody.jdecl j₁ ys₁ v₁ b₁, FnBody.jdecl j₂ ys₂ v₂ b₂ => match addParamsRename ρ ys₁ ys₂ with\n | some ρ' => alphaEqv ρ' v₁ v₂ && alphaEqv (addVarRename ρ j₁.idx j₂.idx) b₁ b₂\n | none => false\n | ρ, FnBody.set x₁ i₁ y₁ b₁, FnBody.set x₂ i₂ y₂ b₂ => aeqv ρ x₁ x₂ && i₁ == i₂ && aeqv ρ y₁ y₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.uset x₁ i₁ y₁ b₁, FnBody.uset x₂ i₂ y₂ b₂ => aeqv ρ x₁ x₂ && i₁ == i₂ && aeqv ρ y₁ y₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.sset x₁ i₁ o₁ y₁ t₁ b₁, FnBody.sset x₂ i₂ o₂ y₂ t₂ b₂ =>\n aeqv ρ x₁ x₂ && i₁ = i₂ && o₁ = o₂ && aeqv ρ y₁ y₂ && t₁ == t₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.setTag x₁ i₁ b₁, FnBody.setTag x₂ i₂ b₂ => aeqv ρ x₁ x₂ && i₁ == i₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.inc x₁ n₁ c₁ p₁ b₁, FnBody.inc x₂ n₂ c₂ p₂ b₂ => aeqv ρ x₁ x₂ && n₁ == n₂ && c₁ == c₂ && p₁ == p₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.dec x₁ n₁ c₁ p₁ b₁, FnBody.dec x₂ n₂ c₂ p₂ b₂ => aeqv ρ x₁ x₂ && n₁ == n₂ && c₁ == c₂ && p₁ == p₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.del x₁ b₁, FnBody.del x₂ b₂ => aeqv ρ x₁ x₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.mdata m₁ b₁, FnBody.mdata m₂ b₂ => m₁ == m₂ && alphaEqv ρ b₁ b₂\n | ρ, FnBody.case n₁ x₁ _ alts₁, FnBody.case n₂ x₂ _ alts₂ => n₁ == n₂ && aeqv ρ x₁ x₂ && Array.isEqv alts₁ alts₂ (fun alt₁ alt₂ =>\n match alt₁, alt₂ with\n | Alt.ctor i₁ b₁, Alt.ctor i₂ b₂ => i₁ == i₂ && alphaEqv ρ b₁ b₂\n | Alt.default b₁, Alt.default b₂ => alphaEqv ρ b₁ b₂\n | _, _ => false)\n | ρ, FnBody.jmp j₁ ys₁, FnBody.jmp j₂ ys₂ => j₁ == j₂ && aeqv ρ ys₁ ys₂\n | ρ, FnBody.ret x₁, FnBody.ret x₂ => aeqv ρ x₁ x₂\n | _, FnBody.unreachable, FnBody.unreachable => true\n | _, _, _ => false",
"start": [
574,
1
],
"end": [
596,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.FnBody.beq",
"code": "def FnBody.beq (b₁ b₂ : FnBody) : Bool :=\n FnBody.alphaEqv ∅ b₁ b₂",
"start": [
598,
1
],
"end": [
599,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.VarIdSet",
"code": "abbrev VarIdSet := RBTree VarId (fun x y => compare x.idx y.idx)",
"start": [
603,
1
],
"end": [
603,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.mkIf",
"code": "def mkIf (x : VarId) (t e : FnBody) : FnBody :=\n FnBody.case `Bool x IRType.uint8 #[\n Alt.ctor {name := ``Bool.false, cidx := 0, size := 0, usize := 0, ssize := 0} e,\n Alt.ctor {name := ``Bool.true, cidx := 1, size := 0, usize := 0, ssize := 0} t\n ]",
"start": [
606,
1
],
"end": [
610,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.getUnboxOpName",
"code": "def getUnboxOpName (t : IRType) : String :=\n match t with\n | IRType.usize => \"lean_unbox_usize\"\n | IRType.uint32 => \"lean_unbox_uint32\"\n | IRType.uint64 => \"lean_unbox_uint64\"\n | IRType.float => \"lean_unbox_float\"\n | _ => \"lean_unbox\"",
"start": [
612,
1
],
"end": [
618,
34
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Main.lean | [
".lake/packages/lean4/src/lean/Lean/Meta/PPGoal.lean",
".lake/packages/lean4/src/lean/Lean/ReservedNameAction.lean"
] | [
{
"full_name": "Lean.Elab.CommandContextInfo.saveNoFileMap",
"code": "def saveNoFileMap : m CommandContextInfo := return {\n env := (← getEnv)\n fileMap := default\n mctx := (← getMCtx)\n options := (← getOptions)\n currNamespace := (← getCurrNamespace)\n openDecls := (← getOpenDecls)\n ngen := (← getNGen)\n }",
"start": [
15,
1
],
"end": [
23,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Elab.CommandContextInfo.save",
"code": "def save [MonadFileMap m] : m CommandContextInfo := do\n let ctx ← saveNoFileMap\n return { ctx with fileMap := (← getFileMap) }",
"start": [
25,
1
],
"end": [
27,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "PartialContextInfo.mergeIntoOuter?",
"code": "def PartialContextInfo.mergeIntoOuter?\n : (inner : PartialContextInfo) → (outer? : Option ContextInfo) → Option ContextInfo\n | .commandCtx info, none =>\n some { info with }\n | .parentDeclCtx _, none =>\n panic! \"Unexpected incomplete InfoTree context info.\"\n | .commandCtx innerInfo, some outer =>\n some { outer with toCommandContextInfo := innerInfo }\n | .parentDeclCtx innerParentDecl, some outer =>\n some { outer with parentDecl? := innerParentDecl }",
"start": [
31,
1
],
"end": [
50,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "CompletionInfo.stx",
"code": "def CompletionInfo.stx : CompletionInfo → Syntax\n | dot i .. => i.stx\n | id stx .. => stx\n | dotId stx .. => stx\n | fieldId stx .. => stx\n | namespaceId stx => stx\n | option stx => stx\n | endSection stx .. => stx\n | tactic stx .. => stx",
"start": [
52,
1
],
"end": [
60,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "CompletionInfo.lctx",
"code": "def CompletionInfo.lctx : CompletionInfo → LocalContext\n | dot i .. => i.lctx\n | id _ _ _ lctx .. => lctx\n | dotId _ _ lctx .. => lctx\n | fieldId _ _ lctx .. => lctx\n | _ => .empty",
"start": [
62,
1
],
"end": [
71,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "CustomInfo.format",
"code": "def CustomInfo.format : CustomInfo → Format\n | i => f!\"CustomInfo({i.value.typeName})\"",
"start": [
73,
1
],
"end": [
74,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "InfoTree.findInfo?",
"code": "partial def InfoTree.findInfo? (p : Info → Bool) (t : InfoTree) : Option Info :=\n match t with\n | context _ t => findInfo? p t\n | node i ts =>\n if p i then\n some i\n else\n ts.findSome? (findInfo? p)\n | _ => none",
"start": [
78,
1
],
"end": [
86,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "InfoTree.substitute",
"code": "partial def InfoTree.substitute (tree : InfoTree) (assignment : PersistentHashMap MVarId InfoTree) : InfoTree :=\n match tree with\n | node i c => node i <| c.map (substitute · assignment)\n | context i t => context i (substitute t assignment)\n | hole id => match assignment.find? id with\n | none => hole id\n | some tree => substitute tree assignment",
"start": [
88,
1
],
"end": [
96,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "ContextInfo.runCoreM",
"code": "def ContextInfo.runCoreM (info : ContextInfo) (x : CoreM α) : IO α := do\n \n (·.1) <$>\n (withOptions (fun _ => info.options) x).toIO\n { currNamespace := info.currNamespace, openDecls := info.openDecls\n fileName := \"<InfoTree>\", fileMap := default }\n { env := info.env, ngen := info.ngen }",
"start": [
98,
1
],
"end": [
108,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "ContextInfo.runMetaM",
"code": "def ContextInfo.runMetaM (info : ContextInfo) (lctx : LocalContext) (x : MetaM α) : IO α := do\n (·.1) <$> info.runCoreM (x.run { lctx := lctx } { mctx := info.mctx })",
"start": [
110,
1
],
"end": [
111,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "ContextInfo.toPPContext",
"code": "def ContextInfo.toPPContext (info : ContextInfo) (lctx : LocalContext) : PPContext :=\n { env := info.env, mctx := info.mctx, lctx := lctx,\n opts := info.options, currNamespace := info.currNamespace, openDecls := info.openDecls }",
"start": [
113,
1
],
"end": [
115,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "ContextInfo.ppSyntax",
"code": "def ContextInfo.ppSyntax (info : ContextInfo) (lctx : LocalContext) (stx : Syntax) : IO Format := do\n ppTerm (info.toPPContext lctx) ⟨stx⟩",
"start": [
117,
1
],
"end": [
118,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "formatStxRange",
"code": "private def formatStxRange (ctx : ContextInfo) (stx : Syntax) : Format :=\n let pos := stx.getPos?.getD 0\n let endPos := stx.getTailPos?.getD pos\n f!\"{fmtPos pos stx.getHeadInfo}-{fmtPos endPos stx.getTailInfo}\"\nwhere fmtPos pos info :=\n let pos := format <| ctx.fileMap.toPosition pos\n match info with\n | .original .. => pos\n | .synthetic (canonical := true) .. => f!\"{pos}†!\"\n | _ => f!\"{pos}†\"",
"start": [
120,
1
],
"end": [
129,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "formatElabInfo",
"code": "private def formatElabInfo (ctx : ContextInfo) (info : ElabInfo) : Format :=\n if info.elaborator.isAnonymous then\n formatStxRange ctx info.stx\n else\n f!\"{formatStxRange ctx info.stx} @ {info.elaborator}\"",
"start": [
131,
1
],
"end": [
135,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "TermInfo.runMetaM",
"code": "def TermInfo.runMetaM (info : TermInfo) (ctx : ContextInfo) (x : MetaM α) : IO α :=\n ctx.runMetaM info.lctx x",
"start": [
137,
1
],
"end": [
138,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "TermInfo.format",
"code": "def TermInfo.format (ctx : ContextInfo) (info : TermInfo) : IO Format := do\n info.runMetaM ctx do\n let ty : Format ← try\n Meta.ppExpr (← Meta.inferType info.expr)\n catch _ =>\n pure \"<failed-to-infer-type>\"\n return f!\"{← Meta.ppExpr info.expr} {if info.isBinder then \"(isBinder := true) \" else \"\"}: {ty} @ {formatElabInfo ctx info.toElabInfo}\"",
"start": [
140,
1
],
"end": [
146,
140
],
"kind": "commanddeclaration"
},
{
"full_name": "CompletionInfo.format",
"code": "def CompletionInfo.format (ctx : ContextInfo) (info : CompletionInfo) : IO Format :=\n match info with\n | .dot i (expectedType? := expectedType?) .. => return f!\"[.] {← i.format ctx} : {expectedType?}\"\n | .id stx _ _ lctx expectedType? => ctx.runMetaM lctx do return f!\"[.] {← ctx.ppSyntax lctx stx} : {expectedType?} @ {formatStxRange ctx info.stx}\"\n | _ => return f!\"[.] {info.stx} @ {formatStxRange ctx info.stx}\"",
"start": [
148,
1
],
"end": [
152,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "CommandInfo.format",
"code": "def CommandInfo.format (ctx : ContextInfo) (info : CommandInfo) : IO Format := do\n return f!\"command @ {formatElabInfo ctx info.toElabInfo}\"",
"start": [
154,
1
],
"end": [
155,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "OptionInfo.format",
"code": "def OptionInfo.format (ctx : ContextInfo) (info : OptionInfo) : IO Format := do\n return f!\"option {info.optionName} @ {formatStxRange ctx info.stx}\"",
"start": [
157,
1
],
"end": [
158,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "FieldInfo.format",
"code": "def FieldInfo.format (ctx : ContextInfo) (info : FieldInfo) : IO Format := do\n ctx.runMetaM info.lctx do\n return f!\"{info.fieldName} : {← Meta.ppExpr (← Meta.inferType info.val)} := {← Meta.ppExpr info.val} @ {formatStxRange ctx info.stx}\"",
"start": [
160,
1
],
"end": [
162,
138
],
"kind": "commanddeclaration"
},
{
"full_name": "ContextInfo.ppGoals",
"code": "def ContextInfo.ppGoals (ctx : ContextInfo) (goals : List MVarId) : IO Format :=\n if goals.isEmpty then\n return \"no goals\"\n else\n ctx.runMetaM {} (return Std.Format.prefixJoin \"\\n\" (← goals.mapM (Meta.ppGoal ·)))",
"start": [
164,
1
],
"end": [
168,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "TacticInfo.format",
"code": "def TacticInfo.format (ctx : ContextInfo) (info : TacticInfo) : IO Format := do\n let ctxB := { ctx with mctx := info.mctxBefore }\n let ctxA := { ctx with mctx := info.mctxAfter }\n let goalsBefore ← ctxB.ppGoals info.goalsBefore\n let goalsAfter ← ctxA.ppGoals info.goalsAfter\n return f!\"Tactic @ {formatElabInfo ctx info.toElabInfo}\\n{info.stx}\\nbefore {goalsBefore}\\nafter {goalsAfter}\"",
"start": [
170,
1
],
"end": [
175,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "MacroExpansionInfo.format",
"code": "def MacroExpansionInfo.format (ctx : ContextInfo) (info : MacroExpansionInfo) : IO Format := do\n let stx ← ctx.ppSyntax info.lctx info.stx\n let output ← ctx.ppSyntax info.lctx info.output\n return f!\"Macro expansion\\n{stx}\\n===>\\n{output}\"",
"start": [
177,
1
],
"end": [
180,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "UserWidgetInfo.format",
"code": "def UserWidgetInfo.format (info : UserWidgetInfo) : Format :=\n f!\"UserWidget {info.id}\\n{Std.ToFormat.format <| info.props.run' {}}\"",
"start": [
182,
1
],
"end": [
183,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "FVarAliasInfo.format",
"code": "def FVarAliasInfo.format (info : FVarAliasInfo) : Format :=\n f!\"FVarAlias {info.userName.eraseMacroScopes}\"",
"start": [
185,
1
],
"end": [
186,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "FieldRedeclInfo.format",
"code": "def FieldRedeclInfo.format (ctx : ContextInfo) (info : FieldRedeclInfo) : Format :=\n f!\"FieldRedecl @ {formatStxRange ctx info.stx}\"",
"start": [
188,
1
],
"end": [
189,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "OmissionInfo.format",
"code": "def OmissionInfo.format (ctx : ContextInfo) (info : OmissionInfo) : IO Format := do\n return f!\"Omission @ {← TermInfo.format ctx info.toTermInfo}\\nReason: {info.reason}\"",
"start": [
191,
1
],
"end": [
192,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Info.format",
"code": "def Info.format (ctx : ContextInfo) : Info → IO Format\n | ofTacticInfo i => i.format ctx\n | ofTermInfo i => i.format ctx\n | ofCommandInfo i => i.format ctx\n | ofMacroExpansionInfo i => i.format ctx\n | ofOptionInfo i => i.format ctx\n | ofFieldInfo i => i.format ctx\n | ofCompletionInfo i => i.format ctx\n | ofUserWidgetInfo i => pure <| i.format\n | ofCustomInfo i => pure <| Std.ToFormat.format i\n | ofFVarAliasInfo i => pure <| i.format\n | ofFieldRedeclInfo i => pure <| i.format ctx\n | ofOmissionInfo i => i.format ctx",
"start": [
194,
1
],
"end": [
206,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Info.toElabInfo?",
"code": "def Info.toElabInfo? : Info → Option ElabInfo\n | ofTacticInfo i => some i.toElabInfo\n | ofTermInfo i => some i.toElabInfo\n | ofCommandInfo i => some i.toElabInfo\n | ofMacroExpansionInfo _ => none\n | ofOptionInfo _ => none\n | ofFieldInfo _ => none\n | ofCompletionInfo _ => none\n | ofUserWidgetInfo _ => none\n | ofCustomInfo _ => none\n | ofFVarAliasInfo _ => none\n | ofFieldRedeclInfo _ => none\n | ofOmissionInfo i => some i.toElabInfo",
"start": [
208,
1
],
"end": [
220,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Info.updateContext?",
"code": "def Info.updateContext? : Option ContextInfo → Info → Option ContextInfo\n | some ctx, ofTacticInfo i => some { ctx with mctx := i.mctxAfter }\n | ctx?, _ => ctx?",
"start": [
222,
1
],
"end": [
238,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "InfoTree.format",
"code": "partial def InfoTree.format (tree : InfoTree) (ctx? : Option ContextInfo := none) : IO Format := do\n match tree with\n | hole id => return .nestD f!\"• ?{toString id.name}\"\n | context i t => format t <| i.mergeIntoOuter? ctx?\n | node i cs => match ctx? with\n | none => return \"• <context-not-available>\"\n | some ctx =>\n let fmt ← i.format ctx\n if cs.size == 0 then\n return .nestD f!\"• {fmt}\"\n else\n let ctx? := i.updateContext? ctx?\n return .nestD f!\"• {fmt}{Std.Format.prefixJoin .line (← cs.toList.mapM fun c => format c ctx?)}\"",
"start": [
240,
1
],
"end": [
252,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "modifyInfoTrees",
"code": "@[inline] private def modifyInfoTrees (f : PersistentArray InfoTree → PersistentArray InfoTree) : m Unit :=\n modifyInfoState fun s => { s with trees := f s.trees }",
"start": [
257,
1
],
"end": [
258,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "getResetInfoTrees",
"code": "def getResetInfoTrees : m (PersistentArray InfoTree) := do\n let trees := (← getInfoState).trees\n modifyInfoTrees fun _ => {}\n return trees",
"start": [
260,
1
],
"end": [
264,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "pushInfoTree",
"code": "def pushInfoTree (t : InfoTree) : m Unit := do\n if (← getInfoState).enabled then\n modifyInfoTrees fun ts => ts.push t",
"start": [
266,
1
],
"end": [
268,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "pushInfoLeaf",
"code": "def pushInfoLeaf (t : Info) : m Unit := do\n if (← getInfoState).enabled then\n pushInfoTree <| InfoTree.node (children := {}) t",
"start": [
270,
1
],
"end": [
272,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "addCompletionInfo",
"code": "def addCompletionInfo (info : CompletionInfo) : m Unit := do\n pushInfoLeaf <| Info.ofCompletionInfo info",
"start": [
274,
1
],
"end": [
275,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "addConstInfo",
"code": "def addConstInfo [MonadEnv m] [MonadError m]\n (stx : Syntax) (n : Name) (expectedType? : Option Expr := none) : m Unit := do\n pushInfoLeaf <| .ofTermInfo {\n elaborator := .anonymous\n lctx := .empty\n expr := (← mkConstWithLevelParams n)\n stx\n expectedType?\n }",
"start": [
277,
1
],
"end": [
285,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "realizeGlobalConstNoOverloadWithInfo",
"code": "def realizeGlobalConstNoOverloadWithInfo (id : Syntax) (expectedType? : Option Expr := none) : CoreM Name := do\n let n ← realizeGlobalConstNoOverload id\n if (← getInfoState).enabled then\n addConstInfo id n expectedType?\n return n",
"start": [
287,
1
],
"end": [
296,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "realizeGlobalConstWithInfos",
"code": "def realizeGlobalConstWithInfos (id : Syntax) (expectedType? : Option Expr := none) : CoreM (List Name) := do\n let ns ← realizeGlobalConst id\n if (← getInfoState).enabled then\n for n in ns do\n addConstInfo id n expectedType?\n return ns",
"start": [
298,
1
],
"end": [
304,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "realizeGlobalNameWithInfos",
"code": "def realizeGlobalNameWithInfos (ref : Syntax) (id : Name) : CoreM (List (Name × List String)) := do\n let ns ← realizeGlobalName id\n if (← getInfoState).enabled then\n for (n, _) in ns do\n addConstInfo ref n\n return ns",
"start": [
306,
1
],
"end": [
312,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "withInfoContext'",
"code": "def withInfoContext' [MonadFinally m] (x : m α) (mkInfo : α → m (Sum Info MVarId)) : m α := do\n if (← getInfoState).enabled then\n let treesSaved ← getResetInfoTrees\n Prod.fst <$> MonadFinally.tryFinally' x fun a? => do\n match a? with\n | none => modifyInfoTrees fun _ => treesSaved\n | some a =>\n let info ← mkInfo a\n modifyInfoTrees fun trees =>\n match info with\n | Sum.inl info => treesSaved.push <| InfoTree.node info trees\n | Sum.inr mvarId => treesSaved.push <| InfoTree.hole mvarId\n else\n x",
"start": [
314,
1
],
"end": [
333,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "withInfoTreeContext",
"code": "def withInfoTreeContext [MonadFinally m] (x : m α) (mkInfoTree : PersistentArray InfoTree → m InfoTree) : m α := do\n if (← getInfoState).enabled then\n let treesSaved ← getResetInfoTrees\n Prod.fst <$> MonadFinally.tryFinally' x fun _ => do\n let st ← getInfoState\n let tree ← mkInfoTree st.trees\n modifyInfoTrees fun _ => treesSaved.push tree\n else\n x",
"start": [
335,
1
],
"end": [
345,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "withInfoContext",
"code": "@[inline] def withInfoContext [MonadFinally m] (x : m α) (mkInfo : m Info) : m α := do\n withInfoTreeContext x (fun trees => do return InfoTree.node (← mkInfo) trees)",
"start": [
347,
1
],
"end": [
349,
80
],
"kind": "commanddeclaration"
},
{
"full_name": "withSavedPartialInfoContext",
"code": "private def withSavedPartialInfoContext [MonadFinally m]\n (x : m α)\n (ctx? : m (Option PartialContextInfo))\n : m α := do\n if !(← getInfoState).enabled then\n return ← x\n let treesSaved ← getResetInfoTrees\n Prod.fst <$> MonadFinally.tryFinally' x fun _ => do\n let st ← getInfoState\n let trees ← st.trees.mapM fun tree => do\n let tree := tree.substitute st.assignment\n match (← ctx?) with\n | none =>\n pure tree\n | some ctx =>\n pure <| InfoTree.context ctx tree\n modifyInfoTrees fun _ => treesSaved ++ trees",
"start": [
351,
1
],
"end": [
367,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "withSaveInfoContext",
"code": "def withSaveInfoContext\n [MonadNameGenerator m]\n [MonadFinally m]\n [MonadEnv m]\n [MonadOptions m]\n [MonadMCtx m]\n [MonadResolveName m]\n [MonadFileMap m]\n (x : m α)\n : m α := do\n withSavedPartialInfoContext x do\n return some <| .commandCtx (← CommandContextInfo.save)",
"start": [
369,
1
],
"end": [
385,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "withSaveParentDeclInfoContext",
"code": "def withSaveParentDeclInfoContext [MonadFinally m] [MonadParentDecl m] (x : m α) : m α := do\n withSavedPartialInfoContext x do\n let some declName ← getParentDeclName?\n | return none\n return some <| .parentDeclCtx declName",
"start": [
387,
1
],
"end": [
396,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "getInfoHoleIdAssignment?",
"code": "def getInfoHoleIdAssignment? (mvarId : MVarId) : m (Option InfoTree) :=\n return (← getInfoState).assignment[mvarId]",
"start": [
398,
1
],
"end": [
399,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "assignInfoHoleId",
"code": "def assignInfoHoleId (mvarId : MVarId) (infoTree : InfoTree) : m Unit := do\n assert! (← getInfoHoleIdAssignment? mvarId).isNone\n modifyInfoState fun s => { s with assignment := s.assignment.insert mvarId infoTree }",
"start": [
401,
1
],
"end": [
403,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "withMacroExpansionInfo",
"code": "def withMacroExpansionInfo [MonadFinally m] [Monad m] [MonadInfoTree m] [MonadLCtx m] (stx output : Syntax) (x : m α) : m α :=\n let mkInfo : m Info := do\n return Info.ofMacroExpansionInfo {\n lctx := (← getLCtx)\n stx, output\n }\n withInfoContext x mkInfo",
"start": [
406,
1
],
"end": [
412,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "withInfoHole",
"code": "@[inline] def withInfoHole [MonadFinally m] [Monad m] [MonadInfoTree m] (mvarId : MVarId) (x : m α) : m α := do\n if (← getInfoState).enabled then\n let treesSaved ← getResetInfoTrees\n Prod.fst <$> MonadFinally.tryFinally' x fun _ => modifyInfoState fun s =>\n if h : s.trees.size > 0 then\n have : s.trees.size - 1 < s.trees.size := Nat.sub_lt h (by decide)\n { s with trees := treesSaved, assignment := s.assignment.insert mvarId s.trees[s.trees.size - 1] }\n else\n { s with trees := treesSaved }\n else\n x",
"start": [
414,
1
],
"end": [
424,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "enableInfoTree",
"code": "def enableInfoTree [MonadInfoTree m] (flag := true) : m Unit :=\n modifyInfoState fun s => { s with enabled := flag }",
"start": [
426,
1
],
"end": [
427,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "withEnableInfoTree",
"code": "def withEnableInfoTree [Monad m] [MonadInfoTree m] [MonadFinally m] (flag : Bool) (x : m α) : m α := do\n let saved := (← getInfoState).enabled\n try\n enableInfoTree flag\n x\n finally\n enableInfoTree saved",
"start": [
429,
1
],
"end": [
435,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "getInfoTrees",
"code": "def getInfoTrees [MonadInfoTree m] [Monad m] : m (PersistentArray InfoTree) :=\n return (← getInfoState).trees",
"start": [
437,
1
],
"end": [
438,
32
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/AddDecl.lean | [
".lake/packages/lean4/src/lean/Lean/CoreM.lean"
] | [
{
"full_name": "Lean.Environment.addDecl",
"code": "def Environment.addDecl (env : Environment) (opts : Options) (decl : Declaration) : Except KernelException Environment :=\n if debug.skipKernelTC.get opts then\n addDeclWithoutChecking env decl\n else\n addDeclCore env (Core.getMaxHeartbeats opts).toUSize decl",
"start": [
17,
1
],
"end": [
21,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Environment.addAndCompile",
"code": "def Environment.addAndCompile (env : Environment) (opts : Options) (decl : Declaration) : Except KernelException Environment := do\n let env ← addDecl env opts decl\n compileDecl env opts decl",
"start": [
23,
1
],
"end": [
25,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addDecl",
"code": "def addDecl (decl : Declaration) : CoreM Unit := do\n profileitM Exception \"type checking\" (← getOptions) do\n withTraceNode `Kernel (fun _ => return m!\"typechecking declaration\") do\n if !(← MonadLog.hasErrors) && decl.hasSorry then\n logWarning \"declaration uses 'sorry'\"\n match (← getEnv).addDecl (← getOptions) decl with\n | .ok env => setEnv env\n | .error ex => throwKernelException ex",
"start": [
27,
1
],
"end": [
34,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addAndCompile",
"code": "def addAndCompile (decl : Declaration) : CoreM Unit := do\n addDecl decl\n compileDecl decl",
"start": [
36,
1
],
"end": [
38,
19
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/DeclarationRange.lean | [
".lake/packages/lean4/src/lean/Lean/AuxRecursor.lean",
".lake/packages/lean4/src/lean/Lean/MonadEnv.lean",
".lake/packages/lean4/src/lean/Lean/ToExpr.lean"
] | [
{
"full_name": "Lean.DeclarationRange",
"code": "structure DeclarationRange where\n pos : Position\n \n charUtf16 : Nat\n endPos : Position\n \n endCharUtf16 : Nat\n deriving Inhabited, DecidableEq, Repr",
"start": [
13,
1
],
"end": [
24,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.DeclarationRanges",
"code": "structure DeclarationRanges where\n range : DeclarationRange\n selectionRange : DeclarationRange\n deriving Inhabited, Repr",
"start": [
30,
1
],
"end": [
33,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addBuiltinDeclarationRanges",
"code": "def addBuiltinDeclarationRanges (declName : Name) (declRanges : DeclarationRanges) : IO Unit :=\n builtinDeclRanges.modify (·.insert declName declRanges)",
"start": [
42,
1
],
"end": [
43,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addDeclarationRanges",
"code": "def addDeclarationRanges [MonadEnv m] (declName : Name) (declRanges : DeclarationRanges) : m Unit :=\n modifyEnv fun env => declRangeExt.insert env declName declRanges",
"start": [
45,
1
],
"end": [
46,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findDeclarationRangesCore?",
"code": "def findDeclarationRangesCore? [Monad m] [MonadEnv m] (declName : Name) : m (Option DeclarationRanges) :=\n return declRangeExt.find? (← getEnv) declName",
"start": [
48,
1
],
"end": [
49,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findDeclarationRanges?",
"code": "def findDeclarationRanges? [Monad m] [MonadEnv m] [MonadLiftT BaseIO m] (declName : Name) : m (Option DeclarationRanges) := do\n let env ← getEnv\n let ranges ← if isAuxRecursor env declName || isNoConfusion env declName || (← isRec declName) then\n findDeclarationRangesCore? declName.getPrefix\n else\n findDeclarationRangesCore? declName\n match ranges with\n | none => return (← builtinDeclRanges.get (m := BaseIO)).find? declName\n | some _ => return ranges",
"start": [
51,
1
],
"end": [
59,
28
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Data/Trie.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Format.lean"
] | [
{
"full_name": "Lean.Data.Trie",
"code": "inductive Trie (α : Type) where\n | leaf : Option α → Trie α\n | node1 : Option α → UInt8 → Trie α → Trie α\n | node : Option α → ByteArray → Array (Trie α) → Trie α",
"start": [
38,
1
],
"end": [
43,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.empty",
"code": "def empty : Trie α := leaf none",
"start": [
48,
1
],
"end": [
49,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.upsert",
"code": "partial def upsert (t : Trie α) (s : String) (f : Option α → α) : Trie α :=\n let rec insertEmpty (i : Nat) : Trie α :=\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n let t := insertEmpty (i + 1)\n node1 none c t\n else\n leaf (f .none)\n let rec loop\n | i, leaf v =>\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n let t := insertEmpty (i + 1)\n node1 v c t\n else\n leaf (f v)\n | i, node1 v c' t' =>\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n if c == c'\n then node1 v c' (loop (i + 1) t')\n else \n let t := insertEmpty (i + 1)\n node v (.mk #[c, c']) #[t, t']\n else\n node1 (f v) c' t'\n | i, node v cs ts =>\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n match cs.findIdx? (· == c) with\n | none =>\n let t := insertEmpty (i + 1)\n node v (cs.push c) (ts.push t)\n | some idx =>\n node v cs (ts.modify idx (loop (i + 1)))\n else\n node (f v) cs ts\n loop 0 t",
"start": [
57,
1
],
"end": [
95,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.insert",
"code": "partial def insert (t : Trie α) (s : String) (val : α) : Trie α :=\n upsert t s (fun _ => val)",
"start": [
97,
1
],
"end": [
99,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.find?",
"code": "partial def find? (t : Trie α) (s : String) : Option α :=\n let rec loop\n | i, leaf val =>\n if i < s.utf8ByteSize then\n none\n else\n val\n | i, node1 val c' t' =>\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n if c == c'\n then loop (i + 1) t'\n else none\n else\n val\n | i, node val cs ts =>\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n match cs.findIdx? (· == c) with\n | none => none\n | some idx => loop (i + 1) (ts.get! idx)\n else\n val\n loop 0 t",
"start": [
101,
1
],
"end": [
125,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.values",
"code": "partial def values (t : Trie α) : Array α := go t |>.run #[] |>.2\n where\n go : Trie α → StateM (Array α) Unit\n | leaf a? => do\n if let some a := a? then\n modify (·.push a)\n | node1 a? _ t' => do\n if let some a := a? then\n modify (·.push a)\n go t'\n | node a? _ ts => do\n if let some a := a? then\n modify (·.push a)\n ts.forM fun t' => go t'",
"start": [
127,
1
],
"end": [
141,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.findPrefix",
"code": "partial def findPrefix (t : Trie α) (pre : String) : Array α := go t 0\n where\n go (t : Trie α) (i : Nat) : Array α :=\n if h : i < pre.utf8ByteSize then\n let c := pre.getUtf8Byte i h\n match t with\n | leaf _val => .empty\n | node1 _val c' t' =>\n if c == c'\n then go t' (i + 1)\n else .empty\n | node _val cs ts =>\n match cs.findIdx? (· == c) with\n | none => .empty\n | some idx => go (ts.get! idx) (i + 1)\n else\n t.values",
"start": [
143,
1
],
"end": [
160,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.matchPrefix",
"code": "partial def matchPrefix (s : String) (t : Trie α) (i : String.Pos) : Option α :=\n let rec loop\n | leaf v, _, res =>\n if v.isSome then v else res\n | node1 v c' t', i, res =>\n let res := if v.isSome then v else res\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n if c == c'\n then loop t' (i + 1) res\n else res\n else\n res\n | node v cs ts, i, res =>\n let res := if v.isSome then v else res\n if h : i < s.utf8ByteSize then\n let c := s.getUtf8Byte i h\n match cs.findIdx? (· == c) with\n | none => res\n | some idx => loop (ts.get! idx) (i + 1) res\n else\n res\n loop t i.byteIdx none",
"start": [
162,
1
],
"end": [
186,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Data.Trie.toStringAux",
"code": "private partial def toStringAux {α : Type} : Trie α → List Format\n | leaf _ => []\n | node1 _ c t =>\n [ format (repr c), Format.group $ Format.nest 4 $ flip Format.joinSep Format.line $ toStringAux t ]\n | node _ cs ts =>\n List.join $ List.zipWith (fun c t =>\n [ format (repr c), (Format.group $ Format.nest 4 $ flip Format.joinSep Format.line $ toStringAux t) ]\n ) cs.toList ts.toList",
"start": [
188,
1
],
"end": [
195,
26
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/IR/Format.lean | [
".lake/packages/lean4/src/lean/Lean/Compiler/IR/Basic.lean"
] | [
{
"full_name": "Lean.IR.formatArg",
"code": "private def formatArg : Arg → Format\n | Arg.var id => format id\n | Arg.irrelevant => \"◾\"",
"start": [
12,
1
],
"end": [
14,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatArray",
"code": "def formatArray {α : Type} [ToFormat α] (args : Array α) : Format :=\n args.foldl (fun r a => r ++ \" \" ++ format a) Format.nil",
"start": [
18,
1
],
"end": [
19,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatLitVal",
"code": "private def formatLitVal : LitVal → Format\n | LitVal.num v => format v\n | LitVal.str v => format (repr v)",
"start": [
21,
1
],
"end": [
23,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatCtorInfo",
"code": "private def formatCtorInfo : CtorInfo → Format\n | { name := name, cidx := cidx, usize := usize, ssize := ssize, .. } => Id.run do\n let mut r := f!\"ctor_{cidx}\"\n if usize > 0 || ssize > 0 then\n r := f!\"{r}.{usize}.{ssize}\"\n if name != Name.anonymous then\n r := f!\"{r}[{name}]\"\n r",
"start": [
27,
1
],
"end": [
34,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatExpr",
"code": "private def formatExpr : Expr → Format\n | Expr.ctor i ys => format i ++ formatArray ys\n | Expr.reset n x => \"reset[\" ++ format n ++ \"] \" ++ format x\n | Expr.reuse x i u ys => \"reuse\" ++ (if u then \"!\" else \"\") ++ \" \" ++ format x ++ \" in \" ++ format i ++ formatArray ys\n | Expr.proj i x => \"proj[\" ++ format i ++ \"] \" ++ format x\n | Expr.uproj i x => \"uproj[\" ++ format i ++ \"] \" ++ format x\n | Expr.sproj n o x => \"sproj[\" ++ format n ++ \", \" ++ format o ++ \"] \" ++ format x\n | Expr.fap c ys => format c ++ formatArray ys\n | Expr.pap c ys => \"pap \" ++ format c ++ formatArray ys\n | Expr.ap x ys => \"app \" ++ format x ++ formatArray ys\n | Expr.box _ x => \"box \" ++ format x\n | Expr.unbox x => \"unbox \" ++ format x\n | Expr.lit v => format v\n | Expr.isShared x => \"isShared \" ++ format x",
"start": [
38,
1
],
"end": [
51,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatIRType",
"code": "private partial def formatIRType : IRType → Format\n | IRType.float => \"float\"\n | IRType.uint8 => \"u8\"\n | IRType.uint16 => \"u16\"\n | IRType.uint32 => \"u32\"\n | IRType.uint64 => \"u64\"\n | IRType.usize => \"usize\"\n | IRType.irrelevant => \"◾\"\n | IRType.object => \"obj\"\n | IRType.tobject => \"tobj\"\n | IRType.struct _ tys =>\n let _ : ToFormat IRType := ⟨formatIRType⟩\n \"struct \" ++ Format.bracket \"{\" (Format.joinSep tys.toList \", \") \"}\"\n | IRType.union _ tys =>\n let _ : ToFormat IRType := ⟨formatIRType⟩\n \"union \" ++ Format.bracket \"{\" (Format.joinSep tys.toList \", \") \"}\"",
"start": [
56,
1
],
"end": [
71,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatParam",
"code": "private def formatParam : Param → Format\n | { x := name, borrow := b, ty := ty } => \"(\" ++ format name ++ \" : \" ++ (if b then \"@& \" else \"\") ++ format ty ++ \")\"",
"start": [
76,
1
],
"end": [
77,
121
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatAlt",
"code": "def formatAlt (fmt : FnBody → Format) (indent : Nat) : Alt → Format\n | Alt.ctor i b => format i.name ++ \" →\" ++ Format.nest indent (Format.line ++ fmt b)\n | Alt.default b => \"default →\" ++ Format.nest indent (Format.line ++ fmt b)",
"start": [
81,
1
],
"end": [
83,
78
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatParams",
"code": "def formatParams (ps : Array Param) : Format :=\n formatArray ps",
"start": [
85,
1
],
"end": [
86,
17
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatFnBodyHead",
"code": "def formatFnBodyHead : FnBody → Format\n | FnBody.vdecl x ty e _ => \"let \" ++ format x ++ \" : \" ++ format ty ++ \" := \" ++ format e\n | FnBody.jdecl j xs _ _ => format j ++ formatParams xs ++ \" := ...\"\n | FnBody.set x i y _ => \"set \" ++ format x ++ \"[\" ++ format i ++ \"] := \" ++ format y\n | FnBody.uset x i y _ => \"uset \" ++ format x ++ \"[\" ++ format i ++ \"] := \" ++ format y\n | FnBody.sset x i o y ty _ => \"sset \" ++ format x ++ \"[\" ++ format i ++ \", \" ++ format o ++ \"] : \" ++ format ty ++ \" := \" ++ format y\n | FnBody.setTag x cidx _ => \"setTag \" ++ format x ++ \" := \" ++ format cidx\n | FnBody.inc x n _ _ _ => \"inc\" ++ (if n != 1 then Format.sbracket (format n) else \"\") ++ \" \" ++ format x\n | FnBody.dec x n _ _ _ => \"dec\" ++ (if n != 1 then Format.sbracket (format n) else \"\") ++ \" \" ++ format x\n | FnBody.del x _ => \"del \" ++ format x\n | FnBody.mdata d _ => \"mdata \" ++ format d\n | FnBody.case _ x _ _ => \"case \" ++ format x ++ \" of ...\"\n | FnBody.jmp j ys => \"jmp \" ++ format j ++ formatArray ys\n | FnBody.ret x => \"ret \" ++ format x\n | FnBody.unreachable => \"⊥\"",
"start": [
88,
1
],
"end": [
102,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatFnBodyHead'",
"code": "@[export lean_ir_format_fn_body_head]\nprivate def formatFnBodyHead' (fn : FnBody) : String :=\n formatFnBodyHead fn |>.pretty",
"start": [
104,
1
],
"end": [
106,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatFnBody",
"code": "partial def formatFnBody (fnBody : FnBody) (indent : Nat := 2) : Format :=\n let rec loop : FnBody → Format\n | FnBody.vdecl x ty e b => \"let \" ++ format x ++ \" : \" ++ format ty ++ \" := \" ++ format e ++ \";\" ++ Format.line ++ loop b\n | FnBody.jdecl j xs v b => format j ++ formatParams xs ++ \" :=\" ++ Format.nest indent (Format.line ++ loop v) ++ \";\" ++ Format.line ++ loop b\n | FnBody.set x i y b => \"set \" ++ format x ++ \"[\" ++ format i ++ \"] := \" ++ format y ++ \";\" ++ Format.line ++ loop b\n | FnBody.uset x i y b => \"uset \" ++ format x ++ \"[\" ++ format i ++ \"] := \" ++ format y ++ \";\" ++ Format.line ++ loop b\n | FnBody.sset x i o y ty b => \"sset \" ++ format x ++ \"[\" ++ format i ++ \", \" ++ format o ++ \"] : \" ++ format ty ++ \" := \" ++ format y ++ \";\" ++ Format.line ++ loop b\n | FnBody.setTag x cidx b => \"setTag \" ++ format x ++ \" := \" ++ format cidx ++ \";\" ++ Format.line ++ loop b\n | FnBody.inc x n _ _ b => \"inc\" ++ (if n != 1 then Format.sbracket (format n) else \"\") ++ \" \" ++ format x ++ \";\" ++ Format.line ++ loop b\n | FnBody.dec x n _ _ b => \"dec\" ++ (if n != 1 then Format.sbracket (format n) else \"\") ++ \" \" ++ format x ++ \";\" ++ Format.line ++ loop b\n | FnBody.del x b => \"del \" ++ format x ++ \";\" ++ Format.line ++ loop b\n | FnBody.mdata d b => \"mdata \" ++ format d ++ \";\" ++ Format.line ++ loop b\n | FnBody.case _ x xType cs => \"case \" ++ format x ++ \" : \" ++ format xType ++ \" of\" ++ cs.foldl (fun r c => r ++ Format.line ++ formatAlt loop indent c) Format.nil\n | FnBody.jmp j ys => \"jmp \" ++ format j ++ formatArray ys\n | FnBody.ret x => \"ret \" ++ format x\n | FnBody.unreachable => \"⊥\"\n loop fnBody",
"start": [
108,
1
],
"end": [
124,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.formatDecl",
"code": "def formatDecl (decl : Decl) (indent : Nat := 2) : Format :=\n match decl with\n | Decl.fdecl f xs ty b _ => \"def \" ++ format f ++ formatParams xs ++ format \" : \" ++ format ty ++ \" :=\" ++ Format.nest indent (Format.line ++ formatFnBody b indent)\n | Decl.extern f xs ty _ => \"extern \" ++ format f ++ formatParams xs ++ format \" : \" ++ format ty",
"start": [
129,
1
],
"end": [
132,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.declToString",
"code": "@[export lean_ir_decl_to_string]\ndef declToString (d : Decl) : String :=\n (format d).pretty",
"start": [
136,
1
],
"end": [
138,
20
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/InitAttr.lean | [
".lake/packages/lean4/src/lean/Lean/AddDecl.lean",
".lake/packages/lean4/src/lean/Lean/Elab/InfoTree/Main.lean",
".lake/packages/lean4/src/lean/Lean/MonadEnv.lean"
] | [
{
"full_name": "Lean.getIOTypeArg",
"code": "private def getIOTypeArg : Expr → Option Expr\n | Expr.app (Expr.const `IO _) arg => some arg\n | _ => none",
"start": [
13,
1
],
"end": [
15,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isUnitType",
"code": "private def isUnitType : Expr → Bool\n | Expr.const `Unit _ => true\n | _ => false",
"start": [
17,
1
],
"end": [
19,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isIOUnit",
"code": "private def isIOUnit (type : Expr) : Bool :=\n match getIOTypeArg type with\n | some type => isUnitType type\n | _ => false",
"start": [
21,
1
],
"end": [
24,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.runModInit",
"code": "@[extern \"lean_run_mod_init\"]\nunsafe opaque runModInit (mod : Name) : IO Bool",
"start": [
26,
1
],
"end": [
31,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.runInit",
"code": "@[extern \"lean_run_init\"]\nunsafe opaque runInit (env : @& Environment) (opts : @& Options) (decl initDecl : @& Name) : IO Unit",
"start": [
33,
1
],
"end": [
35,
101
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerInitAttrUnsafe",
"code": "unsafe def registerInitAttrUnsafe (attrName : Name) (runAfterImport : Bool) (ref : Name) : IO (ParametricAttribute Name) :=\n registerParametricAttribute {\n ref := ref\n name := attrName\n descr := \"initialization procedure for global references\"\n getParam := fun declName stx => do\n let decl ← getConstInfo declName\n match (← Attribute.Builtin.getIdent? stx) with\n | some initFnName =>\n let initFnName ← Elab.realizeGlobalConstNoOverloadWithInfo initFnName\n let initDecl ← getConstInfo initFnName\n match getIOTypeArg initDecl.type with\n | none => throwError \"initialization function '{initFnName}' must have type of the form `IO <type>`\"\n | some initTypeArg =>\n if decl.type == initTypeArg then pure initFnName\n else throwError \"initialization function '{initFnName}' type mismatch\"\n | none =>\n if isIOUnit decl.type then pure Name.anonymous\n else throwError \"initialization function must have type `IO Unit`\"\n afterImport := fun entries => do\n let ctx ← read\n if runAfterImport && (← isInitializerExecutionEnabled) then\n for mod in ctx.env.header.moduleNames,\n modData in ctx.env.header.moduleData,\n modEntries in entries do\n if (← runModInit mod) then\n continue\n if modEntries.isEmpty then\n continue\n if (← interpretedModInits.get).contains mod then\n continue\n interpretedModInits.modify (·.insert mod)\n for c in modData.constNames do\n if let some (decl, initDecl) := modEntries.binSearch (c, default) (Name.quickLt ·.1 ·.1) then\n if initDecl.isAnonymous then\n let initFn ← IO.ofExcept <| ctx.env.evalConst (IO Unit) ctx.opts decl\n initFn\n else\n runInit ctx.env ctx.opts decl initDecl\n }",
"start": [
40,
1
],
"end": [
90,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerInitAttrInner",
"code": "@[implemented_by registerInitAttrUnsafe]\nprivate opaque registerInitAttrInner (attrName : Name) (runAfterImport : Bool) (ref : Name) : IO (ParametricAttribute Name)",
"start": [
92,
1
],
"end": [
93,
124
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.registerInitAttr",
"code": "@[inline]\ndef registerInitAttr (attrName : Name) (runAfterImport : Bool) (ref : Name := by exact decl_name%) : IO (ParametricAttribute Name) :=\n registerInitAttrInner attrName runAfterImport ref",
"start": [
95,
1
],
"end": [
97,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getInitFnNameForCore?",
"code": "def getInitFnNameForCore? (env : Environment) (attr : ParametricAttribute Name) (fn : Name) : Option Name :=\n match attr.getParam? env fn with\n | some Name.anonymous => none\n | some n => some n\n | _ => none",
"start": [
102,
1
],
"end": [
106,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getBuiltinInitFnNameFor?",
"code": "@[export lean_get_builtin_init_fn_name_for]\ndef getBuiltinInitFnNameFor? (env : Environment) (fn : Name) : Option Name :=\n getInitFnNameForCore? env builtinInitAttr fn",
"start": [
108,
1
],
"end": [
110,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getRegularInitFnNameFor?",
"code": "@[export lean_get_regular_init_fn_name_for]\ndef getRegularInitFnNameFor? (env : Environment) (fn : Name) : Option Name :=\n getInitFnNameForCore? env regularInitAttr fn",
"start": [
112,
1
],
"end": [
114,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getInitFnNameFor?",
"code": "@[export lean_get_init_fn_name_for]\ndef getInitFnNameFor? (env : Environment) (fn : Name) : Option Name :=\n getBuiltinInitFnNameFor? env fn <|> getRegularInitFnNameFor? env fn",
"start": [
116,
1
],
"end": [
118,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isIOUnitInitFnCore",
"code": "def isIOUnitInitFnCore (env : Environment) (attr : ParametricAttribute Name) (fn : Name) : Bool :=\n match attr.getParam? env fn with\n | some Name.anonymous => true\n | _ => false",
"start": [
120,
1
],
"end": [
123,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isIOUnitRegularInitFn",
"code": "@[export lean_is_io_unit_regular_init_fn]\ndef isIOUnitRegularInitFn (env : Environment) (fn : Name) : Bool :=\n isIOUnitInitFnCore env regularInitAttr fn",
"start": [
125,
1
],
"end": [
127,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isIOUnitBuiltinInitFn",
"code": "@[export lean_is_io_unit_builtin_init_fn]\ndef isIOUnitBuiltinInitFn (env : Environment) (fn : Name) : Bool :=\n isIOUnitInitFnCore env builtinInitAttr fn",
"start": [
129,
1
],
"end": [
131,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.isIOUnitInitFn",
"code": "def isIOUnitInitFn (env : Environment) (fn : Name) : Bool :=\n isIOUnitBuiltinInitFn env fn || isIOUnitRegularInitFn env fn",
"start": [
133,
1
],
"end": [
134,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.hasInitAttr",
"code": "def hasInitAttr (env : Environment) (fn : Name) : Bool :=\n (getInitFnNameFor? env fn).isSome",
"start": [
136,
1
],
"end": [
137,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.setBuiltinInitAttr",
"code": "def setBuiltinInitAttr (env : Environment) (declName : Name) (initFnName : Name := Name.anonymous) : Except String Environment :=\n builtinInitAttr.setParam env declName initFnName",
"start": [
139,
1
],
"end": [
140,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.declareBuiltin",
"code": "def declareBuiltin (forDecl : Name) (value : Expr) : CoreM Unit := do\n let name ← mkAuxName (`_regBuiltin ++ forDecl) 1\n let type := mkApp (mkConst `IO) (mkConst `Unit)\n let decl := Declaration.defnDecl { name, levelParams := [], type, value, hints := ReducibilityHints.opaque,\n safety := DefinitionSafety.safe }\n match (← getEnv).addAndCompile {} decl with\n | Except.error e => do\n let msg ← (e.toMessageData {}).toString\n throwError \"failed to emit registration code for builtin '{forDecl}': {msg}\"\n | Except.ok env => IO.ofExcept (setBuiltinInitAttr env name) >>= setEnv",
"start": [
142,
1
],
"end": [
152,
75
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/DocString/Extension.lean | [
".lake/packages/lean4/src/lean/Lean/MonadEnv.lean",
".lake/packages/lean4/src/lean/Lean/DeclarationRange.lean",
".lake/packages/lean4/src/lean/Init/Data/String/Extra.lean"
] | [
{
"full_name": "Lean.addBuiltinDocString",
"code": "def addBuiltinDocString (declName : Name) (docString : String) : IO Unit :=\n builtinDocStrings.modify (·.insert declName docString.removeLeadingSpaces)",
"start": [
21,
1
],
"end": [
22,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addDocString",
"code": "def addDocString [Monad m] [MonadError m] [MonadEnv m] (declName : Name) (docString : String) : m Unit := do\n unless (← getEnv).getModuleIdxFor? declName |>.isNone do\n throwError s!\"invalid doc string, declaration '{declName}' is in an imported module\"\n modifyEnv fun env => docStringExt.insert env declName docString.removeLeadingSpaces",
"start": [
24,
1
],
"end": [
27,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addDocString'",
"code": "def addDocString' [Monad m] [MonadError m] [MonadEnv m] (declName : Name) (docString? : Option String) : m Unit :=\n match docString? with\n | some docString => addDocString declName docString\n | none => return ()",
"start": [
29,
1
],
"end": [
32,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.findSimpleDocString?",
"code": "def findSimpleDocString? (env : Environment) (declName : Name) (includeBuiltin := true) : IO (Option String) :=\n if let some docStr := docStringExt.find? env declName then\n return some docStr\n else if includeBuiltin then\n return (← builtinDocStrings.get).find? declName\n else\n return none",
"start": [
34,
1
],
"end": [
45,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.ModuleDoc",
"code": "structure ModuleDoc where\n doc : String\n declarationRange : DeclarationRange",
"start": [
47,
1
],
"end": [
49,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.addMainModuleDoc",
"code": "def addMainModuleDoc (env : Environment) (doc : ModuleDoc) : Environment :=\n moduleDocExt.addEntry env doc",
"start": [
57,
1
],
"end": [
58,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getMainModuleDoc",
"code": "def getMainModuleDoc (env : Environment) : PersistentArray ModuleDoc :=\n moduleDocExt.getState env",
"start": [
60,
1
],
"end": [
61,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getModuleDoc?",
"code": "def getModuleDoc? (env : Environment) (moduleName : Name) : Option (Array ModuleDoc) :=\n env.getModuleIdx? moduleName |>.map fun modIdx => moduleDocExt.getModuleEntries env modIdx",
"start": [
63,
1
],
"end": [
64,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.getDocStringText",
"code": "def getDocStringText [Monad m] [MonadError m] (stx : TSyntax `Lean.Parser.Command.docComment) : m String :=\n match stx.raw[1] with\n | Syntax.atom _ val => return val.extract 0 (val.endPos - ⟨2⟩)\n | _ => throwErrorAt stx \"unexpected doc string{indentD stx.raw[1]}\"",
"start": [
66,
1
],
"end": [
69,
86
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Types.lean | [
".lake/packages/lean4/src/lean/Lean/Data/Trie.lean",
".lake/packages/lean4/src/lean/Lean/Message.lean",
".lake/packages/lean4/src/lean/Lean/Syntax.lean"
] | [
{
"full_name": "Lean.Parser.mkAtom",
"code": "abbrev mkAtom (info : SourceInfo) (val : String) : Syntax :=\n Syntax.atom info val",
"start": [
13,
1
],
"end": [
14,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkIdent",
"code": "abbrev mkIdent (info : SourceInfo) (rawVal : Substring) (val : Name) : Syntax :=\n Syntax.ident info rawVal val []",
"start": [
16,
1
],
"end": [
17,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getNext",
"code": "def getNext (input : String) (pos : String.Pos) : Char :=\n input.get (input.next pos)",
"start": [
19,
1
],
"end": [
21,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.maxPrec",
"code": "def maxPrec : Nat := eval_prec max",
"start": [
23,
1
],
"end": [
28,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.argPrec",
"code": "def argPrec : Nat := eval_prec arg",
"start": [
29,
1
],
"end": [
29,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.leadPrec",
"code": "def leadPrec : Nat := eval_prec lead",
"start": [
30,
1
],
"end": [
30,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.minPrec",
"code": "def minPrec : Nat := eval_prec min",
"start": [
31,
1
],
"end": [
31,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Token",
"code": "abbrev Token := String",
"start": [
33,
1
],
"end": [
33,
23
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.TokenTable",
"code": "abbrev TokenTable := Lean.Data.Trie Token",
"start": [
35,
1
],
"end": [
35,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxNodeKindSet",
"code": "abbrev SyntaxNodeKindSet := PersistentHashMap SyntaxNodeKind Unit",
"start": [
37,
1
],
"end": [
37,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxNodeKindSet.insert",
"code": "def SyntaxNodeKindSet.insert (s : SyntaxNodeKindSet) (k : SyntaxNodeKind) : SyntaxNodeKindSet :=\n PersistentHashMap.insert s k ()",
"start": [
39,
1
],
"end": [
40,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.InputContext",
"code": "structure InputContext where\n input : String\n fileName : String\n fileMap : FileMap\n deriving Inhabited",
"start": [
42,
1
],
"end": [
49,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserModuleContext",
"code": "structure ParserModuleContext where\n env : Environment\n options : Options\n currNamespace : Name := .anonymous\n openDecls : List OpenDecl := []",
"start": [
51,
1
],
"end": [
57,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.CacheableParserContext",
"code": "structure CacheableParserContext where\n prec : Nat\n quotDepth : Nat := 0\n suppressInsideQuot : Bool := false\n savedPos? : Option String.Pos := none\n forbiddenTk? : Option Token := none\n deriving BEq",
"start": [
59,
1
],
"end": [
67,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserContextCore",
"code": "structure ParserContextCore extends InputContext, ParserModuleContext, CacheableParserContext where\n tokens : TokenTable",
"start": [
69,
1
],
"end": [
71,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserContext",
"code": "structure ParserContext extends ParserContextCore where private mk ::",
"start": [
73,
1
],
"end": [
74,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Error",
"code": "structure Error where\n \n unexpectedTk : Syntax := .missing\n unexpected : String := \"\"\n expected : List String := []\n deriving Inhabited, BEq",
"start": [
76,
1
],
"end": [
83,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Error.expectedToString",
"code": "private def expectedToString : List String → String\n | [] => \"\"\n | [e] => e\n | [e1, e2] => e1 ++ \" or \" ++ e2\n | e::es => e ++ \", \" ++ expectedToString es",
"start": [
87,
1
],
"end": [
91,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Error.toString",
"code": "protected def toString (e : Error) : String :=\n let unexpected := if e.unexpected == \"\" then [] else [e.unexpected]\n let expected := if e.expected == [] then [] else\n let expected := e.expected.toArray.qsort (fun e e' => e < e')\n let expected := expected.toList.eraseReps\n [\"expected \" ++ expectedToString expected]\n \"; \".intercalate $ unexpected ++ expected",
"start": [
93,
1
],
"end": [
99,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Error.merge",
"code": "def merge (e₁ e₂ : Error) : Error :=\n match e₂ with\n | { unexpectedTk, unexpected := u, .. } =>\n { unexpectedTk, unexpected := if u == \"\" then e₁.unexpected else u, expected := e₁.expected ++ e₂.expected }",
"start": [
104,
1
],
"end": [
108,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.TokenCacheEntry",
"code": "structure TokenCacheEntry where\n startPos : String.Pos := 0\n stopPos : String.Pos := 0\n token : Syntax := Syntax.missing",
"start": [
112,
1
],
"end": [
115,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserCacheKey",
"code": "structure ParserCacheKey extends CacheableParserContext where\n parserName : Name\n pos : String.Pos\n deriving BEq",
"start": [
117,
1
],
"end": [
120,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserCacheEntry",
"code": "structure ParserCacheEntry where\n stx : Syntax\n lhsPrec : Nat\n newPos : String.Pos\n errorMsg : Option Error",
"start": [
126,
1
],
"end": [
130,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserCache",
"code": "structure ParserCache where\n tokenCache : TokenCacheEntry\n parserCache : HashMap ParserCacheKey ParserCacheEntry",
"start": [
132,
1
],
"end": [
134,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.initCacheForInput",
"code": "def initCacheForInput (input : String) : ParserCache where\n tokenCache := { startPos := input.endPos + ' ' }\n parserCache := {}",
"start": [
136,
1
],
"end": [
138,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack",
"code": "structure SyntaxStack where\n private raw : Array Syntax\n private drop : Nat",
"start": [
140,
1
],
"end": [
143,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.toSubarray",
"code": "def toSubarray (stack : SyntaxStack) : Subarray Syntax :=\n stack.raw.toSubarray stack.drop",
"start": [
147,
1
],
"end": [
148,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.empty",
"code": "def empty : SyntaxStack where\n raw := #[]\n drop := 0",
"start": [
150,
1
],
"end": [
152,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.size",
"code": "def size (stack : SyntaxStack) : Nat :=\n stack.raw.size - stack.drop",
"start": [
154,
1
],
"end": [
155,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.isEmpty",
"code": "def isEmpty (stack : SyntaxStack) : Bool :=\n stack.size == 0",
"start": [
157,
1
],
"end": [
158,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.shrink",
"code": "def shrink (stack : SyntaxStack) (n : Nat) : SyntaxStack :=\n { stack with raw := stack.raw.shrink (stack.drop + n) }",
"start": [
160,
1
],
"end": [
161,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.push",
"code": "def push (stack : SyntaxStack) (a : Syntax) : SyntaxStack :=\n { stack with raw := stack.raw.push a }",
"start": [
163,
1
],
"end": [
164,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.pop",
"code": "def pop (stack : SyntaxStack) : SyntaxStack :=\n if stack.size > 0 then\n { stack with raw := stack.raw.pop }\n else stack",
"start": [
166,
1
],
"end": [
169,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.back",
"code": "def back (stack : SyntaxStack) : Syntax :=\n if stack.size > 0 then\n stack.raw.back\n else\n panic! \"SyntaxStack.back: element is inaccessible\"",
"start": [
171,
1
],
"end": [
175,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.get!",
"code": "def get! (stack : SyntaxStack) (i : Nat) : Syntax :=\n if i < stack.size then\n stack.raw.get! (stack.drop + i)\n else\n panic! \"SyntaxStack.get!: element is inaccessible\"",
"start": [
177,
1
],
"end": [
181,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.SyntaxStack.extract",
"code": "def extract (stack : SyntaxStack) (start stop : Nat) : Array Syntax :=\n stack.raw.extract (stack.drop + start) (stack.drop + stop)",
"start": [
183,
1
],
"end": [
184,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState",
"code": "structure ParserState where\n stxStack : SyntaxStack := .empty\n \n lhsPrec : Nat := 0\n pos : String.Pos := 0\n cache : ParserCache\n errorMsg : Option Error := none\n recoveredErrors : Array (String.Pos × SyntaxStack × Error) := #[]",
"start": [
191,
1
],
"end": [
202,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.hasError",
"code": "@[inline]\ndef hasError (s : ParserState) : Bool :=\n s.errorMsg != none",
"start": [
206,
1
],
"end": [
208,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.stackSize",
"code": "def stackSize (s : ParserState) : Nat :=\n s.stxStack.size",
"start": [
210,
1
],
"end": [
211,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.restore",
"code": "def restore (s : ParserState) (iniStackSz : Nat) (iniPos : String.Pos) : ParserState :=\n { s with stxStack := s.stxStack.shrink iniStackSz, errorMsg := none, pos := iniPos }",
"start": [
213,
1
],
"end": [
214,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.setPos",
"code": "def setPos (s : ParserState) (pos : String.Pos) : ParserState :=\n { s with pos := pos }",
"start": [
216,
1
],
"end": [
217,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.setCache",
"code": "def setCache (s : ParserState) (cache : ParserCache) : ParserState :=\n { s with cache := cache }",
"start": [
219,
1
],
"end": [
220,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.pushSyntax",
"code": "def pushSyntax (s : ParserState) (n : Syntax) : ParserState :=\n { s with stxStack := s.stxStack.push n }",
"start": [
222,
1
],
"end": [
223,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.popSyntax",
"code": "def popSyntax (s : ParserState) : ParserState :=\n { s with stxStack := s.stxStack.pop }",
"start": [
225,
1
],
"end": [
226,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.shrinkStack",
"code": "def shrinkStack (s : ParserState) (iniStackSz : Nat) : ParserState :=\n { s with stxStack := s.stxStack.shrink iniStackSz }",
"start": [
228,
1
],
"end": [
229,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.next",
"code": "def next (s : ParserState) (input : String) (pos : String.Pos) : ParserState :=\n { s with pos := input.next pos }",
"start": [
231,
1
],
"end": [
232,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.next'",
"code": "def next' (s : ParserState) (input : String) (pos : String.Pos) (h : ¬ input.atEnd pos) : ParserState :=\n { s with pos := input.next' pos h }",
"start": [
234,
1
],
"end": [
235,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkNode",
"code": "def mkNode (s : ParserState) (k : SyntaxNodeKind) (iniStackSz : Nat) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, err, recovered⟩ =>\n if err != none && stack.size == iniStackSz then\n let stack := stack.push Syntax.missing\n ⟨stack, lhsPrec, pos, cache, err, recovered⟩\n else\n let newNode := Syntax.node SourceInfo.none k (stack.extract iniStackSz stack.size)\n let stack := stack.shrink iniStackSz\n let stack := stack.push newNode\n ⟨stack, lhsPrec, pos, cache, err, recovered⟩",
"start": [
237,
1
],
"end": [
254,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkTrailingNode",
"code": "def mkTrailingNode (s : ParserState) (k : SyntaxNodeKind) (iniStackSz : Nat) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, err, errs⟩ =>\n let newNode := Syntax.node SourceInfo.none k (stack.extract (iniStackSz - 1) stack.size)\n let stack := stack.shrink (iniStackSz - 1)\n let stack := stack.push newNode\n ⟨stack, lhsPrec, pos, cache, err, errs⟩",
"start": [
256,
1
],
"end": [
262,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.allErrors",
"code": "def allErrors (s : ParserState) : Array (String.Pos × SyntaxStack × Error) :=\n s.recoveredErrors ++ (s.errorMsg.map (fun e => #[(s.pos, s.stxStack, e)])).getD #[]",
"start": [
264,
1
],
"end": [
265,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.setError",
"code": "@[inline]\ndef setError (s : ParserState) (e : Error) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, _, errs⟩ => ⟨stack, lhsPrec, pos, cache, some e, errs⟩",
"start": [
267,
1
],
"end": [
270,
88
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkError",
"code": "def mkError (s : ParserState) (msg : String) : ParserState :=\n s.setError { expected := [msg] } |>.pushSyntax .missing",
"start": [
272,
1
],
"end": [
273,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkUnexpectedError",
"code": "def mkUnexpectedError (s : ParserState) (msg : String) (expected : List String := []) (pushMissing := true) : ParserState :=\n let s := s.setError { unexpected := msg, expected }\n if pushMissing then s.pushSyntax .missing else s",
"start": [
275,
1
],
"end": [
277,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkEOIError",
"code": "def mkEOIError (s : ParserState) (expected : List String := []) : ParserState :=\n s.mkUnexpectedError \"unexpected end of input\" expected",
"start": [
279,
1
],
"end": [
280,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkErrorsAt",
"code": "def mkErrorsAt (s : ParserState) (ex : List String) (pos : String.Pos) (initStackSz? : Option Nat := none) : ParserState := Id.run do\n let mut s := s.setPos pos\n if let some sz := initStackSz? then\n s := s.shrinkStack sz\n s := s.setError { expected := ex }\n s.pushSyntax .missing",
"start": [
282,
1
],
"end": [
287,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkErrorAt",
"code": "def mkErrorAt (s : ParserState) (msg : String) (pos : String.Pos) (initStackSz? : Option Nat := none) : ParserState :=\n s.mkErrorsAt [msg] pos initStackSz?",
"start": [
289,
1
],
"end": [
290,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkUnexpectedTokenErrors",
"code": "def mkUnexpectedTokenErrors (s : ParserState) (ex : List String) (iniPos : String.Pos := 0) : ParserState :=\n let tk := s.stxStack.back\n let s := s.setPos (if iniPos > 0 then iniPos else tk.getPos?.get!)\n let s := s.setError { unexpectedTk := tk, expected := ex }\n s.popSyntax.pushSyntax .missing",
"start": [
292,
1
],
"end": [
302,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkUnexpectedTokenError",
"code": "def mkUnexpectedTokenError (s : ParserState) (msg : String) (iniPos : String.Pos := 0) : ParserState :=\n s.mkUnexpectedTokenErrors [msg] iniPos",
"start": [
304,
1
],
"end": [
309,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mkUnexpectedErrorAt",
"code": "def mkUnexpectedErrorAt (s : ParserState) (msg : String) (pos : String.Pos) : ParserState :=\n s.setPos pos |>.mkUnexpectedError msg",
"start": [
311,
1
],
"end": [
312,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.toErrorMsg",
"code": "def toErrorMsg (ctx : InputContext) (s : ParserState) : String := Id.run do\n let mut errStr := \"\"\n for (pos, _stk, err) in s.allErrors do\n if errStr != \"\" then errStr := errStr ++ \"\\n\"\n let pos := ctx.fileMap.toPosition pos\n errStr := errStr ++ mkErrorStringWithPos ctx.fileName pos (toString err)\n errStr",
"start": [
314,
1
],
"end": [
320,
9
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserFn",
"code": "def ParserFn := ParserContext → ParserState → ParserState",
"start": [
324,
1
],
"end": [
324,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.FirstTokens",
"code": "inductive FirstTokens where\n | epsilon : FirstTokens\n | unknown : FirstTokens\n | tokens : List Token → FirstTokens\n | optTokens : List Token → FirstTokens\n deriving Inhabited",
"start": [
329,
1
],
"end": [
334,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.FirstTokens.seq",
"code": "def seq : FirstTokens → FirstTokens → FirstTokens\n | epsilon, tks => tks\n | optTokens s₁, optTokens s₂ => optTokens (s₁ ++ s₂)\n | optTokens s₁, tokens s₂ => tokens (s₁ ++ s₂)\n | tks, _ => tks",
"start": [
338,
1
],
"end": [
342,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.FirstTokens.toOptional",
"code": "def toOptional : FirstTokens → FirstTokens\n | tokens tks => optTokens tks\n | tks => tks",
"start": [
344,
1
],
"end": [
346,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.FirstTokens.merge",
"code": "def merge : FirstTokens → FirstTokens → FirstTokens\n | epsilon, tks => toOptional tks\n | tks, epsilon => toOptional tks\n | tokens s₁, tokens s₂ => tokens (s₁ ++ s₂)\n | optTokens s₁, optTokens s₂ => optTokens (s₁ ++ s₂)\n | tokens s₁, optTokens s₂ => optTokens (s₁ ++ s₂)\n | optTokens s₁, tokens s₂ => optTokens (s₁ ++ s₂)\n | _, _ => unknown",
"start": [
348,
1
],
"end": [
355,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.FirstTokens.toStr",
"code": "def toStr : FirstTokens → String\n | epsilon => \"epsilon\"\n | unknown => \"unknown\"\n | tokens tks => toString tks\n | optTokens tks => \"?\" ++ toString tks",
"start": [
357,
1
],
"end": [
361,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserInfo",
"code": "structure ParserInfo where\n collectTokens : List Token → List Token := id\n collectKinds : SyntaxNodeKindSet → SyntaxNodeKindSet := id\n firstTokens : FirstTokens := FirstTokens.unknown\n deriving Inhabited",
"start": [
368,
1
],
"end": [
372,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.Parser",
"code": "structure Parser where\n info : ParserInfo := {}\n fn : ParserFn\n deriving Inhabited",
"start": [
374,
1
],
"end": [
377,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.TrailingParser",
"code": "abbrev TrailingParser := Parser",
"start": [
379,
1
],
"end": [
379,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withFn",
"code": "@[inline]\ndef withFn (f : ParserFn → ParserFn) (p : Parser) : Parser := { p with fn := f p.fn }",
"start": [
381,
1
],
"end": [
383,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.adaptCacheableContextFn",
"code": "def adaptCacheableContextFn (f : CacheableParserContext → CacheableParserContext) (p : ParserFn) : ParserFn := fun c s =>\n p { c with toCacheableParserContext := f c.toCacheableParserContext } s",
"start": [
385,
1
],
"end": [
386,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.adaptCacheableContext",
"code": "def adaptCacheableContext (f : CacheableParserContext → CacheableParserContext) : Parser → Parser :=\n withFn (adaptCacheableContextFn f)",
"start": [
388,
1
],
"end": [
389,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withStackDrop",
"code": "private def withStackDrop (drop : Nat) (p : ParserFn) : ParserFn := fun c s =>\n let initDrop := s.stxStack.drop\n let s := p c { s with stxStack.drop := drop }\n { s with stxStack.drop := initDrop }",
"start": [
391,
1
],
"end": [
394,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withResetCacheFn",
"code": "def withResetCacheFn (p : ParserFn) : ParserFn := withStackDrop 0 fun c s =>\n let parserCache := s.cache.parserCache\n let s' := p c { s with cache.parserCache := {} }\n { s' with cache.parserCache := parserCache }",
"start": [
396,
1
],
"end": [
403,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withResetCache",
"code": "@[inherit_doc withResetCacheFn]\ndef withResetCache : Parser → Parser := withFn withResetCacheFn",
"start": [
405,
1
],
"end": [
406,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.adaptUncacheableContextFn",
"code": "def adaptUncacheableContextFn (f : ParserContextCore → ParserContextCore) (p : ParserFn) : ParserFn :=\n withResetCacheFn (fun c s => p ⟨f c.toParserContextCore⟩ s)",
"start": [
408,
1
],
"end": [
410,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withCacheFn",
"code": "def withCacheFn (parserName : Name) (p : ParserFn) : ParserFn := fun c s => Id.run do\n let key := ⟨c.toCacheableParserContext, parserName, s.pos⟩\n if let some r := s.cache.parserCache.find? key then\n return ⟨s.stxStack.push r.stx, r.lhsPrec, r.newPos, s.cache, r.errorMsg, s.recoveredErrors⟩\n let initStackSz := s.stxStack.raw.size\n let s := withStackDrop initStackSz p c { s with lhsPrec := 0, errorMsg := none }\n if s.stxStack.raw.size != initStackSz + 1 then\n panic! s!\"withCacheFn: unexpected stack growth {s.stxStack.raw}\"\n { s with cache.parserCache := s.cache.parserCache.insert key ⟨s.stxStack.back, s.lhsPrec, s.pos, s.errorMsg⟩ }",
"start": [
412,
1
],
"end": [
429,
113
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withCache",
"code": "@[inherit_doc withCacheFn]\ndef withCache (parserName : Name) : Parser → Parser := withFn (withCacheFn parserName)",
"start": [
431,
1
],
"end": [
432,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserFn.run",
"code": "def ParserFn.run (p : ParserFn) (ictx : InputContext) (pmctx : ParserModuleContext) (tokens : TokenTable) (s : ParserState) : ParserState :=\n p { pmctx with\n prec := 0\n toInputContext := ictx\n tokens\n } s",
"start": [
434,
1
],
"end": [
439,
6
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Compiler/IR/CompilerM.lean | [
".lake/packages/lean4/src/lean/Lean/Compiler/IR/Format.lean",
".lake/packages/lean4/src/lean/Lean/Environment.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/IR/Basic.lean"
] | [
{
"full_name": "Lean.IR.LogEntry",
"code": "inductive LogEntry where\n | step (cls : Name) (decls : Array Decl)\n | message (msg : Format)",
"start": [
13,
1
],
"end": [
15,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.LogEntry.fmt",
"code": "protected def fmt : LogEntry → Format\n | step cls decls => Format.bracket \"[\" (format cls) \"]\" ++ decls.foldl (fun fmt decl => fmt ++ Format.line ++ format decl) Format.nil\n | message msg => msg",
"start": [
18,
1
],
"end": [
20,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Log",
"code": "abbrev Log := Array LogEntry",
"start": [
25,
1
],
"end": [
25,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Log.format",
"code": "def Log.format (log : Log) : Format :=\n log.foldl (init := Format.nil) fun fmt entry =>\n f!\"{fmt}{Format.line}{entry}\"",
"start": [
27,
1
],
"end": [
29,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.Log.toString",
"code": "@[export lean_ir_log_to_string]\ndef Log.toString (log : Log) : String :=\n log.format.pretty",
"start": [
31,
1
],
"end": [
33,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.CompilerState",
"code": "structure CompilerState where\n env : Environment\n log : Log := #[]",
"start": [
35,
1
],
"end": [
37,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.CompilerM",
"code": "abbrev CompilerM := ReaderT Options (EStateM String CompilerState)",
"start": [
39,
1
],
"end": [
39,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.log",
"code": "def log (entry : LogEntry) : CompilerM Unit :=\n modify fun s => { s with log := s.log.push entry }",
"start": [
41,
1
],
"end": [
42,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.tracePrefixOptionName",
"code": "def tracePrefixOptionName := `trace.compiler.ir",
"start": [
44,
1
],
"end": [
44,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.isLogEnabledFor",
"code": "private def isLogEnabledFor (opts : Options) (optName : Name) : Bool :=\n match opts.find optName with\n | some (DataValue.ofBool v) => v\n | _ => opts.getBool tracePrefixOptionName",
"start": [
46,
1
],
"end": [
49,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.logDeclsAux",
"code": "private def logDeclsAux (optName : Name) (cls : Name) (decls : Array Decl) : CompilerM Unit := do\n let opts ← read\n if isLogEnabledFor opts optName then\n log (LogEntry.step cls decls)",
"start": [
51,
1
],
"end": [
54,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.logDecls",
"code": "@[inline] def logDecls (cls : Name) (decl : Array Decl) : CompilerM Unit :=\n logDeclsAux (tracePrefixOptionName ++ cls) cls decl",
"start": [
56,
1
],
"end": [
57,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.logMessageIfAux",
"code": "private def logMessageIfAux {α : Type} [ToFormat α] (optName : Name) (a : α) : CompilerM Unit := do\n let opts ← read\n if isLogEnabledFor opts optName then\n log (LogEntry.message (format a))",
"start": [
59,
1
],
"end": [
62,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.logMessageIf",
"code": "@[inline] def logMessageIf {α : Type} [ToFormat α] (cls : Name) (a : α) : CompilerM Unit :=\n logMessageIfAux (tracePrefixOptionName ++ cls) a",
"start": [
64,
1
],
"end": [
65,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.logMessage",
"code": "@[inline] def logMessage {α : Type} [ToFormat α] (a : α) : CompilerM Unit :=\n logMessageIfAux tracePrefixOptionName a",
"start": [
67,
1
],
"end": [
68,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.modifyEnv",
"code": "@[inline] def modifyEnv (f : Environment → Environment) : CompilerM Unit :=\n modify fun s => { s with env := f s.env }",
"start": [
70,
1
],
"end": [
71,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.DeclMap",
"code": "abbrev DeclMap := PHashMap Name Decl",
"start": [
73,
1
],
"end": [
73,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.declLt",
"code": "private abbrev declLt (a b : Decl) :=\n Name.quickLt a.name b.name",
"start": [
75,
1
],
"end": [
76,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.sortDecls",
"code": "private abbrev sortDecls (decls : Array Decl) : Array Decl :=\n decls.qsort declLt",
"start": [
78,
1
],
"end": [
79,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.findAtSorted?",
"code": "private abbrev findAtSorted? (decls : Array Decl) (declName : Name) : Option Decl :=\n let tmpDecl := Decl.extern declName #[] default default\n decls.binSearch tmpDecl declLt",
"start": [
81,
1
],
"end": [
83,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.findEnvDecl",
"code": "@[export lean_ir_find_env_decl]\ndef findEnvDecl (env : Environment) (declName : Name) : Option Decl :=\n match env.getModuleIdxFor? declName with\n | some modIdx => findAtSorted? (declMapExt.getModuleEntries env modIdx) declName\n | none => declMapExt.getState env |>.find? declName",
"start": [
94,
1
],
"end": [
98,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.findDecl",
"code": "def findDecl (n : Name) : CompilerM (Option Decl) :=\n return findEnvDecl (← get).env n",
"start": [
100,
1
],
"end": [
101,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.containsDecl",
"code": "def containsDecl (n : Name) : CompilerM Bool :=\n return (← findDecl n).isSome",
"start": [
103,
1
],
"end": [
104,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.getDecl",
"code": "def getDecl (n : Name) : CompilerM Decl := do\n let (some decl) ← findDecl n | throw s!\"unknown declaration '{n}'\"\n return decl",
"start": [
106,
1
],
"end": [
108,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.addDeclAux",
"code": "@[export lean_ir_add_decl]\ndef addDeclAux (env : Environment) (decl : Decl) : Environment :=\n declMapExt.addEntry (env.addExtraName decl.name) decl",
"start": [
110,
1
],
"end": [
112,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.getDecls",
"code": "def getDecls (env : Environment) : List Decl :=\n declMapExt.getEntries env",
"start": [
114,
1
],
"end": [
115,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.getEnv",
"code": "def getEnv : CompilerM Environment := do\n let s ← get; pure s.env",
"start": [
117,
1
],
"end": [
118,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.addDecl",
"code": "def addDecl (decl : Decl) : CompilerM Unit :=\n modifyEnv fun env => declMapExt.addEntry (env.addExtraName decl.name) decl",
"start": [
120,
1
],
"end": [
121,
77
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.addDecls",
"code": "def addDecls (decls : Array Decl) : CompilerM Unit :=\n decls.forM addDecl",
"start": [
123,
1
],
"end": [
124,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.findEnvDecl'",
"code": "def findEnvDecl' (env : Environment) (n : Name) (decls : Array Decl) : Option Decl :=\n match decls.find? (fun decl => decl.name == n) with\n | some decl => some decl\n | none => findEnvDecl env n",
"start": [
126,
1
],
"end": [
129,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.findDecl'",
"code": "def findDecl' (n : Name) (decls : Array Decl) : CompilerM (Option Decl) :=\n return findEnvDecl' (← get).env n decls",
"start": [
131,
1
],
"end": [
132,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.containsDecl'",
"code": "def containsDecl' (n : Name) (decls : Array Decl) : CompilerM Bool := do\n if decls.any fun decl => decl.name == n then\n return true\n else\n containsDecl n",
"start": [
134,
1
],
"end": [
138,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.getDecl'",
"code": "def getDecl' (n : Name) (decls : Array Decl) : CompilerM Decl := do\n let (some decl) ← findDecl' n decls | throw s!\"unknown declaration '{n}'\"\n return decl",
"start": [
140,
1
],
"end": [
142,
14
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.IR.getSorryDep",
"code": "@[export lean_decl_get_sorry_dep]\ndef getSorryDep (env : Environment) (declName : Name) : Option Name :=\n match findEnvDecl env declName with\n | some (.fdecl (info := { sorryDep? := dep?, .. }) ..) => dep?\n | _ => none",
"start": [
144,
1
],
"end": [
148,
14
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/BuiltinDocAttr.lean | [
".lake/packages/lean4/src/lean/Lean/DocString/Extension.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/InitAttr.lean"
] | [
{
"full_name": "Lean.declareBuiltinDocStringAndRanges",
"code": "def declareBuiltinDocStringAndRanges (declName : Name) : AttrM Unit := do\n if let some doc ← findSimpleDocString? (← getEnv) declName (includeBuiltin := false) then\n declareBuiltin (declName ++ `docString) (mkAppN (mkConst ``addBuiltinDocString) #[toExpr declName, toExpr doc])\n if let some declRanges ← findDeclarationRanges? declName then\n declareBuiltin (declName ++ `declRange) (mkAppN (mkConst ``addBuiltinDeclarationRanges) #[toExpr declName, toExpr declRanges])",
"start": [
12,
1
],
"end": [
16,
131
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Basic.lean | [
".lake/packages/lean4/src/lean/Lean/Parser/Types.lean"
] | [
{
"full_name": "Lean.Parser.dbgTraceStateFn",
"code": "def dbgTraceStateFn (label : String) (p : ParserFn) : ParserFn :=\n fun c s =>\n let sz := s.stxStack.size\n let s' := p c s\n dbg_trace \"{label}\n pos: {s'.pos}\n err: {s'.errorMsg}\n out: {s'.stxStack.extract sz s'.stxStack.size}\"\n s'",
"start": [
62,
1
],
"end": [
70,
7
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.dbgTraceState",
"code": "def dbgTraceState (label : String) : Parser → Parser := withFn (dbgTraceStateFn label)",
"start": [
72,
1
],
"end": [
72,
87
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.epsilonInfo",
"code": "@[noinline]def epsilonInfo : ParserInfo :=\n { firstTokens := FirstTokens.epsilon }",
"start": [
74,
1
],
"end": [
75,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkStackTopFn",
"code": "def checkStackTopFn (p : Syntax → Bool) (msg : String) : ParserFn := fun _ s =>\n if p s.stxStack.back then s\n else s.mkUnexpectedError msg",
"start": [
77,
1
],
"end": [
79,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkStackTop",
"code": "def checkStackTop (p : Syntax → Bool) (msg : String) : Parser := {\n info := epsilonInfo,\n fn := checkStackTopFn p msg\n}",
"start": [
81,
1
],
"end": [
84,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.andthenFn",
"code": "def andthenFn (p q : ParserFn) : ParserFn := fun c s =>\n let s := p c s\n if s.hasError then s else q c s",
"start": [
86,
1
],
"end": [
88,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.andthenInfo",
"code": "@[noinline] def andthenInfo (p q : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens ∘ q.collectTokens,\n collectKinds := p.collectKinds ∘ q.collectKinds,\n firstTokens := p.firstTokens.seq q.firstTokens\n}",
"start": [
90,
1
],
"end": [
94,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.andthen",
"code": "def andthen (p q : Parser) : Parser where\n info := andthenInfo p.info q.info\n fn := andthenFn p.fn q.fn",
"start": [
96,
1
],
"end": [
104,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nodeFn",
"code": "def nodeFn (n : SyntaxNodeKind) (p : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let s := p c s\n s.mkNode n iniSz",
"start": [
109,
1
],
"end": [
112,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.trailingNodeFn",
"code": "def trailingNodeFn (n : SyntaxNodeKind) (p : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let s := p c s\n s.mkTrailingNode n iniSz",
"start": [
114,
1
],
"end": [
117,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nodeInfo",
"code": "@[noinline] def nodeInfo (n : SyntaxNodeKind) (p : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens,\n collectKinds := fun s => (p.collectKinds s).insert n,\n firstTokens := p.firstTokens\n}",
"start": [
119,
1
],
"end": [
123,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.node",
"code": "def node (n : SyntaxNodeKind) (p : Parser) : Parser := {\n info := nodeInfo n p.info,\n fn := nodeFn n p.fn\n}",
"start": [
125,
1
],
"end": [
128,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.errorFn",
"code": "def errorFn (msg : String) : ParserFn := fun _ s =>\n s.mkUnexpectedError msg",
"start": [
130,
1
],
"end": [
131,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.error",
"code": "def error (msg : String) : Parser := {\n info := epsilonInfo,\n fn := errorFn msg\n}",
"start": [
133,
1
],
"end": [
136,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.errorAtSavedPosFn",
"code": "def errorAtSavedPosFn (msg : String) (delta : Bool) : ParserFn := fun c s =>\n match c.savedPos? with\n | none => s\n | some pos =>\n let pos := if delta then c.input.next pos else pos\n s.mkUnexpectedErrorAt msg pos",
"start": [
138,
1
],
"end": [
143,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.errorAtSavedPos",
"code": "def errorAtSavedPos (msg : String) (delta : Bool) : Parser := {\n fn := errorAtSavedPosFn msg delta\n}",
"start": [
145,
1
],
"end": [
150,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkPrecFn",
"code": "def checkPrecFn (prec : Nat) : ParserFn := fun c s =>\n if c.prec <= prec then s\n else s.mkUnexpectedError \"unexpected token at this precedence level; consider parenthesizing the term\"",
"start": [
152,
1
],
"end": [
155,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkPrec",
"code": "def checkPrec (prec : Nat) : Parser := {\n info := epsilonInfo\n fn := checkPrecFn prec\n}",
"start": [
157,
1
],
"end": [
160,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkLhsPrecFn",
"code": "def checkLhsPrecFn (prec : Nat) : ParserFn := fun _ s =>\n if s.lhsPrec >= prec then s\n else s.mkUnexpectedError \"unexpected token at this precedence level; consider parenthesizing the term\"",
"start": [
162,
1
],
"end": [
165,
105
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkLhsPrec",
"code": "def checkLhsPrec (prec : Nat) : Parser := {\n info := epsilonInfo\n fn := checkLhsPrecFn prec\n}",
"start": [
167,
1
],
"end": [
170,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.setLhsPrecFn",
"code": "def setLhsPrecFn (prec : Nat) : ParserFn := fun _ s =>\n if s.hasError then s\n else { s with lhsPrec := prec }",
"start": [
172,
1
],
"end": [
174,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.setLhsPrec",
"code": "def setLhsPrec (prec : Nat) : Parser := {\n info := epsilonInfo\n fn := setLhsPrecFn prec\n}",
"start": [
176,
1
],
"end": [
179,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addQuotDepth",
"code": "private def addQuotDepth (i : Int) (p : Parser) : Parser :=\n adaptCacheableContext (fun c => { c with quotDepth := c.quotDepth + i |>.toNat }) p",
"start": [
181,
1
],
"end": [
182,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.incQuotDepth",
"code": "def incQuotDepth (p : Parser) : Parser := addQuotDepth 1 p",
"start": [
184,
1
],
"end": [
184,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.decQuotDepth",
"code": "def decQuotDepth (p : Parser) : Parser := addQuotDepth (-1) p",
"start": [
186,
1
],
"end": [
186,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.suppressInsideQuot",
"code": "def suppressInsideQuot : Parser → Parser :=\n adaptCacheableContext fun c =>\n if c.quotDepth == 0 then { c with suppressInsideQuot := true } else c",
"start": [
188,
1
],
"end": [
191,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.leadingNode",
"code": "def leadingNode (n : SyntaxNodeKind) (prec : Nat) (p : Parser) : Parser :=\n checkPrec prec >> node n p >> setLhsPrec prec",
"start": [
193,
1
],
"end": [
194,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.trailingNodeAux",
"code": "def trailingNodeAux (n : SyntaxNodeKind) (p : Parser) : TrailingParser := {\n info := nodeInfo n p.info\n fn := trailingNodeFn n p.fn\n}",
"start": [
196,
1
],
"end": [
199,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.trailingNode",
"code": "def trailingNode (n : SyntaxNodeKind) (prec lhsPrec : Nat) (p : Parser) : TrailingParser :=\n checkPrec prec >> checkLhsPrec lhsPrec >> trailingNodeAux n p >> setLhsPrec prec",
"start": [
201,
1
],
"end": [
202,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mergeOrElseErrors",
"code": "def mergeOrElseErrors (s : ParserState) (error1 : Error) (iniPos : String.Pos) (mergeErrors : Bool) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, some error2, errs⟩ =>\n if pos == iniPos then\n ⟨stack, lhsPrec, pos, cache, some (if mergeErrors then error1.merge error2 else error2), errs⟩\n else s\n | other => other",
"start": [
204,
1
],
"end": [
210,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.OrElseOnAntiquotBehavior",
"code": "inductive OrElseOnAntiquotBehavior where\n | acceptLhs | takeLongest | merge deriving BEq",
"start": [
213,
1
],
"end": [
217,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.orelseFnCore",
"code": "def orelseFnCore (p q : ParserFn) (antiquotBehavior := OrElseOnAntiquotBehavior.merge) : ParserFn := fun c s => Id.run do\n let iniSz := s.stackSize\n let iniPos := s.pos\n let mut s := p c s\n match s.errorMsg with\n | some errorMsg =>\n if s.pos == iniPos then\n mergeOrElseErrors (q c (s.restore iniSz iniPos)) errorMsg iniPos true\n else\n s\n | none =>\n let pBack := s.stxStack.back\n if antiquotBehavior == .acceptLhs || s.stackSize != iniSz + 1 || !pBack.isAntiquots then\n return s\n let pPos := s.pos\n s := s.restore iniSz iniPos\n s := q c s\n if s.hasError then\n return s.restore iniSz pPos |>.pushSyntax pBack\n if s.pos > pPos then\n return s\n if s.pos < pPos || antiquotBehavior != .merge || s.stackSize != iniSz + 1 || !s.stxStack.back.isAntiquots then\n return s.restore iniSz pPos |>.pushSyntax pBack\n let qBack := s.stxStack.back\n s := s.popSyntax\n let pushAntiquots stx s :=\n if stx.isOfKind choiceKind then\n { s with stxStack := s.stxStack ++ stx.getArgs }\n else\n s.pushSyntax stx\n s := pushAntiquots pBack s\n s := pushAntiquots qBack s\n s.mkNode choiceKind iniSz",
"start": [
219,
1
],
"end": [
257,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.orelseFn",
"code": "def orelseFn (p q : ParserFn) : ParserFn :=\n orelseFnCore p q",
"start": [
259,
1
],
"end": [
260,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.orelseInfo",
"code": "@[noinline] def orelseInfo (p q : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens ∘ q.collectTokens\n collectKinds := p.collectKinds ∘ q.collectKinds\n firstTokens := p.firstTokens.merge q.firstTokens\n}",
"start": [
262,
1
],
"end": [
266,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.orelse",
"code": "def orelse (p q : Parser) : Parser where\n info := orelseInfo p.info q.info\n fn := orelseFn p.fn q.fn",
"start": [
268,
1
],
"end": [
276,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.noFirstTokenInfo",
"code": "@[noinline] def noFirstTokenInfo (info : ParserInfo) : ParserInfo := {\n collectTokens := info.collectTokens\n collectKinds := info.collectKinds\n}",
"start": [
281,
1
],
"end": [
284,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.atomicFn",
"code": "def atomicFn (p : ParserFn) : ParserFn := fun c s =>\n let iniPos := s.pos\n match p c s with\n | ⟨stack, lhsPrec, _, cache, some msg, errs⟩ => ⟨stack, lhsPrec, iniPos, cache, some msg, errs⟩\n | other => other",
"start": [
286,
1
],
"end": [
290,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.atomic",
"code": "def atomic : Parser → Parser := withFn atomicFn",
"start": [
292,
1
],
"end": [
298,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.RecoveryContext",
"code": "structure RecoveryContext where\n \n initialPos : String.Pos\n \n initialSize : Nat\nderiving BEq, DecidableEq, Repr",
"start": [
300,
1
],
"end": [
306,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.recoverFn",
"code": "def recoverFn (p : ParserFn) (recover : RecoveryContext → ParserFn) : ParserFn := fun c s =>\n let iniPos := s.pos\n let iniSz := s.stxStack.size\n let s' := p c s\n if let some msg := s'.errorMsg then\n let s' := recover ⟨iniPos, iniSz⟩ c {s' with errorMsg := none}\n if s'.hasError then s'\n else {s' with\n pos := s'.pos,\n lhsPrec := s'.lhsPrec,\n cache := s'.cache,\n errorMsg := none,\n recoveredErrors := s'.recoveredErrors.push (s'.pos, s'.stxStack, msg) }\n else s'",
"start": [
308,
1
],
"end": [
327,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.recover'",
"code": "def recover' (parser : Parser) (handler : RecoveryContext → Parser) : Parser where\n info := parser.info\n fn := recoverFn parser.fn fun s => handler s |>.fn",
"start": [
329,
1
],
"end": [
340,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.recover",
"code": "def recover (parser handler : Parser) : Parser := recover' parser fun _ => handler",
"start": [
342,
1
],
"end": [
350,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.optionalFn",
"code": "def optionalFn (p : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let iniPos := s.pos\n let s := p c s\n let s := if s.hasError && s.pos == iniPos then s.restore iniSz iniPos else s\n s.mkNode nullKind iniSz",
"start": [
352,
1
],
"end": [
357,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.optionaInfo",
"code": "@[noinline] def optionaInfo (p : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens\n collectKinds := p.collectKinds\n firstTokens := p.firstTokens.toOptional\n}",
"start": [
359,
1
],
"end": [
363,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.optionalNoAntiquot",
"code": "def optionalNoAntiquot (p : Parser) : Parser := {\n info := optionaInfo p.info\n fn := optionalFn p.fn\n}",
"start": [
365,
1
],
"end": [
368,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.lookaheadFn",
"code": "def lookaheadFn (p : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let iniPos := s.pos\n let s := p c s\n if s.hasError then s else s.restore iniSz iniPos",
"start": [
370,
1
],
"end": [
374,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.lookahead",
"code": "def lookahead : Parser → Parser := withFn lookaheadFn",
"start": [
376,
1
],
"end": [
381,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.notFollowedByFn",
"code": "def notFollowedByFn (p : ParserFn) (msg : String) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let iniPos := s.pos\n let s := p c s\n if s.hasError then\n s.restore iniSz iniPos\n else\n let s := s.restore iniSz iniPos\n s.mkUnexpectedError s!\"unexpected {msg}\"",
"start": [
383,
1
],
"end": [
391,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.notFollowedBy",
"code": "def notFollowedBy (p : Parser) (msg : String) : Parser where\n fn := notFollowedByFn p.fn msg",
"start": [
393,
1
],
"end": [
398,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.manyAux",
"code": "partial def manyAux (p : ParserFn) : ParserFn := fun c s => Id.run do\n let iniSz := s.stackSize\n let iniPos := s.pos\n let mut s := p c s\n if s.hasError then\n return if iniPos == s.pos then s.restore iniSz iniPos else s\n if iniPos == s.pos then\n return s.mkUnexpectedError \"invalid 'many' parser combinator application, parser did not consume anything\"\n if s.stackSize > iniSz + 1 then\n s := s.mkNode nullKind iniSz\n manyAux p c s",
"start": [
400,
1
],
"end": [
410,
16
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.manyFn",
"code": "def manyFn (p : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let s := manyAux p c s\n s.mkNode nullKind iniSz",
"start": [
412,
1
],
"end": [
415,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.manyNoAntiquot",
"code": "def manyNoAntiquot (p : Parser) : Parser := {\n info := noFirstTokenInfo p.info\n fn := manyFn p.fn\n}",
"start": [
417,
1
],
"end": [
420,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.many1Fn",
"code": "def many1Fn (p : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n let s := andthenFn p (manyAux p) c s\n s.mkNode nullKind iniSz",
"start": [
422,
1
],
"end": [
425,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.many1NoAntiquot",
"code": "def many1NoAntiquot : Parser → Parser := withFn many1Fn",
"start": [
427,
1
],
"end": [
427,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByFnAux",
"code": "private partial def sepByFnAux (p : ParserFn) (sep : ParserFn) (allowTrailingSep : Bool) (iniSz : Nat) (pOpt : Bool) : ParserFn :=\n let rec parse (pOpt : Bool) (c s) := Id.run do\n let sz := s.stackSize\n let pos := s.pos\n let mut s := p c s\n if s.hasError then\n if s.pos > pos then\n return s.mkNode nullKind iniSz\n else if pOpt then\n s := s.restore sz pos\n return s.mkNode nullKind iniSz\n else\n s := s.pushSyntax Syntax.missing\n return s.mkNode nullKind iniSz\n if s.stackSize > sz + 1 then\n s := s.mkNode nullKind sz\n let sz := s.stackSize\n let pos := s.pos\n s := sep c s\n if s.hasError then\n s := s.restore sz pos\n return s.mkNode nullKind iniSz\n if s.stackSize > sz + 1 then\n s := s.mkNode nullKind sz\n parse allowTrailingSep c s\n parse pOpt",
"start": [
429,
1
],
"end": [
455,
13
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByFn",
"code": "def sepByFn (allowTrailingSep : Bool) (p : ParserFn) (sep : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n sepByFnAux p sep allowTrailingSep iniSz true c s",
"start": [
457,
1
],
"end": [
459,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy1Fn",
"code": "def sepBy1Fn (allowTrailingSep : Bool) (p : ParserFn) (sep : ParserFn) : ParserFn := fun c s =>\n let iniSz := s.stackSize\n sepByFnAux p sep allowTrailingSep iniSz false c s",
"start": [
461,
1
],
"end": [
463,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByInfo",
"code": "@[noinline] def sepByInfo (p sep : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens ∘ sep.collectTokens\n collectKinds := p.collectKinds ∘ sep.collectKinds\n}",
"start": [
465,
1
],
"end": [
468,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy1Info",
"code": "@[noinline] def sepBy1Info (p sep : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens ∘ sep.collectTokens\n collectKinds := p.collectKinds ∘ sep.collectKinds\n firstTokens := p.firstTokens\n}",
"start": [
470,
1
],
"end": [
474,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByNoAntiquot",
"code": "def sepByNoAntiquot (p sep : Parser) (allowTrailingSep : Bool := false) : Parser := {\n info := sepByInfo p.info sep.info\n fn := sepByFn allowTrailingSep p.fn sep.fn\n}",
"start": [
476,
1
],
"end": [
479,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy1NoAntiquot",
"code": "def sepBy1NoAntiquot (p sep : Parser) (allowTrailingSep : Bool := false) : Parser := {\n info := sepBy1Info p.info sep.info\n fn := sepBy1Fn allowTrailingSep p.fn sep.fn\n}",
"start": [
481,
1
],
"end": [
484,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withResultOfFn",
"code": "def withResultOfFn (p : ParserFn) (f : Syntax → Syntax) : ParserFn := fun c s =>\n let s := p c s\n if s.hasError then s\n else\n let stx := s.stxStack.back\n s.popSyntax.pushSyntax (f stx)",
"start": [
486,
1
],
"end": [
492,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withResultOfInfo",
"code": "@[noinline] def withResultOfInfo (p : ParserInfo) : ParserInfo := {\n collectTokens := p.collectTokens\n collectKinds := p.collectKinds\n}",
"start": [
494,
1
],
"end": [
497,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withResultOf",
"code": "def withResultOf (p : Parser) (f : Syntax → Syntax) : Parser := {\n info := withResultOfInfo p.info\n fn := withResultOfFn p.fn f\n}",
"start": [
499,
1
],
"end": [
502,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.many1Unbox",
"code": "def many1Unbox (p : Parser) : Parser :=\n withResultOf (many1NoAntiquot p) fun stx => if stx.getNumArgs == 1 then stx.getArg 0 else stx",
"start": [
504,
1
],
"end": [
505,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.satisfyFn",
"code": "partial def satisfyFn (p : Char → Bool) (errorMsg : String := \"unexpected character\") : ParserFn := fun c s =>\n let i := s.pos\n if h : c.input.atEnd i then s.mkEOIError\n else if p (c.input.get' i h) then s.next' c.input i h\n else s.mkUnexpectedError errorMsg",
"start": [
507,
1
],
"end": [
511,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.takeUntilFn",
"code": "partial def takeUntilFn (p : Char → Bool) : ParserFn := fun c s =>\n let i := s.pos\n if h : c.input.atEnd i then s\n else if p (c.input.get' i h) then s\n else takeUntilFn p c (s.next' c.input i h)",
"start": [
513,
1
],
"end": [
517,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.takeWhileFn",
"code": "def takeWhileFn (p : Char → Bool) : ParserFn :=\n takeUntilFn (fun c => !p c)",
"start": [
519,
1
],
"end": [
520,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.takeWhile1Fn",
"code": "def takeWhile1Fn (p : Char → Bool) (errorMsg : String) : ParserFn :=\n andthenFn (satisfyFn p errorMsg) (takeWhileFn p)",
"start": [
522,
1
],
"end": [
523,
51
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.finishCommentBlock",
"code": "partial def finishCommentBlock (nesting : Nat) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then eoi s\n else\n let curr := input.get' i h\n let i := input.next' i h\n if curr == '-' then\n if h : input.atEnd i then eoi s\n else\n let curr := input.get' i h\n if curr == '/' then if nesting == 1 then s.next' input i h\n else finishCommentBlock (nesting-1) c (s.next' input i h)\n else\n finishCommentBlock nesting c (s.setPos i)\n else if curr == '/' then\n if h : input.atEnd i then eoi s\n else\n let curr := input.get' i h\n if curr == '-' then finishCommentBlock (nesting+1) c (s.next' input i h)\n else finishCommentBlock nesting c (s.setPos i)\n else finishCommentBlock nesting c (s.setPos i)\nwhere\n eoi s := s.mkUnexpectedError (pushMissing := pushMissingOnError) \"unterminated comment\"",
"start": [
526,
1
],
"end": [
550,
90
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.whitespace",
"code": "partial def whitespace : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then s\n else\n let curr := input.get' i h\n if curr == '\\t' then\n s.mkUnexpectedError (pushMissing := false) \"tabs are not allowed; please configure your editor to expand them\"\n else if curr == '\\r' then\n s.mkUnexpectedError (pushMissing := false) \"isolated carriage returns are not allowed\"\n else if curr.isWhitespace then whitespace c (s.next' input i h)\n else if curr == '-' then\n let i := input.next' i h\n let curr := input.get i\n if curr == '-' then andthenFn (takeUntilFn (fun c => c = '\\n')) whitespace c (s.next input i)\n else s\n else if curr == '/' then\n let i := input.next' i h\n let curr := input.get i\n if curr == '-' then\n let i := input.next i\n let curr := input.get i\n if curr == '-' || curr == '!' then s else andthenFn (finishCommentBlock (pushMissingOnError := false) 1) whitespace c (s.next input i)\n else s\n else s",
"start": [
552,
1
],
"end": [
578,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkEmptySubstringAt",
"code": "def mkEmptySubstringAt (s : String) (p : String.Pos) : Substring := {\n str := s, startPos := p, stopPos := p\n}",
"start": [
580,
1
],
"end": [
582,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawAux",
"code": "private def rawAux (startPos : String.Pos) (trailingWs : Bool) : ParserFn := fun c s =>\n let input := c.input\n let stopPos := s.pos\n let leading := mkEmptySubstringAt input startPos\n let val := input.extract startPos stopPos\n if trailingWs then\n let s := whitespace c s\n let stopPos' := s.pos\n let trailing := { str := input, startPos := stopPos, stopPos := stopPos' : Substring }\n let atom := mkAtom (SourceInfo.original leading startPos trailing (startPos + val)) val\n s.pushSyntax atom\n else\n let trailing := mkEmptySubstringAt input stopPos\n let atom := mkAtom (SourceInfo.original leading startPos trailing (startPos + val)) val\n s.pushSyntax atom",
"start": [
584,
1
],
"end": [
598,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawFn",
"code": "def rawFn (p : ParserFn) (trailingWs := false) : ParserFn := fun c s =>\n let startPos := s.pos\n let s := p c s\n if s.hasError then s else rawAux startPos trailingWs c s",
"start": [
600,
1
],
"end": [
604,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.chFn",
"code": "def chFn (c : Char) (trailingWs := false) : ParserFn :=\n rawFn (satisfyFn (fun d => c == d) (\"'\" ++ toString c ++ \"'\")) trailingWs",
"start": [
606,
1
],
"end": [
607,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawCh",
"code": "def rawCh (c : Char) (trailingWs := false) : Parser := {\n fn := chFn c trailingWs\n}",
"start": [
609,
1
],
"end": [
611,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.hexDigitFn",
"code": "def hexDigitFn : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then s.mkEOIError\n else\n let curr := input.get' i h\n let i := input.next' i h\n if curr.isDigit || ('a' <= curr && curr <= 'f') || ('A' <= curr && curr <= 'F') then s.setPos i\n else s.mkUnexpectedError \"invalid hexadecimal numeral\"",
"start": [
613,
1
],
"end": [
621,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.stringGapFn",
"code": "partial def stringGapFn (seenNewline : Bool) : ParserFn := fun c s =>\n let i := s.pos\n if h : c.input.atEnd i then s else\n let curr := c.input.get' i h\n if curr == '\\n' then\n if seenNewline then\n s.mkUnexpectedError \"unexpected additional newline in string gap\"\n else\n stringGapFn true c (s.next' c.input i h)\n else if curr.isWhitespace then\n stringGapFn seenNewline c (s.next' c.input i h)\n else if seenNewline then\n s\n else\n s.mkUnexpectedError \"expecting newline in string gap\"",
"start": [
623,
1
],
"end": [
643,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.quotedCharCoreFn",
"code": "def quotedCharCoreFn (isQuotable : Char → Bool) (inString : Bool) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then s.mkEOIError\n else\n let curr := input.get' i h\n if isQuotable curr then\n s.next' input i h\n else if curr == 'x' then\n andthenFn hexDigitFn hexDigitFn c (s.next' input i h)\n else if curr == 'u' then\n andthenFn hexDigitFn (andthenFn hexDigitFn (andthenFn hexDigitFn hexDigitFn)) c (s.next' input i h)\n else if inString && curr == '\\n' then\n stringGapFn false c s\n else\n s.mkUnexpectedError \"invalid escape sequence\"",
"start": [
645,
1
],
"end": [
666,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isQuotableCharDefault",
"code": "def isQuotableCharDefault (c : Char) : Bool :=\n c == '\\\\' || c == '\\\"' || c == '\\'' || c == 'r' || c == 'n' || c == 't'",
"start": [
668,
1
],
"end": [
669,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.quotedCharFn",
"code": "def quotedCharFn : ParserFn :=\n quotedCharCoreFn isQuotableCharDefault false",
"start": [
671,
1
],
"end": [
672,
47
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.quotedStringFn",
"code": "def quotedStringFn : ParserFn :=\n quotedCharCoreFn isQuotableCharDefault true",
"start": [
674,
1
],
"end": [
679,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkNodeToken",
"code": "def mkNodeToken (n : SyntaxNodeKind) (startPos : String.Pos) : ParserFn := fun c s => Id.run do\n if s.hasError then\n return s\n let input := c.input\n let stopPos := s.pos\n let leading := mkEmptySubstringAt input startPos\n let val := input.extract startPos stopPos\n let s := whitespace c s\n let wsStopPos := s.pos\n let trailing := { str := input, startPos := stopPos, stopPos := wsStopPos : Substring }\n let info := SourceInfo.original leading startPos trailing stopPos\n s.pushSyntax (Syntax.mkLit n val info)",
"start": [
681,
1
],
"end": [
693,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.charLitFnAux",
"code": "def charLitFnAux (startPos : String.Pos) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then s.mkEOIError\n else\n let curr := input.get' i h\n let s := s.setPos (input.next' i h)\n let s := if curr == '\\\\' then quotedCharFn c s else s\n if s.hasError then s\n else\n let i := s.pos\n let curr := input.get i\n let s := s.setPos (input.next i)\n if curr == '\\'' then mkNodeToken charLitKind startPos c s\n else s.mkUnexpectedError \"missing end of character literal\"",
"start": [
695,
1
],
"end": [
709,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.strLitFnAux",
"code": "partial def strLitFnAux (startPos : String.Pos) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then s.mkUnexpectedErrorAt \"unterminated string literal\" startPos\n else\n let curr := input.get' i h\n let s := s.setPos (input.next' i h)\n if curr == '\\\"' then\n mkNodeToken strLitKind startPos c s\n else if curr == '\\\\' then andthenFn quotedStringFn (strLitFnAux startPos) c s\n else strLitFnAux startPos c s",
"start": [
711,
1
],
"end": [
721,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isRawStrLitStart",
"code": "partial def isRawStrLitStart (input : String) (i : String.Pos) : Bool :=\n if h : input.atEnd i then false\n else\n let curr := input.get' i h\n if curr == '#' then\n isRawStrLitStart input (input.next' i h)\n else\n curr == '\"'",
"start": [
723,
1
],
"end": [
736,
18
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawStrLitFnAux",
"code": "partial def rawStrLitFnAux (startPos : String.Pos) : ParserFn := initState 0\nwhere\n \n errorUnterminated (s : ParserState) := s.mkUnexpectedErrorAt \"unterminated raw string literal\" startPos\n \n initState (num : Nat) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then errorUnterminated s\n else\n let curr := input.get' i h\n let s := s.setPos (input.next' i h)\n if curr == '#' then\n initState (num + 1) c s\n else if curr == '\"' then\n normalState num c s\n else\n errorUnterminated s\n \n normalState (num : Nat) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then errorUnterminated s\n else\n let curr := input.get' i h\n let s := s.setPos (input.next' i h)\n if curr == '\\\"' then\n if num == 0 then\n mkNodeToken strLitKind startPos c s\n else\n closingState num 0 c s\n else\n normalState num c s\n \n closingState (num : Nat) (closingNum : Nat) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then errorUnterminated s\n else\n let curr := input.get' i h\n let s := s.setPos (input.next' i h)\n if curr == '#' then\n if closingNum + 1 == num then\n mkNodeToken strLitKind startPos c s\n else\n closingState num (closingNum + 1) c s\n else if curr == '\\\"' then\n closingState num 0 c s\n else\n normalState num c s",
"start": [
738,
1
],
"end": [
805,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.decimalNumberFn",
"code": "def decimalNumberFn (startPos : String.Pos) (c : ParserContext) : ParserState → ParserState := fun s =>\n let s := takeWhileFn (fun c => c.isDigit) c s\n let input := c.input\n let i := s.pos\n let curr := input.get i\n if curr == '.' || curr == 'e' || curr == 'E' then\n let s := parseOptDot s\n let s := parseOptExp s\n mkNodeToken scientificLitKind startPos c s\n else\n mkNodeToken numLitKind startPos c s\nwhere\n parseOptDot s :=\n let input := c.input\n let i := s.pos\n let curr := input.get i\n if curr == '.' then\n let i := input.next i\n let curr := input.get i\n if curr.isDigit then\n takeWhileFn (fun c => c.isDigit) c (s.setPos i)\n else\n s.setPos i\n else\n s\n\n parseOptExp s :=\n let input := c.input\n let i := s.pos\n let curr := input.get i\n if curr == 'e' || curr == 'E' then\n let i := input.next i\n let i := if input.get i == '-' || input.get i == '+' then input.next i else i\n let curr := input.get i\n if curr.isDigit then\n takeWhileFn (fun c => c.isDigit) c (s.setPos i)\n else\n s.mkUnexpectedError \"missing exponent digits in scientific literal\"\n else\n s",
"start": [
807,
1
],
"end": [
846,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.binNumberFn",
"code": "def binNumberFn (startPos : String.Pos) : ParserFn := fun c s =>\n let s := takeWhile1Fn (fun c => c == '0' || c == '1') \"binary number\" c s\n mkNodeToken numLitKind startPos c s",
"start": [
848,
1
],
"end": [
850,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.octalNumberFn",
"code": "def octalNumberFn (startPos : String.Pos) : ParserFn := fun c s =>\n let s := takeWhile1Fn (fun c => '0' ≤ c && c ≤ '7') \"octal number\" c s\n mkNodeToken numLitKind startPos c s",
"start": [
852,
1
],
"end": [
854,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.hexNumberFn",
"code": "def hexNumberFn (startPos : String.Pos) : ParserFn := fun c s =>\n let s := takeWhile1Fn (fun c => ('0' ≤ c && c ≤ '9') || ('a' ≤ c && c ≤ 'f') || ('A' ≤ c && c ≤ 'F')) \"hexadecimal number\" c s\n mkNodeToken numLitKind startPos c s",
"start": [
856,
1
],
"end": [
858,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.numberFnAux",
"code": "def numberFnAux : ParserFn := fun c s =>\n let input := c.input\n let startPos := s.pos\n if h : input.atEnd startPos then s.mkEOIError\n else\n let curr := input.get' startPos h\n if curr == '0' then\n let i := input.next' startPos h\n let curr := input.get i\n if curr == 'b' || curr == 'B' then\n binNumberFn startPos c (s.next input i)\n else if curr == 'o' || curr == 'O' then\n octalNumberFn startPos c (s.next input i)\n else if curr == 'x' || curr == 'X' then\n hexNumberFn startPos c (s.next input i)\n else\n decimalNumberFn startPos c (s.setPos i)\n else if curr.isDigit then\n decimalNumberFn startPos c (s.next input startPos)\n else\n s.mkError \"numeral\"",
"start": [
860,
1
],
"end": [
880,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isIdCont",
"code": "def isIdCont : String → ParserState → Bool := fun input s =>\n let i := s.pos\n let curr := input.get i\n if curr == '.' then\n let i := input.next i\n if input.atEnd i then\n false\n else\n let curr := input.get i\n isIdFirst curr || isIdBeginEscape curr\n else\n false",
"start": [
882,
1
],
"end": [
893,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isToken",
"code": "private def isToken (idStartPos idStopPos : String.Pos) (tk : Option Token) : Bool :=\n match tk with\n | none => false\n | some tk =>\n tk.endPos ≥ idStopPos - idStartPos",
"start": [
895,
1
],
"end": [
901,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkTokenAndFixPos",
"code": "def mkTokenAndFixPos (startPos : String.Pos) (tk : Option Token) : ParserFn := fun c s =>\n match tk with\n | none => s.mkErrorAt \"token\" startPos\n | some tk =>\n if c.forbiddenTk? == some tk then\n s.mkErrorAt \"forbidden token\" startPos\n else\n let input := c.input\n let leading := mkEmptySubstringAt input startPos\n let stopPos := startPos + tk\n let s := s.setPos stopPos\n let s := whitespace c s\n let wsStopPos := s.pos\n let trailing := { str := input, startPos := stopPos, stopPos := wsStopPos : Substring }\n let atom := mkAtom (SourceInfo.original leading startPos trailing stopPos) tk\n s.pushSyntax atom",
"start": [
904,
1
],
"end": [
919,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkIdResult",
"code": "def mkIdResult (startPos : String.Pos) (tk : Option Token) (val : Name) : ParserFn := fun c s =>\n let stopPos := s.pos\n if isToken startPos stopPos tk then\n mkTokenAndFixPos startPos tk c s\n else\n let input := c.input\n let rawVal := { str := input, startPos := startPos, stopPos := stopPos : Substring }\n let s := whitespace c s\n let trailingStopPos := s.pos\n let leading := mkEmptySubstringAt input startPos\n let trailing := { str := input, startPos := stopPos, stopPos := trailingStopPos : Substring }\n let info := SourceInfo.original leading startPos trailing stopPos\n let atom := mkIdent info rawVal val\n s.pushSyntax atom",
"start": [
921,
1
],
"end": [
934,
22
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.identFnAux",
"code": "partial def identFnAux (startPos : String.Pos) (tk : Option Token) (r : Name) : ParserFn :=\n let rec parse (r : Name) (c s) :=\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then\n s.mkEOIError\n else\n let curr := input.get' i h\n if isIdBeginEscape curr then\n let startPart := input.next' i h\n let s := takeUntilFn isIdEndEscape c (s.setPos startPart)\n if h : input.atEnd s.pos then\n s.mkUnexpectedErrorAt \"unterminated identifier escape\" startPart\n else\n let stopPart := s.pos\n let s := s.next' c.input s.pos h\n let r := .str r (input.extract startPart stopPart)\n if isIdCont input s then\n let s := s.next input s.pos\n parse r c s\n else\n mkIdResult startPos tk r c s\n else if isIdFirst curr then\n let startPart := i\n let s := takeWhileFn isIdRest c (s.next input i)\n let stopPart := s.pos\n let r := .str r (input.extract startPart stopPart)\n if isIdCont input s then\n let s := s.next input s.pos\n parse r c s\n else\n mkIdResult startPos tk r c s\n else\n mkTokenAndFixPos startPos tk c s\n parse r",
"start": [
936,
1
],
"end": [
970,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isIdFirstOrBeginEscape",
"code": "private def isIdFirstOrBeginEscape (c : Char) : Bool :=\n isIdFirst c || isIdBeginEscape c",
"start": [
972,
1
],
"end": [
973,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nameLitAux",
"code": "private def nameLitAux (startPos : String.Pos) : ParserFn := fun c s =>\n let input := c.input\n let s := identFnAux startPos none .anonymous c (s.next input startPos)\n if s.hasError then\n s\n else\n let stx := s.stxStack.back\n match stx with\n | .ident info rawStr _ _ =>\n let s := s.popSyntax\n s.pushSyntax (Syntax.mkNameLit rawStr.toString info)\n | _ => s.mkError \"invalid Name literal\"",
"start": [
975,
1
],
"end": [
986,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.tokenFnAux",
"code": "private def tokenFnAux : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n let curr := input.get i\n if curr == '\\\"' then\n strLitFnAux i c (s.next input i)\n else if curr == '\\'' && getNext input i != '\\'' then\n charLitFnAux i c (s.next input i)\n else if curr.isDigit then\n numberFnAux c s\n else if curr == '`' && isIdFirstOrBeginEscape (getNext input i) then\n nameLitAux i c s\n else if curr == 'r' && isRawStrLitStart input (input.next i) then\n rawStrLitFnAux i c (s.next input i)\n else\n let tk := c.tokens.matchPrefix input i\n identFnAux i tk .anonymous c s",
"start": [
988,
1
],
"end": [
1004,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.updateTokenCache",
"code": "private def updateTokenCache (startPos : String.Pos) (s : ParserState) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, ⟨_, catCache⟩, none, errs⟩ =>\n if stack.size == 0 then s\n else\n let tk := stack.back\n ⟨stack, lhsPrec, pos, ⟨{ startPos := startPos, stopPos := pos, token := tk }, catCache⟩, none, errs⟩\n | other => other",
"start": [
1006,
1
],
"end": [
1014,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.tokenFn",
"code": "def tokenFn (expected : List String := []) : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if input.atEnd i then s.mkEOIError expected\n else\n let tkc := s.cache.tokenCache\n if tkc.startPos == i then\n let s := s.pushSyntax tkc.token\n s.setPos tkc.stopPos\n else\n let s := tokenFnAux c s\n updateTokenCache i s",
"start": [
1016,
1
],
"end": [
1027,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.peekTokenAux",
"code": "def peekTokenAux (c : ParserContext) (s : ParserState) : ParserState × Except ParserState Syntax :=\n let iniSz := s.stackSize\n let iniPos := s.pos\n let s := tokenFn [] c s\n if let some _ := s.errorMsg then (s.restore iniSz iniPos, .error s)\n else\n let stx := s.stxStack.back\n (s.restore iniSz iniPos, .ok stx)",
"start": [
1029,
1
],
"end": [
1036,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.peekToken",
"code": "def peekToken (c : ParserContext) (s : ParserState) : ParserState × Except ParserState Syntax :=\n let tkc := s.cache.tokenCache\n if tkc.startPos == s.pos then\n (s, .ok tkc.token)\n else\n peekTokenAux c s",
"start": [
1038,
1
],
"end": [
1043,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawIdentFn",
"code": "def rawIdentFn : ParserFn := fun c s =>\n let input := c.input\n let i := s.pos\n if input.atEnd i then s.mkEOIError\n else identFnAux i none .anonymous c s",
"start": [
1045,
1
],
"end": [
1050,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.satisfySymbolFn",
"code": "def satisfySymbolFn (p : String → Bool) (expected : List String) : ParserFn := fun c s => Id.run do\n let iniPos := s.pos\n let s := tokenFn expected c s\n if s.hasError then\n return s\n if let .atom _ sym := s.stxStack.back then\n if p sym then\n return s\n s.mkUnexpectedTokenErrors expected iniPos",
"start": [
1052,
1
],
"end": [
1061,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.symbolFnAux",
"code": "def symbolFnAux (sym : String) (errorMsg : String) : ParserFn :=\n satisfySymbolFn (fun s => s == sym) [errorMsg]",
"start": [
1063,
1
],
"end": [
1064,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.symbolInfo",
"code": "def symbolInfo (sym : String) : ParserInfo := {\n collectTokens := fun tks => sym :: tks\n firstTokens := FirstTokens.tokens [ sym ]\n}",
"start": [
1066,
1
],
"end": [
1069,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.symbolFn",
"code": "def symbolFn (sym : String) : ParserFn :=\n symbolFnAux sym (\"'\" ++ sym ++ \"'\")",
"start": [
1071,
1
],
"end": [
1072,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.symbolNoAntiquot",
"code": "def symbolNoAntiquot (sym : String) : Parser :=\n let sym := sym.trim\n { info := symbolInfo sym\n fn := symbolFn sym }",
"start": [
1074,
1
],
"end": [
1077,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkTailNoWs",
"code": "def checkTailNoWs (prev : Syntax) : Bool :=\n match prev.getTailInfo with\n | .original _ _ trailing _ => trailing.stopPos == trailing.startPos\n | _ => false",
"start": [
1079,
1
],
"end": [
1082,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nonReservedSymbolFnAux",
"code": "def nonReservedSymbolFnAux (sym : String) (errorMsg : String) : ParserFn := fun c s => Id.run do\n let s := tokenFn [errorMsg] c s\n if s.hasError then\n return s\n match s.stxStack.back with\n | .atom _ sym' =>\n if sym == sym' then\n return s\n | .ident info rawVal _ _ =>\n if sym == rawVal.toString then\n let s := s.popSyntax\n return s.pushSyntax (Syntax.atom info sym)\n | _ => ()\n s.mkUnexpectedTokenError errorMsg",
"start": [
1084,
1
],
"end": [
1104,
36
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nonReservedSymbolFn",
"code": "def nonReservedSymbolFn (sym : String) : ParserFn :=\n nonReservedSymbolFnAux sym (\"'\" ++ sym ++ \"'\")",
"start": [
1106,
1
],
"end": [
1107,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nonReservedSymbolInfo",
"code": "def nonReservedSymbolInfo (sym : String) (includeIdent : Bool) : ParserInfo := {\n firstTokens :=\n if includeIdent then\n .tokens [ sym, \"ident\" ]\n else\n .tokens [ sym ]\n}",
"start": [
1109,
1
],
"end": [
1115,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nonReservedSymbolNoAntiquot",
"code": "def nonReservedSymbolNoAntiquot (sym : String) (includeIdent := false) : Parser :=\n let sym := sym.trim\n { info := nonReservedSymbolInfo sym includeIdent,\n fn := nonReservedSymbolFn sym }",
"start": [
1117,
1
],
"end": [
1120,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.strAux",
"code": "partial def strAux (sym : String) (errorMsg : String) (j : String.Pos) :ParserFn :=\n let rec parse (j c s) :=\n if h₁ : sym.atEnd j then s\n else\n let i := s.pos\n let input := c.input\n if h₂ : input.atEnd i then s.mkError errorMsg\n else if sym.get' j h₁ != input.get' i h₂ then s.mkError errorMsg\n else parse (sym.next' j h₁) c (s.next' input i h₂)\n parse j",
"start": [
1122,
1
],
"end": [
1131,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkTailWs",
"code": "def checkTailWs (prev : Syntax) : Bool :=\n match prev.getTailInfo with\n | .original _ _ trailing _ => trailing.stopPos > trailing.startPos\n | _ => false",
"start": [
1133,
1
],
"end": [
1136,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkWsBeforeFn",
"code": "def checkWsBeforeFn (errorMsg : String) : ParserFn := fun _ s =>\n let prev := s.stxStack.back\n if checkTailWs prev then s else s.mkError errorMsg",
"start": [
1138,
1
],
"end": [
1140,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkWsBefore",
"code": "def checkWsBefore (errorMsg : String := \"space before\") : Parser where\n info := epsilonInfo\n fn := checkWsBeforeFn errorMsg",
"start": [
1142,
1
],
"end": [
1148,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkTailLinebreak",
"code": "def checkTailLinebreak (prev : Syntax) : Bool :=\n match prev.getTailInfo with\n | .original _ _ trailing _ => trailing.contains '\\n'\n | _ => false",
"start": [
1150,
1
],
"end": [
1153,
15
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkLinebreakBeforeFn",
"code": "def checkLinebreakBeforeFn (errorMsg : String) : ParserFn := fun _ s =>\n let prev := s.stxStack.back\n if checkTailLinebreak prev then s else s.mkError errorMsg",
"start": [
1155,
1
],
"end": [
1157,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkLinebreakBefore",
"code": "def checkLinebreakBefore (errorMsg : String := \"line break\") : Parser where\n info := epsilonInfo\n fn := checkLinebreakBeforeFn errorMsg",
"start": [
1159,
1
],
"end": [
1165,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.pickNonNone",
"code": "private def pickNonNone (stack : SyntaxStack) : Syntax :=\n match stack.toSubarray.findRev? fun stx => !stx.isNone with\n | none => Syntax.missing\n | some stx => stx",
"start": [
1167,
1
],
"end": [
1170,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkNoWsBeforeFn",
"code": "def checkNoWsBeforeFn (errorMsg : String) : ParserFn := fun _ s =>\n let prev := pickNonNone s.stxStack\n if checkTailNoWs prev then s else s.mkError errorMsg",
"start": [
1172,
1
],
"end": [
1174,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkNoWsBefore",
"code": "def checkNoWsBefore (errorMsg : String := \"no space before\") : Parser := {\n info := epsilonInfo\n fn := checkNoWsBeforeFn errorMsg\n}",
"start": [
1176,
1
],
"end": [
1186,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.unicodeSymbolFnAux",
"code": "def unicodeSymbolFnAux (sym asciiSym : String) (expected : List String) : ParserFn :=\n satisfySymbolFn (fun s => s == sym || s == asciiSym) expected",
"start": [
1188,
1
],
"end": [
1189,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.unicodeSymbolInfo",
"code": "def unicodeSymbolInfo (sym asciiSym : String) : ParserInfo := {\n collectTokens := fun tks => sym :: asciiSym :: tks\n firstTokens := FirstTokens.tokens [ sym, asciiSym ]\n}",
"start": [
1191,
1
],
"end": [
1194,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.unicodeSymbolFn",
"code": "def unicodeSymbolFn (sym asciiSym : String) : ParserFn :=\n unicodeSymbolFnAux sym asciiSym [\"'\" ++ sym ++ \"', '\" ++ asciiSym ++ \"'\"]",
"start": [
1196,
1
],
"end": [
1197,
76
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.unicodeSymbolNoAntiquot",
"code": "def unicodeSymbolNoAntiquot (sym asciiSym : String) : Parser :=\n let sym := sym.trim\n let asciiSym := asciiSym.trim\n { info := unicodeSymbolInfo sym asciiSym\n fn := unicodeSymbolFn sym asciiSym }",
"start": [
1199,
1
],
"end": [
1203,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkAtomicInfo",
"code": "def mkAtomicInfo (k : String) : ParserInfo :=\n { firstTokens := FirstTokens.tokens [ k ] }",
"start": [
1205,
1
],
"end": [
1206,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.expectTokenFn",
"code": "def expectTokenFn (k : SyntaxNodeKind) (desc : String) : ParserFn := fun c s =>\n let s := tokenFn [desc] c s\n if !s.hasError && !(s.stxStack.back.isOfKind k) then s.mkUnexpectedTokenError desc else s",
"start": [
1208,
1
],
"end": [
1213,
92
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.numLitFn",
"code": "def numLitFn : ParserFn := expectTokenFn numLitKind \"numeral\"",
"start": [
1215,
1
],
"end": [
1215,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.numLitNoAntiquot",
"code": "def numLitNoAntiquot : Parser := {\n fn := numLitFn\n info := mkAtomicInfo \"num\"\n}",
"start": [
1217,
1
],
"end": [
1220,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.scientificLitFn",
"code": "def scientificLitFn : ParserFn := expectTokenFn scientificLitKind \"scientific number\"",
"start": [
1222,
1
],
"end": [
1222,
86
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.scientificLitNoAntiquot",
"code": "def scientificLitNoAntiquot : Parser := {\n fn := scientificLitFn\n info := mkAtomicInfo \"scientific\"\n}",
"start": [
1224,
1
],
"end": [
1227,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.strLitFn",
"code": "def strLitFn : ParserFn := expectTokenFn strLitKind \"string literal\"",
"start": [
1229,
1
],
"end": [
1229,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.strLitNoAntiquot",
"code": "def strLitNoAntiquot : Parser := {\n fn := strLitFn\n info := mkAtomicInfo \"str\"\n}",
"start": [
1231,
1
],
"end": [
1234,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.charLitFn",
"code": "def charLitFn : ParserFn := expectTokenFn charLitKind \"character literal\"",
"start": [
1236,
1
],
"end": [
1236,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.charLitNoAntiquot",
"code": "def charLitNoAntiquot : Parser := {\n fn := charLitFn\n info := mkAtomicInfo \"char\"\n}",
"start": [
1238,
1
],
"end": [
1241,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nameLitFn",
"code": "def nameLitFn : ParserFn := expectTokenFn nameLitKind \"Name literal\"",
"start": [
1243,
1
],
"end": [
1243,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nameLitNoAntiquot",
"code": "def nameLitNoAntiquot : Parser := {\n fn := nameLitFn\n info := mkAtomicInfo \"name\"\n}",
"start": [
1245,
1
],
"end": [
1248,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.identFn",
"code": "def identFn : ParserFn := expectTokenFn identKind \"identifier\"",
"start": [
1250,
1
],
"end": [
1250,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.identNoAntiquot",
"code": "def identNoAntiquot : Parser := {\n fn := identFn\n info := mkAtomicInfo \"ident\"\n}",
"start": [
1252,
1
],
"end": [
1255,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.rawIdentNoAntiquot",
"code": "def rawIdentNoAntiquot : Parser := {\n fn := rawIdentFn\n}",
"start": [
1257,
1
],
"end": [
1259,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.identEqFn",
"code": "def identEqFn (id : Name) : ParserFn := fun c s =>\n let s := tokenFn [\"identifier\"] c s\n if s.hasError then\n s\n else match s.stxStack.back with\n | .ident _ _ val _ => if val != id then s.mkUnexpectedTokenError s!\"identifier '{id}'\" else s\n | _ => s.mkUnexpectedTokenError \"identifier\"",
"start": [
1261,
1
],
"end": [
1267,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.identEq",
"code": "def identEq (id : Name) : Parser := {\n fn := identEqFn id\n info := mkAtomicInfo \"ident\"\n}",
"start": [
1269,
1
],
"end": [
1272,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.hygieneInfoFn",
"code": "def hygieneInfoFn : ParserFn := fun c s => Id.run do\n let input := c.input\n let finish pos str trailing s :=\n let info := SourceInfo.original str pos trailing pos\n let ident := mkIdent info str .anonymous\n let stx := mkNode hygieneInfoKind #[ident]\n s.pushSyntax stx\n if !s.stxStack.isEmpty then\n let prev := s.stxStack.back\n if let .original leading pos trailing endPos := prev.getTailInfo then\n let str := mkEmptySubstringAt input endPos\n let s := s.popSyntax.pushSyntax <| prev.setTailInfo (.original leading pos str endPos)\n return finish endPos str trailing s\n let str := mkEmptySubstringAt input s.pos\n finish s.pos str str s",
"start": [
1274,
1
],
"end": [
1297,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.hygieneInfoNoAntiquot",
"code": "def hygieneInfoNoAntiquot : Parser := {\n fn := hygieneInfoFn\n info := nodeInfo hygieneInfoKind epsilonInfo\n}",
"start": [
1299,
1
],
"end": [
1302,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.keepTop",
"code": "def keepTop (s : SyntaxStack) (startStackSize : Nat) : SyntaxStack :=\n let node := s.back\n s.shrink startStackSize |>.push node",
"start": [
1306,
1
],
"end": [
1308,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.keepNewError",
"code": "def keepNewError (s : ParserState) (oldStackSize : Nat) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, err, errs⟩ => ⟨keepTop stack oldStackSize, lhsPrec, pos, cache, err, errs⟩",
"start": [
1310,
1
],
"end": [
1312,
108
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.keepPrevError",
"code": "def keepPrevError (s : ParserState) (oldStackSize : Nat) (oldStopPos : String.Pos) (oldError : Option Error) (oldLhsPrec : Nat) : ParserState :=\n match s with\n | ⟨stack, _, _, cache, _, errs⟩ =>\n ⟨stack.shrink oldStackSize, oldLhsPrec, oldStopPos, cache, oldError, errs⟩",
"start": [
1314,
1
],
"end": [
1317,
79
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.mergeErrors",
"code": "def mergeErrors (s : ParserState) (oldStackSize : Nat) (oldError : Error) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, some err, errs⟩ =>\n let newError := if oldError == err then err else oldError.merge err\n ⟨stack.shrink oldStackSize, lhsPrec, pos, cache, some newError, errs⟩\n | other => other",
"start": [
1319,
1
],
"end": [
1324,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.keepLatest",
"code": "def keepLatest (s : ParserState) (startStackSize : Nat) : ParserState :=\n match s with\n | ⟨stack, lhsPrec, pos, cache, _, errs⟩ =>\n ⟨keepTop stack startStackSize, lhsPrec, pos, cache, none, errs⟩",
"start": [
1326,
1
],
"end": [
1329,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserState.replaceLongest",
"code": "def replaceLongest (s : ParserState) (startStackSize : Nat) : ParserState :=\n s.keepLatest startStackSize",
"start": [
1331,
1
],
"end": [
1332,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.invalidLongestMatchParser",
"code": "def invalidLongestMatchParser (s : ParserState) : ParserState :=\n s.mkError \"longestMatch parsers must generate exactly one Syntax node\"",
"start": [
1336,
1
],
"end": [
1337,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.runLongestMatchParser",
"code": "def runLongestMatchParser (left? : Option Syntax) (startLhsPrec : Nat) (p : ParserFn) : ParserFn := fun c s => Id.run do\n \n let mut s := { s with lhsPrec := if left?.isSome then startLhsPrec else maxPrec }\n let startSize := s.stackSize\n if let some left := left? then\n s := s.pushSyntax left\n s := p c s\n if s.stackSize == startSize + 1 then\n s else if s.hasError then\n s.shrinkStack startSize |>.pushSyntax Syntax.missing\n else\n invalidLongestMatchParser s",
"start": [
1339,
1
],
"end": [
1369,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.longestMatchStep",
"code": "def longestMatchStep (left? : Option Syntax) (startSize startLhsPrec : Nat) (startPos : String.Pos) (prevPrio : Nat) (prio : Nat) (p : ParserFn)\n : ParserContext → ParserState → ParserState × Nat := fun c s =>\n let score (s : ParserState) (prio : Nat) :=\n (s.pos.byteIdx, if s.errorMsg.isSome then (0 : Nat) else 1, prio)\n let previousScore := score s prevPrio\n let prevErrorMsg := s.errorMsg\n let prevStopPos := s.pos\n let prevSize := s.stackSize\n let prevLhsPrec := s.lhsPrec\n let s := s.restore prevSize startPos\n let s := runLongestMatchParser left? startLhsPrec p c s\n match (let _ := @lexOrd; compare previousScore (score s prio)) with\n | .lt => (s.keepNewError startSize, prio)\n | .gt => (s.keepPrevError prevSize prevStopPos prevErrorMsg prevLhsPrec, prevPrio)\n | .eq =>\n match prevErrorMsg with\n | none =>\n ({s with lhsPrec := s.lhsPrec.min prevLhsPrec }, prio)\n | some oldError => (s.mergeErrors prevSize oldError, prio)",
"start": [
1371,
1
],
"end": [
1390,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.longestMatchMkResult",
"code": "def longestMatchMkResult (startSize : Nat) (s : ParserState) : ParserState :=\n if s.stackSize > startSize + 1 then s.mkNode choiceKind startSize else s",
"start": [
1392,
1
],
"end": [
1393,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.longestMatchFnAux",
"code": "def longestMatchFnAux (left? : Option Syntax) (startSize startLhsPrec : Nat) (startPos : String.Pos) (prevPrio : Nat) (ps : List (Parser × Nat)) : ParserFn :=\n let rec parse (prevPrio : Nat) (ps : List (Parser × Nat)) :=\n match ps with\n | [] => fun _ s => longestMatchMkResult startSize s\n | p::ps => fun c s =>\n let (s, prevPrio) := longestMatchStep left? startSize startLhsPrec startPos prevPrio p.2 p.1.fn c s\n parse prevPrio ps c s\n parse prevPrio ps",
"start": [
1395,
1
],
"end": [
1402,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.longestMatchFn",
"code": "def longestMatchFn (left? : Option Syntax) : List (Parser × Nat) → ParserFn\n | [] => fun _ s => s.mkError \"longestMatch: empty list\"\n | [p] => fun c s => runLongestMatchParser left? s.lhsPrec p.1.fn c s\n | p::ps => fun c s =>\n let startSize := s.stackSize\n let startLhsPrec := s.lhsPrec\n let startPos := s.pos\n let s := runLongestMatchParser left? s.lhsPrec p.1.fn c s\n longestMatchFnAux left? startSize startLhsPrec startPos p.2 ps c s",
"start": [
1404,
1
],
"end": [
1412,
71
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.anyOfFn",
"code": "def anyOfFn : List Parser → ParserFn\n | [], _, s => s.mkError \"anyOf: empty list\"\n | [p], c, s => p.fn c s\n | p::ps, c, s => orelseFn p.fn (anyOfFn ps) c s",
"start": [
1414,
1
],
"end": [
1417,
50
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkColEqFn",
"code": "def checkColEqFn (errorMsg : String) : ParserFn := fun c s =>\n match c.savedPos? with\n | none => s\n | some savedPos =>\n let savedPos := c.fileMap.toPosition savedPos\n let pos := c.fileMap.toPosition s.pos\n if pos.column = savedPos.column then s\n else s.mkError errorMsg",
"start": [
1419,
1
],
"end": [
1426,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkColEq",
"code": "def checkColEq (errorMsg : String := \"checkColEq\") : Parser where\n fn := checkColEqFn errorMsg",
"start": [
1428,
1
],
"end": [
1434,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkColGeFn",
"code": "def checkColGeFn (errorMsg : String) : ParserFn := fun c s =>\n match c.savedPos? with\n | none => s\n | some savedPos =>\n let savedPos := c.fileMap.toPosition savedPos\n let pos := c.fileMap.toPosition s.pos\n if pos.column ≥ savedPos.column then s\n else s.mkError errorMsg",
"start": [
1436,
1
],
"end": [
1443,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkColGe",
"code": "def checkColGe (errorMsg : String := \"checkColGe\") : Parser where\n fn := checkColGeFn errorMsg",
"start": [
1445,
1
],
"end": [
1453,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkColGtFn",
"code": "def checkColGtFn (errorMsg : String) : ParserFn := fun c s =>\n match c.savedPos? with\n | none => s\n | some savedPos =>\n let savedPos := c.fileMap.toPosition savedPos\n let pos := c.fileMap.toPosition s.pos\n if pos.column > savedPos.column then s\n else s.mkError errorMsg",
"start": [
1455,
1
],
"end": [
1462,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkColGt",
"code": "def checkColGt (errorMsg : String := \"checkColGt\") : Parser where\n fn := checkColGtFn errorMsg",
"start": [
1464,
1
],
"end": [
1477,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkLineEqFn",
"code": "def checkLineEqFn (errorMsg : String) : ParserFn := fun c s =>\n match c.savedPos? with\n | none => s\n | some savedPos =>\n let savedPos := c.fileMap.toPosition savedPos\n let pos := c.fileMap.toPosition s.pos\n if pos.line == savedPos.line then s\n else s.mkError errorMsg",
"start": [
1479,
1
],
"end": [
1486,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkLineEq",
"code": "def checkLineEq (errorMsg : String := \"checkLineEq\") : Parser where\n fn := checkLineEqFn errorMsg",
"start": [
1488,
1
],
"end": [
1495,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withPosition",
"code": "def withPosition : Parser → Parser := withFn fun f c s =>\n adaptCacheableContextFn ({ · with savedPos? := s.pos }) f c s",
"start": [
1497,
1
],
"end": [
1511,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withPositionAfterLinebreak",
"code": "def withPositionAfterLinebreak : Parser → Parser := withFn fun f c s =>\n let prev := s.stxStack.back\n adaptCacheableContextFn (fun c => if checkTailLinebreak prev then { c with savedPos? := s.pos } else c) f c s",
"start": [
1513,
1
],
"end": [
1515,
112
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withoutPosition",
"code": "def withoutPosition (p : Parser) : Parser :=\n adaptCacheableContext ({ · with savedPos? := none }) p",
"start": [
1517,
1
],
"end": [
1523,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withForbidden",
"code": "def withForbidden (tk : Token) (p : Parser) : Parser :=\n adaptCacheableContext ({ · with forbiddenTk? := tk }) p",
"start": [
1525,
1
],
"end": [
1533,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withoutForbidden",
"code": "def withoutForbidden (p : Parser) : Parser :=\n adaptCacheableContext ({ · with forbiddenTk? := none }) p",
"start": [
1535,
1
],
"end": [
1541,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.eoiFn",
"code": "def eoiFn : ParserFn := fun c s =>\n let i := s.pos\n if c.input.atEnd i then s\n else s.mkError \"expected end of file\"",
"start": [
1543,
1
],
"end": [
1546,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.eoi",
"code": "def eoi : Parser := {\n fn := eoiFn\n}",
"start": [
1548,
1
],
"end": [
1550,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.TokenMap",
"code": "def TokenMap (α : Type) := RBMap Name (List α) Name.quickCmp",
"start": [
1552,
1
],
"end": [
1553,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.TokenMap.insert",
"code": "def insert (map : TokenMap α) (k : Name) (v : α) : TokenMap α :=\n match map.find? k with\n | none => .insert map k [v]\n | some vs => .insert map k (v::vs)",
"start": [
1557,
1
],
"end": [
1560,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.PrattParsingTables",
"code": "structure PrattParsingTables where\n leadingTable : TokenMap (Parser × Nat) := {}\n leadingParsers : List (Parser × Nat) := [] trailingTable : TokenMap (Parser × Nat) := {}\n trailingParsers : List (Parser × Nat) := []",
"start": [
1571,
1
],
"end": [
1575,
46
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.LeadingIdentBehavior",
"code": "inductive LeadingIdentBehavior where\n \n | default\n \n | symbol\n \n | both\n deriving Inhabited, BEq, Repr",
"start": [
1580,
1
],
"end": [
1608,
32
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserCategory",
"code": "structure ParserCategory where\n \n declName : Name\n \n kinds : SyntaxNodeKindSet := {}\n \n tables : PrattParsingTables := {}\n \n behavior : LeadingIdentBehavior\n deriving Inhabited",
"start": [
1610,
1
],
"end": [
1641,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserCategories",
"code": "abbrev ParserCategories := PersistentHashMap Name ParserCategory",
"start": [
1643,
1
],
"end": [
1643,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.indexed",
"code": "def indexed {α : Type} (map : TokenMap α) (c : ParserContext) (s : ParserState) (behavior : LeadingIdentBehavior) : ParserState × List α :=\n let (s, stx) := peekToken c s\n let find (n : Name) : ParserState × List α :=\n match map.find? n with\n | some as => (s, as)\n | _ => (s, [])\n match stx with\n | .ok (.atom _ sym) => find (.mkSimple sym)\n | .ok (.ident _ _ val _) =>\n match behavior with\n | .default => find identKind\n | .symbol =>\n match map.find? val with\n | some as => (s, as)\n | none => find identKind\n | .both =>\n match map.find? val with\n | some as =>\n if val == identKind then\n (s, as) else\n match map.find? identKind with\n | some as' => (s, as ++ as')\n | _ => (s, as)\n | none => find identKind\n | .ok (.node _ k _) => find k\n | .ok _ => (s, [])\n | .error s' => (s', [])",
"start": [
1645,
1
],
"end": [
1672,
34
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.CategoryParserFn",
"code": "abbrev CategoryParserFn := Name → ParserFn",
"start": [
1674,
1
],
"end": [
1674,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.categoryParserFn",
"code": "def categoryParserFn (catName : Name) : ParserFn := fun ctx s =>\n categoryParserFnExtension.getState ctx.env catName ctx s",
"start": [
1680,
1
],
"end": [
1681,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.categoryParser",
"code": "def categoryParser (catName : Name) (prec : Nat) : Parser where\n fn := adaptCacheableContextFn ({ · with prec }) (withCacheFn catName (categoryParserFn catName))",
"start": [
1683,
1
],
"end": [
1684,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.termParser",
"code": "def termParser (prec : Nat := 0) : Parser :=\n categoryParser `term prec",
"start": [
1687,
1
],
"end": [
1688,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.checkNoImmediateColon",
"code": "def checkNoImmediateColon : Parser := {\n fn := fun c s =>\n let prev := s.stxStack.back\n if checkTailNoWs prev then\n let input := c.input\n let i := s.pos\n if h : input.atEnd i then s\n else\n let curr := input.get' i h\n if curr == ':' then\n s.mkUnexpectedError \"unexpected ':'\"\n else s\n else s\n}",
"start": [
1694,
1
],
"end": [
1708,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.setExpectedFn",
"code": "def setExpectedFn (expected : List String) (p : ParserFn) : ParserFn := fun c s =>\n match p c s with\n | s'@{ errorMsg := some msg, .. } => { s' with errorMsg := some { msg with expected } }\n | s' => s'",
"start": [
1710,
1
],
"end": [
1713,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.setExpected",
"code": "def setExpected (expected : List String) : Parser → Parser := withFn (setExpectedFn expected)",
"start": [
1715,
1
],
"end": [
1715,
94
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.pushNone",
"code": "def pushNone : Parser := {\n fn := fun _ s => s.pushSyntax mkNullNode\n}",
"start": [
1717,
1
],
"end": [
1719,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.antiquotNestedExpr",
"code": "def antiquotNestedExpr : Parser := node `antiquotNestedExpr (symbolNoAntiquot \"(\" >> decQuotDepth termParser >> symbolNoAntiquot \")\")",
"start": [
1722,
1
],
"end": [
1722,
134
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.antiquotExpr",
"code": "def antiquotExpr : Parser := identNoAntiquot <|> symbolNoAntiquot \"_\" <|> antiquotNestedExpr",
"start": [
1723,
1
],
"end": [
1723,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.tokenAntiquotFn",
"code": "def tokenAntiquotFn : ParserFn := fun c s => Id.run do\n if s.hasError then\n return s\n let iniSz := s.stackSize\n let iniPos := s.pos\n let s := (checkNoWsBefore >> symbolNoAntiquot \"%\" >> symbolNoAntiquot \"$\" >> checkNoWsBefore >> antiquotExpr).fn c s\n if s.hasError then\n return s.restore iniSz iniPos\n s.mkNode (`token_antiquot) (iniSz - 1)",
"start": [
1725,
1
],
"end": [
1733,
41
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.tokenWithAntiquot",
"code": "def tokenWithAntiquot : Parser → Parser := withFn fun f c s =>\n let s := f c s\n if c.input.get s.pos == '%' then\n tokenAntiquotFn c s\n else\n s",
"start": [
1735,
1
],
"end": [
1741,
6
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.symbol",
"code": "def symbol (sym : String) : Parser :=\n tokenWithAntiquot (symbolNoAntiquot sym)",
"start": [
1743,
1
],
"end": [
1744,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nonReservedSymbol",
"code": "def nonReservedSymbol (sym : String) (includeIdent := false) : Parser :=\n tokenWithAntiquot (nonReservedSymbolNoAntiquot sym includeIdent)",
"start": [
1749,
1
],
"end": [
1750,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.unicodeSymbol",
"code": "def unicodeSymbol (sym asciiSym : String) : Parser :=\n tokenWithAntiquot (unicodeSymbolNoAntiquot sym asciiSym)",
"start": [
1752,
1
],
"end": [
1753,
59
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkAntiquot",
"code": "def mkAntiquot (name : String) (kind : SyntaxNodeKind) (anonymous := true) (isPseudoKind := false) : Parser :=\n let kind := kind ++ (if isPseudoKind then `pseudo else .anonymous) ++ `antiquot\n let nameP := node `antiquotName <| checkNoWsBefore (\"no space before ':\" ++ name ++ \"'\") >> symbol \":\" >> nonReservedSymbol name\n let nameP := if anonymous then nameP <|> checkNoImmediateColon >> pushNone else nameP\n leadingNode kind maxPrec <| atomic <|\n setExpected [] \"$\" >>\n manyNoAntiquot (checkNoWsBefore \"\" >> \"$\") >>\n checkNoWsBefore \"no space before spliced term\" >> antiquotExpr >>\n nameP",
"start": [
1755,
1
],
"end": [
1770,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withAntiquotFn",
"code": "def withAntiquotFn (antiquotP p : ParserFn) (isCatAntiquot := false) : ParserFn := fun c s =>\n if c.input.get s.pos == '$' then\n orelseFnCore (antiquotBehavior := if isCatAntiquot then .acceptLhs else .takeLongest) antiquotP p c s\n else\n p c s",
"start": [
1772,
1
],
"end": [
1781,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withAntiquot",
"code": "def withAntiquot (antiquotP p : Parser) : Parser := {\n fn := withAntiquotFn antiquotP.fn p.fn\n info := orelseInfo antiquotP.info p.info\n}",
"start": [
1783,
1
],
"end": [
1787,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withoutInfo",
"code": "def withoutInfo (p : Parser) : Parser := {\n fn := p.fn\n}",
"start": [
1789,
1
],
"end": [
1791,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkAntiquotSplice",
"code": "def mkAntiquotSplice (kind : SyntaxNodeKind) (p suffix : Parser) : Parser :=\n let kind := kind ++ `antiquot_scope\n leadingNode kind maxPrec <| atomic <|\n setExpected [] \"$\" >>\n manyNoAntiquot (checkNoWsBefore \"\" >> \"$\") >>\n checkNoWsBefore \"no space before spliced term\" >> symbol \"[\" >> node nullKind p >> symbol \"]\" >>\n suffix",
"start": [
1793,
1
],
"end": [
1800,
11
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withAntiquotSuffixSpliceFn",
"code": "private def withAntiquotSuffixSpliceFn (kind : SyntaxNodeKind) (suffix : ParserFn) : ParserFn := fun c s => Id.run do\n let iniSz := s.stackSize\n let iniPos := s.pos\n let s := suffix c s\n if s.hasError then\n return s.restore iniSz iniPos\n s.mkNode (kind ++ `antiquot_suffix_splice) (s.stxStack.size - 2)",
"start": [
1802,
1
],
"end": [
1808,
67
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withAntiquotSuffixSplice",
"code": "def withAntiquotSuffixSplice (kind : SyntaxNodeKind) (p suffix : Parser) : Parser where\n info := andthenInfo p.info suffix.info\n fn c s :=\n let s := p.fn c s\n if !s.hasError && s.stxStack.back.isAntiquots then\n withAntiquotSuffixSpliceFn kind suffix.fn c s\n else\n s",
"start": [
1810,
1
],
"end": [
1819,
8
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withAntiquotSpliceAndSuffix",
"code": "def withAntiquotSpliceAndSuffix (kind : SyntaxNodeKind) (p suffix : Parser) :=\n withAntiquot (mkAntiquotSplice kind (withoutInfo p) suffix) (withAntiquotSuffixSplice kind p suffix)",
"start": [
1821,
1
],
"end": [
1823,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.nodeWithAntiquot",
"code": "def nodeWithAntiquot (name : String) (kind : SyntaxNodeKind) (p : Parser) (anonymous := false) : Parser :=\n withAntiquot (mkAntiquot name kind anonymous) $ node kind p",
"start": [
1825,
1
],
"end": [
1826,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepByElemParser",
"code": "def sepByElemParser (p : Parser) (sep : String) : Parser :=\n withAntiquotSpliceAndSuffix `sepBy p (symbol (sep.trim ++ \"*\"))",
"start": [
1832,
1
],
"end": [
1833,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy",
"code": "def sepBy (p : Parser) (sep : String) (psep : Parser := symbol sep) (allowTrailingSep : Bool := false) : Parser :=\n sepByNoAntiquot (sepByElemParser p sep) psep allowTrailingSep",
"start": [
1835,
1
],
"end": [
1836,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.sepBy1",
"code": "def sepBy1 (p : Parser) (sep : String) (psep : Parser := symbol sep) (allowTrailingSep : Bool := false) : Parser :=\n sepBy1NoAntiquot (sepByElemParser p sep) psep allowTrailingSep",
"start": [
1838,
1
],
"end": [
1839,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkResult",
"code": "private def mkResult (s : ParserState) (iniSz : Nat) : ParserState :=\n if s.stackSize == iniSz + 1 then s\n else s.mkNode nullKind iniSz",
"start": [
1841,
1
],
"end": [
1843,
31
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.leadingParserAux",
"code": "def leadingParserAux (kind : Name) (tables : PrattParsingTables) (behavior : LeadingIdentBehavior) : ParserFn := fun c s => Id.run do\n let iniSz := s.stackSize\n let (s, ps) := indexed tables.leadingTable c s behavior\n if s.hasError then\n return s\n let ps := tables.leadingParsers ++ ps\n if ps.isEmpty then\n let s := tokenFn [toString kind] c s\n if s.hasError then\n return s\n return s.mkUnexpectedTokenError (toString kind)\n let s := longestMatchFn none ps c s\n mkResult s iniSz",
"start": [
1845,
1
],
"end": [
1858,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.leadingParser",
"code": "def leadingParser (kind : Name) (tables : PrattParsingTables) (behavior : LeadingIdentBehavior) (antiquotParser : ParserFn) : ParserFn :=\n withAntiquotFn (isCatAntiquot := true) antiquotParser (leadingParserAux kind tables behavior)",
"start": [
1860,
1
],
"end": [
1861,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.trailingLoopStep",
"code": "def trailingLoopStep (tables : PrattParsingTables) (left : Syntax) (ps : List (Parser × Nat)) : ParserFn := fun c s =>\n longestMatchFn left (ps ++ tables.trailingParsers) c s",
"start": [
1863,
1
],
"end": [
1864,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.trailingLoop",
"code": "partial def trailingLoop (tables : PrattParsingTables) (c : ParserContext) (s : ParserState) : ParserState := Id.run do\n let iniSz := s.stackSize\n let iniPos := s.pos\n let (s, ps) := indexed tables.trailingTable c s LeadingIdentBehavior.default\n if s.hasError then\n return s.restore iniSz iniPos\n if ps.isEmpty && tables.trailingParsers.isEmpty then\n return s let left := s.stxStack.back\n let s := s.popSyntax\n let s := trailingLoopStep tables left ps c s\n if s.hasError then\n return if s.pos == iniPos then s.restore (iniSz - 1) iniPos |>.pushSyntax left else s\n trailingLoop tables c s",
"start": [
1866,
1
],
"end": [
1884,
26
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.prattParser",
"code": "def prattParser (kind : Name) (tables : PrattParsingTables) (behavior : LeadingIdentBehavior) (antiquotParser : ParserFn) : ParserFn := fun c s =>\n let s := leadingParser kind tables behavior antiquotParser c s\n if s.hasError then\n s\n else\n trailingLoop tables c s",
"start": [
1886,
1
],
"end": [
1912,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.fieldIdxFn",
"code": "def fieldIdxFn : ParserFn := fun c s =>\n let initStackSz := s.stackSize\n let iniPos := s.pos\n let curr := c.input.get iniPos\n if curr.isDigit && curr != '0' then\n let s := takeWhileFn (fun c => c.isDigit) c s\n mkNodeToken fieldIdxKind iniPos c s\n else\n s.mkErrorAt \"field index\" iniPos initStackSz",
"start": [
1914,
1
],
"end": [
1922,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.fieldIdx",
"code": "def fieldIdx : Parser :=\n withAntiquot (mkAntiquot \"fieldIdx\" `fieldIdx) {\n fn := fieldIdxFn\n info := mkAtomicInfo \"fieldIdx\"\n }",
"start": [
1924,
1
],
"end": [
1928,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.skip",
"code": "def skip : Parser := {\n fn := fun _ s => s\n info := epsilonInfo\n}",
"start": [
1930,
1
],
"end": [
1933,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Syntax.foldArgsM",
"code": "def foldArgsM (s : Syntax) (f : Syntax → β → m β) (b : β) : m β :=\n s.getArgs.foldlM (flip f) b",
"start": [
1942,
1
],
"end": [
1943,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Syntax.foldArgs",
"code": "def foldArgs (s : Syntax) (f : Syntax → β → β) (b : β) : β :=\n Id.run (s.foldArgsM f b)",
"start": [
1945,
1
],
"end": [
1946,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Syntax.forArgsM",
"code": "def forArgsM (s : Syntax) (f : Syntax → m Unit) : m Unit :=\n s.foldArgsM (fun s _ => f s) ()",
"start": [
1948,
1
],
"end": [
1949,
34
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/KeyedDeclsAttribute.lean | [
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/IR/CompilerM.lean",
".lake/packages/lean4/src/lean/Lean/Compiler/InitAttr.lean"
] | [
{
"full_name": "Lean.KeyedDeclsAttribute.Key",
"code": "abbrev Key := Name",
"start": [
24,
1
],
"end": [
24,
19
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.Def",
"code": "structure Def (γ : Type) where\n \n builtinName : Name := Name.anonymous\n \n name : Name\n \n descr : String\n valueTypeName : Name\n \n evalKey (builtin : Bool) (stx : Syntax) : AttrM Key := do\n let stx ← Attribute.Builtin.getIdent stx\n let kind := stx.getId\n if (← getEnv).contains kind && (← Elab.getInfoState).enabled then\n Elab.addConstInfo stx kind none\n pure kind\n onAdded (builtin : Bool) (declName : Name) : AttrM Unit := pure ()\n deriving Inhabited",
"start": [
26,
1
],
"end": [
46,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.OLeanEntry",
"code": "structure OLeanEntry where\n key : Key\n \n declName : Name\n deriving Inhabited",
"start": [
48,
1
],
"end": [
52,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.AttributeEntry",
"code": "structure AttributeEntry (γ : Type) extends OLeanEntry where\n \n value : γ",
"start": [
54,
1
],
"end": [
57,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.Table",
"code": "abbrev Table (γ : Type) := SMap Key (List (AttributeEntry γ))",
"start": [
59,
1
],
"end": [
59,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.ExtensionState",
"code": "structure ExtensionState (γ : Type) where\n newEntries : List OLeanEntry := []\n table : Table γ := {}\n declNames : PHashSet Name := {}\n erased : PHashSet Name := {}\n deriving Inhabited",
"start": [
61,
1
],
"end": [
66,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.Extension",
"code": "abbrev Extension (γ : Type) := ScopedEnvExtension OLeanEntry (AttributeEntry γ) (ExtensionState γ)",
"start": [
68,
1
],
"end": [
68,
99
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute",
"code": "structure KeyedDeclsAttribute (γ : Type) where\n defn : KeyedDeclsAttribute.Def γ\n tableRef : IO.Ref (KeyedDeclsAttribute.Table γ)\n ext : KeyedDeclsAttribute.Extension γ\n deriving Nonempty",
"start": [
72,
1
],
"end": [
78,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.Table.insert",
"code": "private def Table.insert (table : Table γ) (v : AttributeEntry γ) : Table γ :=\n match table.find? v.key with\n | some vs => SMap.insert table v.key (v::vs)\n | none => SMap.insert table v.key [v]",
"start": [
82,
1
],
"end": [
85,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.ExtensionState.insert",
"code": "def ExtensionState.insert (s : ExtensionState γ) (v : AttributeEntry γ) : ExtensionState γ := {\n table := s.table.insert v\n newEntries := v.toOLeanEntry :: s.newEntries\n declNames := s.declNames.insert v.declName\n erased := s.erased.erase v.declName\n}",
"start": [
87,
1
],
"end": [
92,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.addBuiltin",
"code": "def addBuiltin (attr : KeyedDeclsAttribute γ) (key : Key) (declName : Name) (value : γ) : IO Unit :=\n attr.tableRef.modify fun m => m.insert { key, declName, value }",
"start": [
94,
1
],
"end": [
95,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.mkStateOfTable",
"code": "def mkStateOfTable (table : Table γ) : ExtensionState γ := {\n table\n declNames := table.fold (init := {}) fun s _ es => es.foldl (init := s) fun s e => s.insert e.declName\n}",
"start": [
97,
1
],
"end": [
100,
2
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.ExtensionState.erase",
"code": "def ExtensionState.erase (s : ExtensionState γ) (attrName : Name) (declName : Name) : CoreM (ExtensionState γ) := do\n unless s.declNames.contains declName do\n throwError \"'{declName}' does not have [{attrName}] attribute\"\n return { s with erased := s.erased.insert declName, declNames := s.declNames.erase declName }",
"start": [
102,
1
],
"end": [
105,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.init",
"code": "protected unsafe def init {γ} (df : Def γ) (attrDeclName : Name := by exact decl_name%) : IO (KeyedDeclsAttribute γ) := do\n let tableRef ← IO.mkRef ({} : Table γ)\n let ext : Extension γ ← registerScopedEnvExtension {\n name := attrDeclName\n mkInitial := return mkStateOfTable (← tableRef.get)\n ofOLeanEntry := fun _ entry => do\n let ctx ← read\n match ctx.env.evalConstCheck γ ctx.opts df.valueTypeName entry.declName with\n | Except.ok f => return { toOLeanEntry := entry, value := f }\n | Except.error ex => throw (IO.userError ex)\n addEntry := fun s e => s.insert e\n toOLeanEntry := (·.toOLeanEntry)\n }\n unless df.builtinName.isAnonymous do\n registerBuiltinAttribute {\n ref := attrDeclName\n name := df.builtinName\n descr := \"(builtin) \" ++ df.descr\n add := fun declName stx kind => do\n unless kind == AttributeKind.global do throwError \"invalid attribute '{df.builtinName}', must be global\"\n let key ← df.evalKey true stx\n let decl ← getConstInfo declName\n match decl.type with\n | Expr.const c _ =>\n if c != df.valueTypeName then throwError \"unexpected type at '{declName}', '{df.valueTypeName}' expected\"\n else\n \n let val := mkAppN (mkConst ``addBuiltin) #[mkConst df.valueTypeName, mkConst attrDeclName, toExpr key, toExpr declName, mkConst declName]\n declareBuiltin declName val\n df.onAdded true declName\n | _ => throwError \"unexpected type at '{declName}', '{df.valueTypeName}' expected\"\n applicationTime := AttributeApplicationTime.afterCompilation\n }\n registerBuiltinAttribute {\n ref := attrDeclName\n name := df.name\n descr := df.descr\n erase := fun declName => do\n let s := ext.getState (← getEnv)\n let s ← s.erase df.name declName\n modifyEnv fun env => ext.modifyState env fun _ => s\n add := fun declName stx attrKind => do\n let key ← df.evalKey false stx\n match IR.getSorryDep (← getEnv) declName with\n | none =>\n let val ← evalConstCheck γ df.valueTypeName declName\n ext.add { key := key, declName := declName, value := val } attrKind\n df.onAdded false declName\n | _ =>\n pure ()\n applicationTime := AttributeApplicationTime.afterCompilation\n }\n pure { defn := df, tableRef := tableRef, ext := ext }",
"start": [
107,
1
],
"end": [
160,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.getEntries",
"code": "def getEntries {γ} (attr : KeyedDeclsAttribute γ) (env : Environment) (key : Name) : List (AttributeEntry γ) :=\n let s := attr.ext.getState env\n let attrs := s.table.findD key []\n if s.erased.isEmpty then\n attrs\n else\n attrs.filter fun attr => !s.erased.contains attr.declName",
"start": [
162,
1
],
"end": [
169,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.KeyedDeclsAttribute.getValues",
"code": "def getValues {γ} (attr : KeyedDeclsAttribute γ) (env : Environment) (key : Name) : List γ :=\n (getEntries attr env key).map AttributeEntry.value",
"start": [
171,
1
],
"end": [
173,
53
],
"kind": "commanddeclaration"
}
] |
.lake/packages/lean4/src/lean/Lean/Parser/Extension.lean | [
".lake/packages/lean4/src/lean/Lean/ScopedEnvExtension.lean",
".lake/packages/lean4/src/lean/Lean/Parser/Basic.lean",
".lake/packages/lean4/src/lean/Lean/BuiltinDocAttr.lean"
] | [
{
"full_name": "Lean.Parser.registerBuiltinNodeKind",
"code": "def registerBuiltinNodeKind (k : SyntaxNodeKind) : IO Unit :=\n builtinSyntaxNodeKindSetRef.modify fun s => s.insert k",
"start": [
21,
1
],
"end": [
22,
57
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.throwParserCategoryAlreadyDefined",
"code": "private def throwParserCategoryAlreadyDefined {α} (catName : Name) : ExceptT String Id α :=\n throw s!\"parser category '{catName}' has already been defined\"",
"start": [
35,
1
],
"end": [
36,
65
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addParserCategoryCore",
"code": "private def addParserCategoryCore (categories : ParserCategories) (catName : Name) (initial : ParserCategory) : Except String ParserCategories :=\n if categories.contains catName then\n throwParserCategoryAlreadyDefined catName\n else\n pure $ categories.insert catName initial",
"start": [
38,
1
],
"end": [
42,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addBuiltinParserCategory",
"code": "private def addBuiltinParserCategory (catName declName : Name) (behavior : LeadingIdentBehavior) : IO Unit := do\n let categories ← builtinParserCategoriesRef.get\n let categories ← IO.ofExcept $ addParserCategoryCore categories catName { declName, behavior }\n builtinParserCategoriesRef.set categories",
"start": [
44,
1
],
"end": [
49,
44
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.OLeanEntry",
"code": "inductive OLeanEntry where\n | token (val : Token) : OLeanEntry\n | kind (val : SyntaxNodeKind) : OLeanEntry\n | category (catName : Name) (declName : Name) (behavior : LeadingIdentBehavior)\n | parser (catName : Name) (declName : Name) (prio : Nat) : OLeanEntry\n deriving Inhabited",
"start": [
53,
1
],
"end": [
58,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.Entry",
"code": "inductive Entry where\n | token (val : Token) : Entry\n | kind (val : SyntaxNodeKind) : Entry\n | category (catName : Name) (declName : Name) (behavior : LeadingIdentBehavior)\n | parser (catName : Name) (declName : Name) (leading : Bool) (p : Parser) (prio : Nat) : Entry\n deriving Inhabited",
"start": [
60,
1
],
"end": [
65,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.Entry.toOLeanEntry",
"code": "def Entry.toOLeanEntry : Entry → OLeanEntry\n | token v => OLeanEntry.token v\n | kind v => OLeanEntry.kind v\n | category c d b => OLeanEntry.category c d b\n | parser c d _ _ prio => OLeanEntry.parser c d prio",
"start": [
67,
1
],
"end": [
71,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.State",
"code": "structure State where\n tokens : TokenTable := {}\n kinds : SyntaxNodeKindSet := {}\n categories : ParserCategories := {}\n deriving Inhabited",
"start": [
73,
1
],
"end": [
77,
21
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension",
"code": "abbrev ParserExtension := ScopedEnvExtension OLeanEntry Entry State",
"start": [
82,
1
],
"end": [
82,
68
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.mkInitial",
"code": "private def ParserExtension.mkInitial : IO ParserExtension.State := do\n let tokens ← builtinTokenTable.get\n let kinds ← builtinSyntaxNodeKindSetRef.get\n let categories ← builtinParserCategoriesRef.get\n pure { tokens := tokens, kinds := kinds, categories := categories }",
"start": [
84,
1
],
"end": [
88,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addTokenConfig",
"code": "private def addTokenConfig (tokens : TokenTable) (tk : Token) : Except String TokenTable := do\n if tk == \"\" then throw \"invalid empty symbol\"\n else match tokens.find? tk with\n | none => pure $ tokens.insert tk tk\n | some _ => pure tokens",
"start": [
90,
1
],
"end": [
94,
28
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.throwUnknownParserCategory",
"code": "def throwUnknownParserCategory {α} (catName : Name) : ExceptT String Id α :=\n throw s!\"unknown parser category '{catName}'\"",
"start": [
96,
1
],
"end": [
97,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getCategory",
"code": "abbrev getCategory (categories : ParserCategories) (catName : Name) : Option ParserCategory :=\n categories.find? catName",
"start": [
99,
1
],
"end": [
100,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addLeadingParser",
"code": "def addLeadingParser (categories : ParserCategories) (catName declName : Name) (p : Parser) (prio : Nat) : Except String ParserCategories :=\n match getCategory categories catName with\n | none =>\n throwUnknownParserCategory catName\n | some cat =>\n let kinds := cat.kinds.insert declName\n let addTokens (tks : List Token) : Except String ParserCategories :=\n let tks := tks.map Name.mkSimple\n let tables := tks.eraseDups.foldl (init := cat.tables) fun tables tk =>\n { tables with leadingTable := tables.leadingTable.insert tk (p, prio) }\n pure $ categories.insert catName { cat with kinds, tables }\n match p.info.firstTokens with\n | FirstTokens.tokens tks => addTokens tks\n | FirstTokens.optTokens tks => addTokens tks\n | _ =>\n let tables := { cat.tables with leadingParsers := (p, prio) :: cat.tables.leadingParsers }\n pure $ categories.insert catName { cat with kinds, tables }",
"start": [
102,
1
],
"end": [
118,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addTrailingParserAux",
"code": "private def addTrailingParserAux (tables : PrattParsingTables) (p : TrailingParser) (prio : Nat) : PrattParsingTables :=\n let addTokens (tks : List Token) : PrattParsingTables :=\n let tks := tks.map fun tk => Name.mkSimple tk\n tks.eraseDups.foldl (init := tables) fun tables tk =>\n { tables with trailingTable := tables.trailingTable.insert tk (p, prio) }\n match p.info.firstTokens with\n | FirstTokens.tokens tks => addTokens tks\n | FirstTokens.optTokens tks => addTokens tks\n | _ => { tables with trailingParsers := (p, prio) :: tables.trailingParsers }",
"start": [
120,
1
],
"end": [
128,
104
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addTrailingParser",
"code": "def addTrailingParser (categories : ParserCategories) (catName declName : Name) (p : TrailingParser) (prio : Nat) : Except String ParserCategories :=\n match getCategory categories catName with\n | none => throwUnknownParserCategory catName\n | some cat =>\n let kinds := cat.kinds.insert declName\n let tables := addTrailingParserAux cat.tables p prio\n pure $ categories.insert catName { cat with kinds, tables }",
"start": [
130,
1
],
"end": [
136,
64
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addParser",
"code": "def addParser (categories : ParserCategories) (catName declName : Name)\n (leading : Bool) (p : Parser) (prio : Nat) : Except String ParserCategories := do\n match leading, p with\n | true, p => addLeadingParser categories catName declName p prio\n | false, p => addTrailingParser categories catName declName p prio",
"start": [
138,
1
],
"end": [
142,
69
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addParserTokens",
"code": "def addParserTokens (tokenTable : TokenTable) (info : ParserInfo) : Except String TokenTable :=\n let newTokens := info.collectTokens []\n newTokens.foldlM addTokenConfig tokenTable",
"start": [
144,
1
],
"end": [
146,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.updateBuiltinTokens",
"code": "private def updateBuiltinTokens (info : ParserInfo) (declName : Name) : IO Unit := do\n let tokenTable ← builtinTokenTable.swap {}\n match addParserTokens tokenTable info with\n | Except.ok tokenTable => builtinTokenTable.set tokenTable\n | Except.error msg => throw (IO.userError s!\"invalid builtin parser '{declName}', {msg}\")",
"start": [
148,
1
],
"end": [
152,
96
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.addEntryImpl",
"code": "def ParserExtension.addEntryImpl (s : State) (e : Entry) : State :=\n match e with\n | Entry.token tk =>\n match addTokenConfig s.tokens tk with\n | Except.ok tokens => { s with tokens }\n | _ => unreachable!\n | Entry.kind k =>\n { s with kinds := s.kinds.insert k }\n | Entry.category catName declName behavior =>\n if s.categories.contains catName then s\n else { s with\n categories := s.categories.insert catName { declName, behavior } }\n | Entry.parser catName declName leading parser prio =>\n match addParser s.categories catName declName leading parser prio with\n | Except.ok categories => { s with categories }\n | _ => unreachable!",
"start": [
154,
1
],
"end": [
169,
24
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.AliasValue",
"code": "inductive AliasValue (α : Type) where\n | const (p : α)\n | unary (p : α → α)\n | binary (p : α → α → α)",
"start": [
171,
1
],
"end": [
175,
27
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.AliasTable",
"code": "abbrev AliasTable (α) := NameMap (AliasValue α)",
"start": [
177,
1
],
"end": [
177,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.registerAliasCore",
"code": "def registerAliasCore {α} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) (value : AliasValue α) : IO Unit := do\n unless (← initializing) do throw ↑\"aliases can only be registered during initialization\"\n if (← mapRef.get).contains aliasName then\n throw ↑s!\"alias '{aliasName}' has already been declared\"\n mapRef.modify (·.insert aliasName value)",
"start": [
179,
1
],
"end": [
183,
43
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getAlias",
"code": "def getAlias {α} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) : IO (Option (AliasValue α)) := do\n return (← mapRef.get).find? aliasName",
"start": [
185,
1
],
"end": [
186,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getConstAlias",
"code": "def getConstAlias {α} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) : IO α := do\n match (← getAlias mapRef aliasName) with\n | some (AliasValue.const v) => pure v\n | some (AliasValue.unary _) => throw ↑s!\"parser '{aliasName}' is not a constant, it takes one argument\"\n | some (AliasValue.binary _) => throw ↑s!\"parser '{aliasName}' is not a constant, it takes two arguments\"\n | none => throw ↑s!\"parser '{aliasName}' was not found\"",
"start": [
188,
1
],
"end": [
193,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getUnaryAlias",
"code": "def getUnaryAlias {α} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) : IO (α → α) := do\n match (← getAlias mapRef aliasName) with\n | some (AliasValue.unary v) => pure v\n | some _ => throw ↑s!\"parser '{aliasName}' does not take one argument\"\n | none => throw ↑s!\"parser '{aliasName}' was not found\"",
"start": [
195,
1
],
"end": [
199,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getBinaryAlias",
"code": "def getBinaryAlias {α} (mapRef : IO.Ref (AliasTable α)) (aliasName : Name) : IO (α → α → α) := do\n match (← getAlias mapRef aliasName) with\n | some (AliasValue.binary v) => pure v\n | some _ => throw ↑s!\"parser '{aliasName}' does not take two arguments\"\n | none => throw ↑s!\"parser '{aliasName}' was not found\"",
"start": [
201,
1
],
"end": [
205,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserAliasValue",
"code": "abbrev ParserAliasValue := AliasValue Parser",
"start": [
207,
1
],
"end": [
207,
45
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserAliasInfo",
"code": "structure ParserAliasInfo where\n declName : Name := .anonymous\n \n stackSz? : Option Nat := some 1\n \n autoGroupArgs : Bool := stackSz?.isSome",
"start": [
209,
1
],
"end": [
214,
42
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getParserAliasInfo",
"code": "def getParserAliasInfo (aliasName : Name) : IO ParserAliasInfo := do\n return (← parserAliases2infoRef.get).findD aliasName {}",
"start": [
220,
1
],
"end": [
221,
58
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.registerAlias",
"code": "def registerAlias (aliasName declName : Name) (p : ParserAliasValue) (kind? : Option SyntaxNodeKind := none) (info : ParserAliasInfo := {}) : IO Unit := do\n registerAliasCore parserAliasesRef aliasName p\n if let some kind := kind? then\n parserAlias2kindRef.modify (·.insert aliasName kind)\n parserAliases2infoRef.modify (·.insert aliasName { info with declName })",
"start": [
224,
1
],
"end": [
228,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isParserAlias",
"code": "def isParserAlias (aliasName : Name) : IO Bool := do\n match (← getAlias parserAliasesRef aliasName) with\n | some _ => pure true\n | _ => pure false",
"start": [
234,
1
],
"end": [
237,
25
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getSyntaxKindOfParserAlias?",
"code": "def getSyntaxKindOfParserAlias? (aliasName : Name) : IO (Option SyntaxNodeKind) :=\n return (← parserAlias2kindRef.get).find? aliasName",
"start": [
239,
1
],
"end": [
240,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ensureUnaryParserAlias",
"code": "def ensureUnaryParserAlias (aliasName : Name) : IO Unit :=\n discard $ getUnaryAlias parserAliasesRef aliasName",
"start": [
242,
1
],
"end": [
243,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ensureBinaryParserAlias",
"code": "def ensureBinaryParserAlias (aliasName : Name) : IO Unit :=\n discard $ getBinaryAlias parserAliasesRef aliasName",
"start": [
245,
1
],
"end": [
246,
54
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ensureConstantParserAlias",
"code": "def ensureConstantParserAlias (aliasName : Name) : IO Unit :=\n discard $ getConstAlias parserAliasesRef aliasName",
"start": [
248,
1
],
"end": [
249,
53
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkParserOfConstantUnsafe",
"code": "unsafe def mkParserOfConstantUnsafe (constName : Name) (compileParserDescr : ParserDescr → ImportM Parser) : ImportM (Bool × Parser) := do\n let env := (← read).env\n let opts := (← read).opts\n match env.find? constName with\n | none => throw ↑s!\"unknown constant '{constName}'\"\n | some info =>\n match info.type with\n | Expr.const `Lean.Parser.TrailingParser _ =>\n let p ← IO.ofExcept $ env.evalConst Parser opts constName\n pure ⟨false, p⟩\n | Expr.const `Lean.Parser.Parser _ =>\n let p ← IO.ofExcept $ env.evalConst Parser opts constName\n pure ⟨true, p⟩\n | Expr.const `Lean.ParserDescr _ =>\n let d ← IO.ofExcept $ env.evalConst ParserDescr opts constName\n let p ← compileParserDescr d\n pure ⟨true, p⟩\n | Expr.const `Lean.TrailingParserDescr _ =>\n let d ← IO.ofExcept $ env.evalConst TrailingParserDescr opts constName\n let p ← compileParserDescr d\n pure ⟨false, p⟩\n | _ => throw ↑s!\"unexpected parser type at '{constName}' (`ParserDescr`, `TrailingParserDescr`, `Parser` or `TrailingParser` expected)\"",
"start": [
251,
1
],
"end": [
272,
140
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkParserOfConstantAux",
"code": "@[implemented_by mkParserOfConstantUnsafe]\nopaque mkParserOfConstantAux (constName : Name) (compileParserDescr : ParserDescr → ImportM Parser) : ImportM (Bool × Parser)",
"start": [
274,
1
],
"end": [
275,
126
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.compileParserDescr",
"code": "partial def compileParserDescr (categories : ParserCategories) (d : ParserDescr) : ImportM Parser :=\n let rec visit : ParserDescr → ImportM Parser\n | ParserDescr.const n => getConstAlias parserAliasesRef n\n | ParserDescr.unary n d => return (← getUnaryAlias parserAliasesRef n) (← visit d)\n | ParserDescr.binary n d₁ d₂ => return (← getBinaryAlias parserAliasesRef n) (← visit d₁) (← visit d₂)\n | ParserDescr.node k prec d => return leadingNode k prec (← visit d)\n | ParserDescr.nodeWithAntiquot n k d => return withCache k (nodeWithAntiquot n k (← visit d) (anonymous := true))\n | ParserDescr.sepBy p sep psep trail => return sepBy (← visit p) sep (← visit psep) trail\n | ParserDescr.sepBy1 p sep psep trail => return sepBy1 (← visit p) sep (← visit psep) trail\n | ParserDescr.trailingNode k prec lhsPrec d => return trailingNode k prec lhsPrec (← visit d)\n | ParserDescr.symbol tk => return symbol tk\n | ParserDescr.nonReservedSymbol tk includeIdent => return nonReservedSymbol tk includeIdent\n | ParserDescr.parser constName => do\n let (_, p) ← mkParserOfConstantAux constName visit;\n pure p\n | ParserDescr.cat catName prec =>\n match getCategory categories catName with\n | some _ => pure $ categoryParser catName prec\n | none => IO.ofExcept $ throwUnknownParserCategory catName\n visit d",
"start": [
277,
1
],
"end": [
296,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkParserOfConstant",
"code": "def mkParserOfConstant (categories : ParserCategories) (constName : Name) : ImportM (Bool × Parser) :=\n mkParserOfConstantAux constName (compileParserDescr categories)",
"start": [
298,
1
],
"end": [
299,
66
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserAttributeHook",
"code": "structure ParserAttributeHook where\n \n postAdd (catName : Name) (declName : Name) (builtin : Bool) : AttrM Unit",
"start": [
301,
1
],
"end": [
303,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.registerParserAttributeHook",
"code": "def registerParserAttributeHook (hook : ParserAttributeHook) : IO Unit := do\n parserAttributeHooks.modify fun hooks => hook::hooks",
"start": [
307,
1
],
"end": [
308,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.runParserAttributeHooks",
"code": "def runParserAttributeHooks (catName : Name) (declName : Name) (builtin : Bool) : AttrM Unit := do\n let hooks ← parserAttributeHooks.get\n hooks.forM fun hook => hook.postAdd catName declName builtin",
"start": [
310,
1
],
"end": [
312,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserExtension.OLeanEntry.toEntry",
"code": "private def ParserExtension.OLeanEntry.toEntry (s : State) : OLeanEntry → ImportM Entry\n | token tk => return Entry.token tk\n | kind k => return Entry.kind k\n | category c d l => return Entry.category c d l\n | parser catName declName prio => do\n let (leading, p) ← mkParserOfConstant s.categories declName\n return Entry.parser catName declName leading p prio",
"start": [
332,
1
],
"end": [
338,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isParserCategory",
"code": "def isParserCategory (env : Environment) (catName : Name) : Bool :=\n (parserExtension.getState env).categories.contains catName",
"start": [
348,
1
],
"end": [
349,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addParserCategory",
"code": "def addParserCategory (env : Environment) (catName declName : Name) (behavior : LeadingIdentBehavior) : Except String Environment := do\n if isParserCategory env catName then\n throwParserCategoryAlreadyDefined catName\n else\n return parserExtension.addEntry env <| ParserExtension.Entry.category catName declName behavior",
"start": [
351,
1
],
"end": [
355,
100
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.leadingIdentBehavior",
"code": "def leadingIdentBehavior (env : Environment) (catName : Name) : LeadingIdentBehavior :=\n match getCategory (parserExtension.getState env).categories catName with\n | none => LeadingIdentBehavior.default\n | some cat => cat.behavior",
"start": [
357,
1
],
"end": [
360,
29
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.evalParserConstUnsafe",
"code": "unsafe def evalParserConstUnsafe (declName : Name) : ParserFn := fun ctx s => unsafeBaseIO do\n let categories := (parserExtension.getState ctx.env).categories\n match (← (mkParserOfConstant categories declName { env := ctx.env, opts := ctx.options }).toBaseIO) with\n | .ok (_, p) =>\n return adaptUncacheableContextFn (fun ctx => { ctx with tokens := p.info.collectTokens [] |>.foldl (fun tks tk => tks.insert tk tk) ctx.tokens }) p.fn ctx s\n | .error e => return s.mkUnexpectedError e.toString",
"start": [
362,
1
],
"end": [
368,
56
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.evalParserConst",
"code": "@[implemented_by evalParserConstUnsafe]\nopaque evalParserConst (declName : Name) : ParserFn",
"start": [
370,
1
],
"end": [
371,
52
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.evalInsideQuot",
"code": "def evalInsideQuot (declName : Name) : Parser → Parser := withFn fun f c s =>\n if c.quotDepth > 0 && !c.suppressInsideQuot && internal.parseQuotWithCurrentStage.get c.options && c.env.contains declName then\n evalParserConst declName c s\n else\n f c s",
"start": [
379,
1
],
"end": [
384,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addBuiltinParser",
"code": "def addBuiltinParser (catName : Name) (declName : Name) (leading : Bool) (p : Parser) (prio : Nat) : IO Unit := do\n let p := evalInsideQuot declName p\n let categories ← builtinParserCategoriesRef.get\n let categories ← IO.ofExcept $ addParser categories catName declName leading p prio\n builtinParserCategoriesRef.set categories\n builtinSyntaxNodeKindSetRef.modify p.info.collectKinds\n updateBuiltinTokens p.info declName",
"start": [
386,
1
],
"end": [
392,
38
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addBuiltinLeadingParser",
"code": "def addBuiltinLeadingParser (catName : Name) (declName : Name) (p : Parser) (prio : Nat) : IO Unit :=\n addBuiltinParser catName declName true p prio",
"start": [
394,
1
],
"end": [
395,
48
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addBuiltinTrailingParser",
"code": "def addBuiltinTrailingParser (catName : Name) (declName : Name) (p : TrailingParser) (prio : Nat) : IO Unit :=\n addBuiltinParser catName declName false p prio",
"start": [
397,
1
],
"end": [
398,
49
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkCategoryAntiquotParser",
"code": "def mkCategoryAntiquotParser (kind : Name) : Parser :=\n mkAntiquot kind.toString kind (isPseudoKind := true)",
"start": [
400,
1
],
"end": [
401,
55
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkCategoryAntiquotParserFn",
"code": "@[inline] private def mkCategoryAntiquotParserFn (kind : Name) : ParserFn :=\n (mkCategoryAntiquotParser kind).fn",
"start": [
404,
1
],
"end": [
405,
37
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.categoryParserFnImpl",
"code": "def categoryParserFnImpl (catName : Name) : ParserFn := fun ctx s =>\n let catName := if catName == `syntax then `stx else catName let categories := (parserExtension.getState ctx.env).categories\n match getCategory categories catName with\n | some cat =>\n prattParser catName cat.tables cat.behavior (mkCategoryAntiquotParserFn catName) ctx s\n | none => s.mkUnexpectedError (\"unknown parser category '\" ++ toString catName ++ \"'\")",
"start": [
407,
1
],
"end": [
413,
93
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addToken",
"code": "def addToken (tk : Token) (kind : AttributeKind) : AttrM Unit := do\n discard <| ofExcept <| addTokenConfig (parserExtension.getState (← getEnv)).tokens tk\n parserExtension.add (ParserExtension.Entry.token tk) kind",
"start": [
418,
1
],
"end": [
422,
60
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.addSyntaxNodeKind",
"code": "def addSyntaxNodeKind (env : Environment) (k : SyntaxNodeKind) : Environment :=\n parserExtension.addEntry env <| ParserExtension.Entry.kind k",
"start": [
424,
1
],
"end": [
425,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.isValidSyntaxNodeKind",
"code": "def isValidSyntaxNodeKind (env : Environment) (k : SyntaxNodeKind) : Bool :=\n let kinds := (parserExtension.getState env).kinds\n kinds.contains k || (Internal.isStage0 () && env.contains k)",
"start": [
427,
1
],
"end": [
431,
63
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getSyntaxNodeKinds",
"code": "def getSyntaxNodeKinds (env : Environment) : List SyntaxNodeKind :=\n let kinds := (parserExtension.getState env).kinds\n kinds.foldl (fun ks k _ => k::ks) []",
"start": [
433,
1
],
"end": [
435,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getTokenTable",
"code": "def getTokenTable (env : Environment) : TokenTable :=\n (parserExtension.getState env).tokens",
"start": [
437,
1
],
"end": [
438,
40
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkInputContext",
"code": "def mkInputContext (input : String) (fileName : String) (normalizeLineEndings := true) : InputContext :=\n let input' := if normalizeLineEndings then input.crlfToLf else input\n { input := input',\n fileName := fileName,\n fileMap := input'.toFileMap }",
"start": [
441,
1
],
"end": [
445,
35
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkParserState",
"code": "def mkParserState (input : String) : ParserState :=\n { cache := initCacheForInput input }",
"start": [
447,
1
],
"end": [
448,
39
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.runParserCategory",
"code": "def runParserCategory (env : Environment) (catName : Name) (input : String) (fileName := \"<input>\") : Except String Syntax :=\n let p := andthenFn whitespace (categoryParserFnImpl catName)\n let ictx := mkInputContext input fileName\n let s := p.run ictx { env, options := {} } (getTokenTable env) (mkParserState input)\n if !s.allErrors.isEmpty then\n Except.error (s.toErrorMsg ictx)\n else if ictx.input.atEnd s.pos then\n Except.ok s.stxStack.back\n else\n Except.error ((s.mkError \"end of input\").toErrorMsg ictx)",
"start": [
450,
1
],
"end": [
460,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.declareBuiltinParser",
"code": "def declareBuiltinParser (addFnName : Name) (catName : Name) (declName : Name) (prio : Nat) : CoreM Unit :=\n let val := mkAppN (mkConst addFnName) #[toExpr catName, toExpr declName, mkConst declName, mkRawNatLit prio]\n declareBuiltin declName val",
"start": [
462,
1
],
"end": [
464,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.declareLeadingBuiltinParser",
"code": "def declareLeadingBuiltinParser (catName : Name) (declName : Name) (prio : Nat) : CoreM Unit :=\n declareBuiltinParser `Lean.Parser.addBuiltinLeadingParser catName declName prio",
"start": [
466,
1
],
"end": [
467,
82
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.declareTrailingBuiltinParser",
"code": "def declareTrailingBuiltinParser (catName : Name) (declName : Name) (prio : Nat) : CoreM Unit :=\n declareBuiltinParser `Lean.Parser.addBuiltinTrailingParser catName declName prio",
"start": [
469,
1
],
"end": [
470,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.getParserPriority",
"code": "def getParserPriority (args : Syntax) : Except String Nat :=\n match args.getNumArgs with\n | 0 => pure 0\n | 1 => match (args.getArg 0).isNatLit? with\n | some prio => pure prio\n | none => throw \"invalid parser attribute, numeral expected\"\n | _ => throw \"invalid parser attribute, no argument or numeral expected\"",
"start": [
472,
1
],
"end": [
478,
75
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.BuiltinParserAttribute.add",
"code": "private def BuiltinParserAttribute.add (attrName : Name) (catName : Name)\n (declName : Name) (stx : Syntax) (kind : AttributeKind) : AttrM Unit := do\n let prio ← Attribute.Builtin.getPrio stx\n unless kind == AttributeKind.global do throwError \"invalid attribute '{attrName}', must be global\"\n let decl ← getConstInfo declName\n match decl.type with\n | Expr.const `Lean.Parser.TrailingParser _ =>\n declareTrailingBuiltinParser catName declName prio\n | Expr.const `Lean.Parser.Parser _ =>\n declareLeadingBuiltinParser catName declName prio\n | _ => throwError \"unexpected parser type at '{declName}' (`Parser` or `TrailingParser` expected)\"\n declareBuiltinDocStringAndRanges declName\n runParserAttributeHooks catName declName (builtin := true)",
"start": [
480,
1
],
"end": [
492,
61
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.registerBuiltinParserAttribute",
"code": "def registerBuiltinParserAttribute (attrName declName : Name)\n (behavior := LeadingIdentBehavior.default) (ref : Name := by exact decl_name%) : IO Unit := do\n let .str ``Lean.Parser.Category s := declName\n | throw (IO.userError \"`declName` should be in Lean.Parser.Category\")\n let catName := Name.mkSimple s\n addBuiltinParserCategory catName declName behavior\n registerBuiltinAttribute {\n ref := ref\n name := attrName\n descr := \"Builtin parser\"\n add := fun declName stx kind => liftM $ BuiltinParserAttribute.add attrName catName declName stx kind\n applicationTime := AttributeApplicationTime.afterCompilation\n }",
"start": [
494,
1
],
"end": [
509,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserAttribute.add",
"code": "private def ParserAttribute.add (_attrName : Name) (catName : Name) (declName : Name) (stx : Syntax) (attrKind : AttributeKind) : AttrM Unit := do\n let prio ← Attribute.Builtin.getPrio stx\n let env ← getEnv\n let categories := (parserExtension.getState env).categories\n let p ← mkParserOfConstant categories declName\n let leading := p.1\n let parser := p.2\n let tokens := parser.info.collectTokens []\n tokens.forM fun token => do\n try\n addToken token attrKind\n catch\n | Exception.error _ msg => throwError \"invalid parser '{declName}', {msg}\"\n | ex => throw ex\n let kinds := parser.info.collectKinds {}\n kinds.forM fun kind _ => modifyEnv fun env => addSyntaxNodeKind env kind\n let entry := ParserExtension.Entry.parser catName declName leading parser prio\n match addParser categories catName declName leading parser prio with\n | Except.error ex => throwError ex\n | Except.ok _ => parserExtension.add entry attrKind\n runParserAttributeHooks catName declName (builtin := false)",
"start": [
511,
1
],
"end": [
531,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.mkParserAttributeImpl",
"code": "def mkParserAttributeImpl (attrName catName : Name) (ref : Name := by exact decl_name%) : AttributeImpl where\n ref := ref\n name := attrName\n descr := \"parser\"\n add declName stx attrKind := ParserAttribute.add attrName catName declName stx attrKind\n applicationTime := AttributeApplicationTime.afterCompilation",
"start": [
533,
1
],
"end": [
538,
73
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.registerBuiltinDynamicParserAttribute",
"code": "def registerBuiltinDynamicParserAttribute (attrName catName : Name) (ref : Name := by exact decl_name%) : IO Unit := do\n registerBuiltinAttribute (mkParserAttributeImpl attrName catName ref)",
"start": [
540,
1
],
"end": [
542,
72
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.registerParserCategory",
"code": "def registerParserCategory (env : Environment) (attrName catName : Name)\n (behavior := LeadingIdentBehavior.default) (ref : Name := by exact decl_name%) : IO Environment := do\n let env ← IO.ofExcept $ addParserCategory env catName ref behavior\n registerAttributeOfBuilder env `parserAttr ref [DataValue.ofName attrName, DataValue.ofName catName]",
"start": [
550,
1
],
"end": [
553,
103
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.commandParser",
"code": "@[inline] def commandParser (rbp : Nat := 0) : Parser :=\n categoryParser `command rbp",
"start": [
566,
1
],
"end": [
567,
30
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withNamespaces",
"code": "private def withNamespaces (ids : Array Name) (addOpenSimple : Bool) : ParserFn → ParserFn := adaptUncacheableContextFn fun c =>\n let c := ids.foldl (init := c) fun c id =>\n let nss := ResolveName.resolveNamespace c.env c.currNamespace c.openDecls id\n let (env, openDecls) := nss.foldl (init := (c.env, c.openDecls)) fun (env, openDecls) ns =>\n let openDecls := if addOpenSimple then OpenDecl.simple ns [] :: openDecls else openDecls\n let env := parserExtension.activateScoped env ns\n (env, openDecls)\n { c with env, openDecls }\n let tokens := parserExtension.getState c.env |>.tokens\n { c with tokens }",
"start": [
569,
1
],
"end": [
578,
20
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withOpenDeclFnCore",
"code": "def withOpenDeclFnCore (openDeclStx : Syntax) (p : ParserFn) : ParserFn := fun c s =>\n if openDeclStx.getKind == `Lean.Parser.Command.openSimple then\n withNamespaces (openDeclStx[0].getArgs.map fun stx => stx.getId) (addOpenSimple := true) p c s\n else if openDeclStx.getKind == `Lean.Parser.Command.openScoped then\n withNamespaces (openDeclStx[1].getArgs.map fun stx => stx.getId) (addOpenSimple := false) p c s\n else if openDeclStx.getKind == `Lean.Parser.Command.openOnly then\n p c s\n else if openDeclStx.getKind == `Lean.Parser.Command.openHiding then\n p c s\n else\n p c s",
"start": [
580,
1
],
"end": [
592,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withOpenFn",
"code": "def withOpenFn (p : ParserFn) : ParserFn := fun c s =>\n if s.stxStack.size > 0 then\n let stx := s.stxStack.back\n if stx.getKind == `Lean.Parser.Command.open then\n withOpenDeclFnCore stx[1] p c s\n else\n p c s\n else\n p c s",
"start": [
594,
1
],
"end": [
603,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withOpen",
"code": "@[inline] def withOpen : Parser → Parser := withFn withOpenFn",
"start": [
606,
1
],
"end": [
606,
62
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withOpenDeclFn",
"code": "def withOpenDeclFn (p : ParserFn) : ParserFn := fun c s =>\n if s.stxStack.size > 0 then\n let stx := s.stxStack.back\n withOpenDeclFnCore stx p c s\n else\n p c s",
"start": [
608,
1
],
"end": [
614,
10
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.withOpenDecl",
"code": "@[inline] def withOpenDecl : Parser → Parser := withFn withOpenDeclFn",
"start": [
616,
1
],
"end": [
616,
70
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserResolution",
"code": "inductive ParserResolution where\n \n | category (cat : Name)\n \n | parser (decl : Name) (isDescr : Bool)\n \n | alias (p : ParserAliasValue)",
"start": [
624,
1
],
"end": [
637,
33
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.resolveParserNameCore",
"code": "def resolveParserNameCore (env : Environment) (currNamespace : Name)\n (openDecls : List OpenDecl) (ident : Ident) : List ParserResolution := Id.run do\n let ⟨.ident (val := val) (preresolved := pre) ..⟩ := ident | return []\n\n let rec isParser (name : Name) : Option Bool :=\n (env.find? name).bind fun ci =>\n match ci.type with\n | .const ``Parser _ | .const ``TrailingParser _ => some false\n | .const ``ParserDescr _ | .const ``TrailingParserDescr _ => some true\n | _ => none\n\n for pre in pre do\n if let .decl n [] := pre then\n if let some isDescr := isParser n then\n return [.parser n isDescr]\n\n let erased := val.eraseMacroScopes\n\n if isParserCategory env erased then\n return [.category erased]\n\n let resolved ← ResolveName.resolveGlobalName env currNamespace openDecls val |>.filterMap fun\n | (name, []) => (isParser name).map fun isDescr => .parser name isDescr\n | _ => none\n unless resolved.isEmpty do\n return resolved\n\n if let some alias := aliasExtension.getState env |>.find? erased then\n return [.alias alias]\n\n return []",
"start": [
639,
1
],
"end": [
671,
12
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.ParserContext.resolveParserName",
"code": "def ParserContext.resolveParserName (ctx : ParserContext) (id : Ident) : List ParserResolution :=\n Parser.resolveParserNameCore ctx.env ctx.currNamespace ctx.openDecls id",
"start": [
673,
1
],
"end": [
675,
74
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.resolveParserName",
"code": "def resolveParserName (id : Ident) : CoreM (List ParserResolution) :=\n return resolveParserNameCore (← getEnv) (← getCurrNamespace) (← getOpenDecls) id",
"start": [
677,
1
],
"end": [
679,
83
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.parserOfStackFn",
"code": "def parserOfStackFn (offset : Nat) : ParserFn := fun ctx s => Id.run do\n let stack := s.stxStack\n if stack.size < offset + 1 then\n return s.mkUnexpectedError (\"failed to determine parser using syntax stack, stack is too small\")\n let parserName@(.ident ..) := stack.get! (stack.size - offset - 1)\n | s.mkUnexpectedError (\"failed to determine parser using syntax stack, the specified element on the stack is not an identifier\")\n let iniSz := s.stackSize\n let s ← match ctx.resolveParserName ⟨parserName⟩ with\n | [.category cat] =>\n categoryParserFn cat ctx s\n | [.parser parserName _] =>\n adaptUncacheableContextFn (fun ctx =>\n if !internal.parseQuotWithCurrentStage.get ctx.options then\n { ctx with options := ctx.options.setBool `interpreter.prefer_native true }\n else ctx) (evalParserConst parserName) ctx s\n | [.alias alias] =>\n match alias with\n | .const p => p.fn ctx s\n | _ =>\n return s.mkUnexpectedError s!\"parser alias {parserName}, must not take parameters\"\n | _::_::_ => return s.mkUnexpectedError s!\"ambiguous parser name {parserName}\"\n | [] => return s.mkUnexpectedError s!\"unknown parser {parserName}\"\n if !s.hasError && s.stackSize != iniSz + 1 then\n return s.mkUnexpectedError \"expected parser to return exactly one syntax object\"\n s",
"start": [
681,
1
],
"end": [
707,
4
],
"kind": "commanddeclaration"
},
{
"full_name": "Lean.Parser.parserOfStack",
"code": "def parserOfStack (offset : Nat) (prec : Nat := 0) : Parser where\n fn := adaptCacheableContextFn ({ · with prec }) (parserOfStackFn offset)",
"start": [
709,
1
],
"end": [
710,
75
],
"kind": "commanddeclaration"
}
] |