- done: Lean.Expr → Lean.TransformStep
- visit: Lean.Expr → Lean.TransformStep
def
Lean.Core.transform
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.CoreM m]
[inst : MonadControlT Lean.CoreM m]
(input : Lean.Expr)
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
:
Tranform the expression input using pre and post.
pre sis invoked before visiting the children of subterm 's'. If the result isTransformStep.visit sNew, thensNewis traversed by transform. If the result isTransformStep.done sNew, thensis just replaced withsNew. In both cases,sNewmust be definitionally equal tospost sis invoked after visiting the children of subterms.
The term s in both pre s and post s may contain loose bound variables. So, this method is not appropriate for
if one needs to apply operations (e.g., whnf, inferType) that do not handle loose bound variables.
Consider using Meta.transform to avoid loose bound variables.
This method is useful for applying transformations such as beta-reduction and delta-reduction.
Equations
- Lean.Core.transform input pre post = let _ := { }; let __1 := { monadLift := fun {α} x => liftM (liftM x) }; Lean.MonadCacheT.run (Lean.Core.transform.visit pre post _ __1 input)
partial def
Lean.Core.transform.visit
{m : Type → Type}
[inst : Monad m]
[inst : MonadControlT Lean.CoreM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(e : Lean.Expr)
:
partial def
Lean.Core.transform.visit.visitPost
{m : Type → Type}
[inst : Monad m]
[inst : MonadControlT Lean.CoreM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(e : Lean.Expr)
:
Equations
- Lean.Core.betaReduce e = Lean.Core.transform e (fun e => pure (Lean.TransformStep.visit (Lean.Expr.headBeta e))) fun e => pure (Lean.TransformStep.done e)
def
Lean.Meta.transform
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.MetaM m]
[inst : MonadControlT Lean.MetaM m]
[inst : Lean.MonadTrace m]
[inst : Lean.MonadRef m]
[inst : Lean.MonadOptions m]
[inst : Lean.AddMessageContext m]
(input : Lean.Expr)
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(usedLetOnly : optParam Bool false)
:
Similar to Core.transform, but terms provided to pre and post do not contain loose bound variables.
So, it is safe to use any MetaM method at pre and post.
Equations
- One or more equations did not get rendered due to their size.
partial def
Lean.Meta.transform.visit
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.MetaM m]
[inst : MonadControlT Lean.MetaM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(usedLetOnly : optParam Bool false)
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(e : Lean.Expr)
:
partial def
Lean.Meta.transform.visit.visitPost
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.MetaM m]
[inst : MonadControlT Lean.MetaM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(usedLetOnly : optParam Bool false)
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(e : Lean.Expr)
:
partial def
Lean.Meta.transform.visit.visitLambda
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.MetaM m]
[inst : MonadControlT Lean.MetaM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(usedLetOnly : optParam Bool false)
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(fvars : Array Lean.Expr)
(e : Lean.Expr)
:
partial def
Lean.Meta.transform.visit.visitForall
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.MetaM m]
[inst : MonadControlT Lean.MetaM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(usedLetOnly : optParam Bool false)
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(fvars : Array Lean.Expr)
(e : Lean.Expr)
:
partial def
Lean.Meta.transform.visit.visitLet
{m : Type → Type}
[inst : Monad m]
[inst : MonadLiftT Lean.MetaM m]
[inst : MonadControlT Lean.MetaM m]
(pre : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.visit e))
(post : optParam (Lean.Expr → m Lean.TransformStep) fun e => pure (Lean.TransformStep.done e))
(usedLetOnly : optParam Bool false)
(_ : STWorld IO.RealWorld m)
(_ : MonadLiftT (ST IO.RealWorld) m)
(fvars : Array Lean.Expr)
(e : Lean.Expr)
:
Equations
- One or more equations did not get rendered due to their size.
Unfold definitions and theorems in e that are not in the current environment, but are in biggerEnv.
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.