Lean2Js.HelperProof
What each runtime helper computes, read off the tree the printer writes #
What each runtime helper computes, read off the tree the printer writes rather than assumed.
The claims are stated at f + k rather than "for all f at least k" because the evaluator spends one
fuel per node: an offset reduces where an inequality would have to be transported first. Eventually
below turns one into the other.
Lean2Js.HelperSem.bindEq
sourceUsed by
Lean2Js.HelperSem.bind_stuck
sourceUsed by
Lean2Js.HelperSem.bind_thrown
sourceUsed by
Lean2Js.HelperSem.bind_ok
sourceUsed by
Lean2Js.HelperSem.ofRes
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.eventually_of_offset
sourceUsed by
Lean2Js.HelperSem.ofJs_num
sourceUsed by
Lean2Js.HelperSem.ofJs_bigint
sourceUsed by
Lean2Js.HelperSem.ofJs_str
sourceUsed by
Lean2Js.HelperSem.ofJs_bool
sourceUsed by
Lean2Js.HelperSem.ofRes_ok
sourceUsed by
Lean2Js.HelperSem.ofRes_error
sourceUsed by
Lean2Js.HelperSem.applyVal_ext
sourceApplying a function the caller supplied. walk reduces this rather than applyVal itself, so that a
call to a closure — which is what __has hands __all and __find — stays folded until a lemma about
that closure is available.
Used by
Lean2Js.HelperSem.applyVal_lam
sourceUsed by
Lean2Js.HelperSem.tacticWalk
sourceWalks the evaluator down a concrete tree. Everything it unfolds is either the evaluator itself or a table the evaluator consults; nothing about a helper's meaning is in here.
Equations
- Lean2Js.HelperSem.tacticWalk = Lean.ParserDescr.node `Lean2Js.HelperSem.tacticWalk 1024 (Lean.ParserDescr.nonReservedSymbol "walk" false)
Instances For
Used by
Lean2Js.HelperSem.callDef_expr
sourceUsed by
Lean2Js.HelperSem.callDef_block
sourceUsed by
Arithmetic #
Each theorem says what the helper computes, in plain Lean, with no hypothesis about its arguments.
Relating that to what JsSem.helper says is a separate step: the model range-checks a quotient the
helper does not, and the two meet only on the numbers the generated code can actually produce.
Lean2Js.HelperSem.find_fail
sourceUsed by
Lean2Js.HelperSem.find_i53
sourceUsed by
Lean2Js.HelperSem.find_i53div
sourceUsed by
Lean2Js.HelperSem.find_i53mod
sourceUsed by
Lean2Js.HelperSem.find_u32mul
sourceUsed by
Lean2Js.HelperSem.find_u32div
sourceUsed by
Lean2Js.HelperSem.find_u32mod
sourceUsed by
Lean2Js.HelperSem.find_bigdiv
sourceUsed by
Lean2Js.HelperSem.find_bigmod
sourceUsed by
Lean2Js.HelperSem.find_abs
sourceUsed by
Lean2Js.HelperSem.find_min
sourceUsed by
Lean2Js.HelperSem.find_max
sourceUsed by
Lean2Js.HelperSem.calls_fail
sourceUsed by
Lean2Js.HelperSem.calls_i53
sourceUsed by
Lean2Js.HelperSem.calls_i53div
sourceUsed by
Lean2Js.HelperSem.calls_u32div
sourceUsed by
Lean2Js.HelperSem.calls_u32mod
sourceUsed by
Lean2Js.HelperSem.calls_bigdiv
sourceUsed by
Lean2Js.HelperSem.calls_bigmod
sourceUsed by
Lean2Js.HelperSem.calls_i53mod
sourceUsed by
Lean2Js.HelperSem.calls_u32mul
sourceUsed by
Lean2Js.HelperSem.calls_abs_num
sourceUsed by
Lean2Js.HelperSem.calls_abs_big
sourceUsed by
Lean2Js.HelperSem.calls_min_num
sourceUsed by
Lean2Js.HelperSem.calls_min_big
sourceUsed by
Lean2Js.HelperSem.calls_max_num
sourceUsed by
Lean2Js.HelperSem.calls_max_big
sourceUsed by
Strings, arrays and dictionaries without a loop #
Lean2Js.HelperSem.find_chars
sourceUsed by
Lean2Js.HelperSem.find_cp
sourceUsed by
Lean2Js.HelperSem.find_strlen
sourceUsed by
Lean2Js.HelperSem.find_ws
sourceUsed by
Lean2Js.HelperSem.find_startsWith
sourceUsed by
Lean2Js.HelperSem.find_endsWith
sourceUsed by
Lean2Js.HelperSem.find_includes
sourceUsed by
Lean2Js.HelperSem.find_split
sourceUsed by
Lean2Js.HelperSem.find_substring
sourceUsed by
Lean2Js.HelperSem.find_aslice
sourceUsed by
Lean2Js.HelperSem.find_atIdx
sourceUsed by
Lean2Js.HelperSem.find_dget
sourceUsed by
Lean2Js.HelperSem.find_dhas
sourceUsed by
Lean2Js.HelperSem.find_dset
sourceUsed by
Lean2Js.HelperSem.find_dkeys
sourceUsed by
Lean2Js.HelperSem.find_dvalues
sourceUsed by
Lean2Js.HelperSem.find_isObj
sourceUsed by
Lean2Js.HelperSem.calls_chars
sourceUsed by
Lean2Js.HelperSem.calls_cp
sourceUsed by
Lean2Js.HelperSem.find_str
sourceUsed by
Lean2Js.HelperSem.calls_str
sourceUsed by
Lean2Js.HelperSem.find_toInt
sourceUsed by
Lean2Js.HelperSem.toInt_loop
sourceUsed by
Lean2Js.HelperSem.slice1
sourceUsed by
Lean2Js.HelperSem.calls_toInt
sourceUsed by
Lean2Js.HelperSem.calls_strlen
sourceUsed by
Lean2Js.HelperSem.calls_ws
sourceUsed by
Lean2Js.HelperSem.calls_startsWith
sourceUsed by
Lean2Js.HelperSem.calls_endsWith
sourceUsed by
Lean2Js.HelperSem.calls_includes
sourceUsed by
Lean2Js.HelperSem.calls_split
sourceUsed by
Lean2Js.HelperSem.calls_dhas
sourceUsed by
Lean2Js.HelperSem.calls_dkeys
sourceUsed by
Lean2Js.HelperSem.calls_dvalues
sourceUsed by
Lean2Js.HelperSem.calls_dget
sourceUsed by
Lean2Js.HelperSem.calls_dset
sourceUsed by
Lean2Js.HelperSem.calls_isObj
sourceUsed by
Loops #
A loop's fuel is one per element plus a constant, so a claim about a forOf is stated at
f + xs.length + k and proved by induction on the list. The environment is written out rather than left
generic: restore reads every name the enclosing scope binds, and only a concrete list of names lets it
reduce.
Lean2Js.HelperSem.find_aconcat
sourceUsed by
Lean2Js.HelperSem.find_areverse
sourceUsed by
Lean2Js.HelperSem.find_lead
sourceUsed by
Lean2Js.HelperSem.aconcat_loop
sourceUsed by
Lean2Js.HelperSem.calls_aconcat
sourceUsed by
Lean2Js.HelperSem.areverse_loop
sourceThe loop reads xs[i - 1] while iterating over xs itself, so the induction runs on a second list
that only carries the count still to go, and ys.length ≤ xs.length is what keeps that index in range.
Used by
Lean2Js.HelperSem.calls_areverse
sourceUsed by
Lean2Js.HelperSem.isSpaceStr
sourceThe four strings __ws accepts. __lead counts them off the front of an array of strings; that the
array is one string per code point is what __chars supplies, and calls_trim is where the two meet.
Instances For
Used by
Lean2Js.HelperSem.lead_loop
sourceUsed by
Lean2Js.HelperSem.calls_lead
sourceUsed by
Lean2Js.HelperSem.compare_singleton
sourceUsed by
Lean2Js.HelperSem.cmp_char_ge
sourceUsed by
Lean2Js.HelperSem.cmp_char_le
sourceUsed by
Lean2Js.HelperSem.append_ofList_cons
sourceUsed by
Lean2Js.HelperSem.find_upper
sourceUsed by
Lean2Js.HelperSem.upper_loop
sourceUsed by
Lean2Js.HelperSem.calls_upper
sourceUsed by
Lean2Js.HelperSem.find_lower
sourceUsed by
Lean2Js.HelperSem.lower_loop
sourceUsed by
Lean2Js.HelperSem.calls_lower
sourceUsed by
Indices and slices #
The guard each of these writes out is what stands between the model's index and slice — both of
which have a shape they decline to answer for — and the answer the helper returns.
Lean2Js.HelperSem.calls_atIdx
sourceUsed by
Lean2Js.HelperSem.calls_aslice
sourceUsed by
Lean2Js.HelperSem.ofList_cons
sourceUsed by
Lean2Js.HelperSem.joinStrs_chars
sourceUsed by
Lean2Js.HelperSem.calls_substring
sourceUsed by
Lean2Js.HelperSem.find_startsAt
sourceUsed by
Lean2Js.HelperSem.find_indexOf
sourceUsed by
Lean2Js.HelperSem.find_join
sourceUsed by
Lean2Js.HelperSem.calls_startsAt
sourceUsed by
Lean2Js.HelperSem.scanSteps
sourceHow far the loop in __indexOf walks: to the first position the needle sits at, or off the end.
Equations
- Lean2Js.HelperSem.scanSteps t [] = 0
- Lean2Js.HelperSem.scanSteps t (c :: rest) = if t.isPrefixOf (c :: rest) = true then 0 else Lean2Js.HelperSem.scanSteps t rest + 1
Instances For
Used by
Lean2Js.HelperSem.strIndexOfChars_eq
sourceUsed by
Lean2Js.HelperSem.dropTake1
sourceUsed by
Lean2Js.HelperSem.indexOf_loop
sourceUsed by
Lean2Js.HelperSem.calls_indexOf
sourceUsed by
Lean2Js.HelperSem.join_loop
sourceUsed by
Lean2Js.HelperSem.calls_join
sourceUsed by
Lean2Js.HelperSem.find_rep
sourceUsed by
Lean2Js.HelperSem.find_repeat
sourceUsed by
Lean2Js.HelperSem.calls_rep
sourceUsed by
Lean2Js.HelperSem.find_range
sourceUsed by
Lean2Js.HelperSem.range_loop
sourceThe loop keeps no counter of its own: it pushes the length the array has reached, so the element it adds is the index it is at. That is why the induction runs on the accumulator as well as on what is left to walk, and why the numbers start where the accumulator ends rather than at zero.
Used by
Lean2Js.HelperSem.calls_range
sourceUsed by
Lean2Js.HelperSem.calls_repeat
sourceUsed by
Lean2Js.HelperSem.strcmp_loop
sourceUsed by
Lean2Js.HelperSem.find_strcmp
sourceUsed by
Lean2Js.HelperSem.calls_strcmp
sourceUsed by
Deleting a key #
The loop is stated as the foldl it runs, with no hypothesis about the dictionary. That it agrees with
dropping the key — JsSem's filter — needs the keys to be distinct, which is a fact about the values
the generated code hands over rather than about this helper, so it is a separate lemma.
Lean2Js.HelperSem.find_ddelete
sourceUsed by
Lean2Js.HelperSem.dropStep
sourceEquations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.HelperSem.ddelete_loop
sourceUsed by
Lean2Js.HelperSem.calls_ddelete
sourceUsed by
Lean2Js.HelperSem.ddelete_fold
sourceUsed by
Lean2Js.HelperSem.calls_ddelete_distinct
sourceWhat JsSem.helper says, for the dictionaries a Map can actually hold.
Used by
Trimming #
__trim slices between two counts, where strTrim drops from both ends. The two agree, and the only
place they could come apart is a string that is whitespace throughout: there the slice is empty because
its bounds cross, not because the counts line up, so the proof splits that case off first.
Lean2Js.HelperSem.find_trim
sourceUsed by
Lean2Js.HelperSem.calls_lead_chars
sourceUsed by
Lean2Js.HelperSem.calls_trim
sourceUsed by
Traversals #
The callback is ext, so what these compute is stated as a walk of the list that calls it once per
element and stops at the first thrown. That is the shape JsSem's evalMapJs and its siblings
already have, which is what lets the two be put side by side.
Lean2Js.HelperSem.find_map
sourceUsed by
Lean2Js.HelperSem.extMap
sourceEquations
- Lean2Js.HelperSem.extMap ext i [] = Lean2Js.HelperSem.Res.ok []
- Lean2Js.HelperSem.extMap ext i (x_1 :: rest) = do let v ← ext i [x_1] let vs ← Lean2Js.HelperSem.extMap ext i rest Lean2Js.HelperSem.Res.ok (v :: vs)
Instances For
Used by
Lean2Js.HelperSem.map_loop
sourceUsed by
Lean2Js.HelperSem.calls_map
sourceUsed by
Lean2Js.HelperSem.find_filter
sourceUsed by
Lean2Js.HelperSem.extFilter
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.extFilter ext i [] = Lean2Js.HelperSem.Res.ok []
Instances For
Used by
Lean2Js.HelperSem.filter_loop
sourceUsed by
Lean2Js.HelperSem.calls_filter
sourceUsed by
Lean2Js.HelperSem.find_find
sourceUsed by
Lean2Js.HelperSem.find_all
sourceUsed by
Lean2Js.HelperSem.find_any
sourceUsed by
Lean2Js.HelperSem.find_reduce
sourceUsed by
Callbacks #
__all and __find take a function value. The generated code hands them a function it defined, and
__has hands them a closure of its own; the loops below are stated for either, with the fuel a sum over
the elements rather than a length, because a closure that recurses does not cost a constant.
Lean2Js.HelperSem.valAll
sourceThe walk __all performs: the function value is applied to each element, and the first false stops
it. An answer that is not a boolean is a shape the model declines to read.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.valAll P [] = Lean2Js.HelperSem.Res.ok true
Instances For
Used by
Lean2Js.HelperSem.valFind
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.valFind P [] = Lean2Js.HelperSem.Res.ok none
Instances For
Used by
Lean2Js.HelperSem.sumCost
sourceOne element's fuel, plus one for the step.
Equations
- Lean2Js.HelperSem.sumCost cost [] = 0
- Lean2Js.HelperSem.sumCost cost (x_1 :: rest) = cost x_1 + Lean2Js.HelperSem.sumCost cost rest + 1
Instances For
Used by
Lean2Js.HelperSem.Answers
sourceWhat a loop needs of the function value it was handed: on the elements it will actually see, past its
cost there, applying it answers P. An inequality rather than an offset, because the loop applies it with
whatever fuel it has left; restricted to the list because the closure __has builds only answers for
values smaller than the one it was called on.
Equations
- Lean2Js.HelperSem.Answers ext F P cost xs = ∀ (v : Lean2Js.HelperSem.Val), v ∈ xs → ∀ (g : Nat), cost v < g → Lean2Js.HelperSem.applyVal ext g F [v] = P v
Instances For
Used by
Lean2Js.HelperSem.extAll
sourceEquations
- Lean2Js.HelperSem.extAll ext i = Lean2Js.HelperSem.valAll fun (v : Lean2Js.HelperSem.Val) => ext i [v]
Instances For
Used by
Lean2Js.HelperSem.extFind
sourceEquations
- Lean2Js.HelperSem.extFind ext i = Lean2Js.HelperSem.valFind fun (v : Lean2Js.HelperSem.Val) => ext i [v]
Instances For
Used by
Lean2Js.HelperSem.answers_ext
sourceUsed by
Lean2Js.HelperSem.sumCost_zero
sourceUsed by
Lean2Js.HelperSem.find_loop
sourceUsed by
Lean2Js.HelperSem.all_loop
sourceUsed by
Lean2Js.HelperSem.calls_find_gen
sourceUsed by
Lean2Js.HelperSem.calls_all_gen
sourceUsed by
Lean2Js.HelperSem.calls_find
sourceUsed by
Lean2Js.HelperSem.calls_all
sourceUsed by
Lean2Js.HelperSem.extAny
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.extAny ext i [] = Lean2Js.HelperSem.Res.ok false
Instances For
Used by
Lean2Js.HelperSem.any_loop
sourceUsed by
Lean2Js.HelperSem.calls_any
sourceUsed by
Lean2Js.HelperSem.extReduce
sourceEquations
- Lean2Js.HelperSem.extReduce ext i x✝ [] = Lean2Js.HelperSem.Res.ok x✝
- Lean2Js.HelperSem.extReduce ext i x✝ (x_2 :: rest) = (ext i [x✝, x_2]).bind fun (r : Lean2Js.HelperSem.Val) => Lean2Js.HelperSem.extReduce ext i r rest
Instances For
Used by
Lean2Js.HelperSem.reduce_loop
sourceUsed by
Lean2Js.HelperSem.calls_reduce
sourceUsed by
The sort #
__sortBy pairs every element with its key, orders the pairs and reads the elements back out, so the
three helpers under it are proved in that order: the comparison of two keys, the merge of two ordered
runs, and the split that feeds it.
Compares is what keeps a call away from the one case __keyle has no answer for. A number and a
string compared together would reach __strcmp on a number; the key type the compiler insists on is
what says the keys of one call are all numbers or all strings, and this is where that arrives.
Lean2Js.HelperSem.find_keyle
sourceUsed by
Lean2Js.HelperSem.find_merge
sourceUsed by
Lean2Js.HelperSem.find_msort
sourceUsed by
Lean2Js.HelperSem.find_sortBy
sourceUsed by
Lean2Js.HelperSem.valLe
sourceThe order __keyle puts two keys in.
Equations
Instances For
Used by
Lean2Js.HelperSem.compare_ne_gt
sourceUsed by
Lean2Js.HelperSem.compare_strcmp
sourceUsed by
Lean2Js.HelperSem.calls_keyle_num
sourceUsed by
Lean2Js.HelperSem.calls_keyle_str
sourceUsed by
Lean2Js.HelperSem.keyOf
sourceThe key a pair carries. __sortBy builds every pair, so the shape is always [key, element].
Equations
Instances For
Used by
Lean2Js.HelperSem.pairLe
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.Compares
sourceWhat __merge and __msort need of the pairs they are handed: past a cost of its own, __keyle
answers valLe on any two of their keys.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.HelperSem.mergeCost
sourceEquations
- Lean2Js.HelperSem.mergeCost kcost [] = 3
- Lean2Js.HelperSem.mergeCost kcost (x_1 :: rest) = Lean2Js.HelperSem.mergeCost kcost rest + kcost + 12
Instances For
Used by
Lean2Js.HelperSem.IsPair
sourceEvery value the sort moves is a pair __sortBy built.
Equations
Instances For
Used by
Lean2Js.HelperSem.index_pair
sourceUsed by
Lean2Js.HelperSem.index_get
sourceUsed by
Lean2Js.HelperSem.compare_nat_lt
sourceUsed by
Lean2Js.HelperSem.compare_nat_self
sourceUsed by
Lean2Js.HelperSem.at_nat
sourceUsed by
Lean2Js.HelperSem.merge_loop
sourceUsed by
Lean2Js.HelperSem.calls_merge
sourceUsed by
Lean2Js.HelperSem.compare_gt_one
sourceUsed by
Lean2Js.HelperSem.half_cast
sourceUsed by
Lean2Js.HelperSem.mergeSort_split
sourceUsed by
Lean2Js.HelperSem.calls_msort_small
sourceUsed by
Lean2Js.HelperSem.calls_msort
sourceUsed by
Lean2Js.HelperSem.elemOf
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.pairsOf
sourceThe pairs __sortBy builds: each key in front of the element it was worked out from.
Equations
- Lean2Js.HelperSem.pairsOf (k :: ks) (x_2 :: xs) = Lean2Js.HelperSem.Val.arr [k, x_2] :: Lean2Js.HelperSem.pairsOf ks xs
- Lean2Js.HelperSem.pairsOf x✝¹ x✝ = []
Instances For
Used by
Lean2Js.HelperSem.mem_pairsOf
sourceUsed by
Lean2Js.HelperSem.isPair_pairsOf
sourceUsed by
Lean2Js.HelperSem.elemOf_pairsOf
sourceUsed by
Lean2Js.HelperSem.pairs_loop
sourceUsed by
Lean2Js.HelperSem.elems_loop
sourceUsed by
Lean2Js.HelperSem.isNumV
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.isStrV
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.strLens
sourceOne cost for every comparison of one call, taken over all the keys at once: __strcmp walks the
left string, and a bound that holds of each key separately is what the loop needs.
Equations
- Lean2Js.HelperSem.strLens [] = 0
- Lean2Js.HelperSem.strLens (Lean2Js.HelperSem.Val.str s :: rest) = s.toList.length + Lean2Js.HelperSem.strLens rest
- Lean2Js.HelperSem.strLens (x_1 :: rest) = 0 + Lean2Js.HelperSem.strLens rest
Instances For
Used by
Lean2Js.HelperSem.strLens_mem
sourceUsed by
Lean2Js.HelperSem.compares_num
sourceUsed by
Lean2Js.HelperSem.compares_str
sourceUsed by
Lean2Js.HelperSem.calls_sortBy
sourceUsed by
Lean2Js.HelperSem.pairsOf_eq_zip
sourceUsed by
Lean2Js.HelperSem.sortBy_answer
sourceWhat __sortBy answers, read in the shape the model of the generated code assumes: the pairs of key
and element, ordered by key, with the elements read back out.
Used by
Lean2Js.HelperSem.valLe_ofJs
sourceThe order the helpers put two keys in is the order JsSem assumes. Stated for every pair of values
rather than for the keys of one call: neither side orders anything but two numbers or two strings.
Used by
Structural equality #
__eq decides a notion of its own, stated below as eqVal, not JsValue.beq. Two divergences, both
real and both about values the compiler can produce:
- objects are walked key by key with
Object.hasOwn, so{a:1,b:2}and{b:2,a:1}are equal here and unequal underbeq, which compares the field lists in order; - functions never reach the structural path —
typeofsays"function", not"object"— so the helper answersfalsewherebeqcompares the names.
Dictionaries, unlike objects, are compared positionally: the loop checks __dkeys(b)[i] against
the key it is on. Both walks look their values up by key in both operands, so the recursion is on
lookupV, which is not structurally smaller — hence the well-founded definitions, and the fuel a
call needs is a function of the values rather than a constant.
Lean2Js.HelperSem.sizeOf_lookupV
sourceUsed by
Lean2Js.HelperSem.sizeOf_lookupV_pair
sourceUsed by
Lean2Js.HelperSem.eqVal
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.eqVal (Lean2Js.HelperSem.Val.arr xs) (Lean2Js.HelperSem.Val.arr ys) = (xs.length == ys.length && Lean2Js.HelperSem.eqList xs ys)
- Lean2Js.HelperSem.eqVal x✝¹ x✝ = Lean2Js.HelperSem.strictEq x✝¹ x✝
Instances For
Used by
Lean2Js.HelperSem.eqList
sourceEquations
- Lean2Js.HelperSem.eqList [] x✝ = true
- Lean2Js.HelperSem.eqList (head :: tail) [] = false
- Lean2Js.HelperSem.eqList (x_2 :: xs) (y :: ys) = (Lean2Js.HelperSem.eqVal x_2 y && Lean2Js.HelperSem.eqList xs ys)
Instances For
Used by
Lean2Js.HelperSem.eqKeys
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.eqObj
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.eqObj es fs [] = true
Instances For
Used by
Lean2Js.HelperSem.eqFuel
sourceEquations
- Lean2Js.HelperSem.eqFuel (Lean2Js.HelperSem.Val.dict es) (Lean2Js.HelperSem.Val.dict fs) = Lean2Js.HelperSem.eqFuelKeys es fs (List.map (fun (x : String × Lean2Js.HelperSem.Val) => x.fst) es) + 32
- Lean2Js.HelperSem.eqFuel (Lean2Js.HelperSem.Val.arr xs) (Lean2Js.HelperSem.Val.arr ys) = Lean2Js.HelperSem.eqFuelList xs ys + 32
- Lean2Js.HelperSem.eqFuel (Lean2Js.HelperSem.Val.obj es) (Lean2Js.HelperSem.Val.obj fs) = Lean2Js.HelperSem.eqFuelKeys es fs (List.map (fun (x : String × Lean2Js.HelperSem.Val) => x.fst) es) + 32
- Lean2Js.HelperSem.eqFuel x✝¹ x✝ = 16
Instances For
Used by
Lean2Js.HelperSem.eqFuelList
sourceEquations
- Lean2Js.HelperSem.eqFuelList [] x✝ = 0
- Lean2Js.HelperSem.eqFuelList (head :: tail) [] = 0
- Lean2Js.HelperSem.eqFuelList (x_2 :: xs) (y :: ys) = Lean2Js.HelperSem.eqFuel x_2 y + 8 + Lean2Js.HelperSem.eqFuelList xs ys
Instances For
Used by
Lean2Js.HelperSem.eqFuelKeys
sourceEquations
- Lean2Js.HelperSem.eqFuelKeys es fs [] = 0
- Lean2Js.HelperSem.eqFuelKeys es fs (k :: ks) = Lean2Js.HelperSem.eqFuel (Lean2Js.HelperSem.lookupV es k) (Lean2Js.HelperSem.lookupV fs k) + 8 + Lean2Js.HelperSem.eqFuelKeys es fs ks
Instances For
Used by
Lean2Js.HelperSem.eq_dict_loop
sourceUsed by
Lean2Js.HelperSem.eq_arr_loop
sourceUsed by
Lean2Js.HelperSem.eq_obj_loop
sourceUsed by
Lean2Js.HelperSem.find_eq
sourceUsed by
Lean2Js.HelperSem.calls_eq
sourceUsed by
Lean2Js.HelperSem.sizeOf_lookupV_lt
sourceUsed by
Entry checks #
Lean2Js.HelperSem.tyVal
sourceThe value the descriptor the compiler renders denotes. Js.TyDesc.render writes the text; that the
text reads back to this value is the parser's question, not this one.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.tyVal Lean2Js.Js.TyDesc.bool = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "bool"]
- Lean2Js.HelperSem.tyVal Lean2Js.Js.TyDesc.int53 = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "int53"]
- Lean2Js.HelperSem.tyVal Lean2Js.Js.TyDesc.uint32 = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "uint32"]
- Lean2Js.HelperSem.tyVal Lean2Js.Js.TyDesc.string = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "string"]
- Lean2Js.HelperSem.tyVal Lean2Js.Js.TyDesc.bigint = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "bigint"]
- Lean2Js.HelperSem.tyVal t.option = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "option", Lean2Js.HelperSem.tyVal t]
- Lean2Js.HelperSem.tyVal (ok.result err) = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "result", Lean2Js.HelperSem.tyVal ok, Lean2Js.HelperSem.tyVal err]
- Lean2Js.HelperSem.tyVal t.array = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "array", Lean2Js.HelperSem.tyVal t]
- Lean2Js.HelperSem.tyVal t.dict = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "dict", Lean2Js.HelperSem.tyVal t]
- Lean2Js.HelperSem.tyVal t.dictObj = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "dictObj", Lean2Js.HelperSem.tyVal t]
- Lean2Js.HelperSem.tyVal (Lean2Js.Js.TyDesc.ref up) = Lean2Js.HelperSem.Val.arr [Lean2Js.HelperSem.Val.str "ref", Lean2Js.HelperSem.Val.num ↑up]
Instances For
Used by
Lean2Js.HelperSem.tyValFields
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.tyValAlts
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.envVals
sourceOne entry per mu the walk is inside, nearest first, holding what that node bound.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.HelperSem.envVal
sourceThe array those entries reach the helpers as.
Equations
Instances For
Used by
Lean2Js.HelperSem.envVals_cons
sourceUsed by
Lean2Js.HelperSem.envVals_length
sourceUsed by
Lean2Js.HelperSem.envVals_drop
sourceUsed by
Lean2Js.HelperSem.envVals_getElem?
sourceUsed by
Lean2Js.HelperSem.hasV
sourceWhat __has decides. An object's field is read by name, with lookupV, exactly as Js.checkTy
reads it; has_checkTy below is where the two meet.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.bool b) Lean2Js.Js.TyDesc.bool = true
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.num i) Lean2Js.Js.TyDesc.int53 = (decide (Lean2Js.Js.Runtime.safeMin ≤ i) && decide (i ≤ Lean2Js.Js.Runtime.safeMax))
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.num i) Lean2Js.Js.TyDesc.uint32 = (decide (0 ≤ i) && decide (i ≤ 4294967295))
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.str s) Lean2Js.Js.TyDesc.string = true
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.bigint i) Lean2Js.Js.TyDesc.bigint = true
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.arr xs) t.array = Lean2Js.HelperSem.hasList env xs t
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.dict es) t.dict = Lean2Js.HelperSem.hasEntries env es t
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.obj es) t.dictObj = Lean2Js.HelperSem.hasEntries env es t
- Lean2Js.HelperSem.hasV env (Lean2Js.HelperSem.Val.dict es) t.dictObj = Lean2Js.HelperSem.hasEntries env es t
- Lean2Js.HelperSem.hasV env x✝ (Lean2Js.Js.TyDesc.mu key alts) = Lean2Js.HelperSem.hasV ((key, alts) :: env) x✝ (Lean2Js.Js.TyDesc.ctors key alts)
- Lean2Js.HelperSem.hasV env x✝ (Lean2Js.Js.TyDesc.ref up) = match env[up]? with | some b => Lean2Js.HelperSem.hasV (List.drop up env) x✝ (Lean2Js.Js.TyDesc.ctors b.fst b.snd) | none => false
- Lean2Js.HelperSem.hasV env x✝¹ x✝ = false
Instances For
Used by
Lean2Js.HelperSem.hasList
sourceEquations
- Lean2Js.HelperSem.hasList env [] x✝ = true
- Lean2Js.HelperSem.hasList env (x_2 :: rest) x✝ = (Lean2Js.HelperSem.hasV env x_2 x✝ && Lean2Js.HelperSem.hasList env rest x✝)
Instances For
Used by
Lean2Js.HelperSem.hasEntries
sourceEquations
- Lean2Js.HelperSem.hasEntries env [] x✝ = true
- Lean2Js.HelperSem.hasEntries env ((fst, v) :: rest) x✝ = (Lean2Js.HelperSem.hasV env v x✝ && Lean2Js.HelperSem.hasEntries env rest x✝)
Instances For
Used by
Lean2Js.HelperSem.hasFields
source__hasFields asks the object for each declared field by name. A key the descriptor does not name is
never looked at, which is how an object carrying more than the type declares still passes.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.hasFields env es [] = true
Instances For
Used by
Lean2Js.HelperSem.hasFuel
sourceEnough fuel for __has, by the same recursion as hasV. A generous constant per level: the claims
are stated for every larger amount, so an upper bound is all a proof needs.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.arr xs) t.array = Lean2Js.HelperSem.hasFuelList env xs t + 66
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.dict es) t.dict = Lean2Js.HelperSem.hasFuelEntries env es t + 4 * es.length + 66
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.obj es) t.dictObj = Lean2Js.HelperSem.hasFuelEntries env es t + 66
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.dict es) t.dictObj = Lean2Js.HelperSem.hasFuelEntries env es t + 66
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.obj es) t.option = Lean2Js.HelperSem.hasFuelFields env es [("value", t)] + 66
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.obj es) (ok.result err) = Lean2Js.HelperSem.hasFuelFields env es [("value", ok)] + Lean2Js.HelperSem.hasFuelFields env es [("error", err)] + 66
- Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.Val.obj es) (Lean2Js.Js.TyDesc.ctors key alts) = Lean2Js.HelperSem.hasFuelAlts env es alts + 5 * alts.length + 66
- Lean2Js.HelperSem.hasFuel env x✝ (Lean2Js.Js.TyDesc.ctors key alts) = 5 * alts.length + 66
- Lean2Js.HelperSem.hasFuel env x✝ (Lean2Js.Js.TyDesc.mu key alts) = Lean2Js.HelperSem.hasFuel ((key, alts) :: env) x✝ (Lean2Js.Js.TyDesc.ctors key alts) + 2 * List.length env + 200
- Lean2Js.HelperSem.hasFuel env x✝¹ x✝ = 66
Instances For
Used by
Lean2Js.HelperSem.hasFuelList
sourceEquations
- Lean2Js.HelperSem.hasFuelList env [] x✝ = 0
- Lean2Js.HelperSem.hasFuelList env (x_2 :: rest) x✝ = Lean2Js.HelperSem.hasFuel env x_2 x✝ + Lean2Js.HelperSem.hasFuelList env rest x✝ + 8
Instances For
Used by
Lean2Js.HelperSem.hasFuelEntries
sourceEquations
- Lean2Js.HelperSem.hasFuelEntries env [] x✝ = 0
- Lean2Js.HelperSem.hasFuelEntries env ((fst, v) :: rest) x✝ = Lean2Js.HelperSem.hasFuel env v x✝ + Lean2Js.HelperSem.hasFuelEntries env rest x✝ + 8
Instances For
Used by
Lean2Js.HelperSem.hasFuelAlts
sourceEquations
- Lean2Js.HelperSem.hasFuelAlts env es [] = 0
- Lean2Js.HelperSem.hasFuelAlts env es ((c, fields) :: rest) = Lean2Js.HelperSem.hasFuelFields env es fields + Lean2Js.HelperSem.hasFuelAlts env es rest + 8
Instances For
Used by
Lean2Js.HelperSem.hasFuelFields
sourceEquations
- Lean2Js.HelperSem.hasFuelFields env es [] = 0
- Lean2Js.HelperSem.hasFuelFields env es ((n, d) :: rest) = Lean2Js.HelperSem.hasFuel env (Lean2Js.HelperSem.lookupV es n) d + Lean2Js.HelperSem.hasFuelFields env es rest + 16
Instances For
Used by
Reading the object path off the tree #
Lean2Js.HelperSem.find_has
sourceUsed by
Lean2Js.HelperSem.find_hasFields
sourceUsed by
Lean2Js.HelperSem.find_ck
sourceUsed by
Lean2Js.HelperSem.tyValFields_length
sourceUsed by
Lean2Js.HelperSem.getElem?_eq_head?_drop
sourceUsed by
Lean2Js.HelperSem.hasFields_loop
sourceUsed by
Lean2Js.HelperSem.calls_hasFields
sourceUsed by
Stepping the dispatch #
__has is a chain of if (k === "…") guards. walk would normalise every guard below the one that
fires — simp rewrites a subterm before it reduces the match that made it unreachable — and on a body
this size that is the whole cost of the proof. The two lemmas below step the chain by rewriting instead,
so a branch pays only for itself.
Lean2Js.HelperSem.evalStmts_const
sourceUsed by
Lean2Js.HelperSem.has_skip
sourceUsed by
Lean2Js.HelperSem.has_take
sourceUsed by
Lean2Js.HelperSem.cmp_int_ge
sourceUsed by
Lean2Js.HelperSem.cmp_int_le
sourceUsed by
Lean2Js.HelperSem.headName
sourceThe head the compiler renders for a descriptor: what __has dispatches on.
Equations
- Lean2Js.HelperSem.headName Lean2Js.Js.TyDesc.bool = "bool"
- Lean2Js.HelperSem.headName Lean2Js.Js.TyDesc.int53 = "int53"
- Lean2Js.HelperSem.headName Lean2Js.Js.TyDesc.uint32 = "uint32"
- Lean2Js.HelperSem.headName Lean2Js.Js.TyDesc.string = "string"
- Lean2Js.HelperSem.headName Lean2Js.Js.TyDesc.bigint = "bigint"
- Lean2Js.HelperSem.headName t.array = "array"
- Lean2Js.HelperSem.headName value.dict = "dict"
- Lean2Js.HelperSem.headName value.dictObj = "dictObj"
- Lean2Js.HelperSem.headName t.option = "option"
- Lean2Js.HelperSem.headName (ok.result err) = "result"
- Lean2Js.HelperSem.headName (Lean2Js.Js.TyDesc.ctors key alts) = "ctors"
- Lean2Js.HelperSem.headName (Lean2Js.Js.TyDesc.mu key alts) = "mu"
- Lean2Js.HelperSem.headName (Lean2Js.Js.TyDesc.ref up) = "ref"
Instances For
Used by
Lean2Js.HelperSem.has_head
sourceUsed by
Lean2Js.HelperSem.lookup_k
sourceUsed by
Lean2Js.HelperSem.sumCost_hasFuelList
sourceUsed by
Lean2Js.HelperSem.valAll_hasList
sourceUsed by
Lean2Js.HelperSem.answers_element
sourceThe closure __has hands to __all: it asks __has about the element, at the descriptor sitting
one along from the one it is checking. Its cost is not a constant — the call recurses — so the loop is
given a cost per element rather than a length.
Used by
Lean2Js.HelperSem.hasEntries_eq
sourceUsed by
Lean2Js.HelperSem.hasFuelEntries_eq
sourceUsed by
Lean2Js.HelperSem.answers_keyString
sourceThe other closure __has builds: the one that reads a dictionary's keys back as strings. It is
vacuous on the model's side — __dkeys yields .str — but the helper still walks it.
Used by
Lean2Js.HelperSem.sumCost_three
sourceUsed by
Lean2Js.HelperSem.sumCost_four
sourceUsed by
Lean2Js.HelperSem.valAll_keyString
sourceUsed by
Lean2Js.HelperSem.sizeOf_snd_mem
sourceUsed by
Lean2Js.HelperSem.altVal
sourceOne rendered constructor: its name and its fields.
Equations
Instances For
Used by
Lean2Js.HelperSem.tyValAlts_eq
sourceUsed by
Lean2Js.HelperSem.altMatch
sourceWhat the closure __has hands __find computes: the alternative's name against the object's tag.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.HelperSem.valFind_alts
sourceUsed by
Lean2Js.HelperSem.find_alts_notStr
sourceNo alternative matches a key the value does not carry as a string — which is what a Map answers,
since the key a declared type is told apart by is never one of a Map's own.
Used by
Lean2Js.HelperSem.dict_index_notStr
sourceWhat indexing a Map with a declared type's key answers: never a string, whatever the key is, so
no alternative can match it.
Used by
Lean2Js.HelperSem.answers_alt
sourceUsed by
Lean2Js.HelperSem.hasFuelFields_le_alts
sourceUsed by
Lean2Js.HelperSem.drop_take_all
sourceEverything slice(k, length) leaves behind.
Used by
Lean2Js.HelperSem.calls_has
sourceWhat __has decides, for every value and every descriptor the compiler renders.
Used by
Lean2Js.HelperSem.find_norm
sourceUsed by
Lean2Js.HelperSem.find_normFields
sourceUsed by
Lean2Js.HelperSem.normV
sourceWhat __norm builds. The tag keeps the slot the object handed it; the constructor's fields follow in
the order the descriptor names them, and a name the object does not carry is dropped.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.normV tenv (Lean2Js.HelperSem.Val.arr xs) t.array = Lean2Js.HelperSem.Val.arr (Lean2Js.HelperSem.normVList tenv xs t)
- Lean2Js.HelperSem.normV tenv (Lean2Js.HelperSem.Val.dict es) t.dict = Lean2Js.HelperSem.Val.dict (Lean2Js.HelperSem.normVEntries tenv es t)
- Lean2Js.HelperSem.normV tenv (Lean2Js.HelperSem.Val.obj es) t.dictObj = Lean2Js.HelperSem.Val.dict (Lean2Js.HelperSem.mapSetAll [] (Lean2Js.HelperSem.normVEntries tenv es t))
- Lean2Js.HelperSem.normV tenv (Lean2Js.HelperSem.Val.dict es) t.dictObj = Lean2Js.HelperSem.Val.dict (Lean2Js.HelperSem.normVEntries tenv es t)
- Lean2Js.HelperSem.normV tenv x✝ (Lean2Js.Js.TyDesc.mu key alts) = Lean2Js.HelperSem.normV ((key, alts) :: tenv) x✝ (Lean2Js.Js.TyDesc.ctors key alts)
- Lean2Js.HelperSem.normV tenv x✝ (Lean2Js.Js.TyDesc.ref up) = match tenv[up]? with | some b => Lean2Js.HelperSem.normV (List.drop up tenv) x✝ (Lean2Js.Js.TyDesc.ctors b.fst b.snd) | none => x✝
- Lean2Js.HelperSem.normV tenv x✝¹ x✝ = x✝¹
Instances For
Used by
Lean2Js.HelperSem.normVList
sourceEquations
- Lean2Js.HelperSem.normVList tenv [] x✝ = []
- Lean2Js.HelperSem.normVList tenv (x_2 :: rest) x✝ = Lean2Js.HelperSem.normV tenv x_2 x✝ :: Lean2Js.HelperSem.normVList tenv rest x✝
Instances For
Used by
Lean2Js.HelperSem.normVEntries
sourceEquations
- Lean2Js.HelperSem.normVEntries tenv [] x✝ = []
- Lean2Js.HelperSem.normVEntries tenv ((fst, v) :: rest) x✝ = (fst, Lean2Js.HelperSem.normV tenv v x✝) :: Lean2Js.HelperSem.normVEntries tenv rest x✝
Instances For
Used by
Lean2Js.HelperSem.normVFields
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.normFuel
sourceEnough fuel for __norm, by the same recursion as normV and for the reason hasFuel is generous:
the claims are stated for every larger amount.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.Val.arr xs) t.array = Lean2Js.HelperSem.normFuelList tenv xs t + 4 * xs.length + 66
- Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.Val.dict es) t.dict = Lean2Js.HelperSem.normFuelEntries tenv es t + 8 * es.length + 66
- Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.Val.obj es) t.dictObj = Lean2Js.HelperSem.normFuelEntries tenv es t + 8 * es.length + 66
- Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.Val.dict es) t.dictObj = Lean2Js.HelperSem.normFuelEntries tenv es t + 8 * es.length + 66
- Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.Val.obj es) t.option = Lean2Js.HelperSem.normFuelFields tenv es [("value", t)] + 66
- Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.Val.obj es) (Lean2Js.Js.TyDesc.ctors key alts) = Lean2Js.HelperSem.normFuelAlts tenv es alts + 5 * alts.length + 66
- Lean2Js.HelperSem.normFuel tenv x✝ (Lean2Js.Js.TyDesc.ctors key alts) = 5 * alts.length + 66
- Lean2Js.HelperSem.normFuel tenv x✝ (Lean2Js.Js.TyDesc.mu key alts) = Lean2Js.HelperSem.normFuel ((key, alts) :: tenv) x✝ (Lean2Js.Js.TyDesc.ctors key alts) + 2 * List.length tenv + 200
- Lean2Js.HelperSem.normFuel tenv x✝¹ x✝ = 66
Instances For
Used by
Lean2Js.HelperSem.normFuelList
sourceEquations
- Lean2Js.HelperSem.normFuelList tenv [] x✝ = 0
- Lean2Js.HelperSem.normFuelList tenv (x_2 :: rest) x✝ = Lean2Js.HelperSem.normFuel tenv x_2 x✝ + Lean2Js.HelperSem.normFuelList tenv rest x✝ + 8
Instances For
Used by
Lean2Js.HelperSem.normFuelEntries
sourceEquations
- Lean2Js.HelperSem.normFuelEntries tenv [] x✝ = 0
- Lean2Js.HelperSem.normFuelEntries tenv ((fst, v) :: rest) x✝ = Lean2Js.HelperSem.normFuel tenv v x✝ + Lean2Js.HelperSem.normFuelEntries tenv rest x✝ + 8
Instances For
Used by
Lean2Js.HelperSem.normFuelAlts
sourceEquations
- Lean2Js.HelperSem.normFuelAlts tenv es [] = 0
- Lean2Js.HelperSem.normFuelAlts tenv es ((c, fields) :: rest) = Lean2Js.HelperSem.normFuelFields tenv es fields + Lean2Js.HelperSem.normFuelAlts tenv es rest + 8
Instances For
Used by
Lean2Js.HelperSem.normFuelFields
sourceEquations
- Lean2Js.HelperSem.normFuelFields tenv es [] = 0
- Lean2Js.HelperSem.normFuelFields tenv es ((n, d) :: rest) = Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.lookupV es n) d + Lean2Js.HelperSem.normFuelFields tenv es rest + 16
Instances For
Used by
Lean2Js.HelperSem.normPairs
sourceThe pairs __normFields pushes, in the order it pushes them.
Equations
Instances For
Used by
Lean2Js.HelperSem.fromPairs_normPairs
sourceObject.fromEntries over what the loop pushed. It appends rather than replaces because the names are
distinct and none of them is the tag the accumulator already carries.
Used by
Lean2Js.HelperSem.normFields_loop
sourceUsed by
Lean2Js.HelperSem.calls_normFields
sourceUsed by
Lean2Js.HelperSem.normArray_loop
sourceUsed by
Lean2Js.HelperSem.keysDistinctV
sourceWhat no Map can hold: the same key twice. Js.dictKeysDistinct says this of a JsValue; the
source semantics needs it of the Val the helper is handed, because __norm rebuilds a dictionary by
walking its keys.
Equations
Instances For
Used by
Lean2Js.HelperSem.mapsOk
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.mapsOk (Lean2Js.HelperSem.Val.obj es) = Lean2Js.HelperSem.mapsOkFields es
- Lean2Js.HelperSem.mapsOk (Lean2Js.HelperSem.Val.arr xs) = Lean2Js.HelperSem.mapsOkList xs
- Lean2Js.HelperSem.mapsOk x✝ = true
Instances For
Used by
Lean2Js.HelperSem.mapsOkFields
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.mapsOkList
sourceEquations
- Lean2Js.HelperSem.mapsOkList [] = true
- Lean2Js.HelperSem.mapsOkList (x_1 :: rest) = (Lean2Js.HelperSem.mapsOk x_1 && Lean2Js.HelperSem.mapsOkList rest)
Instances For
Used by
Lean2Js.HelperSem.normSet
sourceWhat the dictionary loop leaves in out: each key set, in the order __dkeys hands them over.
Equations
- Lean2Js.HelperSem.normSet tenv es t x✝ [] = x✝
- Lean2Js.HelperSem.normSet tenv es t x✝ (k :: ks) = Lean2Js.HelperSem.normSet tenv es t (Lean2Js.HelperSem.mapSet x✝ k (Lean2Js.HelperSem.normV tenv (Lean2Js.HelperSem.lookupV es k) t)) ks
Instances For
Used by
Lean2Js.HelperSem.normFuelKeys
sourceEquations
- Lean2Js.HelperSem.normFuelKeys tenv es t [] = 0
- Lean2Js.HelperSem.normFuelKeys tenv es t (k :: ks) = Lean2Js.HelperSem.normFuel tenv (Lean2Js.HelperSem.lookupV es k) t + Lean2Js.HelperSem.normFuelKeys tenv es t ks + 12
Instances For
Used by
Lean2Js.HelperSem.normVEntries_keys
sourceUsed by
Lean2Js.HelperSem.mapSetAll_normVEntries
sourceUsed by
Lean2Js.HelperSem.normDictObj_loop
sourceUsed by
Lean2Js.HelperSem.normDict_loop
sourceUsed by
Lean2Js.HelperSem.mapsOkList_mem
sourceUsed by
Lean2Js.HelperSem.mapsOkFields_mem
sourceUsed by
Lean2Js.HelperSem.mapsOk_lookupV
sourceUsed by
Lean2Js.HelperSem.hasList_mem
sourceUsed by
Lean2Js.HelperSem.hasEntries_mem
sourceUsed by
Lean2Js.HelperSem.lookupV_skipV
sourceUsed by
Lean2Js.HelperSem.keysDistinctV_append
sourceUsed by
Lean2Js.HelperSem.normSet_split
sourceWalking a dictionary's keys and looking each one up hands back the entries in order, because a Map
cannot carry the same key twice.
Used by
Lean2Js.HelperSem.normFuelKeys_split
sourceUsed by
Lean2Js.HelperSem.lookupV_mem
sourceUsed by
Lean2Js.HelperSem.mapsOk_lookupV'
sourceUsed by
Lean2Js.HelperSem.hasFields_field
sourceUsed by
Lean2Js.HelperSem.altsOk_findV
sourceUsed by
Lean2Js.HelperSem.normFuelFields_le_alts
sourceUsed by
Lean2Js.HelperSem.fieldsOk_mem
sourceUsed by
Lean2Js.HelperSem.lookup_k_norm
sourceUsed by
Lean2Js.HelperSem.normV_scalar
sourceUsed by
Lean2Js.HelperSem.calls_norm
sourceWhat __norm builds, for every value the entry check accepts and every descriptor the compiler
renders.
Used by
Lean2Js.HelperSem.envVal_nil
sourceUsed by
Lean2Js.HelperSem.calls_ck
source__ck is __has with a throw: what the check accepts comes back rebuilt in the shape the
descriptor names, and what it refuses raises typeError. The environment it starts at is empty.
Used by
The walk back out #
__out is __norm read the other way, and so is everything below: the same recursion, the same fuel
arithmetic, the same branch-by-branch proof. The one node they disagree at is the one the helper exists
for — a dictionary declared to cross as a plain object leaves as one, where __norm on the way in made
the Map the body ran on. Nothing here calls __out yet; what it is here to say is that the JavaScript
Helper.out writes out is the walk Js.outTy describes.
Lean2Js.HelperSem.find_out
sourceUsed by
Lean2Js.HelperSem.find_outFields
sourceUsed by
Lean2Js.HelperSem.outV
sourceWhat __out builds. The tag keeps the slot the object handed it; the constructor's fields follow in
the order the descriptor names them, and a name the object does not carry is dropped.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.outV tenv (Lean2Js.HelperSem.Val.arr xs) t.array = Lean2Js.HelperSem.Val.arr (Lean2Js.HelperSem.outVList tenv xs t)
- Lean2Js.HelperSem.outV tenv (Lean2Js.HelperSem.Val.dict es) t.dict = Lean2Js.HelperSem.Val.dict (Lean2Js.HelperSem.outVEntries tenv es t)
- Lean2Js.HelperSem.outV tenv (Lean2Js.HelperSem.Val.dict es) t.dictObj = Lean2Js.HelperSem.Val.obj (Lean2Js.HelperSem.outVEntries tenv es t)
- Lean2Js.HelperSem.outV tenv x✝ (Lean2Js.Js.TyDesc.mu key alts) = Lean2Js.HelperSem.outV ((key, alts) :: tenv) x✝ (Lean2Js.Js.TyDesc.ctors key alts)
- Lean2Js.HelperSem.outV tenv x✝ (Lean2Js.Js.TyDesc.ref up) = match tenv[up]? with | some b => Lean2Js.HelperSem.outV (List.drop up tenv) x✝ (Lean2Js.Js.TyDesc.ctors b.fst b.snd) | none => x✝
- Lean2Js.HelperSem.outV tenv x✝¹ x✝ = x✝¹
Instances For
Used by
Lean2Js.HelperSem.outVList
sourceEquations
- Lean2Js.HelperSem.outVList tenv [] x✝ = []
- Lean2Js.HelperSem.outVList tenv (x_2 :: rest) x✝ = Lean2Js.HelperSem.outV tenv x_2 x✝ :: Lean2Js.HelperSem.outVList tenv rest x✝
Instances For
Used by
Lean2Js.HelperSem.outVEntries
sourceEquations
- Lean2Js.HelperSem.outVEntries tenv [] x✝ = []
- Lean2Js.HelperSem.outVEntries tenv ((fst, v) :: rest) x✝ = (fst, Lean2Js.HelperSem.outV tenv v x✝) :: Lean2Js.HelperSem.outVEntries tenv rest x✝
Instances For
Used by
Lean2Js.HelperSem.outVFields
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.outFuel
sourceEnough fuel for __out, by the same recursion as outV and for the reason hasFuel is generous:
the claims are stated for every larger amount.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.Val.arr xs) t.array = Lean2Js.HelperSem.outFuelList tenv xs t + 4 * xs.length + 66
- Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.Val.dict es) t.dict = Lean2Js.HelperSem.outFuelEntries tenv es t + 8 * es.length + 66
- Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.Val.dict es) t.dictObj = Lean2Js.HelperSem.outFuelEntries tenv es t + 8 * es.length + 66
- Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.Val.obj es) t.option = Lean2Js.HelperSem.outFuelFields tenv es [("value", t)] + 66
- Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.Val.obj es) (Lean2Js.Js.TyDesc.ctors key alts) = Lean2Js.HelperSem.outFuelAlts tenv es alts + 5 * alts.length + 66
- Lean2Js.HelperSem.outFuel tenv x✝ (Lean2Js.Js.TyDesc.ctors key alts) = 5 * alts.length + 66
- Lean2Js.HelperSem.outFuel tenv x✝ (Lean2Js.Js.TyDesc.mu key alts) = Lean2Js.HelperSem.outFuel ((key, alts) :: tenv) x✝ (Lean2Js.Js.TyDesc.ctors key alts) + 2 * List.length tenv + 200
- Lean2Js.HelperSem.outFuel tenv x✝¹ x✝ = 66
Instances For
Used by
Lean2Js.HelperSem.outFuelList
sourceEquations
- Lean2Js.HelperSem.outFuelList tenv [] x✝ = 0
- Lean2Js.HelperSem.outFuelList tenv (x_2 :: rest) x✝ = Lean2Js.HelperSem.outFuel tenv x_2 x✝ + Lean2Js.HelperSem.outFuelList tenv rest x✝ + 8
Instances For
Used by
Lean2Js.HelperSem.outFuelEntries
sourceEquations
- Lean2Js.HelperSem.outFuelEntries tenv [] x✝ = 0
- Lean2Js.HelperSem.outFuelEntries tenv ((fst, v) :: rest) x✝ = Lean2Js.HelperSem.outFuel tenv v x✝ + Lean2Js.HelperSem.outFuelEntries tenv rest x✝ + 8
Instances For
Used by
Lean2Js.HelperSem.outFuelAlts
sourceEquations
- Lean2Js.HelperSem.outFuelAlts tenv es [] = 0
- Lean2Js.HelperSem.outFuelAlts tenv es ((c, fields) :: rest) = Lean2Js.HelperSem.outFuelFields tenv es fields + Lean2Js.HelperSem.outFuelAlts tenv es rest + 8
Instances For
Used by
Lean2Js.HelperSem.outFuelFields
sourceEquations
- Lean2Js.HelperSem.outFuelFields tenv es [] = 0
- Lean2Js.HelperSem.outFuelFields tenv es ((n, d) :: rest) = Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.lookupV es n) d + Lean2Js.HelperSem.outFuelFields tenv es rest + 16
Instances For
Used by
Lean2Js.HelperSem.outPairs
sourceThe pairs __outFields pushes, in the order it pushes them.
Equations
Instances For
Used by
Lean2Js.HelperSem.fromPairs_outPairs
sourceObject.fromEntries over what the loop pushed. It appends rather than replaces because the names are
distinct and none of them is the tag the accumulator already carries.
Used by
Lean2Js.HelperSem.outFields_loop
sourceUsed by
Lean2Js.HelperSem.calls_outFields
sourceUsed by
Lean2Js.HelperSem.outArray_loop
sourceUsed by
Lean2Js.HelperSem.outSet
sourceWhat the dictionary loop leaves in out: each key set, in the order __dkeys hands them over.
Equations
- Lean2Js.HelperSem.outSet tenv es t x✝ [] = x✝
- Lean2Js.HelperSem.outSet tenv es t x✝ (k :: ks) = Lean2Js.HelperSem.outSet tenv es t (Lean2Js.HelperSem.mapSet x✝ k (Lean2Js.HelperSem.outV tenv (Lean2Js.HelperSem.lookupV es k) t)) ks
Instances For
Used by
Lean2Js.HelperSem.outFuelKeys
sourceEquations
- Lean2Js.HelperSem.outFuelKeys tenv es t [] = 0
- Lean2Js.HelperSem.outFuelKeys tenv es t (k :: ks) = Lean2Js.HelperSem.outFuel tenv (Lean2Js.HelperSem.lookupV es k) t + Lean2Js.HelperSem.outFuelKeys tenv es t ks + 12
Instances For
Used by
Lean2Js.HelperSem.outVEntries_keys
sourceUsed by
Lean2Js.HelperSem.outEntryPairs
sourceThe pairs __out pushes for a dictionary leaving as a plain object, in the order the Map's
iterator hands them over.
Equations
Instances For
Used by
Lean2Js.HelperSem.fromPairs_outEntryPairs
sourceObject.fromEntries over what that loop pushed. It appends rather than replaces because a Map
cannot have handed the same key over twice.
Used by
Lean2Js.HelperSem.outDictObj_loop
sourceThe loop __out runs over a dictionary leaving as a plain object. It walks the entries the Map's
iterator hands over and pushes each one, so the object is built in the order the dictionary held.
Used by
Lean2Js.HelperSem.outDict_loop
sourceUsed by
Lean2Js.HelperSem.outSet_split
sourceWalking a dictionary's keys and looking each one up hands back the entries in order, because a Map
cannot carry the same key twice.
Used by
Lean2Js.HelperSem.outFuelKeys_split
sourceUsed by
Lean2Js.HelperSem.outFuelFields_le_alts
sourceUsed by
Lean2Js.HelperSem.lookup_k_out
sourceUsed by
Lean2Js.HelperSem.outV_scalar
sourceUsed by
Lean2Js.HelperSem.calls_out
sourceWhat __out builds, for every value the entry check accepts and every descriptor the compiler
renders.
Used by
The model of the generated code, read off the source semantics #
Lean2Js.HelperSem.ofJsFields_any
sourceUsed by
Lean2Js.HelperSem.lookupV_ofJsFields
sourceUsed by
Lean2Js.HelperSem.lookupV_ofJsFields_none
sourceUsed by
Lean2Js.HelperSem.ofJsFields_mapSet
sourceUsed by
Lean2Js.HelperSem.ofJsFields_mapSetAll
sourceUsed by
Lean2Js.HelperSem.ofJsFields_keys
sourceUsed by
Lean2Js.HelperSem.keysDistinctV_eq
sourceUsed by
Lean2Js.HelperSem.mapsOk_ofJs
sourceUsed by
Lean2Js.HelperSem.lookupV_ofJsFields_str
sourceUsed by
Lean2Js.HelperSem.strictEq_lookupV_str_false
sourceUsed by
Lean2Js.HelperSem.checkTy_option_unmatched
sourceUsed by
Lean2Js.HelperSem.checkTy_result_unmatched
sourceUsed by
Lean2Js.HelperSem.checkTy_ctors_unmatched
sourceUsed by
Lean2Js.HelperSem.normTy_option_unmatched
sourceUsed by
Lean2Js.HelperSem.normTy_result_unmatched
sourceUsed by
Lean2Js.HelperSem.strictEq_str_lookupV_false
sourceUsed by
Lean2Js.HelperSem.normTy_ctors_unmatched
sourceUsed by
Lean2Js.HelperSem.normV_ofJs
sourceUsed by
The entry check the model runs #
__has and Js.checkTy both read an object's fields by name, so they are the same predicate on every
value and every descriptor, with no side condition on the descriptor at all.
Lean2Js.HelperSem.has_checkTy
sourceUsed by
Lean2Js.HelperSem.calls_has_checkTy
sourceUsed by
Lean2Js.HelperSem.calls_ck_checkTy
sourceWhat the generated code's entry check does to an argument: hand back the value the model's check
normalises to, or throw typeError.
Used by
The walk back out the model runs #
Js.outTy is Js.normTy at every node but the one, and outV is normV at every node but the same
one, so the bridge between them is normV_ofJs with one name substituted and one case fewer: an object
met at a dictObj is no longer an arm of its own on either side.
Lean2Js.HelperSem.outTy_option_unmatched
sourceUsed by
Lean2Js.HelperSem.outTy_result_unmatched
sourceUsed by
Lean2Js.HelperSem.outTy_ctors_unmatched
sourceUsed by
Lean2Js.HelperSem.outV_ofJs
sourceUsed by
Lean2Js.HelperSem.calls_out_outTy
sourceWhat the generated code's walk back out does to a result: hand it back as the model's walk out
leaves it. Nothing is refused and nothing needs to be, which is what the hypothesis says — the value
__out is handed is one the declared type accepts, and decl_correct is what gives that at the one
place the compiler writes this call.
Used by
Walking a value of a type that names itself #
__fold is the helper a fold in the subset compiles to. It walks a value from the leaves up and hands
each node to the one callback the compiler passed, with each field that came round already replaced by
what the callback answered for it — so the callback reads a node of the shape the type declares and
dispatches on the tag, which is what a match does.
Nothing emits a call to it yet: the Core.Expr form and its compilation are the commit after this one.
What is here is the helper and the statement that it computes what the model says, which is the
expensive half and the one this repository requires before a helper may ship.
Lean2Js.HelperSem.specValFields
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.specValEntries
sourceThe spec as the object __fold reads it: one entry per constructor, holding that constructor's
fields in declared order. Written as a recursion rather than through List.map, and reached through an
abbrev, so that the walk can see the obj constructor and step into the read.
Equations
Instances For
Used by
Lean2Js.HelperSem.specVal
sourceEquations
Instances For
Used by
Lean2Js.HelperSem.foldV
sourceWhat __fold computes: the callback's answer for the node, with each field that came round already
replaced by the callback's answer for it.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.foldV ext i key spec x✝ = Lean2Js.HelperSem.Res.stuck
Instances For
Used by
Lean2Js.HelperSem.foldList
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.foldList ext i key spec [] = Lean2Js.HelperSem.Res.ok []
Instances For
Used by
Lean2Js.HelperSem.foldListAt
sourceA field the spec says holds a list of the type coming round. A value that is not an array is one the entry check would not have let through, so the walk declines to answer for it rather than guessing.
Written apart from foldPairs so that the match is on a value and not on a proof: an arm matching on
lookupV es n in place makes that arm depend on the equation, and nothing can then case on the field.
Equations
- Lean2Js.HelperSem.foldListAt ext i key spec (Lean2Js.HelperSem.Val.arr xs) = Lean2Js.HelperSem.foldList ext i key spec xs
- Lean2Js.HelperSem.foldListAt ext i key spec x✝ = Lean2Js.HelperSem.Res.stuck
Instances For
Used by
Lean2Js.HelperSem.foldPairs
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.foldPairs ext i key spec es [] = Lean2Js.HelperSem.Res.ok []
Instances For
Used by
Lean2Js.HelperSem.foldFuel
sourceEnough fuel for __fold, by the same recursion as foldV. A generous constant per level: the
claim is stated for every larger amount, so an upper bound is all a proof needs.
Equations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.foldFuel key spec x✝ = 30
Instances For
Used by
Lean2Js.HelperSem.foldFuelList
sourceEquations
- Lean2Js.HelperSem.foldFuelList key spec [] = 6
- Lean2Js.HelperSem.foldFuelList key spec (x_1 :: rest) = Lean2Js.HelperSem.foldFuel key spec x_1 + Lean2Js.HelperSem.foldFuelList key spec rest + 22
Instances For
Used by
Lean2Js.HelperSem.foldFuelListAt
sourceEquations
- Lean2Js.HelperSem.foldFuelListAt key spec (Lean2Js.HelperSem.Val.arr xs) = Lean2Js.HelperSem.foldFuelList key spec xs + 6
- Lean2Js.HelperSem.foldFuelListAt key spec x✝ = 6
Instances For
Used by
Lean2Js.HelperSem.foldFuelPairs
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.foldFuelPairs key spec es [] = 6
- Lean2Js.HelperSem.foldFuelPairs key spec es ((n, Lean2Js.Js.FoldKind.plain) :: rest) = Lean2Js.HelperSem.foldFuelPairs key spec es rest + 30
Instances For
Used by
Lean2Js.HelperSem.find_fold
sourceUsed by
Lean2Js.HelperSem.pairVals
sourceThe pairs the loop pushes, as the array literals it pushes them as.
Equations
Instances For
Used by
Lean2Js.HelperSem.foldList_loop
sourceUsed by
Lean2Js.HelperSem.foldBody
sourceThe body of the loop __fold runs over a constructor's fields. Named so that the lemma below and
the helper read the same text.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Used by
Lean2Js.HelperSem.foldPairs_loop
sourceUsed by
Lean2Js.HelperSem.fromPairs_pairVals
sourceObject.fromEntries over the pairs the loop pushed. No side condition: what it builds is what
mapSetAll builds, a later pair carrying the same name replacing an earlier one, and that is what the
walk says it builds rather than a list the names have to be distinct for.
Used by
Lean2Js.HelperSem.lookupV_specValEntries
sourceThe spec is read by the constructor's name, so a name the spec does not carry reads as undefined
and the loop the walk runs over it is one the model declines to answer for.
Used by
Lean2Js.HelperSem.calls_fold
source__fold computes what foldV says, at every value and every callback. The value is walked from
the leaves up and each node is handed to the callback once, so a callback that throws stops the walk
where the helper stops it.