Lean2Js.Denotes
What one Core.Expr claims about one ordinary Lean term #
The certificate a reifier assembles, and the rule it applies at each syntactic form. One lemma per form, each stated so that applying it is the whole of the step: the reifier pastes them together in the order its walk visited the term, and nothing it emits needs a tactic.
Fuel is universally quantified throughout. A declaration that calls another runs the callee on what is
left over, so a certificate stated at defaultFuel could not be cited across a call.
Lean2Js.Denote.Denotes
sourceWhat one subterm of the author's def claims about one Core.Expr: if the expression returns, it
returns the encoding of the term. Fuel is universally quantified because a call runs its callee on what
is left over.
Equations
- Lean2Js.Denote.Denotes p env e t = ∀ {f : Nat}, f ≤ Lean2Js.defaultFuel → ∀ (v : Lean2Js.Value), Lean2Js.evalExpr p f env e = Except.ok v → v = Lean2Js.Enc.toValue t
Instances For
Used by
Lean2Js.Denote.denotes_lit
sourceUsed by
Lean2Js.Denote.denotes_litBool
sourceUsed by
Lean2Js.Denote.denotes_litStr
sourceUsed by
Lean2Js.Denote.denotes_var
sourceUsed by
Lean2Js.Denote.denotes_add
sourceUsed by
Lean2Js.Denote.denotes_sub
sourceUsed by
Lean2Js.Denote.denotes_mul
sourceUsed by
Lean2Js.Denote.denotes_div
sourceUsed by
Lean2Js.Denote.denotes_mod
sourceUsed by
Comparison, and the branch it decides #
compareValues answers with an Ordering and the author writes a Prop, so each comparison form needs
the one lemma that lines the two up. They are stated about decide rather than the proposition because
that is what the condition of an if reifies to.
Lean2Js.Denote.denotes_lt
sourceUsed by
Lean2Js.Denote.denotes_le
sourceUsed by
Lean2Js.Denote.denotes_gt
sourceUsed by
Lean2Js.Denote.denotes_ge
sourceUsed by
Lean2Js.Denote.denotes_ite
sourceThe author writes a proposition and eval branches on a Value, so the condition is carried as
decide P and the two sides of the if are walked independently.
Used by
The forms that bind, and the one that crosses a call #
Lean2Js.Denote.denotes_neg
sourceUsed by
Lean2Js.Denote.denotes_abs
sourceUsed by
Lean2Js.Denote.denotes_toString
sourceUsed by
Lean2Js.Denote.denotes_range
sourceUsed by
Lean2Js.Denote.denotes_letE
sourceUsed by
Lean2Js.Denote.denotes_matchE_of
sourceOne arm of a match, once it is known which arm fires. Which one that is depends on the author's
value, so this carries the plumbing and deriving Enc generates the per-type lemma that does the case
analysis — the subset's matchPat is well-founded and does not reduce on its own.
Used by
Lean2Js.Denote.denotes_matchE_split
sourceThe case analysis a match is read by, stated over every value the scrutinee could take. The
splitter could be applied to the scrutinee directly, but its conclusion is the motive applied to what it
splits on, and a reifier that writes the motive out leaves the program and the environment in it as holes
under that binder: applied to the hole standing for the scrutinee they are not a pattern, and two
matches in one term solve each other's scrutinee instead of their own. Asking for h at every y
applies the motive to a bound variable, where each of those holes is solved on its own.
Used by
Lean2Js.Denote.matchPat_bind
sourceA pattern that only binds accepts any value and binds it. matchPat is well-founded and does not
reduce on its own, so the arms a fold is reified to — one per constructor, binding every field — are
read through this rather than by computation.
Used by
Lean2Js.Denote.matchPats_binds
sourceThe same for a whole row of them, which is what a fold's alternative is: the binds it makes are the constructor's field names against the rebuilt node's fields, in order.
Used by
Lean2Js.Denote.ne_of_missed
sourceWhat the matcher's splitter hands an arm about the arms before it, turned around. matchPat compares
the pattern's literal against the value, so a proof that an earlier arm missed needs the literal on the
left and the splitter states it on the right.
Used by
Lean2Js.Denote.denotes_decide_eq_true
sourceUsed by
Walking an array #
Each traversal evaluates its body once per element, at the same fuel the node itself ran at, so the element lemma is an induction over the list rather than a step in the walk.
Lean2Js.Denote.denotes_mapE
sourceUsed by
Lean2Js.Denote.sortPairs_toValue
sourceThe order the walk settles on is the one Arr.sortByKey names. KeyOrd.agrees is what lets the
comparison move from the author's key type to the encoded values, and KeyOrd.scalar is what says the
sort accepts the keys at all.
Used by
Lean2Js.Denote.denotes_sortByKeyE
sourceUsed by
Lean2Js.Denote.denotes_filterE
sourceUsed by
Lean2Js.Denote.denotes_findE
sourceUsed by
Lean2Js.Denote.denotes_allE
sourceUsed by
Lean2Js.Denote.denotes_anyE
sourceUsed by
Lean2Js.Denote.denotes_reduceE
sourceUsed by
The array itself #
The traversals walk an array; these are the forms that build one, take one apart, or measure it. Reading
past the end traps, which is what lets Arr.get be a total Lean function: the certificate claims nothing
in the case the subset refuses to answer in.
Lean2Js.Denote.DenotesItems
sourceThe elements of an array literal, against the list the author wrote. It is a list of terms of one
type where DenotesArgs is a list of Value: a call's arguments need not share a type and an array's
elements do.
Equations
- Lean2Js.Denote.DenotesItems p env [] [] = True
- Lean2Js.Denote.DenotesItems p env (e :: es) (x_2 :: xs) = (Lean2Js.Denote.Denotes p env e x_2 ∧ Lean2Js.Denote.DenotesItems p env es xs)
- Lean2Js.Denote.DenotesItems p env x✝¹ x✝ = False
Instances For
Used by
Lean2Js.Denote.denotesItems_nil
sourceUsed by
Lean2Js.Denote.denotesItems_cons
sourceUsed by
Lean2Js.Denote.denotes_arrayLit
sourceUsed by
Lean2Js.Denote.denotes_lengthArr
sourceUsed by
Lean2Js.Denote.denotes_index
sourceUsed by
Lean2Js.Denote.denotes_arraySlice
sourceUsed by
Lean2Js.Denote.denotes_arrayReverse
sourceUsed by
Lean2Js.Denote.denotes_concatArr
sourceUsed by
Strings #
A string is a list of code points on both sides — eval counts and slices String.toList, and the
generated code goes through Array.from to do the same. What differs is case folding and trimming, where
Lean's own functions are full Unicode and the subset's are not: the prelude names the subset's, and the
walk reads the prelude rather than String.trim.
Lean2Js.Denote.denotes_lengthStr
sourceUsed by
Lean2Js.Denote.denotes_concatStr
sourceUsed by
Lean2Js.Denote.denotes_trim
sourceUsed by
Lean2Js.Denote.denotes_upper
sourceUsed by
Lean2Js.Denote.denotes_toInt
sourceUsed by
Lean2Js.Denote.denotes_lower
sourceUsed by
Lean2Js.Denote.denotes_startsWith
sourceUsed by
Lean2Js.Denote.denotes_endsWith
sourceUsed by
Lean2Js.Denote.denotes_includes
sourceUsed by
Lean2Js.Denote.denotes_split
sourceUsed by
Lean2Js.Denote.denotes_indexOf
sourceUsed by
Lean2Js.Denote.denotes_repeat
sourceUsed by
Lean2Js.Denote.denotes_join
sourceUsed by
Lean2Js.Denote.denotes_substring
sourceUsed by
Ordering a String is by code point on both sides, but Lean states it as String.lt and eval
answers with an Ordering, so each comparison needs the lemma that lines the two up — the same shape the
Int comparisons take, over a different order.
Lean2Js.Denote.denotes_ltStr
sourceUsed by
Lean2Js.Denote.denotes_leStr
sourceUsed by
Lean2Js.Denote.denotes_gtStr
sourceUsed by
Lean2Js.Denote.denotes_geStr
sourceUsed by
Dictionaries #
The keys survive the encoding untouched and the values are encoded one by one, so every form below comes down to one equation between a list operation on the author's entries and the same operation on the encoded ones.
Lean2Js.Denote.denotes_dictGet
sourceUsed by
Lean2Js.Denote.denotes_dictHas
sourceUsed by
Lean2Js.Denote.denotes_dictSet
sourceUsed by
Lean2Js.Denote.denotes_dictDelete
sourceUsed by
Lean2Js.Denote.denotes_dictKeys
sourceUsed by
Lean2Js.Denote.denotes_dictValues
sourceUsed by
Lean2Js.Denote.denotes_lengthDict
sourceUsed by
The same seven over a Dict.Obj. Each proof is its Dict twin with one name substituted: the two
spellings encode to the same Value.dict, so what the evaluator does to a receiver does not depend on
which of them the author declared.
Lean2Js.Denote.denotes_dictObjGet
sourceUsed by
Lean2Js.Denote.denotes_dictObjHas
sourceUsed by
Lean2Js.Denote.denotes_dictObjSet
sourceUsed by
Lean2Js.Denote.denotes_dictObjDelete
sourceUsed by
Lean2Js.Denote.denotes_dictObjKeys
sourceUsed by
Lean2Js.Denote.denotes_dictObjValues
sourceUsed by
Lean2Js.Denote.denotes_lengthDictObj
sourceUsed by
Lean2Js.Denote.DenotesEntries
sourceThe entries of a dictionary literal. The keys are part of the form rather than evaluated, so what is walked is only the values, and the lemma carries the keys as an equation.
Equations
- Lean2Js.Denote.DenotesEntries p env [] [] = True
- Lean2Js.Denote.DenotesEntries p env ((k, e) :: es) ((k', x_2) :: xs) = (k = k' ∧ Lean2Js.Denote.Denotes p env e x_2 ∧ Lean2Js.Denote.DenotesEntries p env es xs)
- Lean2Js.Denote.DenotesEntries p env x✝¹ x✝ = False
Instances For
Used by
Lean2Js.Denote.denotesEntries_nil
sourceUsed by
Lean2Js.Denote.denotesEntries_cons
sourceUsed by
Lean2Js.Denote.denotes_dictLit
sourceUsed by
Lean2Js.Denote.denotes_dictObjLit
sourceThe twin at the other spelling. The value the two build is the same — Dict.Obj and Dict encode
alike — so only the flag the literal carries differs, and with it the type the compiler gives it.
Used by
UInt32 #
The integer that wraps where Int53 traps. Lean's UInt32 wraps at the same bound and divides the same
natural numbers, so an author writes the ordinary operators and no prelude function stands between — /
and % included, which is what separates this from Int53.
Lean2Js.Denote.denotes_addU32
sourceUsed by
Lean2Js.Denote.denotes_subU32
sourceUsed by
Lean2Js.Denote.denotes_mulU32
sourceUsed by
Lean2Js.Denote.denotes_divU32
sourceUsed by
Lean2Js.Denote.denotes_modU32
sourceUsed by
compareValues orders two UInt32s by toNat, and Lean orders them by the same, so each comparison
is the Nat one under a different name.
Lean2Js.Denote.denotes_ltU32
sourceUsed by
Lean2Js.Denote.denotes_leU32
sourceUsed by
Lean2Js.Denote.denotes_gtU32
sourceUsed by
Lean2Js.Denote.denotes_geU32
sourceUsed by
BigInt #
Int took the encoding into Int53, so the integer that need not fit in a JS number is a type of its
own. Nothing here traps on a bound — the only form that still refuses is a zero divisor.
Lean2Js.Denote.denotes_litBig
sourceUsed by
Lean2Js.Denote.denotes_addBig
sourceUsed by
Lean2Js.Denote.denotes_subBig
sourceUsed by
Lean2Js.Denote.denotes_mulBig
sourceUsed by
Lean2Js.Denote.denotes_divBig
sourceUsed by
Lean2Js.Denote.denotes_modBig
sourceUsed by
Lean2Js.Denote.denotes_negBig
sourceUsed by
Lean2Js.Denote.denotes_absBig
sourceUsed by
Lean2Js.Denote.denotes_ltBig
sourceUsed by
Lean2Js.Denote.denotes_leBig
sourceUsed by
Lean2Js.Denote.denotes_gtBig
sourceUsed by
Lean2Js.Denote.denotes_geBig
sourceUsed by
Equality, the short-circuiting connectives, and the two that pick a side #
&& and || do not go through applyBin at all: eval stops before the right operand when the left
one settles the answer, so each has a lemma of its own. Lean's && stops too, but for a different
reason — its right operand is a value, and there is nothing there to stop.
Lean2Js.Denote.denotes_eq
sourceUsed by
Lean2Js.Denote.denotes_ne
sourceUsed by
Lean2Js.Denote.denotes_and
sourceUsed by
Lean2Js.Denote.denotes_or
sourceUsed by
Lean2Js.Denote.denotes_min
sourceUsed by
Lean2Js.Denote.denotes_max
sourceUsed by
Lean2Js.Denote.denotes_minU32
sourceUsed by
Lean2Js.Denote.denotes_maxU32
sourceUsed by
Lean2Js.Denote.DenotesArgs
sourceThe arguments of a call, paired with the values the callee's certificate is stated about. It is a
list of Value rather than of encoded terms because a call's arguments need not share a type.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.Denote.DenotesArgs p env [] [] = True
- Lean2Js.Denote.DenotesArgs p env x✝¹ x✝ = False
Instances For
Used by
Lean2Js.Denote.denotesArgs_nil
sourceUsed by
Lean2Js.Denote.denotesArgs_cons
sourceUsed by
Lean2Js.Denote.denotes_call
sourceWhere one declaration's certificate cites another's. The callee runs on whatever fuel is left, which
is why Denotes quantifies over it: a certificate stated at defaultFuel could not be used here.
Used by
A function that crossed the boundary #
No Lean function value knows which declaration it is, so there is no Enc for one and a function-typed
argument is not a value the encoding carries. What crosses is the declaration's name, and what the
receiver has to be told about the name is what a certificate says about a declaration. That claim is the
hypothesis on the certificate of every declaration that takes a function.
Lean2Js.Denote.DenotesFn
sourceThe name a function-typed argument arrives as, together with what running it does.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.Denote.denotesFn_of
sourceUsed by
Lean2Js.Denote.denotesArgs_fnRef
sourcePassing one on. The argument evaluates to the name rather than to an encoding, so this is where
DenotesArgs stops being about Enc.
Used by
Lean2Js.Denote.denotes_callFn
sourceCalling one. The environment holds the name the caller passed, and calleeOf is what turns the
parameter's own name into it.
Used by
Making a value of the author's own type, and taking one apart #
Building one goes through the program: eval looks the type up to find the field names to pair the
arguments with, so a certificate that builds a value names the program the way a caller does. Reading a
field does not — the encoding of the value already carries the field, whatever program it came from.
Lean2Js.Denote.denotes_ctor
sourceUsed by
Lean2Js.Denote.denotes_proj
sourceUsed by
Option and Except #
Both have a form of their own rather than being constructors of a declared type, so neither goes through
the program. The side the term does not determine is carried as an annotation, which is why each lemma
takes a Ty it never looks at.
Lean2Js.Denote.denotes_noneE
sourceUsed by
Lean2Js.Denote.denotes_someE
sourceUsed by
Lean2Js.Denote.denotes_okE
sourceUsed by
Lean2Js.Denote.denotes_errorE
sourceUsed by
Walking a value of a type that names itself #
A fold evaluates its scrutinee and then walks it, and the walk is on the value rather than on the
expression, so the step that reads it cannot be one lemma: T.fold is written per type and so is the
theorem that the subset's walk computes it. This is everything around that theorem, which is what
deriving Enc generates and hands over as hw. denotes_mapE's twin, with the walk abstracted where
that one has evalMapItems_denotes.