lean2js

Lean2Js.Correct

source

Compiler correctness for a fragment of the subset #

Compiler correctness. Proves "if the reference semantics returns a value, the generated JS returns the same value" for a fragment of the subset.

The target is limited to a fragment so that the reach of the proof stays unambiguous. Outside the fragment, Agree.checkAgreement checks agreement at run time against the shipped artifact.

Why the fragment stops here #

Every binary operator is in, so the next form to reach for is the call, and that needs Sound.TypeChecked over the whole subset: the callee's body is arbitrary syntax.

inductive

Lean2Js.Correct.InFragment

source

The syntax the proof reaches.

Instances For
    Used by
      theorem

      Lean2Js.Correct.InFragment.all

      source

      Every shape of the subset is in the fragment. The proof reaches the whole syntax, so the induction the judgement drives reads as a case analysis on the expression.

      Used by
        theorem

        Lean2Js.Correct.InFragment.allList

        source
        Used by
          theorem

          Lean2Js.Correct.InFragment.allValues

          source
          [Core.Discriminators] (entries : List (String × Core.Expr)) (entry : String × Core.Expr) :
          entry ∈ entries → InFragment entry.snd
          Used by
            theorem

            Lean2Js.Correct.InFragment.allAlts

            source
            [Core.Discriminators] (alts : List Core.Alt) (alt : Core.Alt) :
            alt ∈ alts → InFragment alt.body
            Used by
              theorem

              Lean2Js.Correct.InFragment.typeChecked

              source

              Everything the correctness proof reaches is also reached by type soundness, which the arithmetic cases need to know that the values in the environment match the types the compiler read.

              Used by
                def

                Lean2Js.Correct.encodeEnv

                source
                Equations
                Instances For
                  Used by
                    def

                    Lean2Js.Correct.Eventually

                    source
                    (m : Js.Module) (env : Js.JsEnv) (je : Js.Expr) (v : Js.JsValue) :

                    The relation "given enough fuel, the generated code returns this value". Quantifying the fuel existentially lets subexpressions compose even when each needs a different amount.

                    Equations
                    Instances For
                      Used by
                        theorem

                        Lean2Js.Correct.lookup_encodeEnv

                        source
                        [Core.Discriminators] {env : Env} {name : String} {v : Value} (h : env.lookup? name = some v) :
                        Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == name) (encodeEnv env)) = some (encodeValue v)
                        Used by
                          theorem

                          Lean2Js.Correct.eventually_lit

                          source
                          [Core.Discriminators] (m : Js.Module) (env : Js.JsEnv) (v : Js.JsValue) (je : Js.Expr) (h : ∀ (g : Nat), Js.eval m (g + 1) env je = Except.ok v) :
                          Eventually m env je v
                          Used by
                            theorem

                            Lean2Js.Correct.eventually_num

                            source
                            Used by
                              theorem

                              Lean2Js.Correct.eventually_big

                              source
                              Used by
                                theorem

                                Lean2Js.Correct.eventually_str

                                source
                                Used by
                                  theorem

                                  Lean2Js.Correct.eventually_bool

                                  source
                                  Used by
                                    theorem

                                    Lean2Js.Correct.eventually_arrowCall

                                    source
                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jv jb : Js.Expr} {w v : Js.JsValue} (h1 : Eventually m env jv w) (h2 : Eventually m ((name, w) :: env) jb v) :
                                    Eventually m env (Js.Expr.arrowCall [name] jb [jv]) v
                                    Used by
                                      theorem

                                      Lean2Js.Correct.eventually_not

                                      source
                                      [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jx : Js.Expr} {b : Bool} (h : Eventually m env jx (Js.JsValue.bool b)) :
                                      Used by
                                        theorem

                                        Lean2Js.Correct.eventually_neg_num

                                        source
                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jx : Js.Expr} {i : Int} (h : Eventually m env jx (Js.JsValue.num i)) :
                                        Used by
                                          theorem

                                          Lean2Js.Correct.eventually_neg_big

                                          source
                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jx : Js.Expr} {i : Int} (h : Eventually m env jx (Js.JsValue.bigint i)) :
                                          Used by
                                            theorem

                                            Lean2Js.Correct.eventually_call1

                                            source
                                            [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jx : Js.Expr} {w r : Js.JsValue} (h : Eventually m env jx w) (hh : Js.helper name [w] = some (Except.ok r)) :
                                            Eventually m env (Js.Expr.call name [jx]) r
                                            Used by
                                              theorem

                                              Lean2Js.Correct.eventually_objLit0

                                              source

                                              A constructor value is an object literal whose first field is the tag.

                                              Used by
                                                theorem

                                                Lean2Js.Correct.eventually_objLit1

                                                source
                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {key ctor field : String} {jx : Js.Expr} {w : Js.JsValue} (h : Eventually m env jx w) :
                                                Used by
                                                  def

                                                  Lean2Js.Correct.EventuallyList

                                                  source
                                                  (m : Js.Module) (env : Js.JsEnv) (jes : List Js.Expr) (vs : List Js.JsValue) :

                                                  The list an object, array or dictionary literal evaluates before it builds the value.

                                                  Equations
                                                  Instances For
                                                    Used by
                                                      theorem

                                                      Lean2Js.Correct.eventuallyList_nil

                                                      source
                                                      Used by
                                                        theorem

                                                        Lean2Js.Correct.eventuallyList_cons

                                                        source
                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {je : Js.Expr} {jes : List Js.Expr} {v : Js.JsValue} {vs : List Js.JsValue} (h : Eventually m env je v) (ht : EventuallyList m env jes vs) :
                                                        EventuallyList m env (je :: jes) (v :: vs)
                                                        Used by
                                                          theorem

                                                          Lean2Js.Correct.eventually_arrayLit

                                                          source
                                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jes : List Js.Expr} {vs : List Js.JsValue} (h : EventuallyList m env jes vs) :
                                                          Used by
                                                            theorem

                                                            Lean2Js.Correct.eventually_objLit

                                                            source
                                                            [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {fields : List (String × Js.Expr)} {vs : List Js.JsValue} (h : EventuallyList m env (List.map (fun (x : String × Js.Expr) => x.snd) fields) vs) :
                                                            Eventually m env (Js.Expr.objLit fields) (Js.JsValue.obj ((List.map (fun (x : String × Js.Expr) => x.fst) fields).zip vs))
                                                            Used by
                                                              theorem

                                                              Lean2Js.Correct.eventually_dictLit

                                                              source
                                                              [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {entries : List (String × Js.Expr)} {vs : List Js.JsValue} (h : EventuallyList m env (List.map (fun (x : String × Js.Expr) => x.snd) entries) vs) :
                                                              Eventually m env (Js.Expr.dictLit entries) (Js.JsValue.dict ((List.map (fun (x : String × Js.Expr) => x.fst) entries).zip vs))
                                                              Used by
                                                                theorem

                                                                Lean2Js.Correct.eventually_call3

                                                                source
                                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {j1 j2 j3 : Js.Expr} {a b c r : Js.JsValue} (h1 : Eventually m env j1 a) (h2 : Eventually m env j2 b) (h3 : Eventually m env j3 c) (hh : Js.helper name [a, b, c] = some (Except.ok r)) :
                                                                Eventually m env (Js.Expr.call name [j1, j2, j3]) r
                                                                Used by
                                                                  theorem

                                                                  Lean2Js.Correct.encodeList_map_str

                                                                  source
                                                                  Used by
                                                                    theorem

                                                                    Lean2Js.Correct.hasInfix_eq

                                                                    source
                                                                    [Core.Discriminators] (needle hay : List Char) :
                                                                    hasInfix needle hay = Js.Runtime.strIncludes needle hay
                                                                    Used by
                                                                      theorem

                                                                      Lean2Js.Correct.int53_range

                                                                      source
                                                                      Used by
                                                                        theorem

                                                                        Lean2Js.Correct.strToInt_eq

                                                                        source
                                                                        Used by
                                                                          theorem

                                                                          Lean2Js.Correct.helper_strUn

                                                                          source

                                                                          The string helpers the compiler emits compute what applyStrUn and applyStrBin compute; the two sides are written as the same functions on the code points.

                                                                          Used by
                                                                            theorem

                                                                            Lean2Js.Correct.indexOfChars_eq

                                                                            source
                                                                            Used by
                                                                              theorem

                                                                              Lean2Js.Correct.joinFrom_eq

                                                                              source
                                                                              [Core.Discriminators] (sep : String) (ss : List String) (acc : String) :
                                                                              Js.Runtime.strJoinFrom sep acc ss = joinFrom sep acc ss
                                                                              Used by
                                                                                theorem

                                                                                Lean2Js.Correct.joinStr_eq

                                                                                source
                                                                                Used by
                                                                                  theorem

                                                                                  Lean2Js.Correct.repeatFrom_eq

                                                                                  source
                                                                                  Used by
                                                                                    theorem

                                                                                    Lean2Js.Correct.helper_strBin

                                                                                    source
                                                                                    Used by
                                                                                      theorem

                                                                                      Lean2Js.Correct.strBin_err_indexOf

                                                                                      source

                                                                                      indexOf is the one string pair that can fail: a position past the safe integers traps the way a length does.

                                                                                      Used by
                                                                                        theorem

                                                                                        Lean2Js.Correct.strBin_err_repeat

                                                                                        source

                                                                                        repeat is the other one: a result longer than the safe integers traps before the string is built.

                                                                                        Used by
                                                                                          theorem

                                                                                          Lean2Js.Correct.applyStrUn_str

                                                                                          source
                                                                                          Used by
                                                                                            theorem

                                                                                            Lean2Js.Correct.strSlice_of_sliceStr

                                                                                            source

                                                                                            substring counts code points on both sides. The model's extra guard against a bound outside the safe integers is the one the reference semantics gets from the argument being an Int53 at all.

                                                                                            Used by
                                                                                              theorem

                                                                                              Lean2Js.Correct.strSlice_trap

                                                                                              source
                                                                                              Used by
                                                                                                theorem

                                                                                                Lean2Js.Correct.eventually_member

                                                                                                source
                                                                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jobj : Js.Expr} {fields : List (String × Js.JsValue)} {field : String} {w : Js.JsValue} (h : Eventually m env jobj (Js.JsValue.obj fields)) (hf : Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == field) fields) = some w) :
                                                                                                Eventually m env (jobj.member field) w
                                                                                                Used by
                                                                                                  theorem

                                                                                                  Lean2Js.Correct.eventually_length_arr

                                                                                                  source
                                                                                                  [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jarr : Js.Expr} {xs : List Js.JsValue} (h : Eventually m env jarr (Js.JsValue.arr xs)) :
                                                                                                  Eventually m env (jarr.member "length") (Js.JsValue.num ↑xs.length)
                                                                                                  Used by
                                                                                                    theorem

                                                                                                    Lean2Js.Correct.eventually_size_dict

                                                                                                    source
                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jd : Js.Expr} {entries : List (String × Js.JsValue)} (h : Eventually m env jd (Js.JsValue.dict entries)) :
                                                                                                    Eventually m env (jd.member "size") (Js.JsValue.num ↑entries.length)
                                                                                                    Used by
                                                                                                      theorem

                                                                                                      Lean2Js.Correct.helper_strlen

                                                                                                      source
                                                                                                      Used by
                                                                                                        theorem

                                                                                                        Lean2Js.Correct.encodeFields_find

                                                                                                        source
                                                                                                        [Core.Discriminators] (entries : List (String × Value)) (k : String) :
                                                                                                        Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == k) (encodeFields entries)) = Option.map encodeValue (Option.map (fun (x : String × Value) => x.snd) (List.find? (fun (x : String × Value) => x.fst == k) entries))

                                                                                                        The dictionary helpers read and write the encoded entries the way the reference semantics reads and writes the entries themselves; the encoding only touches the values.

                                                                                                        Used by
                                                                                                          theorem

                                                                                                          Lean2Js.Correct.encodeFields_any

                                                                                                          source
                                                                                                          [Core.Discriminators] (entries : List (String × Value)) (k : String) :
                                                                                                          ((encodeFields entries).any fun (x : String × Js.JsValue) => x.fst == k) = entries.any fun (x : String × Value) => x.fst == k
                                                                                                          Used by
                                                                                                            theorem

                                                                                                            Lean2Js.Correct.encodeFields_filter

                                                                                                            source
                                                                                                            [Core.Discriminators] (entries : List (String × Value)) (k : String) :
                                                                                                            encodeFields (List.filter (fun (x : String × Value) => x.fst != k) entries) = List.filter (fun (x : String × Js.JsValue) => x.fst != k) (encodeFields entries)
                                                                                                            Used by
                                                                                                              theorem

                                                                                                              Lean2Js.Correct.encodeFields_map_set

                                                                                                              source
                                                                                                              [Core.Discriminators] (entries : List (String × Value)) (k : String) (v : Value) :
                                                                                                              encodeFields (List.map (fun (e : String × Value) => if (e.fst == k) = true then (k, v) else e) entries) = List.map (fun (e : String × Js.JsValue) => if (e.fst == k) = true then (k, encodeValue v) else e) (encodeFields entries)
                                                                                                              Used by
                                                                                                                theorem

                                                                                                                Lean2Js.Correct.encodeFields_append

                                                                                                                source
                                                                                                                Used by
                                                                                                                  theorem

                                                                                                                  Lean2Js.Correct.encodeFields_with

                                                                                                                  source
                                                                                                                  Used by
                                                                                                                    theorem

                                                                                                                    Lean2Js.Correct.encodeValue_dictLookup

                                                                                                                    source
                                                                                                                    [Core.Discriminators] (entries : List (String × Value)) (k : String) :
                                                                                                                    encodeValue (dictLookup entries k) = match Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == k) (encodeFields entries)) with | some v => Js.JsValue.obj [("tag", Js.JsValue.str "some"), ("value", v)] | none => Js.JsValue.obj [("tag", Js.JsValue.str "none")]
                                                                                                                    Used by
                                                                                                                      theorem

                                                                                                                      Lean2Js.Correct.helper_dget

                                                                                                                      source
                                                                                                                      [Core.Discriminators] (entries : List (String × Js.JsValue)) (k : String) :
                                                                                                                      Js.helper "__dget" [Js.JsValue.dict entries, Js.JsValue.str k] = some (Except.ok (match Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == k) entries) with | some v => Js.JsValue.obj [("tag", Js.JsValue.str "some"), ("value", v)] | none => Js.JsValue.obj [("tag", Js.JsValue.str "none")]))
                                                                                                                      Used by
                                                                                                                        theorem

                                                                                                                        Lean2Js.Correct.helper_dhas

                                                                                                                        source
                                                                                                                        Used by
                                                                                                                          theorem

                                                                                                                          Lean2Js.Correct.helper_dset

                                                                                                                          source
                                                                                                                          Used by
                                                                                                                            theorem

                                                                                                                            Lean2Js.Correct.helper_dkeys

                                                                                                                            source
                                                                                                                            Used by
                                                                                                                              theorem

                                                                                                                              Lean2Js.Correct.helper_dvalues

                                                                                                                              source
                                                                                                                              [Core.Discriminators] (entries : List (String × Js.JsValue)) :
                                                                                                                              Js.helper "__dvalues" [Js.JsValue.dict entries] = some (Except.ok (Js.JsValue.arr (List.map (fun (x : String × Js.JsValue) => x.snd) entries)))
                                                                                                                              Used by
                                                                                                                                theorem

                                                                                                                                Lean2Js.Correct.helper_ddelete

                                                                                                                                source
                                                                                                                                Used by
                                                                                                                                  theorem

                                                                                                                                  Lean2Js.Correct.member_encodeObj

                                                                                                                                  source
                                                                                                                                  [Core.Discriminators] {key ctor field : String} {fields : List (String × Value)} {v : Value} (hne : field ≠ key) (hf : Option.map (fun (x : String × Value) => x.snd) (List.find? (fun (x : String × Value) => x.fst == field) fields) = some v) :
                                                                                                                                  Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == field) ((key, Js.JsValue.str ctor) :: encodeFields fields)) = some (encodeValue v)

                                                                                                                                  A field read finds the field, not the constructor's name the value carries in front of it. The two cannot collide: a type may not declare a field named the key it carries that name under, and the fragment reads no such name.

                                                                                                                                  Used by
                                                                                                                                    theorem

                                                                                                                                    Lean2Js.Correct.encodeFields_eq

                                                                                                                                    source
                                                                                                                                    [Core.Discriminators] (fields : List (String × Value)) :
                                                                                                                                    encodeFields fields = List.map (fun (e : String × Value) => (e.fst, encodeValue e.snd)) fields
                                                                                                                                    Used by
                                                                                                                                      theorem

                                                                                                                                      Lean2Js.Correct.encodeList_eq

                                                                                                                                      source
                                                                                                                                      Used by
                                                                                                                                        theorem

                                                                                                                                        Lean2Js.Correct.encodeList_rangeValues

                                                                                                                                        source
                                                                                                                                        Used by
                                                                                                                                          theorem

                                                                                                                                          Lean2Js.Correct.at?_ok

                                                                                                                                          source
                                                                                                                                          [Core.Discriminators] {xs : List Value} {n : Int} {v : Value} (hn : int53Min ≤ n ∧ n ≤ int53Max) (hlo : ¬n < 0) (hg : xs[n.toNat]? = some v) :

                                                                                                                                          The array reads count elements on both sides. The model's extra guard against an index outside the safe integers is the one the reference semantics gets from the index being an Int53 at all.

                                                                                                                                          Used by
                                                                                                                                            theorem

                                                                                                                                            Lean2Js.Correct.at?_err

                                                                                                                                            source
                                                                                                                                            [Core.Discriminators] {xs : List Value} {n : Int} (hbad : n < 0 ∨ ↑xs.length ≤ n) :
                                                                                                                                            Js.Runtime.at? (encodeList xs) n = Except.error "indexOutOfBounds"
                                                                                                                                            Used by
                                                                                                                                              theorem

                                                                                                                                              Lean2Js.Correct.arrSlice_of_sliceArr

                                                                                                                                              source
                                                                                                                                              Used by
                                                                                                                                                theorem

                                                                                                                                                Lean2Js.Correct.arrSlice_trap

                                                                                                                                                source
                                                                                                                                                Used by
                                                                                                                                                  theorem

                                                                                                                                                  Lean2Js.Correct.helper_at

                                                                                                                                                  source
                                                                                                                                                  Used by
                                                                                                                                                    theorem

                                                                                                                                                    Lean2Js.Correct.helper_aslice

                                                                                                                                                    source
                                                                                                                                                    Used by
                                                                                                                                                      theorem

                                                                                                                                                      Lean2Js.Correct.helper_areverse

                                                                                                                                                      source
                                                                                                                                                      Used by
                                                                                                                                                        theorem

                                                                                                                                                        Lean2Js.Correct.helper_i53

                                                                                                                                                        source
                                                                                                                                                        Used by
                                                                                                                                                          theorem

                                                                                                                                                          Lean2Js.Correct.helper_abs_num

                                                                                                                                                          source
                                                                                                                                                          Used by
                                                                                                                                                            theorem

                                                                                                                                                            Lean2Js.Correct.helper_abs_big

                                                                                                                                                            source
                                                                                                                                                            Used by
                                                                                                                                                              theorem

                                                                                                                                                              Lean2Js.Correct.helper_str

                                                                                                                                                              source
                                                                                                                                                              Used by
                                                                                                                                                                theorem

                                                                                                                                                                Lean2Js.Correct.helper_range

                                                                                                                                                                source
                                                                                                                                                                Used by
                                                                                                                                                                  theorem

                                                                                                                                                                  Lean2Js.Correct.i53_of_mkInt53

                                                                                                                                                                  source
                                                                                                                                                                  Used by
                                                                                                                                                                    theorem

                                                                                                                                                                    Lean2Js.Correct.absInt

                                                                                                                                                                    source
                                                                                                                                                                    [Core.Discriminators] (i : Int) :
                                                                                                                                                                    (if i < 0 then -i else i) = ↑i.natAbs
                                                                                                                                                                    Used by
                                                                                                                                                                      theorem

                                                                                                                                                                      Lean2Js.Correct.eventually_call2

                                                                                                                                                                      source
                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jl jr : Js.Expr} {a b r : Js.JsValue} (h1 : Eventually m env jl a) (h2 : Eventually m env jr b) (hh : Js.helper name [a, b] = some (Except.ok r)) :
                                                                                                                                                                      Eventually m env (Js.Expr.call name [jl, jr]) r
                                                                                                                                                                      Used by
                                                                                                                                                                        theorem

                                                                                                                                                                        Lean2Js.Correct.eventually_andL

                                                                                                                                                                        source
                                                                                                                                                                        Used by
                                                                                                                                                                          theorem

                                                                                                                                                                          Lean2Js.Correct.eventually_andR

                                                                                                                                                                          source
                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jl jr : Js.Expr} {w : Js.JsValue} (h1 : Eventually m env jl (Js.JsValue.bool true)) (h2 : Eventually m env jr w) :
                                                                                                                                                                          Eventually m env (Js.Expr.binary "&&" jl jr) w
                                                                                                                                                                          Used by
                                                                                                                                                                            theorem

                                                                                                                                                                            Lean2Js.Correct.eventually_orL

                                                                                                                                                                            source
                                                                                                                                                                            Used by
                                                                                                                                                                              theorem

                                                                                                                                                                              Lean2Js.Correct.eventually_orR

                                                                                                                                                                              source
                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jl jr : Js.Expr} {w : Js.JsValue} (h1 : Eventually m env jl (Js.JsValue.bool false)) (h2 : Eventually m env jr w) :
                                                                                                                                                                              Eventually m env (Js.Expr.binary "||" jl jr) w
                                                                                                                                                                              Used by
                                                                                                                                                                                theorem

                                                                                                                                                                                Lean2Js.Correct.eval_binary_plus

                                                                                                                                                                                source
                                                                                                                                                                                [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                Js.eval m (g + 1) env (Js.Expr.binary "+" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "+" a b
                                                                                                                                                                                Used by
                                                                                                                                                                                  theorem

                                                                                                                                                                                  Lean2Js.Correct.eval_binary_minus

                                                                                                                                                                                  source
                                                                                                                                                                                  [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                  Js.eval m (g + 1) env (Js.Expr.binary "-" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "-" a b
                                                                                                                                                                                  Used by
                                                                                                                                                                                    theorem

                                                                                                                                                                                    Lean2Js.Correct.eval_binary_times

                                                                                                                                                                                    source
                                                                                                                                                                                    [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                    Js.eval m (g + 1) env (Js.Expr.binary "*" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "*" a b
                                                                                                                                                                                    Used by
                                                                                                                                                                                      theorem

                                                                                                                                                                                      Lean2Js.Correct.eval_binary_shr

                                                                                                                                                                                      source
                                                                                                                                                                                      [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                      Js.eval m (g + 1) env (Js.Expr.binary ">>>" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith ">>>" a b
                                                                                                                                                                                      Used by
                                                                                                                                                                                        theorem

                                                                                                                                                                                        Lean2Js.Correct.eventually_binary

                                                                                                                                                                                        source
                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {op : String} {jl jr : Js.Expr} {a b r : Js.JsValue} (hred : ∀ (g : Nat), Js.eval m (g + 1) env (Js.Expr.binary op jl jr) = do let x ← Js.eval m g env jl let y ← Js.eval m g env jr Js.arith op x y) (h1 : Eventually m env jl a) (h2 : Eventually m env jr b) (har : Js.arith op a b = Except.ok r) :
                                                                                                                                                                                        Eventually m env (Js.Expr.binary op jl jr) r
                                                                                                                                                                                        Used by
                                                                                                                                                                                          theorem

                                                                                                                                                                                          Lean2Js.Correct.u32_lt

                                                                                                                                                                                          source
                                                                                                                                                                                          [Core.Discriminators] (n : UInt32) :
                                                                                                                                                                                          ↑n.toNat < 4294967296
                                                                                                                                                                                          Used by
                                                                                                                                                                                            theorem

                                                                                                                                                                                            Lean2Js.Correct.u32_add

                                                                                                                                                                                            source
                                                                                                                                                                                            [Core.Discriminators] (x y : UInt32) :
                                                                                                                                                                                            Js.Runtime.u32 (↑x.toNat + ↑y.toNat) = ↑(x + y).toNat
                                                                                                                                                                                            Used by
                                                                                                                                                                                              theorem

                                                                                                                                                                                              Lean2Js.Correct.u32_sub

                                                                                                                                                                                              source
                                                                                                                                                                                              [Core.Discriminators] (x y : UInt32) :
                                                                                                                                                                                              Js.Runtime.u32 (↑x.toNat - ↑y.toNat) = ↑(x - y).toNat
                                                                                                                                                                                              Used by
                                                                                                                                                                                                theorem

                                                                                                                                                                                                Lean2Js.Correct.u32_mul

                                                                                                                                                                                                source
                                                                                                                                                                                                [Core.Discriminators] (x y : UInt32) :
                                                                                                                                                                                                Js.Runtime.u32 (↑x.toNat * ↑y.toNat) = ↑(x * y).toNat
                                                                                                                                                                                                Used by
                                                                                                                                                                                                  theorem

                                                                                                                                                                                                  Lean2Js.Correct.u32_of_lt

                                                                                                                                                                                                  source
                                                                                                                                                                                                  [Core.Discriminators] {i : Int} (h0 : 0 ≤ i) (h : i < 4294967296) :
                                                                                                                                                                                                  Used by
                                                                                                                                                                                                    theorem

                                                                                                                                                                                                    Lean2Js.Correct.eventually_plus_str

                                                                                                                                                                                                    source
                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jl jr : Js.Expr} {x y : String} (h1 : Eventually m env jl (Js.JsValue.str x)) (h2 : Eventually m env jr (Js.JsValue.str y)) :
                                                                                                                                                                                                    Eventually m env (Js.Expr.binary "+" jl jr) (Js.JsValue.str (x ++ y))
                                                                                                                                                                                                    Used by
                                                                                                                                                                                                      theorem

                                                                                                                                                                                                      Lean2Js.Correct.encodeList_append

                                                                                                                                                                                                      source
                                                                                                                                                                                                      Used by
                                                                                                                                                                                                        theorem

                                                                                                                                                                                                        Lean2Js.Correct.helper_aconcat

                                                                                                                                                                                                        source
                                                                                                                                                                                                        Used by
                                                                                                                                                                                                          theorem

                                                                                                                                                                                                          Lean2Js.Correct.helper_i53div

                                                                                                                                                                                                          source
                                                                                                                                                                                                          Used by
                                                                                                                                                                                                            theorem

                                                                                                                                                                                                            Lean2Js.Correct.helper_i53mod

                                                                                                                                                                                                            source
                                                                                                                                                                                                            Used by
                                                                                                                                                                                                              theorem

                                                                                                                                                                                                              Lean2Js.Correct.helper_u32div

                                                                                                                                                                                                              source
                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                Lean2Js.Correct.helper_u32mod

                                                                                                                                                                                                                source
                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                  Lean2Js.Correct.helper_bigdiv

                                                                                                                                                                                                                  source
                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                    Lean2Js.Correct.helper_bigmod

                                                                                                                                                                                                                    source
                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                      Lean2Js.Correct.u32_of_natCast

                                                                                                                                                                                                                      source
                                                                                                                                                                                                                      [Core.Discriminators] {n : Nat} (h : n < 4294967296) :
                                                                                                                                                                                                                      Js.Runtime.u32 ↑n = ↑n
                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                        Lean2Js.Correct.u32_tdiv

                                                                                                                                                                                                                        source
                                                                                                                                                                                                                        [Core.Discriminators] (x y : UInt32) :
                                                                                                                                                                                                                        Js.Runtime.u32 ((↑x.toNat).tdiv ↑y.toNat) = ↑(x / y).toNat
                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                          Lean2Js.Correct.u32_tmod

                                                                                                                                                                                                                          source
                                                                                                                                                                                                                          [Core.Discriminators] (x y : UInt32) :
                                                                                                                                                                                                                          Js.Runtime.u32 ((↑x.toNat).tmod ↑y.toNat) = ↑(x % y).toNat
                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                            Lean2Js.Correct.helper_u32mul

                                                                                                                                                                                                                            source
                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                              Lean2Js.Correct.helper_min_num

                                                                                                                                                                                                                              source
                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                Lean2Js.Correct.helper_min_big

                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                  Lean2Js.Correct.helper_max_num

                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                    Lean2Js.Correct.helper_max_big

                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                      Lean2Js.Correct.string_compare_toList

                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                        Lean2Js.Correct.helper_strcmp

                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                          Lean2Js.Correct.strcmp_compare

                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                            Lean2Js.Correct.u32_compare

                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                            [Core.Discriminators] (m n : Nat) :
                                                                                                                                                                                                                                            compare ↑m ↑n = compare m n
                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                              Lean2Js.Correct.eval_binary_lt

                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                              [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                                                                              Js.eval m (g + 1) env (Js.Expr.binary "<" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "<" a b
                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                Lean2Js.Correct.eval_binary_le

                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                                                                                Js.eval m (g + 1) env (Js.Expr.binary "<=" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "<=" a b
                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                  Lean2Js.Correct.eval_binary_gt

                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                  [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                                                                                  Js.eval m (g + 1) env (Js.Expr.binary ">" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith ">" a b
                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                    Lean2Js.Correct.eval_binary_ge

                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                    [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                                                                                    Js.eval m (g + 1) env (Js.Expr.binary ">=" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith ">=" a b
                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                      Lean2Js.Correct.arith_lt

                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                        Lean2Js.Correct.arith_le

                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                          Lean2Js.Correct.arith_gt

                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                            Lean2Js.Correct.arith_ge

                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                              Lean2Js.Correct.order_num

                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                Lean2Js.Correct.order_big

                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                  Lean2Js.Correct.u32_beq

                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                  [Core.Discriminators] (x y : UInt32) :
                                                                                                                                                                                                                                                                  (↑x.toNat == ↑y.toNat) = (x == y)
                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                    Lean2Js.Correct.beq_encodeValue

                                                                                                                                                                                                                                                                    source

                                                                                                                                                                                                                                                                    Encoding preserves equality, but only between values of one type. Untyped the statement is false: Int53 0 and UInt32 0 are different values that both encode to .num 0.

                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                      Lean2Js.Correct.beq_encodeFields

                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                        Lean2Js.Correct.beq_encodeList

                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                          Lean2Js.Correct.beq_encodeEntries

                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                            Lean2Js.Correct.eval_binary_eqq

                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                            [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                                                                                                            Js.eval m (g + 1) env (Js.Expr.binary "===" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "===" a b
                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                              Lean2Js.Correct.eval_binary_neqq

                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                              [Core.Discriminators] (m : Js.Module) (g : Nat) (env : Js.JsEnv) (jl jr : Js.Expr) :
                                                                                                                                                                                                                                                                              Js.eval m (g + 1) env (Js.Expr.binary "!==" jl jr) = do let a ← Js.eval m g env jl let b ← Js.eval m g env jr Js.arith "!==" a b
                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                Lean2Js.Correct.arith_eqq

                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                  Lean2Js.Correct.arith_neqq

                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                    Lean2Js.Correct.helper_eq

                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                      Lean2Js.Correct.sameValue_encodeValue

                                                                                                                                                                                                                                                                                      source

                                                                                                                                                                                                                                                                                      === compares scalars by value, so the model's sameValue reaches Value.beq only where the compiler has already decided the operands are scalars.

                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                        Lean2Js.Correct.cond_true

                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jc jt jel : Js.Expr} {v : Js.JsValue} (h1 : Eventually m env jc (Js.JsValue.bool true)) (h2 : Eventually m env jt v) :
                                                                                                                                                                                                                                                                                        Eventually m env (jc.cond jt jel) v
                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                          Lean2Js.Correct.cond_false

                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jc jt jel : Js.Expr} {v : Js.JsValue} (h1 : Eventually m env jc (Js.JsValue.bool false)) (h2 : Eventually m env jel v) :
                                                                                                                                                                                                                                                                                          Eventually m env (jc.cond jt jel) v
                                                                                                                                                                                                                                                                                          Used by

                                                                                                                                                                                                                                                                                            Failing, at every large enough amount of fuel #

                                                                                                                                                                                                                                                                                            The mirror of Eventually. Where that carries a value across the boundary, this carries a thrown code, and each shape the compiler emits has to be shown to pass one along.

                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                            Lean2Js.Correct.EventuallyErr

                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                            (m : Js.Module) (env : Js.JsEnv) (je : Js.Expr) (code : String) :
                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventuallyErr_not

                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jx : Js.Expr} {code : String} (h : EventuallyErr m env jx code) :
                                                                                                                                                                                                                                                                                                EventuallyErr m env (Js.Expr.unary "!" jx) code
                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventuallyErr_neg

                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jx : Js.Expr} {code : String} (h : EventuallyErr m env jx code) :
                                                                                                                                                                                                                                                                                                  EventuallyErr m env (Js.Expr.unary "-" jx) code
                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventuallyErr_binaryL

                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {op : String} {jl jr : Js.Expr} {code : String} (h : EventuallyErr m env jl code) :
                                                                                                                                                                                                                                                                                                    EventuallyErr m env (Js.Expr.binary op jl jr) code
                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventuallyErr_binaryR

                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {op : String} {jl jr : Js.Expr} {a : Js.JsValue} {code : String} (hand : op ≠ "&&") (hor : op ≠ "||") (h1 : Eventually m env jl a) (h2 : EventuallyErr m env jr code) :
                                                                                                                                                                                                                                                                                                      EventuallyErr m env (Js.Expr.binary op jl jr) code
                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_andR

                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jl jr : Js.Expr} {code : String} (h1 : Eventually m env jl (Js.JsValue.bool true)) (h2 : EventuallyErr m env jr code) :
                                                                                                                                                                                                                                                                                                        EventuallyErr m env (Js.Expr.binary "&&" jl jr) code
                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventuallyErr_orR

                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jl jr : Js.Expr} {code : String} (h1 : Eventually m env jl (Js.JsValue.bool false)) (h2 : EventuallyErr m env jr code) :
                                                                                                                                                                                                                                                                                                          EventuallyErr m env (Js.Expr.binary "||" jl jr) code
                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventuallyErr_condC

                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jc jt je : Js.Expr} {code : String} (h : EventuallyErr m env jc code) :
                                                                                                                                                                                                                                                                                                            EventuallyErr m env (jc.cond jt je) code
                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyErr_condT

                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jc jt je : Js.Expr} {code : String} (h1 : Eventually m env jc (Js.JsValue.bool true)) (h2 : EventuallyErr m env jt code) :
                                                                                                                                                                                                                                                                                                              EventuallyErr m env (jc.cond jt je) code
                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventuallyErr_condE

                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jc jt je : Js.Expr} {code : String} (h1 : Eventually m env jc (Js.JsValue.bool false)) (h2 : EventuallyErr m env je code) :
                                                                                                                                                                                                                                                                                                                EventuallyErr m env (jc.cond jt je) code
                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventuallyErr_arrowArg

                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jv jb : Js.Expr} {code : String} (h : EventuallyErr m env jv code) :
                                                                                                                                                                                                                                                                                                                  EventuallyErr m env (Js.Expr.arrowCall [name] jb [jv]) code
                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventuallyErr_arrowBody

                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jv jb : Js.Expr} {w : Js.JsValue} {code : String} (h1 : Eventually m env jv w) (h2 : EventuallyErr m ((name, w) :: env) jb code) :
                                                                                                                                                                                                                                                                                                                    EventuallyErr m env (Js.Expr.arrowCall [name] jb [jv]) code
                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventuallyErr_objLit1

                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {key ctor field : String} {jx : Js.Expr} {code : String} (h : EventuallyErr m env jx code) :
                                                                                                                                                                                                                                                                                                                      EventuallyErr m env (Js.Expr.objLit [(key, Js.Expr.str ctor), (field, jx)]) code
                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_member

                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jobj : Js.Expr} {field code : String} (h : EventuallyErr m env jobj code) :
                                                                                                                                                                                                                                                                                                                        EventuallyErr m env (jobj.member field) code
                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.encodeFields_zip

                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventually_ctorObj

                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {ctorName : String} {names : List String} {jes : List Js.Expr} {vs : List Js.JsValue} (hlen : names.length = jes.length) (h : EventuallyList m env jes vs) :
                                                                                                                                                                                                                                                                                                                            Eventually m env (Compile.objOf ctorName (names.zip jes)) (Js.JsValue.obj ((Core.keyFor ctorName, Js.JsValue.str ctorName) :: names.zip vs))

                                                                                                                                                                                                                                                                                                                            A constructor value is the tag followed by the fields, zipped back onto the names the type declares them under.

                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventually_dictLitZip

                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {keys : List String} {jes : List Js.Expr} {vs : List Js.JsValue} (hlen : keys.length = jes.length) (h : EventuallyList m env jes vs) :
                                                                                                                                                                                                                                                                                                                              Eventually m env (Js.Expr.dictLit (keys.zip jes)) (Js.JsValue.dict (keys.zip vs))
                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.EventuallyListErr

                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                (m : Js.Module) (env : Js.JsEnv) (jes : List Js.Expr) (code : String) :
                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventuallyListErr_head

                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {je : Js.Expr} {jes : List Js.Expr} {code : String} (h : EventuallyErr m env je code) :
                                                                                                                                                                                                                                                                                                                                    EventuallyListErr m env (je :: jes) code
                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventuallyListErr_tail

                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {je : Js.Expr} {jes : List Js.Expr} {v : Js.JsValue} {code : String} (h : Eventually m env je v) (ht : EventuallyListErr m env jes code) :
                                                                                                                                                                                                                                                                                                                                      EventuallyListErr m env (je :: jes) code
                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_arrayLit

                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {jes : List Js.Expr} {code : String} (h : EventuallyListErr m env jes code) :
                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventuallyErr_objLit

                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {fields : List (String × Js.Expr)} {code : String} (h : EventuallyListErr m env (List.map (fun (x : String × Js.Expr) => x.snd) fields) code) :
                                                                                                                                                                                                                                                                                                                                          EventuallyErr m env (Js.Expr.objLit fields) code
                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventuallyErr_dictLit

                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {entries : List (String × Js.Expr)} {code : String} (h : EventuallyListErr m env (List.map (fun (x : String × Js.Expr) => x.snd) entries) code) :
                                                                                                                                                                                                                                                                                                                                            EventuallyErr m env (Js.Expr.dictLit entries) code
                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyErr_ctorObj

                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {ctorName : String} {names : List String} {jes : List Js.Expr} {code : String} (hlen : names.length = jes.length) (h : EventuallyListErr m env jes code) :
                                                                                                                                                                                                                                                                                                                                              EventuallyErr m env (Compile.objOf ctorName (names.zip jes)) code
                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventuallyErr_dictLitZip

                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {keys : List String} {jes : List Js.Expr} {code : String} (hlen : keys.length = jes.length) (h : EventuallyListErr m env jes code) :
                                                                                                                                                                                                                                                                                                                                                EventuallyErr m env (Js.Expr.dictLit (keys.zip jes)) code
                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventuallyErr_call1

                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jx : Js.Expr} {code : String} (h : EventuallyErr m env jx code) :
                                                                                                                                                                                                                                                                                                                                                  EventuallyErr m env (Js.Expr.call name [jx]) code
                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventuallyErr_call1_helper

                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jx : Js.Expr} {w : Js.JsValue} {code : String} (h : Eventually m env jx w) (hh : Js.helper name [w] = some (Except.error code)) :
                                                                                                                                                                                                                                                                                                                                                    EventuallyErr m env (Js.Expr.call name [jx]) code
                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventuallyErr_call3_1

                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {j1 j2 j3 : Js.Expr} {code : String} (h : EventuallyErr m env j1 code) :
                                                                                                                                                                                                                                                                                                                                                      EventuallyErr m env (Js.Expr.call name [j1, j2, j3]) code
                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_call3_2

                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {j1 j2 j3 : Js.Expr} {a : Js.JsValue} {code : String} (h1 : Eventually m env j1 a) (h : EventuallyErr m env j2 code) :
                                                                                                                                                                                                                                                                                                                                                        EventuallyErr m env (Js.Expr.call name [j1, j2, j3]) code
                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventuallyErr_call3_3

                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {j1 j2 j3 : Js.Expr} {a b : Js.JsValue} {code : String} (h1 : Eventually m env j1 a) (h2 : Eventually m env j2 b) (h : EventuallyErr m env j3 code) :
                                                                                                                                                                                                                                                                                                                                                          EventuallyErr m env (Js.Expr.call name [j1, j2, j3]) code
                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventuallyErr_call3_helper

                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {j1 j2 j3 : Js.Expr} {a b c : Js.JsValue} {code : String} (h1 : Eventually m env j1 a) (h2 : Eventually m env j2 b) (h3 : Eventually m env j3 c) (hh : Js.helper name [a, b, c] = some (Except.error code)) :
                                                                                                                                                                                                                                                                                                                                                            EventuallyErr m env (Js.Expr.call name [j1, j2, j3]) code
                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyErr_call2L

                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jl jr : Js.Expr} {code : String} (h : EventuallyErr m env jl code) :
                                                                                                                                                                                                                                                                                                                                                              EventuallyErr m env (Js.Expr.call name [jl, jr]) code
                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventuallyErr_call2R

                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jl jr : Js.Expr} {a : Js.JsValue} {code : String} (h1 : Eventually m env jl a) (h2 : EventuallyErr m env jr code) :
                                                                                                                                                                                                                                                                                                                                                                EventuallyErr m env (Js.Expr.call name [jl, jr]) code
                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventuallyErr_call2_helper

                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {env : Js.JsEnv} {name : String} {jl jr : Js.Expr} {a b : Js.JsValue} {code : String} (h1 : Eventually m env jl a) (h2 : Eventually m env jr b) (hh : Js.helper name [a, b] = some (Except.error code)) :
                                                                                                                                                                                                                                                                                                                                                                  EventuallyErr m env (Js.Expr.call name [jl, jr]) code
                                                                                                                                                                                                                                                                                                                                                                  Used by

                                                                                                                                                                                                                                                                                                                                                                    One shape, whichever operand failed #

                                                                                                                                                                                                                                                                                                                                                                    Every shape compileExpr emits for a binary node evaluates the left operand and then the right, so a thrown code from either travels out. Reading it off the compiler's tables once keeps the induction from repeating the argument sixteen times.

                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.numericHelper_errL

                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {ty : Core.Ty} {op : Core.BinOp} {jl jr je : Js.Expr} {code : String} (h : Compile.numericHelper ty op jl jr = some je) (hl : EventuallyErr m jenv jl code) :
                                                                                                                                                                                                                                                                                                                                                                    EventuallyErr m jenv je code
                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.numericHelper_errR

                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {ty : Core.Ty} {op : Core.BinOp} {jl jr je : Js.Expr} {a : Js.JsValue} {code : String} (h : Compile.numericHelper ty op jl jr = some je) (ha : Eventually m jenv jl a) (hr : EventuallyErr m jenv jr code) :
                                                                                                                                                                                                                                                                                                                                                                      EventuallyErr m jenv je code
                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.compileExpr_bin_errL

                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {p : Core.Program} {ctx : Compile.Ctx} {op : Core.BinOp} {lhsE rhsE : Core.Expr} {je jl jr : Js.Expr} {ty tl : Core.Ty} {code : String} (hcl : Compile.compileExpr p ctx lhsE = Except.ok (jl, tl)) (hcr : Compile.compileExpr p ctx rhsE = Except.ok (jr, tl)) (hc : Compile.compileExpr p ctx (Core.Expr.bin op lhsE rhsE) = Except.ok (je, ty)) (hl : EventuallyErr m jenv jl code) :
                                                                                                                                                                                                                                                                                                                                                                        EventuallyErr m jenv je code
                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.compileExpr_bin_errR

                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {p : Core.Program} {ctx : Compile.Ctx} {op : Core.BinOp} {lhsE rhsE : Core.Expr} {je jl jr : Js.Expr} {ty tl : Core.Ty} {a : Js.JsValue} {code : String} (hand : op ≠ Core.BinOp.and) (hor : op ≠ Core.BinOp.or) (hcl : Compile.compileExpr p ctx lhsE = Except.ok (jl, tl)) (hcr : Compile.compileExpr p ctx rhsE = Except.ok (jr, tl)) (hc : Compile.compileExpr p ctx (Core.Expr.bin op lhsE rhsE) = Except.ok (je, ty)) (ha : Eventually m jenv jl a) (hr : EventuallyErr m jenv jr code) :
                                                                                                                                                                                                                                                                                                                                                                          EventuallyErr m jenv je code
                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.compileArgs_length

                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {p : Core.Program} {ctx : Compile.Ctx} {items : List Core.Expr} {js : List (Js.Expr × Core.Ty)} :
                                                                                                                                                                                                                                                                                                                                                                            Compile.compileArgs p ctx items = Except.ok js → js.length = items.length

                                                                                                                                                                                                                                                                                                                                                                            The dictionary operations: the operand the compiler read as a Dict, the expression it emitted, and the type it gave back.

                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.compileValues_length

                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {p : Core.Program} {ctx : Compile.Ctx} {entries : List (String × Core.Expr)} {js : List (Js.Expr × Core.Ty)} :
                                                                                                                                                                                                                                                                                                                                                                              Compile.compileValues p ctx entries = Except.ok js → js.length = entries.length
                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.evalArgs_length

                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {p : Core.Program} {f : Nat} {env : Env} {items : List Core.Expr} {vs : List Value} :
                                                                                                                                                                                                                                                                                                                                                                                evalArgs p f env items = Except.ok vs → vs.length = items.length
                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                  structure

                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.JsEnvAgrees

                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] (env : Env) (jenv : Js.JsEnv) :

                                                                                                                                                                                                                                                                                                                                                                                  The generated environment binds everything the reference one does, to the encoding of the same value. It may bind more: a public function's entry check leaves the raw parameters in scope, and the compiled body never names them.

                                                                                                                                                                                                                                                                                                                                                                                  scrutFree is the other half, and match is why it is here: the generated arm chain runs under the scrutinee bound to scrutName, so a reference environment that bound that name too would be read on one side and shadowed on the other. Every name a program can bind went through validateIdent, which rejects the __ prefix.

                                                                                                                                                                                                                                                                                                                                                                                  bodyFree is why a call the compiler redirects to a declaration's body lands on the module's function of that name: calleeName lets a binding holding a function shadow the module's own, and nothing the generated code binds is spelled under the body prefix.

                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.JsEnvAgrees.scrutFree

                                                                                                                                                                                                                                                                                                                                                                                      source

                                                                                                                                                                                                                                                                                                                                                                                      The reference environment binds no reserved name, so in particular not the scrutinee's.

                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.lookup_cons_none

                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {env : Env} {name : String} {v : Value} {key : String} (hname : name ≠ key) (h : env.lookup? key = none) :
                                                                                                                                                                                                                                                                                                                                                                                        Env.lookup? ((name, v) :: env) key = none
                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.JsEnvAgrees.cons

                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {env : Env} {jenv : Js.JsEnv} {name : String} {v : Value} (h : JsEnvAgrees env jenv) (hname : isReserved name = false) :
                                                                                                                                                                                                                                                                                                                                                                                          JsEnvAgrees ((name, v) :: env) ((name, encodeValue v) :: jenv)
                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.lookup_of_encodeEnv

                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {env : Env} {name : String} {jv : Js.JsValue} :
                                                                                                                                                                                                                                                                                                                                                                                            Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == name) (encodeEnv env)) = some jv → ∃ (v : Value), env.lookup? name = some v

                                                                                                                                                                                                                                                                                                                                                                                            The names of encodeEnv env are the names of env, so an unreserved one found there is bound.

                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.jsEnvAgrees_encodeEnv

                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] (env : Env) (hres : ∀ (name : String) (v : Value), env.lookup? name = some v → isReserved name = false) :
                                                                                                                                                                                                                                                                                                                                                                                              Used by

                                                                                                                                                                                                                                                                                                                                                                                                Traversals #

                                                                                                                                                                                                                                                                                                                                                                                                The reference semantics and the model walk an array with one auxiliary function each, written to the same shape, so a traversal needs a lemma that walks the two together. The body's induction hypothesis is taken over every environment, which is what lets it apply one element at a time.

                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.isNumKey_encode

                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.isStrKey_encode

                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.key_of_keysOk

                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {ps : List (Value × Value)} (h : keysOk ps = true) {pr : Value × Value} (hp : pr ∈ ps) :
                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.keyLe_encode

                                                                                                                                                                                                                                                                                                                                                                                                      source

                                                                                                                                                                                                                                                                                                                                                                                                      The two sides order the keys the same way. uint32 is why this asks for the key to be one of the two key shapes rather than holding for every value: it encodes to a number the model would compare, and the reference semantics refuses it.

                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.sortPairs_encode

                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.keysOk_of_hasElemTy

                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {p : Core.Program} {keys xs : List Value} {tbody : Core.Ty} (hkey : tbody = Core.Ty.int53 ∨ tbody = Core.Ty.string) (h : Value.hasElemTy p keys tbody = true) :
                                                                                                                                                                                                                                                                                                                                                                                                          keysOk (keys.zip xs) = true

                                                                                                                                                                                                                                                                                                                                                                                                          The key type the compiler insists on is what says the sort never refuses the keys it was handed.

                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventually_sortByJs

                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs keys vs : List Js.JsValue} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalMapJs m g' jenv binder jbody xs = Except.ok keys) (hs : Js.sortPairs (keys.zip xs) = Except.ok vs) :
                                                                                                                                                                                                                                                                                                                                                                                                            Eventually m jenv (jarr.sortByJs binder jbody) (Js.JsValue.arr vs)
                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventually_mapJs

                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs vs : List Js.JsValue} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalMapJs m g' jenv binder jbody xs = Except.ok vs) :
                                                                                                                                                                                                                                                                                                                                                                                                              Eventually m jenv (jarr.mapJs binder jbody) (Js.JsValue.arr vs)
                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventually_filterJs

                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs vs : List Js.JsValue} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalFilterJs m g' jenv binder jbody xs = Except.ok vs) :
                                                                                                                                                                                                                                                                                                                                                                                                                Eventually m jenv (jarr.filterJs binder jbody) (Js.JsValue.arr vs)
                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventually_findJs

                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {v : Js.JsValue} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalFindJs m g' jenv binder jbody xs = Except.ok v) :
                                                                                                                                                                                                                                                                                                                                                                                                                  Eventually m jenv (jarr.findJs binder jbody) v
                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventually_quantJs

                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {op : Core.QuantOp} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {v : Js.JsValue} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalQuantJs m g' jenv op binder jbody xs = Except.ok v) :
                                                                                                                                                                                                                                                                                                                                                                                                                    Eventually m jenv (Js.Expr.quantJs op jarr binder jbody) v
                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventually_reduceJs

                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jinit jbody : Js.Expr} {accName elemName : String} {xs : List Js.JsValue} {acc v : Js.JsValue} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hi : Eventually m jenv jinit acc) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalReduceJs m g' jenv accName elemName jbody acc xs = Except.ok v) :
                                                                                                                                                                                                                                                                                                                                                                                                                      Eventually m jenv (jarr.reduceJs jinit accName elemName jbody) v
                                                                                                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                                                                                                        Arms #

                                                                                                                                                                                                                                                                                                                                                                                                                        match compiles to an arrow that binds the scrutinee to scrutName and then to a chain of conditionals, one per arm: the arm's tests conjoined with &&, its body applied to the values its pattern reads. The last arm carries no test — exhaustiveness was checked at compile time, so falling through to it is what the compiler decided is safe.

                                                                                                                                                                                                                                                                                                                                                                                                                        Three things therefore have to line up with firstMatch: a matching pattern makes its tests true, a pattern that does not match makes the conjunction false without evaluating past the test that failed, and the values the arm reads out of the scrutinee are the ones the pattern bound.

                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventually_eqq

                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jl jr : Js.Expr} {a b : Js.JsValue} (hl : Eventually m jenv jl a) (hr : Eventually m jenv jr b) :
                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventually_and_false

                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jl jr : Js.Expr} (h : Eventually m jenv jl (Js.JsValue.bool false)) :
                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventually_and_true

                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jl jr : Js.Expr} {b : Bool} (hl : Eventually m jenv jl (Js.JsValue.bool true)) (hr : Eventually m jenv jr (Js.JsValue.bool b)) :
                                                                                                                                                                                                                                                                                                                                                                                                                            Eventually m jenv (Js.Expr.binary "&&" jl jr) (Js.JsValue.bool b)
                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventually_andFold_false

                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventually_andFold_true

                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} (ts : List Js.Expr) (t : Js.Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                Eventually m jenv t (Js.JsValue.bool true) → (∀ (x : Js.Expr), x ∈ ts → Eventually m jenv x (Js.JsValue.bool true)) → Eventually m jenv (List.foldl (Js.Expr.binary "&&") t ts) (Js.JsValue.bool true)
                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                  def

                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.TestsFail

                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                  (m : Js.Module) (jenv : Js.JsEnv) :

                                                                                                                                                                                                                                                                                                                                                                                                                                  The tests of an arm the scrutinee does not take: the one that decides it evaluates to false, and every test before it to true. Nothing is said about the tests after it — && short-circuits, and an inner test that reads a field the value does not carry is exactly what that protects.

                                                                                                                                                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.TestsFail.append_right

                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {l r : List Js.Expr} :
                                                                                                                                                                                                                                                                                                                                                                                                                                      TestsFail m jenv l → TestsFail m jenv (l ++ r)
                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.TestsFail.append_left

                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {l r : List Js.Expr} :
                                                                                                                                                                                                                                                                                                                                                                                                                                        (∀ (x : Js.Expr), x ∈ l → Eventually m jenv x (Js.JsValue.bool true)) → TestsFail m jenv r → TestsFail m jenv (l ++ r)
                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventually_andFold_of_fail

                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} (ts : List Js.Expr) (t : Js.Expr) :
                                                                                                                                                                                                                                                                                                                                                                                                                                          TestsFail m jenv (t :: ts) → Eventually m jenv (List.foldl (Js.Expr.binary "&&") t ts) (Js.JsValue.bool false)
                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventually_arrowCallN

                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {names : List String} {paths : List Js.Expr} {vals : List Js.JsValue} {jbody : Js.Expr} {v : Js.JsValue} (hargs : EventuallyList m jenv paths vals) (hlen : names.length = vals.length) (hbody : Eventually m (Js.bindAll names vals ++ jenv) jbody v) :
                                                                                                                                                                                                                                                                                                                                                                                                                                            Eventually m jenv (Js.Expr.arrowCall names jbody paths) v
                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                              def

                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.LookupsAgree

                                                                                                                                                                                                                                                                                                                                                                                                                                              source

                                                                                                                                                                                                                                                                                                                                                                                                                                              Each declared field name reads back the value the reference semantics has at that position. The two sides line up by name on the generated side and by position on the reference side, which is why the names have to be distinct and none of them may be tag.

                                                                                                                                                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.lookupsAgree_of_hasFieldTys

                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {p : Core.Program} (fields : List (String × Value)) (ftys : List (String × Core.Ty)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                  Value.hasFieldTys p fields ftys = true → (List.map (fun (x : String × Core.Ty) => x.fst) ftys).Nodup → ∀ (pre : List (String × Js.JsValue)), (∀ (n : String), n ∈ List.map (fun (x : String × Core.Ty) => x.fst) ftys → List.find? (fun (x : String × Js.JsValue) => x.fst == n) pre = none) → LookupsAgree (pre ++ encodeFields fields) ftys (List.map (fun (x : String × Value) => x.snd) fields)
                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                    def

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.PathsAgree

                                                                                                                                                                                                                                                                                                                                                                                                                                                    source

                                                                                                                                                                                                                                                                                                                                                                                                                                                    The values an arm's paths read, against the values its pattern bound: the same names in the same order, and no name the scrutinee binding could shadow.

                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                        def

                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.EventuallyEach

                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.ValuesTyped.length

                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {p : Core.Program} {vs : List Value} {tys : List Core.Ty} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                            ValuesTyped p vs tys → vs.length = tys.length
                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyEach_members

                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {path : Js.Expr} {obj : List (String × Js.JsValue)} (hpath : Eventually m jenv path (Js.JsValue.obj obj)) (ftys : List (String × Core.Ty)) (vs : List Value) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                              LookupsAgree obj ftys vs → EventuallyEach m jenv (List.map (fun (f : String × Core.Ty) => path.member f.fst) ftys) vs
                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.SignatureOk

                                                                                                                                                                                                                                                                                                                                                                                                                                                                source

                                                                                                                                                                                                                                                                                                                                                                                                                                                                What the arm chain needs from the program's type declarations: a constructor's fields are named apart from each other and from the key its name is carried under, and every value the type admits carries its own constructor under that same key — an arm tests one key, and the value it is tested against wrote the key of whatever constructor it was built with. Compile.validateType checks both and compileProgram runs it over every declared type, so Decl.decl_correct discharges this from the module it was handed.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.signatureOk_fields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {p : Core.Program} (hsig : SignatureOk p) {ty : Core.Ty} {heads : List (Compile.Head × List (String × Core.Ty))} {name : String} {ftys : List (String × Core.Ty)} (hs : Compile.signature p.types ty = some heads) (hfind : Option.map (fun (x : Compile.Head × List (String × Core.Ty)) => x.snd) (List.find? (fun (x : Compile.Head × List (String × Core.Ty)) => x.fst == Compile.Head.ctor name) heads) = some ftys) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (∀ (f : String × Core.Ty), f ∈ ftys → f.fst ≠ Core.keyFor name) ∧ (List.map (fun (x : String × Core.Ty) => x.fst) ftys).Nodup
                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.signatureOk_key

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {p : Core.Program} (hsig : SignatureOk p) {ty : Core.Ty} {heads : List (Compile.Head × List (String × Core.Ty))} {name ctor : String} {ftys : List (String × Core.Ty)} {flds : List (String × Value)} (hs : Compile.signature p.types ty = some heads) (hfind : Option.map (fun (x : Compile.Head × List (String × Core.Ty)) => x.snd) (List.find? (fun (x : Compile.Head × List (String × Core.Ty)) => x.fst == Compile.Head.ctor name) heads) = some ftys) (hv : Value.hasTy p (Value.obj ctor flds) ty = true) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The key an arm tests is the key the value it is tested against wrote its constructor under.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.obj_of_signature_ctor

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {p : Core.Program} {ty : Core.Ty} {heads : List (Compile.Head × List (String × Core.Ty))} {name : String} {ftys : List (String × Core.Ty)} {v : Value} (hs : Compile.signature p.types ty = some heads) (hfind : Option.map (fun (x : Compile.Head × List (String × Core.Ty)) => x.snd) (List.find? (fun (x : Compile.Head × List (String × Core.Ty)) => x.fst == Compile.Head.ctor name) heads) = some ftys) (hv : Value.hasTy p v ty = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ∃ (ctor : String), ∃ (fields : List (String × Value)), v = Value.obj ctor fields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        A constructor pattern only compiles against a type whose values are objects. bool has a signature too, but its heads are literals, so the lookup by constructor name fails before this is reached.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.sameValue_comm

                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.litJs_ok

                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventually_litTest

                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} {ty : Core.Ty} {l : Core.Lit} {jl path : Js.Expr} {v : Value} (hlit : Compile.litJs ty l = Except.ok jl) (hv : Value.hasTy p v ty = true) (hpath : Eventually m jenv path (encodeValue v)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Eventually m jenv (Js.Expr.binary "===" path jl) (Js.JsValue.bool ((litValue l).beq v))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventually_tagTest

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {path : Js.Expr} {ctor name : String} {fields : List (String × Value)} (hkey : Core.keyFor ctor = Core.keyFor name) (hpath : Eventually m jenv path (encodeValue (Value.obj ctor fields))) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Eventually m jenv (Js.Expr.binary "===" (path.member (Core.keyFor name)) (Js.Expr.str name)) (Js.JsValue.bool (ctor == name))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.PathsAgree.append

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {p1 : List (String × Js.Expr × Core.Ty)} {b1 : Env} {p2 : List (String × Js.Expr × Core.Ty)} {b2 : Env} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  PathsAgree m jenv p1 b1 → PathsAgree m jenv p2 b2 → PathsAgree m jenv (p1 ++ p2) (b1 ++ b2)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.patParts_matched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) (ty : Core.Ty) (path : Js.Expr) (pat : Core.Pat) (v : Value) (tests : List Js.Expr) (pbinds : List (String × Js.Expr × Core.Ty)) (binds : Env) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Value.hasTy p v ty = true → Compile.patParts p.types ty path pat = Except.ok (tests, pbinds) → Eventually m jenv path (encodeValue v) → matchPat pat v = some binds → (∀ (t : Js.Expr), t ∈ tests → Eventually m jenv t (Js.JsValue.bool true)) ∧ PathsAgree m jenv pbinds binds

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    A pattern that matched makes every test the compiler emitted true, and the paths the arm reads land on the values the pattern bound.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.patParts_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) (ty : Core.Ty) (path : Js.Expr) (pat : Core.Pat) (v : Value) (tests : List Js.Expr) (pbinds : List (String × Js.Expr × Core.Ty)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Value.hasTy p v ty = true → Compile.patParts p.types ty path pat = Except.ok (tests, pbinds) → Eventually m jenv path (encodeValue v) → matchPat pat v = none → TestsFail m jenv tests

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      A pattern that did not match makes the conjunction false: the test that decides it evaluates to false, and the ones before it to true.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.patPartsList_matched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) (tys : List Core.Ty) (paths : List Js.Expr) (pats : List Core.Pat) (vs : List Value) (tests : List Js.Expr) (pbinds : List (String × Js.Expr × Core.Ty)) (binds : Env) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        ValuesTyped p vs tys → Compile.patPartsList p.types tys paths pats = Except.ok (tests, pbinds) → EventuallyEach m jenv paths vs → matchPats pats vs = some binds → (∀ (t : Js.Expr), t ∈ tests → Eventually m jenv t (Js.JsValue.bool true)) ∧ PathsAgree m jenv pbinds binds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.patPartsList_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) (tys : List Core.Ty) (paths : List Js.Expr) (pats : List Core.Pat) (vs : List Value) (tests : List Js.Expr) (pbinds : List (String × Js.Expr × Core.Ty)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ValuesTyped p vs tys → Compile.patPartsList p.types tys paths pats = Except.ok (tests, pbinds) → EventuallyEach m jenv paths vs → pats.length = vs.length → matchPats pats vs = none → TestsFail m jenv tests
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventually_ident

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {name : String} {w : Js.JsValue} (h : Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == name) jenv) = some w) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Eventually m jenv (Js.Expr.ident name) w
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.JsEnvAgrees.consScrut

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {env : Env} {jenv : Js.JsEnv} (h : JsEnvAgrees env jenv) (w : Js.JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.PathsAgree.names

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {pbinds : List (String × Js.Expr × Core.Ty)} {binds : Env} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                PathsAgree m jenv pbinds binds → List.map (fun (x : String × Js.Expr × Core.Ty) => x.fst) pbinds = List.map (fun (x : String × Value) => x.fst) binds
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.PathsAgree.eventuallyList

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {pbinds : List (String × Js.Expr × Core.Ty)} {binds : Env} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  PathsAgree m jenv pbinds binds → EventuallyList m jenv (List.map (fun (x : String × Js.Expr × Core.Ty) => x.snd.fst) pbinds) (encodeList (List.map (fun (x : String × Value) => x.snd) binds))
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.PathsAgree.jsEnvAgrees

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {env : Env} {jenv : Js.JsEnv} (hjenv : JsEnvAgrees env jenv) {pbinds : List (String × Js.Expr × Core.Ty)} {binds : Env} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    PathsAgree m jenv pbinds binds → JsEnvAgrees (binds ++ env) (Js.bindAll (List.map (fun (x : String × Js.Expr × Core.Ty) => x.fst) pbinds) (encodeList (List.map (fun (x : String × Value) => x.snd) binds)) ++ jenv)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.compileAlts_cons_inv

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {p : Core.Program} {ctx : Compile.Ctx} {tscrut : Core.Ty} {alt : Core.Alt} {rest : List Core.Alt} {arms : List Compile.Arm} (h : Compile.compileAlts p ctx tscrut (alt :: rest) = Except.ok arms) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      ∃ (tests : List Js.Expr), ∃ (pbinds : List (String × Js.Expr × Core.Ty)), ∃ (jbody : Js.Expr), ∃ (tbody : Core.Ty), ∃ (tail : List Compile.Arm), Compile.patParts p.types tscrut (Js.Expr.ident Compile.scrutName) alt.pat = Except.ok (tests, pbinds) ∧ Compile.compileExpr p (List.map (fun (b : String × Js.Expr × Core.Ty) => (b.fst, b.snd.snd)) pbinds ++ ctx) alt.body = Except.ok (jbody, tbody) ∧ Compile.compileAlts p ctx tscrut rest = Except.ok tail ∧ arms = { tests := tests, names := List.map (fun (x : String × Js.Expr × Core.Ty) => x.fst) pbinds, paths := List.map (fun (x : String × Js.Expr × Core.Ty) => x.snd.fst) pbinds, body := jbody, ty := tbody } :: tail
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        A fold's arms, and the node the walk rebuilt #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        A fold reads its alternatives exactly as a match does, but against a node that is not a value of the declared type: every field that came round carries the fold's answer for it rather than the field. These are the twins of patParts_matched, patParts_unmatched and eventually_chain against that node. Only the top level differs — what a folded field binds is an ordinary type, so everything nested inside goes to patPartsList_matched and its partner unchanged.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.head_ctor_beq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.heads_find_of_findAt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] (cs : List Core.CtorDef) (ctor : String) (c : Core.CtorDef) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          List.find? (fun (x : Core.CtorDef) => x.name == ctor) cs = some c → Option.map (fun (x : Compile.Head × List (String × Core.Ty)) => x.snd) (List.find? (fun (x : Compile.Head × List (String × Core.Ty)) => x.fst == Compile.Head.ctor ctor) (List.map (fun (c : Core.CtorDef) => (Compile.Head.ctor c.name, List.map (fun (f : Core.Field) => (f.name, f.ty)) c.fields)) cs)) = some (List.map (fun (f : Core.Field) => (f.name, f.ty)) c.fields)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          A constructor the declaration names is the head the signature carries, with the fields it declares. Both sides read ctorsAt, so the lookup that finds one finds the other.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.specOf_find_aux

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] (tn : String) (ta : List Core.Ty) (cs : List Core.CtorDef) (ctor : String) (c : Core.CtorDef) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            List.find? (fun (x : Core.CtorDef) => x.name == ctor) cs = some c → Option.map (fun (x : String × List (String × Js.FoldKind)) => x.snd) (List.find? (fun (x : String × List (String × Js.FoldKind)) => x.fst == ctor) (List.map (fun (c : Core.CtorDef) => (c.name, List.map (fun (f : Core.Field) => (f.name, Compile.jsFoldKind (Core.foldKindOf tn ta f.ty))) c.fields)) cs)) = some (List.map (fun (f : Core.Field) => (f.name, Compile.jsFoldKind (Core.foldKindOf tn ta f.ty))) c.fields)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The spec the emitter wrote names each constructor with the fields that come round. foldSpecOf and TypeDef.findAt? both read ctorsAt, so the entry for a constructor is the declaration's.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.foldSpecOf_find

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {p : Core.Program} {tn : String} {ta : List Core.Ty} {t : Core.TypeDef} {ctor : String} {c : Core.CtorDef} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hc : t.findAt? ta ctor = some c) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.foldKey_eq

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {p : Core.Program} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {t : Core.TypeDef} {name ctor : String} {c : Core.CtorDef} {fields : List (String × Value)} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hname : t.findAt? ta name = some c) (hv : Value.hasTy p (Value.obj ctor fields) (Core.Ty.named tn ta) = true) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                The key a fold's alternative tests is the key the value it walks wrote its constructor under. Both constructors belong to the type the fold names, and SignatureOk settles the key for every value that type admits — which is what makes the one key Helper.fold is handed right for every node.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.mapSetAll_of_nodup

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] (ps acc : List (String × Js.JsValue)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (∀ (q : String × Js.JsValue), q ∈ ps → ∀ (a : String × Js.JsValue), a ∈ acc → q.fst ≠ a.fst) → (List.map (fun (x : String × Js.JsValue) => x.fst) ps).Nodup → Js.Runtime.mapSetAll acc ps = acc ++ ps

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  A node rebuilt with a set-all is the node written out: what the walk was handed comes first and each field is appended after it. Every mapSet is an append because the fields are named apart from each other and from the key, which is what SignatureOk gives.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.foldFields_names

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {p : Core.Program} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {result : Core.Ty} {t : Core.TypeDef} {ctor : String} {c : Core.CtorDef} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hfind : t.findAt? ta ctor = some c) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    (∀ (f : String × Core.Ty), f ∈ Compile.foldFieldTys tn ta result c.fields → f.fst ≠ Core.keyFor ctor) ∧ (List.map (fun (x : String × Core.Ty) => x.fst) (Compile.foldFieldTys tn ta result c.fields)).Nodup

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    A fold's rebuilt node carries its fields named apart from each other and from the key its constructor is written under. foldFieldTys leaves the declared names alone, and SignatureOk is what says those are apart — the same fact a match reads, at the same constructor.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.foldEach_members

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {result : Core.Ty} {t : Core.TypeDef} {path : Js.Expr} {ctor : String} {fields : List (String × Value)} {c : Core.CtorDef} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hfind : t.findAt? ta ctor = some c) (hft : Value.hasFieldTys p fields (Compile.foldFieldTys tn ta result c.fields) = true) (hpath : Eventually m jenv path (encodeValue (Value.obj ctor fields))) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      EventuallyEach m jenv (List.map (fun (f : String × Core.Ty) => path.member f.fst) (Compile.foldFieldTys tn ta result c.fields)) (List.map (fun (x : String × Value) => x.snd) fields)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Every path a fold's alternative reads lands on the field the rebuilt node carries there.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.foldPatParts_matched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {result : Core.Ty} {t : Core.TypeDef} {path : Js.Expr} {pat : Core.Pat} {ctor : String} {fields : List (String × Value)} {c : Core.CtorDef} {tests : List Js.Expr} {pbinds : List (String × Js.Expr × Core.Ty)} {binds : Env} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hfind : t.findAt? ta ctor = some c) (hft : Value.hasFieldTys p fields (Compile.foldFieldTys tn ta result c.fields) = true) (hpp : Compile.foldPatParts p.types tn ta result path pat = Except.ok (tests, pbinds)) (hpath : Eventually m jenv path (encodeValue (Value.obj ctor fields))) (hm : matchPat pat (Value.obj ctor fields) = some binds) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        (∀ (tst : Js.Expr), tst ∈ tests → Eventually m jenv tst (Js.JsValue.bool true)) ∧ PathsAgree m jenv pbinds binds

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        A fold's alternative that matched makes every test the compiler emitted true, and the paths the arm reads land on the values the pattern bound.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The twin of patParts_matched, against the node the walk rebuilt. What is asked of that node is not that it is a value of the declared type — it is not one, the fields that came round carry the fold's answers — but that its fields are the ones foldFieldTys names.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.foldPatParts_unmatched

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {p : Core.Program} {m : Js.Module} {jenv : Js.JsEnv} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {result : Core.Ty} {t : Core.TypeDef} {path : Js.Expr} {pat : Core.Pat} {ctor : String} {fields ofields : List (String × Value)} {c : Core.CtorDef} {tests : List Js.Expr} {pbinds : List (String × Js.Expr × Core.Ty)} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hfind : t.findAt? ta ctor = some c) (hov : Value.hasTy p (Value.obj ctor ofields) (Core.Ty.named tn ta) = true) (hft : Value.hasFieldTys p fields (Compile.foldFieldTys tn ta result c.fields) = true) (hpp : Compile.foldPatParts p.types tn ta result path pat = Except.ok (tests, pbinds)) (hpath : Eventually m jenv path (encodeValue (Value.obj ctor fields))) (hm : matchPat pat (Value.obj ctor fields) = none) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          TestsFail m jenv tests

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          A fold's alternative that did not match makes the conjunction false: the test that decides it evaluates to false, and the ones before it to true. The twin of patParts_unmatched.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.compileFoldAlts_cons_inv

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {p : Core.Program} {ctx : Compile.Ctx} {tn : String} {ta : List Core.Ty} {result : Core.Ty} {alt : Core.Alt} {rest : List Core.Alt} {arms : List Compile.Arm} (h : Compile.compileFoldAlts p ctx tn ta result (alt :: rest) = Except.ok arms) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            ∃ (tests : List Js.Expr), ∃ (pbinds : List (String × Js.Expr × Core.Ty)), ∃ (jbody : Js.Expr), ∃ (tbody : Core.Ty), ∃ (tail : List Compile.Arm), Compile.foldPatParts p.types tn ta result (Js.Expr.ident Compile.scrutName) alt.pat = Except.ok (tests, pbinds) ∧ Compile.compileExpr p (List.map (fun (b : String × Js.Expr × Core.Ty) => (b.fst, b.snd.snd)) pbinds ++ ctx) alt.body = Except.ok (jbody, tbody) ∧ Compile.compileFoldAlts p ctx tn ta result rest = Except.ok tail ∧ arms = { tests := tests, names := List.map (fun (x : String × Js.Expr × Core.Ty) => x.fst) pbinds, paths := List.map (fun (x : String × Js.Expr × Core.Ty) => x.snd.fst) pbinds, body := jbody, ty := tbody } :: tail

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            compileAlts_cons_inv over compileFoldAlts: the arms are the alternatives one for one, each with the tests and binders its pattern gave and its body compiled against them.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventually_foldJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jscrut : Js.Expr} {key : String} {spec : Js.FoldSpec} {binder : String} {jbody : Js.Expr} {x w : Js.JsValue} (ha : Eventually m jenv jscrut x) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalFoldJs m g' jenv key spec binder jbody x = Except.ok w) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Eventually m jenv (jscrut.foldJs key spec binder jbody) w

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              A fold evaluates its scrutinee and then walks it, which is what evalFoldJs does. The twin of eventually_mapJs.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.ctorFields_not_key

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {p : Core.Program} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {t : Core.TypeDef} {ctor : String} {c : Core.CtorDef} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hfind : t.findAt? ta ctor = some c) (fd : Core.Field) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                fd ∈ c.fields → fd.name ≠ Core.keyFor ctor

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                A constructor's fields are named apart from the key its own name is carried under, so a field is read past the tag entry the node carries first.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.encodeFields_map_fst

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] (fs : List (String × Value)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  List.map (fun (x : String × Js.JsValue) => x.fst) (encodeFields fs) = List.map (fun (x : String × Value) => x.fst) fs
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.fst_of_hasFieldTys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {p : Core.Program} (fs : List (String × Value)) (ftys : List (String × Core.Ty)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Value.hasFieldTys p fs ftys = true → List.map (fun (x : String × Value) => x.fst) fs = List.map (fun (x : String × Core.Ty) => x.fst) ftys

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    A value's fields are named by the types it was checked against, in the same order.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.lookupField_encodeFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.findAt_first

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {t : Core.TypeDef} (ta : List Core.Ty) {first : Core.CtorDef} {rest : List Core.CtorDef} (hctors : t.ctors = first :: rest) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The type the fold names has a first constructor, so the key Helper.fold is handed is a key some constructor of that type is carried under.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.mapSetAll_encodeFields

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {p : Core.Program} (hsig : SignatureOk p) {tn : String} {ta : List Core.Ty} {result : Core.Ty} {t : Core.TypeDef} {ctor key : String} {fs : List (String × Value)} {c : Core.CtorDef} (ht : List.find? (fun (x : Core.TypeDef) => x.name == tn) p.types = some t) (hfind : t.findAt? ta ctor = some c) (hfsty : Value.hasFieldTys p fs (Compile.foldFieldTys tn ta result c.fields) = true) (hkey : key = Core.keyFor ctor) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          The node evalFoldJs rebuilds with a set-all is the node encodeValue writes for the fold's answer at that constructor: the key comes first and the walked fields follow it in the order they were walked. Every mapSet is an append because SignatureOk names the fields apart from each other and from the key, and foldFieldTys left those names alone.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Walking a fold #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            A fold recurses on the value rather than on the expression, so its four walkers need an induction of their own: one strong induction on a bound for the value's size, carrying all four at once because they call each other. Sound.hasTy_of_fold is that induction for the types; this is it for the values.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The fuel is existential at every level and a node's arms run at the fuel its own walk was handed, so each level takes the max of what its subwalks asked for. A finite value asks for a finite amount.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Calls #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            A call is the one shape that leaves the expression it sits in: the callee's body is not a subterm, and the name it lands on is settled at run time by the environment. These read the generated side of that.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.helper_of_unreserved

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {name : String} (h : isReserved name = false) (args : List Js.JsValue) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Js.helper name args = none

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            No name a program can write is a runtime helper: validateIdent rejects the reserved prefix and the helper dispatch is guarded by it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.find?_name

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {p : Core.Program} {name : String} {d : Core.Decl} (h : p.find? name = some d) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              d.name = name

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              A declaration found by name carries that name.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventually_fnRef

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {name : String} (hfree : Option.map (fun (x : String × Js.JsValue) => x.snd) (List.find? (fun (x : String × Js.JsValue) => x.fst == name) jenv) = none) (hmod : (List.find? (fun (x : Js.Func) => x.name == name) m.funcs).isSome = true) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                A function reference in the generated code: the name is not bound, so it reads the module's own function of that name.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.calleeName_agrees

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {env : Env} {jenv : Js.JsEnv} {name : String} (h : JsEnvAgrees env jenv) (hname : isReserved name = false) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Js.calleeName jenv name = calleeOf env name

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  The generated code and the reference semantics pick the same callee. A function value in the reference environment is one the generated environment holds under the same name; anything else leaves both sides with the name they were given.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.calleeName_bodyName

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {env : Env} {jenv : Js.JsEnv} {name : String} (h : JsEnvAgrees env jenv) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Js.calleeName jenv (bodyName name) = bodyName name

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    A call the compiler redirected to a declaration's body lands on the module's function of that name. Nothing the generated code binds carries the body prefix, so no binding shadows it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventually_call

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {name : String} {jargs : List Js.Expr} {jvs : List Js.JsValue} {r : Js.JsValue} (hname : Js.helper name jvs = none) (hargs : EventuallyList m jenv jargs jvs) (hcall : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.callFunctionAt m g' (Js.calleeName jenv name) jvs = Except.ok r) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Eventually m jenv (Js.Expr.call name jargs) r

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      A call in the generated code: the arguments evaluate, the name is no helper, and the callee returns what the reference semantics returned.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Stated with "no helper answers this call" rather than with the reserved prefix, because the two callees the compiler writes sit on opposite sides of that prefix: a declaration's own name is outside it and a declaration's body is inside it, and neither is a row of the table.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventually_check

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {d : Js.TyDesc} {je : Js.Expr} {w : Js.JsValue} (hx : Eventually m jenv je w) (hc : Js.checkTy [] w d = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Eventually m jenv (Js.Expr.check d je) (Js.normTy [] w d)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        A call through a function value crosses the boundary, so what comes back is read the way an argument is: where the check accepts it, the caller holds what the normalisation makes of it.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventuallyErr_check

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {d : Js.TyDesc} {je : Js.Expr} {code : String} (hx : EventuallyErr m jenv je code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          EventuallyErr m jenv (Js.Expr.check d je) code

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          The same when what it reads threw: the check never runs, so the code the callee raised is the code the caller sees.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventuallyErr_call

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {name : String} {jargs : List Js.Expr} {jvs : List Js.JsValue} {code : String} (hname : Js.helper name jvs = none) (hargs : EventuallyList m jenv jargs jvs) (hcall : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.callFunctionAt m g' (Js.calleeName jenv name) jvs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            EventuallyErr m jenv (Js.Expr.call name jargs) code

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The same when the callee throws.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyErr_call_args

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {name : String} {jargs : List Js.Expr} {code : String} (hargs : EventuallyListErr m jenv jargs code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              EventuallyErr m jenv (Js.Expr.call name jargs) code

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              And when an argument throws before the call is made.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.ModuleHasDecls

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Every declaration has a function of its own name in the module. Decl reads it off the compiled program; a function reference evaluates to the name, and the generated code resolves it there.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.DeclAgrees

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    What a call through a function value needs about the declaration it lands on: at this much reference fuel, the module's function of that name returns what the body returns. The body runs at exactly the fuel the call is left with, so this is the same fuel the expression-level statement is at.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    The entry and not the body, because a function reference evaluates to the declared name: passing a declaration by name calls it the way a consumer would, entry check and all. A call the compiler can see the callee of goes to DeclBodyAgrees instead.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    What the entry hands back is read through the declared return type, so this does not say the caller is holding encodeValue v: it says the caller is holding something the descriptor accepts, and that reading it back in is what the body built. That is what the compiled call does with it — a call through a function value is a crossing in both directions.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.DeclBodyAgrees

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        The same for the body function, which is where a call whose callee the compiler read off the program goes. The arguments are already the encoding of values of the declared types, which is exactly what the entry check would have handed back, so the check is the one thing this statement does without.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.AgreesAt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Expression-level agreement at one amount of the reference semantics' fuel.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            The induction runs on this rather than on the fragment derivation: a call evaluates the callee's body, which is not a subterm of the call, at one less fuel.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.fragment_correct_succ

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] (p : Core.Program) (m : Js.Module) (hsig : SignatureOk p) (hprog : ProgramTyped p) (hmod : ModuleHasDecls p m) (f : Nat) (ih : AgreesAt p m f) (ihd : DeclAgrees p m f) (ihdb : DeclBodyAgrees p m f) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                AgreesAt p m (f + 1)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                One step of the induction behind fragment_correct_in, carrying agreement from f to f + 1.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                The induction is on fuel rather than on the fragment derivation because a call runs the callee's body, which is not a subterm of the call. Every shape evaluates its subterms with one less fuel, so the hypothesis at f reaches subterms and callee bodies alike.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.Mirrorable

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  (err : Err) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  The failures the trap direction carries across: every one but the reference side's own.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  outOfFuel is what makes eval total, and the claim about the generated code is stated at every large enough amount of the model's, so a run only eval ran out of has nothing to match. Every other failure is carried, noMatchingAlternative included — the generated chain takes its last arm without a test, and Exhaustive.firstMatch_isSome is what says the reference semantics takes an arm too.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Refusing what the reference semantics refuses #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      The other direction of fragment_correct_in. Agree compares two failures by their thrown code, so that is what this carries across too: not "both fail" but "both fail the same way".

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.i53_err_of_mkInt53

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {i : Int} {err : Err} (h : mkInt53 i = Except.error err) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.i53_guard_trap

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.numericHelper_trap

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {p : Core.Program} {ty : Core.Ty} {op : Core.BinOp} {jl jr je : Js.Expr} {a b : Value} {err : Err} (hnh : Compile.numericHelper ty op jl jr = some je) (ha : Value.hasTy p a ty = true) (hb : Value.hasTy p b ty = true) (herr : applyBin op a b = Except.error err) (hla : Eventually m jenv jl (encodeValue a)) (hrb : Eventually m jenv jr (encodeValue b)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          EventuallyErr m jenv je err.code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            def

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.EnvCovers

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            (env : Env) (ctx : Compile.Ctx) :

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Every name the compiler has in scope is bound in the reference environment. EnvTyped says only that the two agree where both have the name, which leaves eval free to fail on a lookup the generated code answers.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.EnvCovers.cons

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {env : Env} {ctx : Compile.Ctx} {name : String} {ty : Core.Ty} {v : Value} (h : EnvCovers env ctx) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                EnvCovers ((name, v) :: env) ((name, ty) :: ctx)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.evalExpr_zero

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.compareValues_ok

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {p : Core.Program} {ty : Core.Ty} {a b : Value} {op : Core.BinOp} (hord : Compile.isOrdered ty = true) (ha : Value.hasTy p a ty = true) (hb : Value.hasTy p b ty = true) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.compileExpr_bin_trap

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {p : Core.Program} {ctx : Compile.Ctx} {op : Core.BinOp} {lhsE rhsE : Core.Expr} {je jl jr : Js.Expr} {ty tl : Core.Ty} {a b : Value} {err : Err} (hand : op ≠ Core.BinOp.and) (hor : op ≠ Core.BinOp.or) (hcl : Compile.compileExpr p ctx lhsE = Except.ok (jl, tl)) (hcr : Compile.compileExpr p ctx rhsE = Except.ok (jr, tl)) (hc : Compile.compileExpr p ctx (Core.Expr.bin op lhsE rhsE) = Except.ok (je, ty)) (ha : Value.hasTy p a tl = true) (hb : Value.hasTy p b tl = true) (herr : applyBin op a b = Except.error err) (hla : Eventually m jenv jl (encodeValue a)) (hrb : Eventually m jenv jr (encodeValue b)) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      EventuallyErr m jenv je err.code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_mapJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder code : String} (ha : EventuallyErr m jenv jarr code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        EventuallyErr m jenv (jarr.mapJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventuallyErr_sortByJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder code : String} (ha : EventuallyErr m jenv jarr code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          EventuallyErr m jenv (jarr.sortByJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventuallyErr_sortByJs_items

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalMapJs m g' jenv binder jbody xs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            EventuallyErr m jenv (jarr.sortByJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyErr_mapJs_items

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalMapJs m g' jenv binder jbody xs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              EventuallyErr m jenv (jarr.mapJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventuallyErr_foldJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jscrut : Js.Expr} {key : String} {spec : Js.FoldSpec} {binder : String} {jbody : Js.Expr} {code : String} (ha : EventuallyErr m jenv jscrut code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                EventuallyErr m jenv (jscrut.foldJs key spec binder jbody) code

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                A fold evaluates its scrutinee and then walks it, so a scrutinee that throws throws out of the fold. The twin of eventuallyErr_mapJs.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventuallyErr_foldJs_walk

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jscrut : Js.Expr} {key : String} {spec : Js.FoldSpec} {binder : String} {jbody : Js.Expr} {x : Js.JsValue} {code : String} (ha : Eventually m jenv jscrut x) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalFoldJs m g' jenv key spec binder jbody x = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  EventuallyErr m jenv (jscrut.foldJs key spec binder jbody) code

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  The same for a walk that throws once the scrutinee is in hand. The twin of eventuallyErr_mapJs_items.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventuallyErr_filterJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder code : String} (ha : EventuallyErr m jenv jarr code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    EventuallyErr m jenv (jarr.filterJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.eventuallyErr_filterJs_items

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalFilterJs m g' jenv binder jbody xs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      EventuallyErr m jenv (jarr.filterJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_findJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder code : String} (ha : EventuallyErr m jenv jarr code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        EventuallyErr m jenv (jarr.findJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.eventuallyErr_findJs_items

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalFindJs m g' jenv binder jbody xs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          EventuallyErr m jenv (jarr.findJs binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Lean2Js.Correct.eventuallyErr_quantJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {op : Core.QuantOp} {jarr jbody : Js.Expr} {binder code : String} (ha : EventuallyErr m jenv jarr code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            EventuallyErr m jenv (Js.Expr.quantJs op jarr binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.eventuallyErr_quantJs_items

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {op : Core.QuantOp} {jarr jbody : Js.Expr} {binder : String} {xs : List Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalQuantJs m g' jenv op binder jbody xs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              EventuallyErr m jenv (Js.Expr.quantJs op jarr binder jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Lean2Js.Correct.eventuallyErr_reduceJs

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jinit jbody : Js.Expr} {accName elemName code : String} (ha : EventuallyErr m jenv jarr code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                EventuallyErr m jenv (jarr.reduceJs jinit accName elemName jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.eventuallyErr_reduceJs_init

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jinit jbody : Js.Expr} {accName elemName : String} {xs : List Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hi : EventuallyErr m jenv jinit code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  EventuallyErr m jenv (jarr.reduceJs jinit accName elemName jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Lean2Js.Correct.eventuallyErr_reduceJs_items

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {jarr jinit jbody : Js.Expr} {accName elemName : String} {xs : List Js.JsValue} {acc : Js.JsValue} {code : String} (ha : Eventually m jenv jarr (Js.JsValue.arr xs)) (hi : Eventually m jenv jinit acc) (hb : ∃ (g : Nat), ∀ (g' : Nat), g ≤ g' → Js.evalReduceJs m g' jenv accName elemName jbody acc xs = Except.error code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    EventuallyErr m jenv (jarr.reduceJs jinit accName elemName jbody) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.EnvCovers.append

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] {p : Core.Program} {env : Env} {ctx : Compile.Ctx} (h : EnvCovers env ctx) {benv : Env} {bctx : Compile.Ctx} :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      BindsAgree p benv bctx → EnvCovers (benv ++ env) (bctx ++ ctx)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Lean2Js.Correct.eventuallyErr_arrowCallN

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        [Core.Discriminators] {m : Js.Module} {jenv : Js.JsEnv} {names : List String} {paths : List Js.Expr} {vals : List Js.JsValue} {jbody : Js.Expr} {code : String} (hargs : EventuallyList m jenv paths vals) (hlen : names.length = vals.length) (hbody : EventuallyErr m (Js.bindAll names vals ++ jenv) jbody code) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        EventuallyErr m jenv (Js.Expr.arrowCall names jbody paths) code
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        Used by

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Walking a fold that throws #

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          The mirror of eventuallyFold_of_fold, on the same strong induction over a bound for the value's size and carrying the same four walkers at once. Where that one carries a value across, this carries the thrown code, and the walk has one more shape to account for at every level: a subwalk that throws, with the walks before it having answered.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          noMatchingAlternative is not one of those shapes. Exhaustive.foldFirstMatch_isSome says an alternative matches the rebuilt node, which is what the compiler's usefulFold check bought.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Lean2Js.Correct.DeclTraps

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          The same for a callee that throws.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Lean2Js.Correct.DeclBodyTraps

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              The same for the body function.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  abbrev

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Lean2Js.Correct.TrapsAt

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  @[reducible, inline]

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Expression-level trap agreement at one amount of the reference semantics' fuel.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Equations
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  • One or more equations did not get rendered due to their size.
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  Instances For
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    Used by
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      theorem

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Lean2Js.Correct.fragment_traps_succ

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      source
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      [Core.Discriminators] (p : Core.Program) (m : Js.Module) (hsig : SignatureOk p) (hprog : ProgramTyped p) (f : Nat) (iha : AgreesAt p m f) (ih : TrapsAt p m f) (ihd : DeclTraps p m f) (ihdb : DeclBodyTraps p m f) :
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      TrapsAt p m (f + 1)

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      One step of the induction behind fragment_traps_in, carrying the thrown code from f to f + 1.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      On fuel for the same reason as fragment_correct_succ: the callee's body is not a subterm of the call.

                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      Used by