File: .lake/packages/lean4/src/lean/Lean/Elab/MutualDef.lean

full_name: Lean.Elab.DefViewElabHeader.tacSnap?
code: /-- `DefView` plus header elaboration data and snapshot. -/
structure DefViewElabHeader extends DefView, DefViewElabHeaderData where
  /--
  Snapshot for incremental processing of top-level tactic block, if any.

  Invariant: if the bundle's `old?` is set, then the state *up to the start* of the tactic block is
  unchanged, i.e. reuse is possible.
  -/
  tacSnap? : Option (Language.SnapshotBundle Tactic.TacticParsedSnapshot)
  /--
  Snapshot for incremental processing of definition body.

  Invariant: if the bundle's `old?` is set, then elaboration of the body is guaranteed to result in
  the same elaboration result and state, i.e. reuse is possible.
  -/
  bodySnap? : Option (Language.SnapshotBundle (Option BodyProcessedSnapshot))
  deriving Inhabited
goal: Option (Lean.Language.SnapshotBundle Lean.Elab.Tactic.TacticParsedSnapshot)

full_name: Lean.Elab.instInhabitedDefViewElabHeader
code: /-- `DefView` plus header elaboration data and snapshot. -/
structure DefViewElabHeader extends DefView, DefViewElabHeaderData where
  /--
  Snapshot for incremental processing of top-level tactic block, if any.

  Invariant: if the bundle's `old?` is set, then the state *up to the start* of the tactic block is
  unchanged, i.e. reuse is possible.
  -/
  tacSnap? : Option (Language.SnapshotBundle Tactic.TacticParsedSnapshot)
  /--
  Snapshot for incremental processing of definition body.

  Invariant: if the bundle's `old?` is set, then elaboration of the body is guaranteed to result in
  the same elaboration result and state, i.e. reuse is possible.
  -/
  bodySnap? : Option (Language.SnapshotBundle (Option BodyProcessedSnapshot))
  deriving Inhabited
goal: Inhabited Lean.Elab.DefViewElabHeader

full_name: Lean.Elab.DefViewElabHeader.bodySnap?
code: /-- `DefView` plus header elaboration data and snapshot. -/
structure DefViewElabHeader extends DefView, DefViewElabHeaderData where
  /--
  Snapshot for incremental processing of top-level tactic block, if any.

  Invariant: if the bundle's `old?` is set, then the state *up to the start* of the tactic block is
  unchanged, i.e. reuse is possible.
  -/
  tacSnap? : Option (Language.SnapshotBundle Tactic.TacticParsedSnapshot)
  /--
  Snapshot for incremental processing of definition body.

  Invariant: if the bundle's `old?` is set, then elaboration of the body is guaranteed to result in
  the same elaboration result and state, i.e. reuse is possible.
  -/
  bodySnap? : Option (Language.SnapshotBundle (Option BodyProcessedSnapshot))
  deriving Inhabited
goal: Option (Lean.Language.SnapshotBundle (Option Lean.Elab.BodyProcessedSnapshot))

full_name: Lean.Elab.DefViewElabHeader
code: /-- `DefView` plus header elaboration data and snapshot. -/
structure DefViewElabHeader extends DefView, DefViewElabHeaderData where
  /--
  Snapshot for incremental processing of top-level tactic block, if any.

  Invariant: if the bundle's `old?` is set, then the state *up to the start* of the tactic block is
  unchanged, i.e. reuse is possible.
  -/
  tacSnap? : Option (Language.SnapshotBundle Tactic.TacticParsedSnapshot)
  /--
  Snapshot for incremental processing of definition body.

  Invariant: if the bundle's `old?` is set, then elaboration of the body is guaranteed to result in
  the same elaboration result and state, i.e. reuse is possible.
  -/
  bodySnap? : Option (Language.SnapshotBundle (Option BodyProcessedSnapshot))
  deriving Inhabited
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.checkModifiers
code: private def checkModifiers (m₁ m₂ : Modifiers) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.checkKinds
code: private def checkKinds (k₁ k₂ : DefKind) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.check
code: private def check (prevHeaders : Array DefViewElabHeader) (newHeader : DefViewElabHeader) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.registerFailedToInferDefTypeInfo
code: private def registerFailedToInferDefTypeInfo (type : Expr) (ref : Syntax) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.isMultiConstant?
code: /--
  Return `some [b, c]` if the given `views` are representing a declaration of the form
  ```
  opaque a b c : Nat
  ```  -/
