Return true
if e
is a lcProof
application.
Recall that we use lcProof
to erase all nested proofs.
Equations
- Lean.Compiler.LCNF.ToLCNF.isLCProof e = Lean.Expr.isAppOfArity e `lcProof 1
Create the temporary lcProof
Equations
- Lean.Compiler.LCNF.ToLCNF.mkLcProof p = Lean.mkApp (Lean.mkConst `lcProof) p
- jp: Lean.Compiler.LCNF.FunDecl → Lean.Compiler.LCNF.ToLCNF.Element
- fun: Lean.Compiler.LCNF.FunDecl → Lean.Compiler.LCNF.ToLCNF.Element
- let: Lean.Compiler.LCNF.LetDecl → Lean.Compiler.LCNF.ToLCNF.Element
- cases: Lean.Compiler.LCNF.Param → Lean.Compiler.LCNF.Cases → Lean.Compiler.LCNF.ToLCNF.Element
- unreach: Lean.Compiler.LCNF.Param → Lean.Compiler.LCNF.ToLCNF.Element
Auxiliary inductive datatype for constructing LCNF Code
objects.
The toLCNF
function maintains a sequence of elements that is eventually
converted into Code
.
Instances For
Equations
- Lean.Compiler.LCNF.ToLCNF.instInhabitedElement = { default := Lean.Compiler.LCNF.ToLCNF.Element.jp default }
State for BindCasesM
monad
Mapping from _alt.
variables to new join points
Auxiliary monad for implementing bindCases
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).
lctx : Lean.LocalContextCache from Lean regular expression to LCNF argument.
toLCNFType
cachetypeCache : Lean.HashMap Lean.Expr Lean.ExprisTypeFormerType cache
isTypeFormerTypeCache : Lean.HashMap Lean.Expr BoolLCNF 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 acasesOn
into LCNF, we add constructor fields that are types and type formers into this set. SeevisitCases
.toAny : Lean.FVarIdSet
Instances For
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.
Equations
- Lean.Compiler.LCNF.ToLCNF.letValueToArg e prefixName = do let __do_lift ← Lean.Compiler.LCNF.ToLCNF.mkAuxLetDecl e prefixName pure (Lean.Compiler.LCNF.Arg.fvar __do_lift)
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.
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.
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
- Lean.Compiler.LCNF.toLCNF e = Lean.Compiler.LCNF.ToLCNF.run do let __do_lift ← Lean.Compiler.LCNF.ToLCNF.toLCNF.visit e Lean.Compiler.LCNF.ToLCNF.toCode __do_lift
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:]
Visit a matcher
/casesOn
alternative.