Lean2Js.HelperAgree
The helper table the model assumes, proved against the source that ships #
The model of the generated code assumes a table of runtime helpers, Js.helper. What that table says
each helper answers is proved here against what the shipped source computes, so the hand-written
JavaScript stops being taken on trust.
Four rows ask for something of their arguments, and helperArgsOk is where all four are written
down. Three are the model being more careful than the helper — __i53div and __str re-check the
Int53 range the type has already given, and __ddelete is stated on the dictionaries a Map can
actually hold. The fourth, __eq, is a real divergence: see eqShape.
Conversion #
Lean2Js.HelperSem.ofJsList_eq
sourceUsed by
Lean2Js.HelperSem.ofJsFields_eq
sourceUsed by
Lean2Js.HelperSem.ofJs_arr
sourceUsed by
Lean2Js.HelperSem.ofJs_obj
sourceUsed by
Lean2Js.HelperSem.ofJs_dict
sourceUsed by
Lean2Js.HelperSem.ofJs_fn
sourceUsed by
Lean2Js.HelperSem.ofRes_fail
sourceUsed by
Entry lists #
Lean2Js.HelperSem.find?_ofJs
sourceUsed by
Lean2Js.HelperSem.any_ofJs
sourceUsed by
Lean2Js.HelperSem.any_eq_find?
sourceUsed by
Lean2Js.HelperSem.filter_ofJs
sourceUsed by
Lean2Js.HelperSem.keys_ofJs
sourceUsed by
Lean2Js.HelperSem.mapSet_ofJs
sourceUsed by
Lean2Js.HelperSem.lookupV_ofJs
sourceUsed by
Arithmetic #
>>> 0 reads a product's residue modulo 2^32, and truncating either factor to int32 first leaves that
residue alone, so Math.imul is the multiplication the model does.
Lean2Js.HelperSem.u32_emod
sourceUsed by
Lean2Js.HelperSem.u32_congr
sourceUsed by
Lean2Js.HelperSem.toInt32_emod
sourceUsed by
Lean2Js.HelperSem.u32_imul
sourceUsed by
Lean2Js.HelperSem.tdiv_mem_i53
sourceTruncated division never leaves the Int53 range the numerator was already in, which is why
__i53div can return without the range check the model still writes.
Used by
Numbers #
Lean2Js.HelperSem.agree_i53
sourceUsed by
Lean2Js.HelperSem.agree_i53div
sourceUsed by
Lean2Js.HelperSem.agree_i53mod
sourceUsed by
Lean2Js.HelperSem.agree_u32mul
sourceUsed by
Lean2Js.HelperSem.agree_u32div
sourceUsed by
Lean2Js.HelperSem.agree_u32mod
sourceUsed by
Lean2Js.HelperSem.agree_bigdiv
sourceUsed by
Lean2Js.HelperSem.agree_bigmod
sourceUsed by
Lean2Js.HelperSem.agree_abs_num
sourceUsed by
Lean2Js.HelperSem.agree_abs_big
sourceUsed by
Lean2Js.HelperSem.agree_min_num
sourceUsed by
Lean2Js.HelperSem.agree_min_big
sourceUsed by
Lean2Js.HelperSem.agree_max_num
sourceUsed by
Lean2Js.HelperSem.agree_max_big
sourceUsed by
Arrays #
Lean2Js.HelperSem.agree_at
sourceUsed by
Lean2Js.HelperSem.agree_aslice
sourceUsed by
Lean2Js.HelperSem.agree_aconcat
sourceUsed by
Lean2Js.HelperSem.agree_areverse
sourceUsed by
Lean2Js.HelperSem.agree_range
sourceUsed by
Dictionaries #
Lean2Js.HelperSem.agree_dhas
sourceUsed by
Lean2Js.HelperSem.agree_dkeys
sourceUsed by
Lean2Js.HelperSem.agree_dvalues
sourceUsed by
Lean2Js.HelperSem.agree_dset
sourceUsed by
Lean2Js.HelperSem.agree_ddelete
sourceUsed by
Lean2Js.HelperSem.agree_dget
sourceUsed by
Strings #
Lean2Js.HelperSem.agree_strcmp
sourceUsed by
Lean2Js.HelperSem.agree_str
sourceUsed by
Lean2Js.HelperSem.agree_toInt
sourceUsed by
Lean2Js.HelperSem.agree_strlen
sourceUsed by
Lean2Js.HelperSem.agree_trim
sourceUsed by
Lean2Js.HelperSem.agree_upper
sourceUsed by
Lean2Js.HelperSem.agree_lower
sourceUsed by
Lean2Js.HelperSem.agree_startsWith
sourceUsed by
Lean2Js.HelperSem.agree_endsWith
sourceUsed by
Lean2Js.HelperSem.agree_includes
sourceUsed by
Lean2Js.HelperSem.agree_split
sourceUsed by
Lean2Js.HelperSem.agree_indexOf
sourceUsed by
Lean2Js.HelperSem.agree_join
sourceUsed by
Lean2Js.HelperSem.agree_repeat
sourceUsed by
Lean2Js.HelperSem.agree_substring
sourceUsed by
Structural equality #
__eq walks an object's fields by name and the model's beq walks them in order, so the two part
company on a permutation; and a Map cannot hold one key twice while the model's association list can.
eqShape is exactly the pair of shapes on which they do agree. A function value is not one of the
divergences: a value of a function type is a reference to a top-level function, and both compare those
by name.
Lean2Js.HelperSem.eqShape
sourceEquations
- One or more equations did not get rendered due to their size.
- Lean2Js.HelperSem.eqShape (Lean2Js.Js.JsValue.arr xs) (Lean2Js.Js.JsValue.arr ys) = Lean2Js.HelperSem.eqShapeList xs ys
- Lean2Js.HelperSem.eqShape x✝¹ x✝ = true
Instances For
Used by
Lean2Js.HelperSem.eqShapeList
sourceEquations
- Lean2Js.HelperSem.eqShapeList (x_2 :: xs) (y :: ys) = (Lean2Js.HelperSem.eqShape x_2 y && Lean2Js.HelperSem.eqShapeList xs ys)
- Lean2Js.HelperSem.eqShapeList x✝¹ x✝ = true
Instances For
Used by
Lean2Js.HelperSem.eqShapeFields
sourceEquations
- Lean2Js.HelperSem.eqShapeFields ((fst, x_2) :: xs) ((fst_1, y) :: ys) = (Lean2Js.HelperSem.eqShape x_2 y && Lean2Js.HelperSem.eqShapeFields xs ys)
- Lean2Js.HelperSem.eqShapeFields x✝¹ x✝ = true
Instances For
Used by
Lean2Js.HelperSem.lookupV_cons_ne
sourceUsed by
Lean2Js.HelperSem.lookupV_cons_self
sourceUsed by
Lean2Js.HelperSem.eqObj_cons
sourceUsed by
Lean2Js.HelperSem.eqKeys_cons
sourceUsed by
Lean2Js.HelperSem.ne_of_contains_false
sourceUsed by
Lean2Js.HelperSem.beqList_length
sourceUsed by
Lean2Js.HelperSem.beqFields_length
sourceUsed by
Lean2Js.HelperSem.keys_length
sourceUsed by
Lean2Js.HelperSem.eq_beq
sourceUsed by
Lean2Js.HelperSem.agree_eq
sourceUsed by
The table #
Lean2Js.HelperSem.helperArgsOk
sourceWhat a call has to satisfy for the shipped source to answer what the model's table says. Three rows
are the model being the more careful of the two — two re-check an Int53 range the type has already
given, and one is stated on dictionaries a Map can actually hold — and one is a real divergence.
Equations
- Lean2Js.HelperSem.helperArgsOk "__i53div" [Lean2Js.Js.JsValue.num a, head] = (Lean2Js.Js.Runtime.safeMin ≤ a ∧ a ≤ Lean2Js.Js.Runtime.safeMax)
- Lean2Js.HelperSem.helperArgsOk "__str" [Lean2Js.Js.JsValue.num a] = (Lean2Js.Js.Runtime.safeMin ≤ a ∧ a ≤ Lean2Js.Js.Runtime.safeMax)
- Lean2Js.HelperSem.helperArgsOk "__ddelete" [Lean2Js.Js.JsValue.dict es, head] = (Lean2Js.Js.keysDistinct (List.map (fun (x : String × Lean2Js.Js.JsValue) => x.fst) es) = true)
- Lean2Js.HelperSem.helperArgsOk "__eq" [a, b] = (Lean2Js.HelperSem.eqShape a b = true)
- Lean2Js.HelperSem.helperArgsOk name args = True
Instances For
Used by
Lean2Js.HelperSem.helper_agrees
sourceEvery row of Js.helper is answered by the JavaScript the compiler writes out, so what the helpers
behind the table are left trusted for is what helperArgsOk still asks of a call.
The table is not the whole of what the model assumes about hand-written JavaScript. JsSem.eval carries
__ck, __out and the seven traversal helpers as rules of its own rather than as rows, and those are
answered by HelperProof.calls_ck_checkTy, calls_out_outTy, calls_map, calls_filter, calls_find,
calls_all, calls_any, calls_reduce and calls_sortBy. calls_out_outTy is the one of those that
asks something of its argument: __out walks a value the declared type accepts, which is what the entry
hands it and what decl_correct says the body produced. __sortBy asks something of its arguments the way four of the rows
do: the keys of one call are all numbers or all strings, which is what the key type the compiler insists
on gives.