private def isMultiConstant? (views : Array DefView) : Option (List Name) 
goal: Option (List Lean.Name)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.getPendindMVarErrorMessage
code: private def getPendindMVarErrorMessage (views : Array DefView) : String 
goal: String

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.cleanupOfNat
code: /--
Convert terms of the form `OfNat <type> (OfNat.ofNat Nat <num> ..)` into `OfNat <type> <num>`.
We use this method on instance declaration types.
The motivation is to address a recurrent mistake when users forget to use `nat_lit` when declaring `OfNat` instances.
See issues #1389 and #875
-/
private def cleanupOfNat (type : Expr) : MetaM Expr 
goal: Lean.MetaM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.elabHeaders.mkTacTask
code: /--
Elaborates only the declaration view headers. We have to elaborate the headers first because we
support mutually recursive declarations in Lean 4.
-/
private def elabHeaders (views : Array DefView)
    (bodyPromises : Array (IO.Promise (Option BodyProcessedSnapshot)))
    (tacPromises : Array (IO.Promise Tactic.TacticParsedSnapshot)) :
    TermElabM (Array DefViewElabHeader) 
goal: Lean.Elab.TermElabM (Option Lean.Syntax × Option (Lean.Language.SnapshotTask Lean.Elab.Tactic.TacticParsedSnapshot))

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.elabHeaders.getBodyTerm?
code: /--
Elaborates only the declaration view headers. We have to elaborate the headers first because we
support mutually recursive declarations in Lean 4.
-/
private def elabHeaders (views : Array DefView)
    (bodyPromises : Array (IO.Promise (Option BodyProcessedSnapshot)))
    (tacPromises : Array (IO.Promise Tactic.TacticParsedSnapshot)) :
    TermElabM (Array DefViewElabHeader) 
goal: Option Lean.Syntax

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.elabHeaders
code: /--
Elaborates only the declaration view headers. We have to elaborate the headers first because we
support mutually recursive declarations in Lean 4.
-/
private def elabHeaders (views : Array DefView)
    (bodyPromises : Array (IO.Promise (Option BodyProcessedSnapshot)))
    (tacPromises : Array (IO.Promise Tactic.TacticParsedSnapshot)) :
    TermElabM (Array DefViewElabHeader) 
goal: Lean.Elab.TermElabM (Array Lean.Elab.DefViewElabHeader)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.elabHeaders.mkBodyTask
code: /--
Elaborates only the declaration view headers. We have to elaborate the headers first because we
support mutually recursive declarations in Lean 4.
-/
private def elabHeaders (views : Array DefView)
    (bodyPromises : Array (IO.Promise (Option BodyProcessedSnapshot)))
    (tacPromises : Array (IO.Promise Tactic.TacticParsedSnapshot)) :
    TermElabM (Array DefViewElabHeader) 
goal: Lean.Language.SnapshotTask (Option Lean.Elab.BodyProcessedSnapshot)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.withFunLocalDecls
code: /--
  Create auxiliary local declarations `fs` for the given headers using their `shortDeclName` and `type`, given headers, and execute `k fs`.
  The new free variables are tagged as `auxDecl`.
  Remark: `fs.size = headers.size`.
