Equations
- Lean.Meta.isDefEqNative s t = let isDefEq := fun s t => toLBoolM (Lean.Meta.isExprDefEqAux s t); do let s? ← Lean.Meta.reduceNative? s let t? ← Lean.Meta.reduceNative? t match s?, t? with | some s, some t => isDefEq s t | some s, none => isDefEq s t | none, some t => isDefEq s t | none, none => pure Lean.LBool.undef
Equations
- Lean.Meta.isDefEqNat s t = let isDefEq := fun s t => toLBoolM (Lean.Meta.isExprDefEqAux s t); if (Lean.Expr.hasFVar s || Lean.Expr.hasMVar s || Lean.Expr.hasFVar t || Lean.Expr.hasMVar t) = true then pure Lean.LBool.undef else do let s? ← Lean.Meta.reduceNat? s let t? ← Lean.Meta.reduceNat? t match s?, t? with | some s, some t => isDefEq s t | some s, none => isDefEq s t | none, some t => isDefEq s t | none, none => pure Lean.LBool.undef
Equations
- Lean.Meta.isDefEqStringLit s t = let isDefEq := fun s t => toLBoolM (Lean.Meta.isExprDefEqAux s t); if (Lean.Expr.isStringLit s && Lean.Expr.isAppOf t `String.mk) = true then isDefEq (Lean.Meta.toCtorIfLit s) t else if (Lean.Expr.isAppOf s `String.mk && Lean.Expr.isStringLit t) = true then isDefEq s (Lean.Meta.toCtorIfLit t) else pure Lean.LBool.undef
Equations
- Lean.Meta.isEtaUnassignedMVar e = match Lean.Expr.etaExpanded? e with | some (Lean.Expr.mvar mvarId x) => do let a ← Lean.Meta.isReadOnlyOrSyntheticOpaqueExprMVar mvarId if a = true then pure false else do let a ← Lean.Meta.isExprMVarAssigned mvarId if a = true then pure false else pure true | x => pure false
@[specialize]
def
Lean.Meta.isDefEqBindingDomain
(fvars : Array Lean.Expr)
(ds₂ : Array Lean.Expr)
(k : Lean.MetaM Bool)
:
Equations
- Lean.Meta.isDefEqBindingDomain fvars ds₂ k = (fun loop => loop 0) (Lean.Meta.isDefEqBindingDomain.loop fvars ds₂ k)
partial def
Lean.Meta.isDefEqBindingDomain.loop
(fvars : Array Lean.Expr)
(ds₂ : Array Lean.Expr)
(k : Lean.MetaM Bool)
(i : Nat)
:
def
Lean.Meta.mkAuxMVar
(lctx : Lean.LocalContext)
(localInsts : Lean.LocalInstances)
(type : Lean.Expr)
(numScopeArgs : optParam Nat 0)
:
Equations
- Lean.Meta.mkAuxMVar lctx localInsts type numScopeArgs = Lean.Meta.mkFreshExprMVarAt lctx localInsts type Lean.MetavarKind.natural Lean.Name.anonymous numScopeArgs
- mvarId : Lean.MVarId
- mvarDecl : Lean.MetavarDecl
- fvars : Array Lean.Expr
- hasCtxLocals : Bool
- rhs : Lean.Expr
@[inline]
Equations
- Lean.Meta.CheckAssignment.throwCheckAssignmentFailure = throw (Lean.Exception.internal Lean.Meta.CheckAssignment.checkAssignmentExceptionId)
Equations
- Lean.Meta.CheckAssignment.throwOutOfScopeFVar = throw (Lean.Exception.internal Lean.Meta.CheckAssignment.outOfScopeExceptionId)
Equations
@[inline]
def
Lean.Meta.CheckAssignment.run
(x : Lean.Meta.CheckAssignment.CheckAssignmentM Lean.Expr)
(mvarId : Lean.MVarId)
(fvars : Array Lean.Expr)
(hasCtxLocals : Bool)
(v : Lean.Expr)
:
Equations
- Lean.Meta.CheckAssignment.run x mvarId fvars hasCtxLocals v = do let mvarDecl ← Lean.Meta.getMVarDecl mvarId let ctx : Lean.Meta.CheckAssignment.Context := { mvarId := mvarId, mvarDecl := mvarDecl, fvars := fvars, hasCtxLocals := hasCtxLocals, rhs := v } let x : Lean.Meta.CheckAssignment.CheckAssignmentM (Option Lean.Expr) := Lean.catchInternalIds [Lean.Meta.CheckAssignment.outOfScopeExceptionId, Lean.Meta.CheckAssignment.checkAssignmentExceptionId] (do let e ← x pure (some e)) fun x => pure none StateRefT'.run' (ReaderT.run x ctx) { cache := ∅ }
partial def
Lean.Meta.CheckAssignment.assignToConstFun
(mvar : Lean.Expr)
(numArgs : Nat)
(newMVar : Lean.Expr)
:
partial def
Lean.Meta.CheckAssignment.checkAssignmentAux
(mvarId : Lean.MVarId)
(fvars : Array Lean.Expr)
(hasCtxLocals : Bool)
(v : Lean.Expr)
:
def
Lean.Meta.CheckAssignmentQuick.check
(hasCtxLocals : Bool)
(ctxApprox : Bool)
(mctx : Lean.MetavarContext)
(lctx : Lean.LocalContext)
(mvarDecl : Lean.MetavarDecl)
(mvarId : Lean.MVarId)
(fvars : Array Lean.Expr)
(e : Lean.Expr)
:
Equations
- Lean.Meta.CheckAssignmentQuick.check hasCtxLocals ctxApprox mctx lctx mvarDecl mvarId fvars e = (fun visit => visit e) (Lean.Meta.CheckAssignmentQuick.check.visit hasCtxLocals mctx lctx mvarDecl mvarId fvars)
partial def
Lean.Meta.CheckAssignmentQuick.check.visit
(hasCtxLocals : Bool)
(mctx : Lean.MetavarContext)
(lctx : Lean.LocalContext)
(mvarDecl : Lean.MetavarDecl)
(mvarId : Lean.MVarId)
(fvars : Array Lean.Expr)
(e : Lean.Expr)
:
Equations
- Lean.Meta.checkAssignment mvarId fvars v = do let r ← forIn fvars { fst := none, snd := PUnit.unit } fun fvar r => let r := r.snd; do let a ← Lean.Meta.inferType fvar let a ← Lean.Meta.occursCheck mvarId a if a = true then do pure PUnit.unit pure (ForInStep.yield { fst := none, snd := PUnit.unit }) else pure (ForInStep.done { fst := some none, snd := PUnit.unit }) let x : PUnit := r.snd let _do_jp : PUnit → Lean.MetaM (Option Lean.Expr) := fun y => if (!Lean.Expr.hasExprMVar v && !Lean.Expr.hasFVar v) = true then pure (some v) else do let mvarDecl ← Lean.Meta.getMVarDecl mvarId let hasCtxLocals : Bool := Array.any fvars (fun fvar => Lean.LocalContext.containsFVar mvarDecl.lctx fvar) 0 (Array.size fvars) let ctx ← read let mctx ← Lean.getMCtx if Lean.Meta.CheckAssignmentQuick.check hasCtxLocals ctx.config.ctxApprox mctx ctx.lctx mvarDecl mvarId fvars v = true then pure (some v) else do let v ← Lean.Meta.instantiateMVars v Lean.Meta.CheckAssignment.checkAssignmentAux mvarId fvars hasCtxLocals v match r.fst with | none => do let y ← pure PUnit.unit _do_jp y | some a => pure a
@[inline]
Equations
- Lean.Meta.whenUndefDo x k = do let status ← x match status with | Lean.LBool.true => pure true | Lean.LBool.false => pure false | Lean.LBool.undef => k