Lean2Js.Renderable
That the compiler only builds modules the reader takes back #
That the module compileProgram builds is one the reader in Parse takes back.
Roundtrip proves parseModule (render m) = some m for every m its RenderableModule accepts. What
that leaves open is whether the compiler ever builds a module outside it. It does not, and this file is
the argument: every name the compiler writes went through validateIdent or starts with the reserved
prefix, every operator it writes is one of a handful it spells itself, and the doc comment is built from
names and type renderings, none of which contain a *.
No * reaches the doc comment #
A doc comment goes into /** */ unescaped, so Renderable asks it not to spell */. The doc is built
from names and type renderings, and neither can contain a * at all, which is the stronger and much
shorter thing to prove.
Lean2Js.Compile.noStar
sourceInstances For
Used by
Lean2Js.Compile.noStar_append
sourceUsed by
Lean2Js.Compile.noCommentClose_of_all_ne_star
sourceUsed by
Lean2Js.Compile.noCommentClose_of_noStar
sourceUsed by
Lean2Js.Compile.ne_star_of_isIdentPart
sourceUsed by
Lean2Js.Compile.noStar_of_okName
sourceUsed by
Type renderings carry no * #
A type renders as keywords, punctuation and the names of the types it mentions. wfTy has already found
every one of those names in p.types, and validateType has already put every one of those through
validateIdent, so the whole rendering is made of identifier characters and the separators between them.
The scope is empty wherever a declaration's types are checked, so Ty.var never survives to be rendered
and a type parameter's name never has to be accounted for.
Lean2Js.Compile.TypeNamesOk
sourceEvery type the program declares is named by an identifier.
Equations
- Lean2Js.Compile.TypeNamesOk p = ∀ (t : Lean2Js.Core.TypeDef), t ∈ p.types → Lean2Js.okName t.name = true
Instances For
Used by
Lean2Js.Compile.typeNamesOk_of_validated
sourceUsed by
Lean2Js.Compile.okName_of_findType
sourceUsed by
Lean2Js.Compile.noStar_render
sourceUsed by
Lean2Js.Compile.noStar_renderArgs
sourceUsed by
Lean2Js.Compile.noStar_renderParamsRest
sourceUsed by
Lean2Js.Compile.noStar_renderParams
sourceUsed by
Lean2Js.Compile.noStar_render_of_wfParamTy
sourceUsed by
Lean2Js.Compile.noStar_declSigRest
sourceUsed by
Lean2Js.Compile.noStar_declSig
sourceUsed by
Names the compiler writes #
Renderable asks a name to be an identifier, and a name in callee position to be none of the ten the
reader gives a meaning of its own. A user's name went through validateIdent, which rejects both the
__ prefix and the JavaScript keywords, and those two rejections between them cover all ten.
Lean2Js.Compile.okCallee_of_validateIdent
sourceUsed by
Lean2Js.Compile.okCallee_bodyName
sourceThe name a declaration's body is compiled under is a callee the reader takes back: it is spelled as
an identifier, and none of the names the reader gives a meaning of its own carries _ where the body
prefix does.
Used by
What the compiler is holding while it builds an expression #
The names in scope and the names of the declarations are the only two places a compiled expression can
pick a name up from that is not one the compiler spells itself. Both went through validateIdent.
Lean2Js.Compile.CtxOk
sourceEquations
- Lean2Js.Compile.CtxOk ctx = ∀ (x : String × Lean2Js.Core.Ty), x ∈ ctx → Lean2Js.Parse.okCallee x.fst = true
Instances For
Used by
Lean2Js.Compile.DeclNamesOk
sourceEquations
- Lean2Js.Compile.DeclNamesOk p = ∀ (d : Lean2Js.Core.Decl), d ∈ p.decls → Lean2Js.Parse.okCallee d.name = true
Instances For
Used by
Lean2Js.Compile.FieldNamesOk
sourceField names reach the generated code through .field and through the paths a pattern reads, so a
match and a projection both need them to be identifiers.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Compile.ArmOk
sourceOne lowered match arm the reader can take back: the tests it runs, the names it binds, the paths it
reads them from and the body under them.
Equations
Instances For
Used by
Lean2Js.Compile.renderableList_append
sourceUsed by
Lean2Js.Compile.renderableList_nil
sourceUsed by
Lean2Js.Compile.renderablePairs_nil
sourceUsed by
Lean2Js.Compile.renderableList_of_all
sourceUsed by
Lean2Js.Compile.renderablePairs_zip
sourceUsed by
Lean2Js.Compile.renderable_objOf
sourceUsed by
The lowered match #
chain conjoins an arm's tests with && and nests the arms into conditionals, and apply wraps an
arm's body in an arrow when it binds anything. Both build only shapes the reader has.
Lean2Js.Compile.renderable_foldl_and
sourceUsed by
Lean2Js.Compile.renderable_apply
sourceUsed by
Lean2Js.Compile.renderable_chain
sourceUsed by
Patterns #
A pattern lowers to tests over paths into the scrutinee. The paths are built by reading fields, so the
field names a signature reports have to be identifiers; the declared ones went through validateType
and the built-in ones are value and error.
Lean2Js.Compile.okName_of_signature
sourceUsed by
Lean2Js.Compile.BindsOk
sourceWhat a pattern's bindings have to be for the arm built from them to be readable back: a name the reader can read, bound to a path it can read.
Equations
- Lean2Js.Compile.BindsOk binds = binds.all fun (b : String × Lean2Js.Js.Expr × Lean2Js.Core.Ty) => Lean2Js.Parse.okCallee b.fst && Lean2Js.Parse.RenderableExpr b.snd.fst
Instances For
Used by
Lean2Js.Compile.renderable_litJs
sourceUsed by
Lean2Js.Compile.renderable_patParts
sourceUsed by
Building readable expressions #
One lemma per shape the compiler builds, so that the case analysis over compileExpr reads as the shape
it emits rather than as an unfolding of RenderableExpr.
Lean2Js.Compile.renderableList_cons
sourceUsed by
Lean2Js.Compile.renderable_num
sourceUsed by
Lean2Js.Compile.renderable_bigLit
sourceUsed by
Lean2Js.Compile.renderable_str
sourceUsed by
Lean2Js.Compile.renderable_bool
sourceUsed by
Lean2Js.Compile.renderable_ident
sourceUsed by
Lean2Js.Compile.renderable_unary
sourceUsed by
Lean2Js.Compile.renderable_binary
sourceUsed by
Lean2Js.Compile.renderable_cond
sourceUsed by
Lean2Js.Compile.renderable_call
sourceUsed by
Lean2Js.Compile.renderable_arrowCall
sourceUsed by
Lean2Js.Compile.renderable_member
sourceUsed by
Lean2Js.Compile.renderable_arrayLit
sourceUsed by
Lean2Js.Compile.renderable_dictLit
sourceUsed by
Lean2Js.Compile.renderable_mapJs
sourceUsed by
Lean2Js.Compile.renderable_filterJs
sourceUsed by
Lean2Js.Compile.renderable_sortByJs
sourceUsed by
Lean2Js.Compile.renderable_findJs
sourceUsed by
Lean2Js.Compile.renderable_quantJs
sourceUsed by
Lean2Js.Compile.renderable_reduceJs
sourceUsed by
Lean2Js.Compile.renderable_check
sourceUsed by
Lean2Js.Compile.renderable_out
sourceUsed by
Lean2Js.Compile.renderable_foldJs
sourceA fold's call is readable back where its scrutinee and its arm chain are. The key it indexes by and
the spec it hands __fold are read off the declared type rather than written by an author, and the
reader takes both back from the text without a name of its own.
Used by
Lean2Js.Compile.renderable_retWalk
sourceThe entry's walk out is renderable either way: where it emits nothing the expression is the call itself, and where it emits the walk it is the call inside one more form.
Used by
Lean2Js.Compile.okCallee_of_ctx
sourceUsed by
Lean2Js.Compile.okCallee_of_decl
sourceUsed by
Lean2Js.Compile.okName_of_okCallee
sourceUsed by
Lean2Js.Compile.ctxOk_cons
sourceUsed by
Lean2Js.Compile.ctxOk_append
sourceUsed by
Lean2Js.Compile.okCallee_of_decl_name
sourceUsed by
Lean2Js.Compile.renderable_numericHelper
sourceUsed by
Lean2Js.Compile.okOp_of_orderSymbol
sourceUsed by
Lean2Js.Compile.okCallee_strUnHelper
sourceUsed by
Lean2Js.Compile.okCallee_strBinHelper
sourceUsed by
Lean2Js.Compile.okName_of_ctorsAt
sourceUsed by
Lean2Js.Compile.okName_of_proj
sourceThe name a field read writes after the dot is the name of a field the type declares, and
validateType has already put that through validateIdent.
Used by
Lean2Js.Compile.renderablePairs_cons
sourceUsed by
Lean2Js.Compile.renderable_foldPatParts
sourceA fold's alternative reads the paths a match's reads. Only the types its binders carry move — a
field that came round is bound to the answer for it — and a type is not something the reader sees.
Used by
Every expression the compiler builds #
The recursion is compileExpr's own: the names it picks up come from the scope and from the declarations,
the operators and callees it writes it spells itself, and everything else is one of its subexpressions.
Lean2Js.Compile.renderable_compiled
sourceUsed by
The statements a declaration's body becomes #
The entry's consts bind the declared names to the raw __p0, __p1, … it was called with, and the
body's are the lets lined up at its head. Both are names the reader takes back: the declared ones went
through validateIdent and the raw ones are the compiler's own.
Lean2Js.Compile.isDigit_digitChar
sourceUsed by
Lean2Js.Compile.toDigitsCore_all_digit
sourceUsed by
Lean2Js.Compile.repr_all_digit
sourceNat.repr is a wall to a proof that wants to read its characters back, but not to one that only
wants to know they are digits.
Used by
Lean2Js.Compile.okCallee_rawParam
sourceUsed by
Lean2Js.Compile.rawParams_all_okName
sourceUsed by
Lean2Js.Compile.ctxOk_of_params
sourceUsed by
Lean2Js.Compile.renderable_compileFinish
sourceUsed by
Lean2Js.Compile.renderable_compileBody
sourceUsed by
Lean2Js.Compile.renderable_paramChecks
sourceUsed by
The declaration and the program #
Lean2Js.Compile.fieldNamesOk_of_validated
sourceUsed by
Lean2Js.Compile.renderable_paramIdents
sourceUsed by
Lean2Js.Compile.paramNames_all_okName
sourceUsed by
Lean2Js.Compile.renderableFunc_of_compileDecl
sourceUsed by
Lean2Js.Compile.declNames_of_compileDecls
sourceUsed by
Lean2Js.Compile.renderable_compileDecls
sourceUsed by
Lean2Js.Compile.renderableModule_of_compileProgram
sourceNothing the compiler builds falls outside what the reader takes back. Renderable names the trees
render does not separate, and this says the compiler never writes one: the names it emits are the ones
validateIdent accepted or the ones it spells itself, and its operators and callees are a fixed handful
that the reader does not dispatch on.
Used by
Lean2Js.Compile.parseModule_render_of_compileProgram
sourceThe file the compiler writes reads back as the module it was compiled from. No side condition is
left: the roundtrip holds of everything compileProgram produces.