-/
private partial def withFunLocalDecls {α} (headers : Array DefViewElabHeader) (k : Array Expr → TermElabM α) : TermElabM α 
goal: Lean.Elab.TermElabM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.withFunLocalDecls.loop
code: /--
  Create auxiliary local declarations `fs` for the given headers using their `shortDeclName` and `type`, given headers, and execute `k fs`.
  The new free variables are tagged as `auxDecl`.
  Remark: `fs.size = headers.size`.
-/
private partial def withFunLocalDecls {α} (headers : Array DefViewElabHeader) (k : Array Expr → TermElabM α) : TermElabM α 
goal: Lean.Elab.TermElabM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.expandWhereStructInst
code: private def expandWhereStructInst : Macro
  
goal: Lean.Macro

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.declValToTerm
code: private def declValToTerm (declVal : Syntax) : MacroM Syntax 
goal: Lean.MacroM Lean.Syntax

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.declValToTerminationHint
code: /-- Elaborates the termination hints in a `declVal` syntax. -/
private def declValToTerminationHint (declVal : Syntax) : TermElabM WF.TerminationHints 
goal: Lean.Elab.TermElabM Lean.Elab.WF.TerminationHints

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.elabFunValues
code: private def elabFunValues (headers : Array DefViewElabHeader) : TermElabM (Array Expr) 
goal: Lean.Elab.TermElabM (Array Lean.Expr)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.collectUsed
code: private def collectUsed (headers : Array DefViewElabHeader) (values : Array Expr) (toLift : List LetRecToLift)
    : StateRefT CollectFVars.State MetaM Unit 
goal: StateRefT' IO.RealWorld Lean.CollectFVars.State Lean.MetaM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.removeUnusedVars
code: private def removeUnusedVars (vars : Array Expr) (headers : Array DefViewElabHeader) (values : Array Expr) (toLift : List LetRecToLift)
    : TermElabM (LocalContext × LocalInstances × Array Expr) 
goal: Lean.Elab.TermElabM (Lean.LocalContext × Lean.LocalInstances × Array Lean.Expr)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.withUsed
code: private def withUsed {α} (vars : Array Expr) (headers : Array DefViewElabHeader) (values : Array Expr) (toLift : List LetRecToLift)
    (k : Array Expr → TermElabM α) : TermElabM α 
goal: Lean.Elab.TermElabM α

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.isExample
code: private def isExample (views : Array DefView) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.isTheorem
code: private def isTheorem (views : Array DefView) : Bool 
goal: Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.instantiateMVarsAtHeader
code: private def instantiateMVarsAtHeader (header : DefViewElabHeader) : TermElabM DefViewElabHeader 
goal: Lean.Elab.TermElabM Lean.Elab.DefViewElabHeader

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.instantiateMVarsAtLetRecToLift
code: private def instantiateMVarsAtLetRecToLift (toLift : LetRecToLift) : TermElabM LetRecToLift 
goal: Lean.Elab.TermElabM Lean.Elab.Term.LetRecToLift

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.typeHasRecFun
code: private def typeHasRecFun (type : Expr) (funFVars : Array Expr) (letRecsToLift : List LetRecToLift) : Option FVarId 
goal: Option Lean.FVarId

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.getFunName
code: private def getFunName (fvarId : FVarId) (letRecsToLift : List LetRecToLift) : TermElabM Name 
goal: Lean.Elab.TermElabM Lean.Name

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.checkLetRecsToLiftTypes
code: /--
Ensures that the of let-rec definition types do not contain functions being defined.
In principle, this test can be improved. We could perform it after we separate the set of functions is strongly connected components.
However, this extra complication doesn't seem worth it.
-/
private def checkLetRecsToLiftTypes (funVars : Array Expr) (letRecsToLift : List LetRecToLift) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: Lean.Elab.Term.MutualClosure.UsedFVarsMap
code: /-- A mapping from FVarId to Set of FVarIds. -/
abbrev UsedFVarsMap 
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.mkInitialUsedFVarsMap
code: /--
Create the `UsedFVarsMap` mapping that takes the variable id for the mutually recursive functions being defined to the set of
free variables in its definition.

