- foApprox : Bool
- ctxApprox : Bool
- quasiPatternApprox : Bool
When
constApprox
is set to true, we solve?m t =?= c
using?m := fun _ => c
when?m t
is not a higher-order pattern andc
is not an application asconstApprox : BoolWhen the following flag is set,
isDefEq
throws the exeptionExeption.isDefEqStuck
whenever it encounters a constraint?m ... =?= t
where?m
is read only. This feature is useful for type class resolution where we may want to notify the caller that the TC problem may be solveable later after it assigns?m
.isDefEqStuckEx : Bool- transparency : Lean.Meta.TransparencyMode
If zetaNonDep == false, then non dependent let-decls are not zeta expanded.
zetaNonDep : BoolWhen
trackZeta == true
, we store zetaFVarIds all free variables that have been zeta-expanded.trackZeta : Bool- unificationHints : Bool
Enables proof irrelevance at
isDefEq
proofIrrelevance : BoolBy default synthetic opaque metavariables are not assigned by
isDefEq
. Motivation: we want to make sure typing constraints resolved during elaboration should not "fill" holes that are supposed to be filled using tactics. However, this restriction is too restrictive for tactics such asexact t
. When elaboratingt
, we dot not fill named holes when solving typing constraints or TC resolution. But, we ignore the restriction when we try to unify the type oft
with the goal target type. We claim this is not a hack and is defensible behavior because this last unification step is not really part of the term elaboration.assignSyntheticOpaque : BoolWhen
ignoreLevelDepth
isfalse
, only universe level metavariables with depth == metavariable context depth can be assigned. We used to haveignoreLevelDepth == false
always, but this setting produced counterintuitive behavior in a few cases. Recall that universe levels are often ignored by users, they may not even be aware they exist. We still use this restriction for regular metavariables. See discussion at the beginning ofMetavarContext.lean
. We claim it is reasonable to ignore this restriction for universe metavariables because their values are often contrained by the terms is instances and simp theorems. TODO: we should delete this configuration option and the methodisReadOnlyLevelMVar
after we have more tests.ignoreLevelMVarDepth : BoolEnable/Disable support for offset constraints such as
?x + 1 =?= e
offsetCnstrs : BoolEta for structures configuration mode.
etaStruct : Lean.Meta.EtaStructMode
- binderInfo : Lean.BinderInfo
- hasFwdDeps : Bool
- isProp : Bool
- isDecInst : Bool
Equations
- Lean.Meta.instInhabitedParamInfo = { default := { binderInfo := default, hasFwdDeps := default, backDeps := default, isProp := default, isDecInst := default } }
Equations
- Lean.Meta.ParamInfo.isImplicit p = (p.binderInfo == Lean.BinderInfo.implicit)
Equations
- Lean.Meta.ParamInfo.isInstImplicit p = (p.binderInfo == Lean.BinderInfo.instImplicit)
Equations
- Lean.Meta.ParamInfo.isStrictImplicit p = (p.binderInfo == Lean.BinderInfo.strictImplicit)
Equations
- Lean.Meta.ParamInfo.isExplicit p = (p.binderInfo == Lean.BinderInfo.default || p.binderInfo == Lean.BinderInfo.auxDecl)
- transparency : Lean.Meta.TransparencyMode
- expr : Lean.Expr
Equations
- Lean.Meta.instInhabitedInfoCacheKey = { default := { transparency := default, expr := default, nargs? := default } }
Equations
- Lean.Meta.instBEqInfoCacheKey = { beq := [anonymous] }
Equations
- One or more equations did not get rendered due to their size.
Equations
- inferType : Lean.Meta.InferTypeCache
- funInfo : Lean.Meta.FunInfoCache
- synthInstance : Lean.Meta.SynthInstanceCache
- whnfDefault : Lean.Meta.WhnfCache
- whnfAll : Lean.Meta.WhnfCache
- defEqDefault : Lean.Meta.DefEqCache
- defEqAll : Lean.Meta.DefEqCache
Equations
- One or more equations did not get rendered due to their size.
- lhs : Lean.Expr
- rhs : Lean.Expr
- lctx : Lean.LocalContext
- localInstances : Lean.LocalInstances
"Context" for a postponed universe constraint.
lhs
and rhs
are the surrounding isDefEq
call when the postponed constraint was created.
- ref : Lean.Syntax
- lhs : Lean.Level
- rhs : Lean.Level
- ctx? : Option Lean.Meta.DefEqContext
Auxiliary structure for representing postponed universe constraints.
Remark: the fields ref
and rootDefEq?
are used for error message generation only.
Remark: we may consider improving the error message generation in the future.
Equations
- Lean.Meta.instInhabitedPostponedEntry = { default := { ref := default, lhs := default, rhs := default, ctx? := default } }
- mctx : Lean.MetavarContext
- cache : Lean.Meta.Cache
- zetaFVarIds : Lean.FVarIdSet
- postponed : Std.PersistentArray Lean.Meta.PostponedEntry
Equations
- Lean.Meta.instInhabitedState = { default := { mctx := default, cache := default, zetaFVarIds := default, postponed := default } }
Equations
- Lean.Meta.instInhabitedSavedState = { default := { core := default, meta := default } }
- config : Lean.Meta.Config
- lctx : Lean.LocalContext
- localInstances : Lean.LocalInstances
Not
none
when inside of anisDefEq
test. SeePostponedEntry
.defEqCtx? : Option Lean.Meta.DefEqContextTrack the number of nested
synthPending
invocations. Nested invocations can happen when the type class resolution invokessynthPending
.Remark: in the current implementation, `synthPending` fails if `synthPendingDepth > 0`. We will add a configuration option if necessary.
synthPendingDepth : NatA predicate to control whether a constant can be unfolded or not at
whnf
. Note that we do not cache results atwhnf
whencanUnfold?
is notnone
.canUnfold? : Option (Lean.Meta.Config → Lean.ConstantInfo → Lean.CoreM Bool)
Equations
- Lean.Meta.instMonadMetaM = let i := inferInstanceAs (Monad Lean.MetaM); Monad.mk
Equations
- Lean.Meta.instInhabitedMetaM = { default := fun x x => default }
Equations
- Lean.Meta.instMonadLCtxMetaM = { getLCtx := do let a ← read pure a.lctx }
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.instAddMessageContextMetaM = { addMessageContext := Lean.addMessageContextFull }
Equations
- Lean.Meta.saveState = do let a ← getThe Lean.Core.State let a_1 ← get pure { core := a, meta := a_1 }
Restore backtrackable parts of the state.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.instMonadBacktrackSavedStateMetaM = { saveState := Lean.Meta.saveState, restoreState := fun s => Lean.Meta.SavedState.restore s }
Equations
- Lean.Meta.MetaM.run x ctx s = StateRefT'.run (x ctx) s
Equations
- Lean.Meta.MetaM.run' x ctx s = Prod.fst <$> Lean.Meta.MetaM.run x ctx s
Equations
- Lean.Meta.MetaM.toIO x ctxCore sCore ctx s = do let discr ← Lean.Core.CoreM.toIO (Lean.Meta.MetaM.run x ctx s) ctxCore sCore match discr with | ((a, s), sCore) => pure (a, sCore, s)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.throwIsDefEqStuck = throw (Lean.Exception.internal Lean.Meta.isDefEqStuckExceptionId)
Equations
Equations
- Lean.Meta.mapMetaM f x = controlAt Lean.MetaM fun runInBase => f (stM Lean.MetaM m α) (runInBase x)
Equations
- Lean.Meta.map1MetaM f k = controlAt Lean.MetaM fun runInBase => f (stM Lean.MetaM m α) fun b => runInBase (k b)
Equations
- Lean.Meta.map2MetaM f k = controlAt Lean.MetaM fun runInBase => f (stM Lean.MetaM m α) fun b c => runInBase (k b c)
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.getLocalInstances = do let a ← read pure a.localInstances
Equations
- Lean.Meta.getConfig = do let a ← read pure a.config
Equations
- Lean.Meta.setMCtx mctx = modify fun s => { mctx := mctx, cache := s.cache, zetaFVarIds := s.zetaFVarIds, postponed := s.postponed }
Equations
- Lean.Meta.resetZetaFVarIds = modify fun s => { mctx := s.mctx, cache := s.cache, zetaFVarIds := ∅, postponed := s.postponed }
Equations
- Lean.Meta.getZetaFVarIds = do let a ← get pure a.zetaFVarIds
Equations
- Lean.Meta.getPostponed = do let a ← get pure a.postponed
Equations
- Lean.Meta.setPostponed postponed = modify fun s => { mctx := s.mctx, cache := s.cache, zetaFVarIds := s.zetaFVarIds, postponed := postponed }
Equations
- Lean.Meta.modifyPostponed f = modify fun s => { mctx := s.mctx, cache := s.cache, zetaFVarIds := s.zetaFVarIds, postponed := f s.postponed }
Equations
- One or more equations did not get rendered due to their size.
Reduces an expression to its Weak Head Normal Form. This is when the topmost expression has been fully reduced, but may contain subexpressions which have not been reduced.
Returns the inferred type of the given expression, or fails if it is not type-correct.
Equations
- Lean.Meta.whnfForall e = do let e' ← Lean.Meta.whnf e if Lean.Expr.isForall e' = true then pure e' else pure e
Equations
- Lean.Meta.withIncRecDepth x = Lean.Meta.mapMetaM (fun {α} => Lean.withIncRecDepth) x
Equations
- Lean.Meta.mkFreshExprMVarAt lctx localInsts type kind userName numScopeArgs = do let a ← Lean.mkFreshMVarId Lean.Meta.mkFreshExprMVarAtCore a lctx localInsts type kind userName numScopeArgs
Equations
- Lean.Meta.mkFreshLevelMVar = do let mvarId ← Lean.mkFreshMVarId Lean.modifyMCtx fun mctx => Lean.MetavarContext.addLevelMVarDecl mctx mvarId pure (Lean.mkLevelMVar mvarId)
Equations
- Lean.Meta.mkFreshExprMVar type? kind userName = Lean.Meta.mkFreshExprMVarImpl type? kind userName
Equations
- Lean.Meta.mkFreshTypeMVar kind userName = do let u ← Lean.Meta.mkFreshLevelMVar Lean.Meta.mkFreshExprMVar (some (Lean.mkSort u)) kind userName
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.mkFreshLevelMVars num = Nat.foldM (fun x us => do let a ← Lean.Meta.mkFreshLevelMVar pure (a :: us)) [] num
Equations
Equations
- Lean.Meta.mkConstWithFreshMVarLevels declName = do let info ← Lean.getConstInfo declName let a ← Lean.Meta.mkFreshLevelMVarsFor info pure (Lean.mkConst declName a)
Equations
- Lean.Meta.getTransparency = do let a ← Lean.Meta.getConfig pure a.transparency
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.setMVarKind mvarId kind = Lean.modifyMCtx fun mctx => Lean.MetavarContext.setMVarKind mctx mvarId kind
Equations
- Lean.Meta.setMVarType mvarId type = Lean.modifyMCtx fun mctx => Lean.MetavarContext.setMVarType mctx mvarId type
Equations
- Lean.Meta.isReadOnlyExprMVar mvarId = do let a ← Lean.Meta.getMVarDecl mvarId let a_1 ← Lean.getMCtx pure (a.depth != a_1.depth)
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.setMVarUserName mvarId newUserName = Lean.modifyMCtx fun mctx => Lean.MetavarContext.setMVarUserName mctx mvarId newUserName
Equations
- Lean.Meta.isExprMVarAssigned mvarId = do let a ← Lean.getMCtx pure (Lean.MetavarContext.isExprAssigned a mvarId)
Equations
- Lean.Meta.getExprMVarAssignment? mvarId = do let a ← Lean.getMCtx pure (Lean.MetavarContext.getExprAssignment? a mvarId)
Return true if e
contains mvarId
directly or indirectly
Equations
- Lean.Meta.occursCheck mvarId e = do let a ← Lean.getMCtx pure (Lean.MetavarContext.occursCheck a mvarId e)
Equations
- Lean.Meta.assignExprMVar mvarId val = Lean.modifyMCtx fun mctx => Lean.MetavarContext.assignExpr mctx mvarId val
Equations
- Lean.Meta.isDelayedAssigned mvarId = do let a ← Lean.getMCtx pure (Lean.MetavarContext.isDelayedAssigned a mvarId)
Equations
- Lean.Meta.getDelayedAssignment? mvarId = do let a ← Lean.getMCtx pure (Lean.MetavarContext.getDelayedAssignment? a mvarId)
Equations
- Lean.Meta.hasAssignableMVar e = do let a ← Lean.getMCtx pure (Lean.MetavarContext.hasAssignableMVar a e)
Equations
- Lean.Meta.throwUnknownFVar fvarId = Lean.throwError (Lean.toMessageData "unknown free variable '" ++ Lean.toMessageData (Lean.mkFVar fvarId) ++ Lean.toMessageData "'")
Equations
- Lean.Meta.findLocalDecl? fvarId = do let a ← Lean.getLCtx pure (Lean.LocalContext.find? a fvarId)
Equations
- Lean.Meta.getLocalDecl fvarId = do let a ← Lean.getLCtx match Lean.LocalContext.find? a fvarId with | some d => pure d | none => Lean.Meta.throwUnknownFVar fvarId
Equations
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
- Lean.Meta.abstract e xs = Lean.Meta.abstractRange e (Array.size xs) xs
Takes an array xs
of free variables or metavariables and a term e
that may contain those variables, and abstracts and binds them as universal quantifiers.
- if
usedOnly = true
then only variables that the expression body depends on will appear. - if
usedLetOnly = true
same asusedOnly
except for let-bound variables. (That is, local constants which have been assigned a value.)
Equations
- One or more equations did not get rendered due to their size.
Takes an array xs
of free variables and metavariables and a
body term e
and creates fun ..xs => e
, suitably
abstracting e
and the types in xs
.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.mkLetFVars xs e usedLetOnly binderInfoForMVars = Lean.Meta.mkLambdaFVars xs e false usedLetOnly binderInfoForMVars
Creates the expression d → b
Equations
- Lean.Meta.mkArrow d b = do let a ← liftM (Lean.mkFreshUserName `x) pure (Lean.mkForall a Lean.BinderInfo.default d b)
fun _ : Unit => a
Equations
- Lean.Meta.mkFunUnit a = do let a ← liftM (Lean.mkFreshUserName `x) pure (Lean.mkLambda a Lean.BinderInfo.default (Lean.mkConst `Unit) a)
Equations
- Lean.Meta.elimMVarDeps xs e preserveOrder = if Array.isEmpty xs = true then pure e else Lean.Meta.liftMkBindingM (Lean.MetavarContext.elimMVarDeps xs e preserveOrder)
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Execute x
allowing isDefEq
to assign synthetic opaque metavariables.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.savingCache = Lean.Meta.mapMetaM fun {α} => Lean.Meta.savingCacheImpl
Equations
- Lean.Meta.getTheoremInfo info = do let a ← Lean.Meta.shouldReduceAll if a = true then pure (some info) else pure none
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Reset synthInstance
cache, execute x
, and restore cache
Equations
- Lean.Meta.resettingSynthInstanceCache = Lean.Meta.mapMetaM fun {α} => Lean.Meta.resettingSynthInstanceCacheImpl
Equations
- Lean.Meta.resettingSynthInstanceCacheWhen b x = if b = true then Lean.Meta.resettingSynthInstanceCache x else x
Add entry { className := className, fvar := fvar }
to localInstances,
and then execute continuation k
.
It resets the type class cache using resettingSynthInstanceCache
.
Equations
- Lean.Meta.withNewLocalInstance className fvar = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withNewLocalInstanceImp className fvar
Equations
- Lean.Meta.isClass? type = tryCatch (Lean.Meta.isClassImp? type) fun x => pure none
Equations
- Lean.Meta.withNewLocalInstances fvars j = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withNewLocalInstancesImpAux fvars j
Given type
of the form forall xs, A
, execute k xs A
.
This combinator will declare local declarations, create free variables for them,
execute k
with updated local context, and make sure the cache is restored after executing k
.
Equations
- Lean.Meta.forallTelescope type k = Lean.Meta.map2MetaM (fun {α} k => Lean.Meta.forallTelescopeImp type k) k
Similar to forallTelescope
, but given type
of the form forall xs, A
,
it reduces A
and continues bulding the telescope if it is a forall
.
Equations
- Lean.Meta.forallTelescopeReducing type k = Lean.Meta.map2MetaM (fun {α} k => Lean.Meta.forallTelescopeReducingImp type k) k
Similar to forallTelescopeReducing
, stops constructing the telescope when
it reaches size maxFVars
.
Equations
- Lean.Meta.forallBoundedTelescope type maxFVars? k = Lean.Meta.map2MetaM (fun {α} k => Lean.Meta.forallBoundedTelescopeImp type maxFVars? k) k
Similar to lambdaTelescope
but for lambda and let expressions.
Equations
- Lean.Meta.lambdaLetTelescope e k = Lean.Meta.map2MetaM (fun {α} k => Lean.Meta.lambdaTelescopeImp e true k) k
Given e
of the form fun ..xs => A
, execute k xs A
.
This combinator will declare local declarations, create free variables for them,
execute k
with updated local context, and make sure the cache is restored after executing k
.
Equations
- Lean.Meta.lambdaTelescope e k = Lean.Meta.map2MetaM (fun {α} k => Lean.Meta.lambdaTelescopeImp e false k) k
Return the parameter names for the given global declaration.
Equations
- One or more equations did not get rendered due to their size.
Given e
of the form forall ..xs, A
, this combinator will create a new
metavariable for each x
in xs
and instantiate A
with these.
Returns a product containing
- the new metavariables
- the binder info for the
xs
- the instantiated
A
Equations
- Lean.Meta.forallMetaTelescope e kind = Lean.Meta.forallMetaTelescopeReducingAux e false none kind
Similar to forallMetaTelescope
, but if e = forall ..xs, A
it will reduce A
to construct further mvars.
Equations
- Lean.Meta.forallMetaTelescopeReducing e maxMVars? kind = Lean.Meta.forallMetaTelescopeReducingAux e true maxMVars? kind
Similar to forallMetaTelescopeReducing
, stops
constructing the telescope when it reaches size maxMVars
.
Equations
- Lean.Meta.forallMetaBoundedTelescope e maxMVars kind = Lean.Meta.forallMetaTelescopeReducingAux e true (some maxMVars) kind
Similar to forallMetaTelescopeReducingAux
but for lambda expressions.
Equations
- Lean.Meta.lambdaMetaTelescope e maxMVars? = Lean.Meta.lambdaMetaTelescope.process maxMVars? #[] #[] 0 e
Create a free variable x
with name, binderInfo and type, add it to the context and run in k
.
Then revert the context.
Equations
- Lean.Meta.withLocalDecl name bi type k = Lean.Meta.map1MetaM (fun {α} k => Lean.Meta.withLocalDeclImp name bi type k) k
Equations
- Lean.Meta.withLocalDeclD name type k = Lean.Meta.withLocalDecl name Lean.BinderInfo.default type k
Append an array of free variables xs
to the local context and execute k xs
.
declInfos takes the form of an array consisting of:
- the name of the variable
- the binder info of the variable
- a type constructor for the variable, where the array consists of all of the free variables defined prior to this one. This is needed because the type of the variable may depend on prior variables.
Equations
- Lean.Meta.withLocalDecls declInfos k = Lean.Meta.withLocalDecls.loop declInfos k #[]
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.withNewBinderInfos bs k = Lean.Meta.mapMetaM (fun {α} k => Lean.Meta.withNewBinderInfosImp bs k) k
Equations
- Lean.Meta.withLetDecl name type val k = Lean.Meta.map1MetaM (fun {α} k => Lean.Meta.withLetDeclImp name type val k) k
Equations
- One or more equations did not get rendered due to their size.
Register any local instance in decls
Equations
- Lean.Meta.withLocalInstances decls = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withLocalInstancesImp decls
Equations
- Lean.Meta.withExistingLocalDecls decls = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withExistingLocalDeclsImp decls
Save cache and MetavarContext
, bump the MetavarContext
depth, execute x
,
and restore saved data.
Metavariable context depths are used to control which metavariables may be assigned in isDefEq
.
See the docstring of isDefEq
for more information.
Equations
- Lean.Meta.withNewMCtxDepth = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withNewMCtxDepthImp
Equations
- Lean.Meta.withLCtx lctx localInsts = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withLocalContextImp lctx localInsts
Execute x
using the given metavariable LocalContext
and LocalInstances
.
The type class resolution cache is flushed when executing x
if its LocalInstances
are
different from the current ones.
Equations
- Lean.Meta.withMVarContext mvarId = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withMVarContextImp mvarId
Equations
- Lean.Meta.withMCtx mctx = Lean.Meta.mapMetaM fun {α} => Lean.Meta.withMCtxImp mctx
Execute x
using approximate unification: foApprox
, ctxApprox
and quasiPatternApprox
.
Equations
- Lean.Meta.approxDefEq = Lean.Meta.mapMetaM fun {α} => Lean.Meta.approxDefEqImp
Similar to approxDefEq
, but uses all available approximations.
We don't use constApprox
by default at approxDefEq
because it often produces undesirable solution for monadic code.
For example, suppose we have pure (x > 0)
which has type ?m Prop
. We also have the goal [Pure ?m]
.
Now, assume the expected type is IO Bool
. Then, the unification constraint ?m Prop =?= IO Bool
could be solved
as ?m := fun _ => IO Bool
using constApprox
, but this spurious solution would generate a failure when we try to
solve [Pure (fun _ => IO Bool)]
Equations
- Lean.Meta.fullApproxDefEq = Lean.Meta.mapMetaM fun {α} => Lean.Meta.fullApproxDefEqImp
Equations
- Lean.Meta.normalizeLevel u = do let u ← Lean.Meta.instantiateLevelMVars u pure (Lean.Level.normalize u)
Equations
- Lean.Meta.assignLevelMVar mvarId u = Lean.modifyMCtx fun mctx => Lean.MetavarContext.assignLevel mctx mvarId u
whnf
with reducible transparency.
whnf
with default transparency.
whnf
with instances transparency.
Equations
- One or more equations did not get rendered due to their size.
Equations
Equations
Return true iff e
depends on the free variable fvarId
Equations
- Lean.Meta.dependsOn e fvarId = do let a ← Lean.getMCtx pure (Lean.MetavarContext.exprDependsOn a e fvarId)
Return true iff e
depends on the free variable fvarId
Equations
- Lean.Meta.localDeclDependsOn localDecl fvarId = do let a ← Lean.getMCtx pure (Lean.MetavarContext.localDeclDependsOn a localDecl fvarId)
Return true iff e
depends on a free variable x
s.t. pf x
, or an unassigned metavariable ?m
s.t. pm ?m
is true.
Equations
- Lean.Meta.dependsOnPred e pf pm = do let a ← Lean.getMCtx pure (Lean.MetavarContext.findExprDependsOn a e pf pm)
Return true iff the local declaration localDecl
depends on a free variable x
s.t. pf x
, an unassigned metavariable ?m
s.t. pm ?m
is true.
Equations
- Lean.Meta.localDeclDependsOnPred localDecl pf pm = do let a ← Lean.getMCtx pure (Lean.MetavarContext.findLocalDeclDependsOn a localDecl pf pm)
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.orElse x y = do let s ← Lean.saveState tryCatch x fun x => do Lean.Meta.SavedState.restore s y ()
Equations
- Lean.Meta.instOrElseMetaM = { orElse := Lean.Meta.orElse }
Equations
- Lean.Meta.instAlternativeMetaM = Alternative.mk (fun {x} => Lean.throwError (Lean.toMessageData "failed")) fun {α} => Lean.Meta.orElse
Similar to orelse
, but merge errors. Note that internal errors are not caught.
The default mergeRef
uses the ref
(position information) for the first message.
The default mergeMsg
combines error messages using Format.line ++ Format.line
as a separator.
Equations
- Lean.Meta.orelseMergeErrors x y mergeRef mergeMsg = controlAt Lean.MetaM fun runInBase => Lean.Meta.orelseMergeErrorsImp (runInBase x) (runInBase y) mergeRef mergeMsg
Execute x
, and apply f
to the produced error message
Equations
- Lean.Meta.mapErrorImp x f = tryCatch x fun ex => match ex with | Lean.Exception.error ref msg => throw (Lean.Exception.error ref (f msg)) | ex => throw ex
Equations
- Lean.Meta.mapError x f = controlAt Lean.MetaM fun runInBase => Lean.Meta.mapErrorImp (runInBase x) f
Sort free variables using an order x < y
iff x
was defined before y
.
If a free variable is not in the local context, we use their id.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.isListLevelDefEqAux [] [] = pure true
- Lean.Meta.isListLevelDefEqAux (u :: us) (v :: vs) = (Lean.Meta.isLevelDefEqAux u v <&&> Lean.Meta.isListLevelDefEqAux us vs)
- Lean.Meta.isListLevelDefEqAux _fun_discr _fun_discr = pure false
Equations
- One or more equations did not get rendered due to their size.
Equations
- Lean.Meta.mkLevelStuckErrorMessage entry = Lean.Meta.mkLeveErrorMessageCore "stuck at solving universe constraint" entry
Equations
- Lean.Meta.mkLevelErrorMessage entry = Lean.Meta.mkLeveErrorMessageCore "failed to solve universe constraint" entry
checkpointDefEq x
executes x
and process all postponed universe level constraints produced by x
.
We keep the modifications only if processPostponed
return true and x
returned true
.
If mayPostpone == false
, all new postponed universe level constraints must be solved before returning.
We currently try to postpone universe constraints as much as possible, even when by postponing them we
are not sure whether x
really succeeded or not.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Equations
- One or more equations did not get rendered due to their size.
Determines whether two expressions are definitionally equal to each other.
To control how metavariables are assigned and unified, metavariables and their context have a "depth".
Given a metavariable ?m
and a MetavarContext
mctx
, ?m
is not assigned if ?m.depth != mctx.depth
.
The combinator withNewMCtxDepth x
will bump the depth while executing x
.
So, withNewMCtxDepth (isDefEq a b)
is isDefEq
without any mvar assignment happening
whereas isDefEq a b
will assign any metavariables of the current depth in a
and b
to unify them.
For matching (where only mvars in b
should be assigned), we create the term inside the withNewMCtxDepth
.
For an example, see Lean.Meta.Simp.tryTheoremWithExtraArgs?
Equations
- Lean.Meta.isDefEq t s = Lean.Meta.isExprDefEq t s
Equations
- One or more equations did not get rendered due to their size.