# Documentation

Lean.Compiler.LCNF.ToLCNF

Return true if e is a lcProof application. Recall that we use lcProof to erase all nested proofs.

Equations

Create the temporary lcProof

Equations

Auxiliary inductive datatype for constructing LCNF Code objects. The toLCNF function maintains a sequence of elements that is eventually converted into Code.

Instances For
@[inline]

State for BindCasesM monad Mapping from _alt. variables to new join points

Equations
@[inline]

Auxiliary monad for implementing bindCases

Equations

This method returns code that at each exit point of cases, it jumps to jpDecl. It is similar to Code.bind, but we add special support for inlineMatcher. The inlineMatcher function inlines the auxiliary _match_ declarations. To make sure there is no code duplication, inlineMatcher creates auxiliary declarations _alt.. We can say the _alt. declarations are pre join points. For each auxiliary declaration used at an exit point of cases, this method creates an new auxiliary join point that invokes _alt., and then jumps to jpDecl. The goal is to make sure the auxiliary join point is the only occurrence of _alt., then simp will inline it. That is, our goal is to try to promote the pre join points _alt. into a proper join point.

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.
• Local context containing the original Lean types (not LCNF ones).

• Cache from Lean regular expression to LCNF argument.

• toLCNFType cache

typeCache :
• isTypeFormerType cache

isTypeFormerTypeCache :
• LCNF sequence, we chain it to create a LCNF Code object.

• Fields that are type formers must be replaced with ◾◾ in the resulting code. Otherwise, we have data occurring in types. When converting a casesOn into LCNF, we add constructor fields that are types and type formers into this set. See visitCases.

Instances For
@[inline]
Equations
@[inline]
Equations
• One or more equations did not get rendered due to their size.

Add LCNF element to the current sequence

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.

Create Code that executes the current seq and then returns result

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.
Equations
• One or more equations did not get rendered due to their size.

Create a new local declaration using a Lean regular type.

Equations
• One or more equations did not get rendered due to their size.
def Lean.Compiler.LCNF.ToLCNF.mkLetDecl (binderName : Lean.Name) (type : Lean.Expr) (value : Lean.Expr) (type' : Lean.Expr) (arg : Lean.Compiler.LCNF.Arg) :
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.
• = pure (ps, )
Equations
Equations
• One or more equations did not get rendered due to their size.
• = if (n == 0) = true then pure (ps, ) else pure (ps, )
Equations
• One or more equations did not get rendered due to their size.

Eta-expand with n lambdas.

Equations
• One or more equations did not get rendered due to their size.

Eta reduce implicits. We use this function to eliminate introduced by the implicit lambda feature, where it generates terms such as fun {α} => ReaderT.pure

Equations
• One or more equations did not get rendered due to their size.

Put the given expression in LCNF.

• Nested proofs are replaced with lcProof-applications.
• Eta-expand applications of declarations that satisfy shouldEtaExpand.
• Put computationally relevant expressions in A-normal form.
Equations

Giving f a constant .const declName us, convert args into args', and return .const declName us args'

Eta expand if under applied, otherwise apply k

If args.size == arity, then just return app. Otherwise return

let k := app
k args[arity:]

partial def Lean.Compiler.LCNF.ToLCNF.toLCNF.visitAlt (ctorName : Lean.Name) (numParams : Nat) (e : Lean.Expr) :

Visit a matcher/casesOn alternative.