For `mainFVars`, this is just the set of section variables `sectionVars` used.
For nested let-rec functions, we collect their free variables.

Recall that a `let rec` expressions are encoded as follows in the elaborator.
```lean
let rec
  f : A := t,
  g : B := s;
body
```
is encoded as
```lean
let f : A := ?m₁;
let g : B := ?m₂;
body
```
where `?m₁` and `?m₂` are synthetic opaque metavariables. That are assigned by this module.
We may have nested `let rec`s.
```lean
let rec f : A :=
    let rec g : B := t;
    s;
body
```
is encoded as
```lean
let f : A := ?m₁;
body
```
and the body of `f` is stored the field `val` of a `LetRecToLift`. For the example above,
we would have a `LetRecToLift` containing:
```
{
  mvarId := m₁,
  val    := `(let g : B := ?m₂; body)
  ...
}
```
Note that `g` is not a free variable at `(let g : B := ?m₂; body)`. We recover the fact that
`f` depends on `g` because it contains `m₂`
-/
private def mkInitialUsedFVarsMap [Monad m] [MonadMCtx m] (sectionVars : Array Expr) (mainFVarIds : Array FVarId) (letRecsToLift : Array LetRecToLift)
    : m UsedFVarsMap 
goal: m Lean.Elab.Term.MutualClosure.UsedFVarsMap

full_name: Lean.Elab.Term.MutualClosure.FixPoint.State.usedFVarsMap
code: structure State where
  usedFVarsMap : UsedFVarsMap := {}
  modified     : Bool         := false
goal: Lean.Elab.Term.MutualClosure.UsedFVarsMap

full_name: Lean.Elab.Term.MutualClosure.FixPoint.State.modified
code: structure State where
  usedFVarsMap : UsedFVarsMap := {}
  modified     : Bool         := false
goal: Bool

full_name: Lean.Elab.Term.MutualClosure.FixPoint.State
code: structure State where
  usedFVarsMap : UsedFVarsMap := {}
  modified     : Bool         := false
goal: Type

full_name: Lean.Elab.Term.MutualClosure.FixPoint.M
code: abbrev M 
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.isModified
code: private def isModified : M Bool 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Bool

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.resetModified
code: private def resetModified : M Unit 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.markModified
code: private def markModified : M Unit 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.getUsedFVarsMap
code: private def getUsedFVarsMap : M UsedFVarsMap 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Lean.Elab.Term.MutualClosure.UsedFVarsMap

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.modifyUsedFVars
code: private def modifyUsedFVars (f : UsedFVarsMap → UsedFVarsMap) : M Unit 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.merge
code: private def merge (s₁ s₂ : FVarIdSet) : M FVarIdSet 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Lean.FVarIdSet

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.updateUsedVarsOf
code: private def updateUsedVarsOf (fvarId : FVarId) : M Unit 
goal: Lean.Elab.Term.MutualClosure.FixPoint.M Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.FixPoint.fixpoint
code: private partial def fixpoint : Unit → M Unit
  
goal: Unit → Lean.Elab.Term.MutualClosure.FixPoint.M Unit

full_name: Lean.Elab.Term.MutualClosure.FixPoint.run
code: def run (letRecFVarIds : Array FVarId) (usedFVarsMap : UsedFVarsMap) : UsedFVarsMap 
goal: Lean.Elab.Term.MutualClosure.UsedFVarsMap

full_name: Lean.Elab.Term.MutualClosure.FreeVarMap
code: abbrev FreeVarMap 
goal: Type

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.mkFreeVarMap
code: private def mkFreeVarMap [Monad m] [MonadMCtx m]
    (sectionVars : Array Expr) (mainFVarIds : Array FVarId)
    (recFVarIds : Array FVarId) (letRecsToLift : Array LetRecToLift) : m FreeVarMap 
goal: m Lean.Elab.Term.MutualClosure.FreeVarMap

full_name: Lean.Elab.Term.MutualClosure.ClosureState.localDecls
code: structure ClosureState where
  newLocalDecls : Array LocalDecl := #[]
  localDecls    : Array LocalDecl := #[]
  newLetDecls   : Array LocalDecl := #[]
  exprArgs      : Array Expr      := #[]
goal: Array Lean.LocalDecl

full_name: Lean.Elab.Term.MutualClosure.ClosureState
code: structure ClosureState where
  newLocalDecls : Array LocalDecl := #[]
  localDecls    : Array LocalDecl := #[]
  newLetDecls   : Array LocalDecl := #[]
  exprArgs      : Array Expr      := #[]
goal: Type

full_name: Lean.Elab.Term.MutualClosure.ClosureState.newLocalDecls
code: structure ClosureState where
  newLocalDecls : Array LocalDecl := #[]
  localDecls    : Array LocalDecl := #[]
  newLetDecls   : Array LocalDecl := #[]
  exprArgs      : Array Expr      := #[]
goal: Array Lean.LocalDecl

full_name: Lean.Elab.Term.MutualClosure.ClosureState.newLetDecls
code: structure ClosureState where
  newLocalDecls : Array LocalDecl := #[]
  localDecls    : Array LocalDecl := #[]
  newLetDecls   : Array LocalDecl := #[]
  exprArgs      : Array Expr      := #[]
goal: Array Lean.LocalDecl

full_name: Lean.Elab.Term.MutualClosure.ClosureState.exprArgs
code: structure ClosureState where
  newLocalDecls : Array LocalDecl := #[]
  localDecls    : Array LocalDecl := #[]
  newLetDecls   : Array LocalDecl := #[]
  exprArgs      : Array Expr      := #[]
goal: Array Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.pickMaxFVar?
code: private def pickMaxFVar? (lctx : LocalContext) (fvarIds : Array FVarId) : Option FVarId 
goal: Option Lean.FVarId

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.preprocess
code: private def preprocess (e : Expr) : TermElabM Expr 
goal: Lean.Elab.TermElabM Lean.Expr

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.pushNewVars
code: /-- Push free variables in `s` to `toProcess` if they are not already there. -/
private def pushNewVars (toProcess : Array FVarId) (s : CollectFVars.State) : Array FVarId 
goal: Array Lean.FVarId

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.pushLocalDecl
code: private def pushLocalDecl (toProcess : Array FVarId) (fvarId : FVarId) (userName : Name) (type : Expr) (bi : BinderInfo) (kind : LocalDeclKind)
    : StateRefT ClosureState TermElabM (Array FVarId) 
goal: StateRefT' IO.RealWorld Lean.Elab.Term.MutualClosure.ClosureState Lean.Elab.TermElabM (Array Lean.FVarId)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.mkClosureForAux
code: private partial def mkClosureForAux (toProcess : Array FVarId) : StateRefT ClosureState TermElabM Unit 
goal: StateRefT' IO.RealWorld Lean.Elab.Term.MutualClosure.ClosureState Lean.Elab.TermElabM Unit

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.mkClosureFor
code: private partial def mkClosureFor (freeVars : Array FVarId) (localDecls : Array LocalDecl) : TermElabM ClosureState 
goal: Lean.Elab.TermElabM Lean.Elab.Term.MutualClosure.ClosureState

full_name: Lean.Elab.Term.MutualClosure.LetRecClosure
code: structure LetRecClosure where
  ref        : Syntax
  localDecls : Array LocalDecl
  /-- Expression used to replace occurrences of the let-rec `FVarId`. -/
  closed     : Expr
  toLift     : LetRecToLift
goal: Type

full_name: Lean.Elab.Term.MutualClosure.LetRecClosure.closed
code: structure LetRecClosure where
  ref        : Syntax
  localDecls : Array LocalDecl
  /-- Expression used to replace occurrences of the let-rec `FVarId`. -/
  closed     : Expr
  toLift     : LetRecToLift
goal: Lean.Expr

full_name: Lean.Elab.Term.MutualClosure.LetRecClosure.toLift
code: structure LetRecClosure where
  ref        : Syntax
  localDecls : Array LocalDecl
  /-- Expression used to replace occurrences of the let-rec `FVarId`. -/
  closed     : Expr
  toLift     : LetRecToLift
goal: Lean.Elab.Term.LetRecToLift

full_name: Lean.Elab.Term.MutualClosure.LetRecClosure.localDecls
code: structure LetRecClosure where
  ref        : Syntax
  localDecls : Array LocalDecl
  /-- Expression used to replace occurrences of the let-rec `FVarId`. -/
  closed     : Expr
  toLift     : LetRecToLift
goal: Array Lean.LocalDecl

full_name: Lean.Elab.Term.MutualClosure.LetRecClosure.ref
code: structure LetRecClosure where
  ref        : Syntax
  localDecls : Array LocalDecl
  /-- Expression used to replace occurrences of the let-rec `FVarId`. -/
  closed     : Expr
  toLift     : LetRecToLift
goal: Lean.Syntax

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.mkLetRecClosureFor
code: private def mkLetRecClosureFor (toLift : LetRecToLift) (freeVars : Array FVarId) : TermElabM LetRecClosure 
goal: Lean.Elab.TermElabM Lean.Elab.Term.MutualClosure.LetRecClosure

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.MutualClosure.mkLetRecClosures
code: private def mkLetRecClosures (sectionVars : Array Expr) (mainFVarIds : Array FVarId) (recFVarIds : Array FVarId) (letRecsToLift : Array LetRecToLift) : TermElabM (List LetRecClosure) 
goal: Lean.Elab.TermElabM (List Lean.Elab.Term.MutualClosure.LetRecClosure)

full_name: Lean.Elab.Term.MutualClosure.Replacement
code: /-- Mapping from FVarId of mutually recursive functions being defined to "closure" expression. -/
abbrev Replacement 
goal: Type

full_name: Lean.Elab.Term.MutualClosure.insertReplacementForMainFns
code: def insertReplacementForMainFns (r : Replacement) (sectionVars : Array Expr) (mainHeaders : Array DefViewElabHeader) (mainFVars : Array Expr) : Replacement 
goal: Lean.Elab.Term.MutualClosure.Replacement

full_name: Lean.Elab.Term.MutualClosure.insertReplacementForLetRecs
code: def insertReplacementForLetRecs (r : Replacement) (letRecClosures : List LetRecClosure) : Replacement 
goal: Lean.Elab.Term.MutualClosure.Replacement

full_name: Lean.Elab.Term.MutualClosure.Replacement.apply
code: def Replacement.apply (r : Replacement) (e : Expr) : Expr 
goal: Lean.Expr

full_name: Lean.Elab.Term.MutualClosure.pushMain
code: def pushMain (preDefs : Array PreDefinition) (sectionVars : Array Expr) (mainHeaders : Array DefViewElabHeader) (mainVals : Array Expr)
    : TermElabM (Array PreDefinition) 
goal: Lean.Elab.TermElabM (Array Lean.Elab.PreDefinition)

full_name: Lean.Elab.Term.MutualClosure.pushLetRecs
code: def pushLetRecs (preDefs : Array PreDefinition) (letRecClosures : List LetRecClosure) (kind : DefKind) (modifiers : Modifiers) : MetaM (Array PreDefinition) 
goal: Lean.MetaM (Array Lean.Elab.PreDefinition)

full_name: Lean.Elab.Term.MutualClosure.getKindForLetRecs
code: def getKindForLetRecs (mainHeaders : Array DefViewElabHeader) : DefKind 
goal: Lean.Elab.DefKind

full_name: Lean.Elab.Term.MutualClosure.getModifiersForLetRecs
code: def getModifiersForLetRecs (mainHeaders : Array DefViewElabHeader) : Modifiers 
goal: Lean.Elab.Modifiers

full_name: Lean.Elab.Term.MutualClosure.main
code: /--
- `sectionVars`:   The section variables used in the `mutual` block.
- `mainHeaders`:   The elaborated header of the top-level definitions being defined by the mutual block.
- `mainFVars`:     The auxiliary variables used to represent the top-level definitions being defined by the mutual block.
- `mainVals`:      The elaborated value for the top-level definitions
- `letRecsToLift`: The let-rec's definitions that need to be lifted
-/
def main (sectionVars : Array Expr) (mainHeaders : Array DefViewElabHeader) (mainFVars : Array Expr) (mainVals : Array Expr) (letRecsToLift : List LetRecToLift)
    : TermElabM (Array PreDefinition) 
goal: Lean.Elab.TermElabM (Array Lean.Elab.PreDefinition)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.getAllUserLevelNames
code: private def getAllUserLevelNames (headers : Array DefViewElabHeader) : List Name 
goal: List Lean.Name

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.levelMVarToParamHeaders
code: /-- Eagerly convert universe metavariables occurring in theorem headers to universe parameters. -/
private def levelMVarToParamHeaders (views : Array DefView) (headers : Array DefViewElabHeader) : TermElabM (Array DefViewElabHeader) 
goal: Lean.Elab.TermElabM (Array Lean.Elab.DefViewElabHeader)

full_name: _private.«.lake».packages.lean4.src.lean.Lean.Elab.MutualDef.0.Lean.Elab.Term.levelMVarToParamHeaders.process
code: /-- Eagerly convert universe metavariables occurring in theorem headers to universe parameters. -/
private def levelMVarToParamHeaders (views : Array DefView) (headers : Array DefViewElabHeader) : TermElabM (Array DefViewElabHeader) 
goal: StateRefT' IO.RealWorld Nat Lean.Elab.TermElabM (Array Lean.Elab.DefViewElabHeader)

full_name: Lean.Elab.Term.checkForHiddenUnivLevels.visitLevel
code: partial def checkForHiddenUnivLevels (allUserLevelNames : List Name) (preDefs : Array PreDefinition) : TermElabM Unit 
goal: ReaderT Lean.Expr Lean.Elab.TermElabM Unit

full_name: Lean.Elab.Term.checkForHiddenUnivLevels.visit
code: partial def checkForHiddenUnivLevels (allUserLevelNames : List Name) (preDefs : Array PreDefinition) : TermElabM Unit 
goal: ReaderT Lean.Expr (Lean.MonadCacheT Lean.ExprStructEq Unit Lean.Elab.TermElabM) Unit

full_name: Lean.Elab.Term.checkForHiddenUnivLevels
code: partial def checkForHiddenUnivLevels (allUserLevelNames : List Name) (preDefs : Array PreDefinition) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: Lean.Elab.Term.elabMutualDef
code: def elabMutualDef (vars : Array Expr) (views : Array DefView) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: Lean.Elab.Term.elabMutualDef.go
code: def elabMutualDef (vars : Array Expr) (views : Array DefView) : TermElabM Unit 
goal: Lean.Elab.TermElabM Unit

full_name: Lean.Elab.Term.elabMutualDef.processDeriving
code: def elabMutualDef (vars : Array Expr) (views : Array DefView) : TermElabM Unit 
goal: Lean.Elab.TermElabM PUnit

full_name: Lean.Elab.Command.elabMutualDef
code: def elabMutualDef (ds : Array Syntax) : CommandElabM Unit 
goal: Lean.Elab.Command.CommandElabM Unit

full_name: Lean.Elab.Command.initFn._@..lake.packages.lean4.src.lean.Lean.Elab.MutualDef._hyg.15558
code: builtin_initialize
  registerTraceClass `Elab.definition.mkClosure
goal: IO Unit